17 #ifndef _CELLULAR_STATEMACHINE_H_ 18 #define _CELLULAR_STATEMACHINE_H_ 20 #include "events/EventQueue.h" 21 #include "CellularNetwork.h" 22 #include "CellularCommon.h" 23 #include "PlatformMutex.h" 35 friend class UT_CellularStateMachine;
54 STATE_REGISTERING_NETWORK,
55 STATE_ATTACHING_NETWORK,
141 void set_timeout(std::chrono::duration<int, std::milli> timeout);
146 bool get_network_registration(CellularNetwork::RegistrationType type, CellularNetwork::RegistrationStatus &status,
bool &is_registered);
147 bool is_registered();
152 void state_power_on();
153 void state_device_ready();
154 void state_sim_pin();
155 void state_signal_quality();
156 void state_registering();
157 void state_attaching();
159 void retry_state_or_fail();
161 void report_failure(
const char *msg);
163 void device_ready_cb();
165 bool check_is_target_reached();
166 void send_event_cb(cellular_connection_status_t status);
167 void change_timeout(
const std::chrono::duration<int, std::milli> &timeout);
180 const char *_sim_pin;
182 std::chrono::duration<int> _start_time;
183 std::chrono::duration<int> _event_timeout;
185 std::chrono::duration<uint16_t> _retry_timeout_array[CELLULAR_RETRY_ARRAY_SIZE];
186 int _retry_array_length;
189 bool _command_success;
192 cellular_connection_status_t _current_event;
197 std::chrono::duration<int, std::milli> _state_timeout_power_on;
198 std::chrono::duration<int, std::milli> _state_timeout_sim_pin;
199 std::chrono::duration<int, std::milli> _state_timeout_registration;
200 std::chrono::duration<int, std::milli> _state_timeout_network;
201 std::chrono::duration<int, std::milli> _state_timeout_connect;
bool get_current_status(CellularStateMachine::CellularState ¤t_state, CellularStateMachine::CellularState &target_state)
Get the current status of the state machine.
CellularStateMachine(CellularDevice &device, events::EventQueue &queue, CellularNetwork &nw)
Constructor.
CellularState
Cellular connection states.
void stop()
Stop event queue dispatching and close cellular interfaces.
signed int nsapi_error_t
Type used to represent error codes.
nsapi_error_t start_dispatch()
Start event queue dispatching.
void cellular_event_changed(nsapi_event_t ev, intptr_t ptr)
CellularDevice updates about network events and cellular events.
void get_retry_timeout_array(uint16_t *timeout, int &array_len) const
Get retry timeout array.
CellularStateMachine class.
const char * get_state_string(CellularState state) const
returns readable format of the given state.
An abstract interface for connecting to a network and getting information from it.
void set_sim_pin(const char *sim_pin)
Set cellular device SIM PIN code.
nsapi_error_t run_to_state(CellularState state)
Runs state machine to connected state unless callback method set with set_state_callback return false...
void set_cellular_callback(mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb)
Register cellular specific for status changes.
Callback class based on template specialization.
void set_retry_timeout_array(const uint16_t timeout[], int array_len)
Sets the timeout array for network rejects.
void set_timeout(std::chrono::duration< int, std::milli > timeout)
Change all cellular state timeouts.
void reset()
Reset the state machine to init state.
void set_plmn(const char *plmn)
Sets the operator plmn which is used when registering to a network specified by plmn.