@@ -299,7 +299,7 @@ void AT_CellularContext::delete_current_context()
299
299
_at.at_cmd_discard (" +CGDCONT" , " =" , " %d" , _cid);
300
300
301
301
if (_at.get_last_error () == NSAPI_ERROR_OK) {
302
- _cid = - 1 ;
302
+ set_cid (- 1 ) ;
303
303
_new_context_set = false ;
304
304
}
305
305
@@ -347,7 +347,7 @@ bool AT_CellularContext::get_context()
347
347
{
348
348
_at.cmd_start_stop (" +CGDCONT" , " ?" );
349
349
_at.resp_start (" +CGDCONT:" );
350
- _cid = - 1 ;
350
+ set_cid (- 1 ) ;
351
351
int cid_max = 0 ; // needed when creating new context
352
352
char apn[MAX_ACCESSPOINT_NAME_LENGTH];
353
353
int apn_len = 0 ;
@@ -373,7 +373,7 @@ bool AT_CellularContext::get_context()
373
373
if (get_property (pdp_type_t_to_cellular_property (pdp_type)) ||
374
374
((pdp_type == IPV4V6_PDP_TYPE && (get_property (PROPERTY_IPV4_PDP_TYPE) && get_property (PROPERTY_IPV6_PDP_TYPE))) && !_nonip_req)) {
375
375
_pdp_type = pdp_type;
376
- _cid = cid;
376
+ set_cid ( cid) ;
377
377
}
378
378
}
379
379
}
@@ -423,7 +423,7 @@ bool AT_CellularContext::set_new_context(int cid)
423
423
424
424
if (success) {
425
425
_pdp_type = pdp_type;
426
- _cid = cid;
426
+ set_cid ( cid) ;
427
427
_new_context_set = true ;
428
428
tr_info (" New PDP context %d, type %d" , _cid, pdp_type);
429
429
}
@@ -661,7 +661,7 @@ void AT_CellularContext::do_disconnect()
661
661
if (_new_context_set) {
662
662
delete_current_context ();
663
663
}
664
- _cid = - 1 ;
664
+ set_cid (- 1 ) ;
665
665
_cb_data.error = NSAPI_ERROR_NO_CONNECTION;
666
666
}
667
667
@@ -697,7 +697,7 @@ void AT_CellularContext::do_disconnect()
697
697
if (_new_context_set) {
698
698
delete_current_context ();
699
699
}
700
- _cid = - 1 ;
700
+ set_cid (- 1 ) ;
701
701
_cb_data.error = _at.unlock_return_error ();
702
702
}
703
703
@@ -994,13 +994,15 @@ void AT_CellularContext::cellular_callback(nsapi_event_t ev, intptr_t ptr)
994
994
} else if (ev == NSAPI_EVENT_CONNECTION_STATUS_CHANGE && ptr == NSAPI_STATUS_DISCONNECTED) {
995
995
tr_info (" cellular_callback: PPP mode and NSAPI_STATUS_DISCONNECTED" );
996
996
_cb_data.error = NSAPI_ERROR_NO_CONNECTION;
997
+ set_cid (-1 );
997
998
_is_connected = false ;
998
999
ppp_disconnected ();
999
1000
}
1000
1001
}
1001
1002
#else
1002
1003
if (ev == NSAPI_EVENT_CONNECTION_STATUS_CHANGE && ptr == NSAPI_STATUS_DISCONNECTED) {
1003
1004
tr_info (" cb: CellularContext disconnected" );
1005
+ set_cid (-1 );
1004
1006
_is_connected = false ;
1005
1007
}
1006
1008
#endif // NSAPI_PPP_AVAILABLE
@@ -1065,3 +1067,11 @@ void AT_CellularContext::set_disconnect()
1065
1067
_is_connected = false ;
1066
1068
_device->cellular_callback (NSAPI_EVENT_CONNECTION_STATUS_CHANGE, NSAPI_STATUS_DISCONNECTED, this );
1067
1069
}
1070
+
1071
+ void AT_CellularContext::set_cid (int cid)
1072
+ {
1073
+ _cid = cid;
1074
+ if (_stack) {
1075
+ static_cast <AT_CellularStack *>(_stack)->set_cid (_cid);
1076
+ }
1077
+ }
0 commit comments