Skip to content

Commit b5d68b5

Browse files
author
Mirela Chirica
committed
Cellular: In LTE mode last PDP context cannot be deactivated
1 parent f15dbf2 commit b5d68b5

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,34 @@ nsapi_error_t AT_CellularNetwork::disconnect()
421421
return err;
422422
#else
423423
_at.lock();
424-
_at.cmd_start("AT+CGACT=0,");
425-
_at.write_int(_cid);
424+
425+
_is_context_active = false;
426+
size_t active_contexts_count = 0;
427+
_at.cmd_start("AT+CGACT?");
426428
_at.cmd_stop();
427-
_at.resp_start();
429+
_at.resp_start("+CGACT:");
430+
while (_at.info_resp()) {
431+
int context_id = _at.read_int();
432+
int context_activation_state = _at.read_int();
433+
if (context_activation_state == 1) {
434+
active_contexts_count++;
435+
if (context_id == _cid) {
436+
_is_context_active = true;
437+
}
438+
}
439+
}
428440
_at.resp_stop();
441+
442+
// 3GPP TS 27.007:
443+
// For EPS, if an attempt is made to disconnect the last PDN connection, then the MT responds with ERROR
444+
if (_is_context_active && (_current_act < RAT_E_UTRAN || active_contexts_count > 1)) {
445+
_at.cmd_start("AT+CGACT=0,");
446+
_at.write_int(_cid);
447+
_at.cmd_stop();
448+
_at.resp_start();
449+
_at.resp_stop();
450+
}
451+
429452
_at.restore_at_timeout();
430453

431454
_at.remove_urc_handler("+CGEV:", callback(this, &AT_CellularNetwork::urc_cgev));

0 commit comments

Comments
 (0)