@@ -44,11 +44,11 @@ const int STM_STOPPED = -99;
44
44
namespace mbed {
45
45
46
46
CellularStateMachine::CellularStateMachine (CellularDevice &device, events::EventQueue &queue) :
47
- _cellularDevice (device), _state(STATE_INIT), _next_state(_state), _target_state(_state),
48
- _event_status_cb (0 ), _network(0 ), _power(0 ), _sim(0 ), _queue(queue), _queue_thread(0 ), _sim_pin(0 ),
49
- _retry_count (0 ), _event_timeout(-1 ), _event_id(-1 ), _plmn(0 ), _command_success(false ),
50
- _plmn_network_found (false ), _is_retry(false ), _cb_data(), _current_event(NSAPI_EVENT_CONNECTION_STATUS_CHANGE),
51
- _active_context (false )
47
+ _cellularDevice (device), _state(STATE_INIT), _next_state(_state), _target_state(_state),
48
+ _event_status_cb (0 ), _network(0 ), _power(0 ), _sim(0 ), _queue(queue), _queue_thread(0 ), _sim_pin(0 ),
49
+ _retry_count (0 ), _event_timeout(-1 ), _event_id(-1 ), _plmn(0 ), _command_success(false ),
50
+ _plmn_network_found (false ), _is_retry(false ), _cb_data(), _current_event(NSAPI_EVENT_CONNECTION_STATUS_CHANGE),
51
+ _active_context (false )
52
52
{
53
53
#if MBED_CONF_CELLULAR_RANDOM_MAX_START_DELAY == 0
54
54
_start_time = 0 ;
@@ -157,7 +157,7 @@ bool CellularStateMachine::open_sim()
157
157
// report current state so callback can set sim pin if needed
158
158
if (_event_status_cb) {
159
159
_cb_data.status_data = state;
160
- _event_status_cb ((nsapi_event_t )CellularSIMStatusChanged, (intptr_t )&_cb_data);
160
+ _event_status_cb ((nsapi_event_t )CellularSIMStatusChanged, (intptr_t )&_cb_data);
161
161
}
162
162
163
163
if (state == CellularSIM::SimStatePinNeeded) {
@@ -197,7 +197,7 @@ bool CellularStateMachine::is_registered()
197
197
}
198
198
199
199
bool CellularStateMachine::get_network_registration (CellularNetwork::RegistrationType type,
200
- CellularNetwork::RegistrationStatus &status, bool &is_registered)
200
+ CellularNetwork::RegistrationStatus &status, bool &is_registered)
201
201
{
202
202
is_registered = false ;
203
203
bool is_roaming = false ;
@@ -255,7 +255,7 @@ void CellularStateMachine::report_failure(const char *msg)
255
255
_event_id = -1 ;
256
256
if (_event_status_cb) {
257
257
_cb_data.final_try = true ;
258
- _event_status_cb (_current_event, (intptr_t )&_cb_data);
258
+ _event_status_cb (_current_event, (intptr_t )&_cb_data);
259
259
}
260
260
261
261
tr_error (" Target state %s was not reached. Returning from state: %s" , get_state_string (_target_state), get_state_string (_state));
@@ -379,7 +379,7 @@ bool CellularStateMachine::device_ready()
379
379
return false ;
380
380
}
381
381
if (_event_status_cb) {
382
- _event_status_cb ((nsapi_event_t )CellularDeviceReady, (intptr_t )&_cb_data);
382
+ _event_status_cb ((nsapi_event_t )CellularDeviceReady, (intptr_t )&_cb_data);
383
383
}
384
384
_power->remove_device_ready_urc_cb (mbed::callback (this , &CellularStateMachine::ready_urc_cb));
385
385
_cellularDevice.close_power ();
@@ -493,7 +493,7 @@ void CellularStateMachine::state_attaching()
493
493
_sim = NULL ;
494
494
if (_event_status_cb) {
495
495
_cb_data.status_data = CellularNetwork::Attached;
496
- _event_status_cb (_current_event, (intptr_t )&_cb_data);
496
+ _event_status_cb (_current_event, (intptr_t )&_cb_data);
497
497
}
498
498
} else {
499
499
retry_state_or_fail ();
@@ -527,29 +527,29 @@ nsapi_error_t CellularStateMachine::run_to_state(CellularStateMachine::CellularS
527
527
_mutex.unlock ();
528
528
return NSAPI_ERROR_NO_MEMORY;
529
529
}
530
- _mutex.unlock ();
530
+ _mutex.unlock ();
531
531
return NSAPI_ERROR_OK;
532
532
}
533
533
534
534
void CellularStateMachine::pre_event (CellularState state)
535
535
{
536
536
tr_debug (" CellularStateMachine::pre_event, state: %s, _target_state: %s, _event_id: %d" , get_state_string (state), get_state_string (_target_state), _event_id);
537
- if (_target_state < state) {
537
+ if (_target_state < state) {
538
538
// new wanted state will not be achieved with current _target_state so update it
539
539
_target_state = state;
540
540
} else {
541
541
// wanted state is already / will be achieved, return without launching new event
542
542
return ;
543
543
}
544
- // if _event_id is -1 it means that new event is not going to be launched so we must launch new event
544
+ // if _event_id is -1 it means that new event is not going to be launched so we must launch new event
545
545
if (_event_id == -1 ) {
546
546
if (!_cb_data.final_try ) {
547
547
// update next state so that we don't continue from previous state if state machine was paused and then started again.
548
548
// but only if earlier try did not finish to failure, then we must continue from that state
549
549
_state = _next_state;
550
550
}
551
- enter_to_state (_next_state);
552
- _event_id = _queue.call_in (0 , this , &CellularStateMachine::event);
551
+ enter_to_state (_next_state);
552
+ _event_id = _queue.call_in (0 , this , &CellularStateMachine::event);
553
553
if (!_event_id) {
554
554
_event_id = -1 ;
555
555
report_failure (" Failed to call queue." );
@@ -655,7 +655,7 @@ void CellularStateMachine::set_cellular_callback(mbed::Callback<void(nsapi_event
655
655
656
656
void CellularStateMachine::cellular_event_changed (nsapi_event_t ev, intptr_t ptr)
657
657
{
658
- cell_callback_data_t *data = (cell_callback_data_t *)ptr;
658
+ cell_callback_data_t *data = (cell_callback_data_t *)ptr;
659
659
if (ev >= NSAPI_EVENT_CELLULAR_STATUS_BASE && ev <= NSAPI_EVENT_CELLULAR_STATUS_END) {
660
660
tr_debug (" FSM: cellular_event_changed called with event: %d, err: %d, data: %d _state: %s" , ev, data->error , data->status_data , get_state_string (_state));
661
661
} else {
0 commit comments