CellularStateMachine class. More...
#include <CellularStateMachine.h>
Public Types |
Public Member Functions | |
CellularStateMachine (CellularDevice &device, events::EventQueue &queue, CellularNetwork &nw) | |
Constructor. More... | |
void | set_cellular_callback (mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb) |
Register cellular specific for status changes. More... | |
nsapi_error_t | start_dispatch () |
Start event queue dispatching. More... | |
void | stop () |
Stop event queue dispatching and close cellular interfaces. More... | |
nsapi_error_t | run_to_state (CellularState state) |
Runs state machine to connected state unless callback method set with set_state_callback return false to stop. More... | |
void | set_sim_pin (const char *sim_pin) |
Set cellular device SIM PIN code. More... | |
void | set_retry_timeout_array (const uint16_t timeout[], int array_len) |
Sets the timeout array for network rejects. More... | |
void | set_plmn (const char *plmn) |
Sets the operator plmn which is used when registering to a network specified by plmn. More... | |
const char * | get_state_string (CellularState state) const |
returns readable format of the given state. More... | |
bool | get_current_status (CellularStateMachine::CellularState ¤t_state, CellularStateMachine::CellularState &target_state) |
Get the current status of the state machine. More... | |
void | cellular_event_changed (nsapi_event_t ev, intptr_t ptr) |
CellularDevice updates about network events and cellular events. More... | |
void | reset () |
Reset the state machine to init state. More... | |
void | get_retry_timeout_array (uint16_t *timeout, int &array_len) const |
Get retry timeout array. More... | |
void | set_timeout (std::chrono::duration< int, std::milli > timeout) |
Change all cellular state timeouts. More... | |
CellularStateMachine class.
Finite State Machine for attaching to cellular network. Used by CellularDevice.
Definition at line 33 of file CellularStateMachine.h.
enum CellularState |
Cellular connection states.
Definition at line 48 of file CellularStateMachine.h.
CellularStateMachine | ( | CellularDevice & | device, |
events::EventQueue & | queue, | ||
CellularNetwork & | nw | ||
) |
Constructor.
device | reference to CellularDevice |
queue | reference to queue used in state transitions |
nw | reference to CellularNetwork |
void cellular_event_changed | ( | nsapi_event_t | ev, |
intptr_t | ptr | ||
) |
CellularDevice updates about network events and cellular events.
ev | Event type |
ptr | Event type specific data |
bool get_current_status | ( | CellularStateMachine::CellularState & | current_state, |
CellularStateMachine::CellularState & | target_state | ||
) |
Get the current status of the state machine.
Thread safe.
current_state | |
target_state |
void get_retry_timeout_array | ( | uint16_t * | timeout, |
int & | array_len | ||
) | const |
Get retry timeout array.
timeout | Pointer to timeout array |
array_len | Max lenght of the array |
const char* get_state_string | ( | CellularState | state | ) | const |
returns readable format of the given state.
Used for printing states while debugging.
state | state which is returned in string format |
void reset | ( | ) |
Reset the state machine to init state.
After reset state machine can be used again to run to wanted state.
nsapi_error_t run_to_state | ( | CellularState | state | ) |
Runs state machine to connected state unless callback method set with set_state_callback return false to stop.
void set_cellular_callback | ( | mbed::Callback< void(nsapi_event_t, intptr_t)> | status_cb | ) |
Register cellular specific for status changes.
The specified status callback function will be called on device status changes. The parameters on the callback are the event type and event-type dependent reason parameter.
status_cb | The callback for status changes |
void set_plmn | ( | const char * | plmn | ) |
Sets the operator plmn which is used when registering to a network specified by plmn.
If plmn is not set then automatic registering is used when registering to a cellular network. Does not start any operations.
plmn | operator in numeric format. See more from 3GPP TS 27.007 chapter 7.3. |
void set_retry_timeout_array | ( | const uint16_t | timeout[], |
int | array_len | ||
) |
Sets the timeout array for network rejects.
After reject next item is tried and after all items are waited and still fails then current network event will fail.
timeout | timeout array using seconds |
array_len | length of the array |
void set_sim_pin | ( | const char * | sim_pin | ) |
Set cellular device SIM PIN code.
sim_pin | PIN code |
void set_timeout | ( | std::chrono::duration< int, std::milli > | timeout | ) |
Change all cellular state timeouts.
timeout | Timeout value (milliseconds) |
nsapi_error_t start_dispatch | ( | ) |
Start event queue dispatching.
void stop | ( | ) |
Stop event queue dispatching and close cellular interfaces.