Mistake on this page?
Report an issue in GitHub or email us
Public Types | Public Member Functions
CellularStateMachine Class Reference

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 &current_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...
 

Detailed Description

CellularStateMachine class.

Finite State Machine for attaching to cellular network. Used by CellularDevice.

Definition at line 33 of file CellularStateMachine.h.

Member Enumeration Documentation

Cellular connection states.

Definition at line 48 of file CellularStateMachine.h.

Constructor & Destructor Documentation

Constructor.

Parameters
devicereference to CellularDevice
queuereference to queue used in state transitions
nwreference to CellularNetwork

Member Function Documentation

void cellular_event_changed ( nsapi_event_t  ev,
intptr_t  ptr 
)

CellularDevice updates about network events and cellular events.

Parameters
evEvent type
ptrEvent 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.

Parameters
current_state
target_state
Returns
true if state machine is running, false is not
void get_retry_timeout_array ( uint16_t *  timeout,
int &  array_len 
) const

Get retry timeout array.

Parameters
timeoutPointer to timeout array
array_lenMax 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.

Parameters
statestate which is returned in string format
Returns
string format of the given state
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.

Returns
see nsapi_error_t, 0 on success
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.

Parameters
status_cbThe 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.

Parameters
plmnoperator 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.

Parameters
timeouttimeout array using seconds
array_lenlength of the array
void set_sim_pin ( const char *  sim_pin)

Set cellular device SIM PIN code.

Parameters
sim_pinPIN code
void set_timeout ( std::chrono::duration< int, std::milli >  timeout)

Change all cellular state timeouts.

Parameters
timeoutTimeout value (milliseconds)
nsapi_error_t start_dispatch ( )

Start event queue dispatching.

Returns
see nsapi_error_t, 0 on success
void stop ( )

Stop event queue dispatching and close cellular interfaces.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.