@@ -79,6 +79,10 @@ void CellularConnectionFSM::stop()
79
79
if (_cellularDevice) {
80
80
_cellularDevice->close_power ();
81
81
_cellularDevice->close_network ();
82
+ _cellularDevice->close_sim ();
83
+ _power = NULL ;
84
+ _network = NULL ;
85
+ _sim = NULL ;
82
86
}
83
87
if (_queue_thread) {
84
88
_queue_thread->terminate ();
@@ -289,7 +293,7 @@ void CellularConnectionFSM::report_failure(const char* msg)
289
293
290
294
const char * CellularConnectionFSM::get_state_string (CellularState state)
291
295
{
292
- static const char *strings[] = { " Init" , " Power" , " Device ready" , " SIM pin" , " Registering network" , " Attaching network" , " Connecting network" , " Connected" };
296
+ static const char *strings[] = { " Init" , " Power" , " Device ready" , " SIM pin" , " Registering network" , " Attaching network" , " Activating PDP Context " , " Connecting network" , " Connected" };
293
297
return strings[state];
294
298
}
295
299
@@ -446,7 +450,7 @@ void CellularConnectionFSM::state_attaching()
446
450
CellularNetwork::AttachStatus attach_status;
447
451
if (get_attach_network (attach_status)) {
448
452
if (attach_status == CellularNetwork::Attached) {
449
- enter_to_state (STATE_CONNECTING_NETWORK );
453
+ enter_to_state (STATE_ACTIVATING_PDP_CONTEXT );
450
454
} else {
451
455
set_attach_network ();
452
456
retry_state_or_fail ();
@@ -456,6 +460,18 @@ void CellularConnectionFSM::state_attaching()
456
460
}
457
461
}
458
462
463
+ void CellularConnectionFSM::state_activating_pdp_context ()
464
+ {
465
+ _cellularDevice->set_timeout (TIMEOUT_CONNECT);
466
+ tr_info (" Activate PDP Context (timeout %d ms)" , TIMEOUT_CONNECT);
467
+ if (_network->activate_context () == NSAPI_ERROR_OK) {
468
+ // when using modems stack connect is synchronous
469
+ _next_state = STATE_CONNECTING_NETWORK;
470
+ } else {
471
+ retry_state_or_fail ();
472
+ }
473
+ }
474
+
459
475
void CellularConnectionFSM::state_connect_to_network ()
460
476
{
461
477
_cellularDevice->set_timeout (TIMEOUT_CONNECT);
@@ -501,6 +517,9 @@ void CellularConnectionFSM::event()
501
517
case STATE_ATTACHING_NETWORK:
502
518
state_attaching ();
503
519
break ;
520
+ case STATE_ACTIVATING_PDP_CONTEXT:
521
+ state_activating_pdp_context ();
522
+ break ;
504
523
case STATE_CONNECTING_NETWORK:
505
524
state_connect_to_network ();
506
525
break ;
0 commit comments