File tree Expand file tree Collapse file tree 1 file changed +26
-3
lines changed
features/cellular/framework/AT Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -421,11 +421,34 @@ nsapi_error_t AT_CellularNetwork::disconnect()
421
421
return err;
422
422
#else
423
423
_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?" );
426
428
_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
+ }
428
440
_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
+
429
452
_at.restore_at_timeout ();
430
453
431
454
_at.remove_urc_handler (" +CGEV:" , callback (this , &AT_CellularNetwork::urc_cgev));
You can’t perform that action at this time.
0 commit comments