@@ -40,9 +40,9 @@ namespace mbed
40
40
{
41
41
42
42
CellularConnectionFSM::CellularConnectionFSM () :
43
- _serial (0 ), _state(STATE_INIT), _next_state(_state), _status_callback(0 ), _event_status_cb(0 ), _network(0 ), _power(0 ), _sim(0 ),
44
- _queue (8 * EVENTS_EVENT_SIZE), _queue_thread(0 ), _cellularDevice(0 ), _retry_count(0 ), _event_timeout(-1 ),
45
- _at_queue (8 * EVENTS_EVENT_SIZE), _eventID(0 )
43
+ _serial (0 ), _state(STATE_INIT), _next_state(_state), _status_callback(0 ), _event_status_cb(0 ), _network(0 ), _power(0 ), _sim(0 ),
44
+ _queue (8 * EVENTS_EVENT_SIZE), _queue_thread(0 ), _cellularDevice(0 ), _retry_count(0 ), _event_timeout(-1 ),
45
+ _at_queue (8 * EVENTS_EVENT_SIZE), _eventID(0 ), _auto_registration( false )
46
46
{
47
47
memset (_sim_pin, 0 , sizeof (_sim_pin));
48
48
#if MBED_CONF_CELLULAR_RANDOM_MAX_START_DELAY == 0
@@ -164,7 +164,7 @@ bool CellularConnectionFSM::open_sim()
164
164
tr_warn (" PIN required but No SIM pin provided." );
165
165
}
166
166
}
167
- break ;
167
+ break ;
168
168
case CellularSIM::SimStatePukNeeded:
169
169
tr_info (" SIM PUK code needed..." );
170
170
break ;
@@ -290,18 +290,22 @@ const char* CellularConnectionFSM::get_state_string(CellularState state)
290
290
return strings[state];
291
291
}
292
292
293
- bool CellularConnectionFSM::is_automatic_registering ()
293
+ nsapi_error_t CellularConnectionFSM::is_automatic_registering (bool & auto_reg )
294
294
{
295
+ if (_auto_registration == CellularNetwork::NWModeAutomatic) {
296
+ auto_reg = _auto_registration;
297
+ return NSAPI_ERROR_OK;
298
+ }
295
299
CellularNetwork::NWRegisteringMode mode;
296
300
nsapi_error_t err = _network->get_network_registering_mode (mode);
297
- tr_debug (" automatic registering mode: %d" , mode);
298
- if (err == NSAPI_ERROR_OK && mode == CellularNetwork::NWModeAutomatic) {
299
- return true ;
301
+ if (err == NSAPI_ERROR_OK) {
302
+ tr_info (" automatic registering mode: %d" , mode);
303
+ _auto_registration = (mode == CellularNetwork::NWModeAutomatic);
304
+ auto_reg = _auto_registration;
300
305
}
301
- return false ;
306
+ return err ;
302
307
}
303
308
304
-
305
309
nsapi_error_t CellularConnectionFSM::continue_from_state (CellularState state)
306
310
{
307
311
tr_info (" Continue state from %s to %s" , get_state_string ((CellularConnectionFSM::CellularState)_state),
@@ -427,7 +431,9 @@ void CellularConnectionFSM::state_registering()
427
431
// we are already registered, go to attach
428
432
enter_to_state (STATE_ATTACHING_NETWORK);
429
433
} else {
430
- if (!is_automatic_registering ()) { // when we support plmn add this : || plmn
434
+ bool auto_reg = false ;
435
+ nsapi_error_t err = is_automatic_registering (auto_reg);
436
+ if (err == NSAPI_ERROR_OK && !auto_reg) { // when we support plmn add this : || plmn
431
437
// automatic registering is not on, set registration and retry
432
438
_cellularDevice->set_timeout (TIMEOUT_REGISTRATION);
433
439
set_network_registration ();
@@ -456,8 +462,7 @@ void CellularConnectionFSM::state_connect_to_network()
456
462
{
457
463
_cellularDevice->set_timeout (TIMEOUT_NETWORK);
458
464
tr_info (" Connect to cellular network (timeout %d ms)" , TIMEOUT_NETWORK);
459
- nsapi_error_t err = _network->connect ();
460
- if (err == NSAPI_ERROR_OK) {
465
+ if (_network->connect () == NSAPI_ERROR_OK) {
461
466
// when using modems stack connect is synchronous
462
467
_next_state = STATE_CONNECTED;
463
468
} else {
@@ -582,7 +587,7 @@ void CellularConnectionFSM::ready_urc_cb()
582
587
{
583
588
tr_debug (" Device ready URC func called" );
584
589
if (_state == STATE_DEVICE_READY && _power->set_at_mode () == NSAPI_ERROR_OK) {
585
- tr_info (" State was STATE_DEVICE_READY and at mode ready, cancel state and move to next" );
590
+ tr_debug (" State was STATE_DEVICE_READY and at mode ready, cancel state and move to next" );
586
591
_queue.cancel (_eventID);
587
592
if (device_ready ()) {
588
593
continue_from_state (STATE_SIM_PIN);
0 commit comments