Class CellularDevice. More...
#include <CellularDevice.h>
Public Member Functions | |
CellularDevice () | |
Default constructor. More... | |
virtual | ~CellularDevice () |
virtual Destructor More... | |
virtual nsapi_error_t | shutdown () |
Shutdown cellular device to minimum functionality. More... | |
virtual events::EventQueue * | get_queue () |
Get event queue that can be chained to main event queue. More... | |
virtual nsapi_error_t | clear ()=0 |
Clear modem to a default initial state. More... | |
virtual CellularContext * | get_context_list () const =0 |
Get the linked list of CellularContext instances. More... | |
virtual nsapi_error_t | hard_power_on ()=0 |
Sets the modem up for powering on This is equivalent to plugging in the device, i.e., attaching power and serial port. More... | |
virtual nsapi_error_t | hard_power_off ()=0 |
Sets the modem in unplugged state. More... | |
virtual nsapi_error_t | soft_power_on ()=0 |
Powers up the modem. More... | |
virtual nsapi_error_t | soft_power_off ()=0 |
Powers down the modem. More... | |
virtual nsapi_error_t | set_pin (const char *sim_pin)=0 |
Open the SIM card by setting the pin code for SIM. More... | |
virtual nsapi_error_t | get_sim_state (SimState &state)=0 |
Get SIM card's state. More... | |
virtual CellularContext * | create_context (const char *apn=NULL, bool cp_req=false, bool nonip_req=false)=0 |
Creates a new CellularContext interface. More... | |
virtual void | delete_context (CellularContext *context)=0 |
Deletes the given CellularContext instance. More... | |
virtual void | modem_debug_on (bool on)=0 |
Turn modem debug traces on. More... | |
virtual nsapi_error_t | init ()=0 |
Initialize cellular device must be called right after the module is ready. More... | |
virtual nsapi_error_t | is_ready ()=0 |
Check whether the device is ready to accept commands. More... | |
virtual void | set_ready_cb (Callback< void()> callback)=0 |
Set callback function to listen when device is ready. More... | |
virtual nsapi_error_t | set_power_save_mode (int periodic_time, int active_time=0)=0 |
Set power save mode. More... | |
virtual ATHandler * | get_at_handler ()=0 |
Get the current ATHandler instance in use for debug purposes etc. More... | |
virtual nsapi_error_t | set_baud_rate (int baud_rate)=0 |
Sets cellular modem to given baud rate. More... | |
virtual CellularNetwork * | open_network ()=0 |
Create new CellularNetwork interface. More... | |
virtual CellularSMS * | open_sms ()=0 |
Create new CellularSMS interface. More... | |
virtual void | close_sms ()=0 |
Closes the opened CellularSMS by deleting the CellularSMS instance. More... | |
virtual CellularInformation * | open_information ()=0 |
Create new CellularInformation interface. More... | |
virtual void | close_network ()=0 |
Closes the opened CellularNetwork by deleting the CellularNetwork instance. More... | |
virtual void | close_information ()=0 |
Closes the opened CellularInformation by deleting the CellularInformation instance. More... | |
virtual void | set_timeout (int timeout)=0 |
Set the default response timeout. More... | |
void | set_sim_pin (const char *sim_pin) |
Set the pin code for SIM card. More... | |
void | set_plmn (const char *plmn) |
Plmn to use when registering to cellular network. More... | |
nsapi_error_t | set_device_ready () |
Start the interface. More... | |
nsapi_error_t | set_sim_ready () |
Start the interface. More... | |
nsapi_error_t | register_to_network () |
Start the interface. More... | |
nsapi_error_t | attach_to_network () |
Start the interface. More... | |
void | attach (Callback< void(nsapi_event_t, intptr_t)> status_cb) |
Register callback for status reporting. More... | |
void | set_retry_timeout_array (const uint16_t timeout[], int array_len) |
Set an array of timeouts to wait before CellularStateMachine retries after failure. More... | |
Static Public Member Functions | |
static CellularDevice * | get_default_instance () |
Returns singleton instance of CellularDevice, if Mbed target board has a supported onboard modem, or provide-default is defined for a cellular driver in JSON configuration files. More... | |
static CellularDevice * | get_target_default_instance () |
Return target onboard instance of CellularDevice. More... | |
Protected Member Functions | |
virtual void | cellular_callback (nsapi_event_t ev, intptr_t ptr, CellularContext *ctx=NULL) |
Cellular callback to be attached to Network and CellularStateMachine classes. More... | |
void | get_retry_timeout_array (uint16_t *timeout, int &array_len) const |
Get the retry array from the CellularStateMachine. More... | |
Class CellularDevice.
An abstract interface that defines opening and closing of cellular interfaces. You can delete or close opened interfaces only through this class.
Definition at line 56 of file CellularDevice.h.
CellularDevice | ( | ) |
Default constructor.
|
virtual |
virtual Destructor
void attach | ( | Callback< void(nsapi_event_t, intptr_t)> | status_cb | ) |
Register callback for status reporting.
The specified status callback function will be called on the network and cellular 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. |
nsapi_error_t attach_to_network | ( | ) |
Start the interface.
Attempts to attach the device to cellular network. API is asynchronous. Application can get results from CellularContext callback, which is set with attach(...), or callback, which is set by attach(...), in this class.
|
protectedvirtual |
Cellular callback to be attached to Network and CellularStateMachine classes.
CellularContext calls this when in PPP mode to provide network changes. This method will broadcast to every interested classes: CellularContext (might be many) and CellularStateMachine if available.
Reimplemented in AT_CellularDevice.
|
pure virtual |
Clear modem to a default initial state.
Clear persistent user data from the modem, such as PDP contexts.
cellular.clear-on-connect: true
.Implemented in AT_CellularDevice.
|
pure virtual |
Closes the opened CellularInformation by deleting the CellularInformation instance.
Implemented in AT_CellularDevice.
|
pure virtual |
Closes the opened CellularNetwork by deleting the CellularNetwork instance.
Implemented in AT_CellularDevice.
|
pure virtual |
Closes the opened CellularSMS by deleting the CellularSMS instance.
|
pure virtual |
Creates a new CellularContext interface.
fh | file handle used in communication to modem. This can be, for example, UART handle. If null, then the default file handle is used. |
apn | access point to use with context, can be null. |
cp_req | flag indicating if EPS control plane optimization is required |
nonip_req | flag indicating if this context is required to be Non-IP |
Implemented in AT_CellularDevice.
|
pure virtual |
Deletes the given CellularContext instance.
context | CellularContext to delete |
Implemented in AT_CellularDevice.
|
pure virtual |
Get the current ATHandler instance in use for debug purposes etc.
Implemented in AT_CellularDevice.
|
pure virtual |
Get the linked list of CellularContext instances.
Implemented in AT_CellularDevice.
|
static |
Returns singleton instance of CellularDevice, if Mbed target board has a supported onboard modem, or provide-default is defined for a cellular driver in JSON configuration files.
Otherwise returns NULL. See NetworkInterface::get_default_instance for details.
|
virtual |
Get event queue that can be chained to main event queue.
|
protected |
Get the retry array from the CellularStateMachine.
Array is used in retry logic. Array contains seconds and retry logic uses those second to wait before trying again.
timeout | timeout array containing seconds for retry logic. Must have space for CELLULAR_RETRY_ARRAY_SIZE (defined in CellularCommon.h) |
array_len | length of the timeout array on return |
|
pure virtual |
Get SIM card's state.
state | current state of SIM |
Implemented in AT_CellularDevice, UBLOX_N2XX, QUECTEL_BC95, and QUECTEL_M26.
|
static |
Return target onboard instance of CellularDevice.
|
pure virtual |
Sets the modem in unplugged state.
This is equivalent to pulling the plug off of the device, i.e., detaching power and serial port.
This puts the modem in the lowest power state.
Implemented in AT_CellularDevice, TELIT_ME310, TELIT_ME910, and QUECTEL_EC2X.
|
pure virtual |
Sets the modem up for powering on This is equivalent to plugging in the device, i.e., attaching power and serial port.
In general, hard_power_on and soft_power_on provides a simple hardware abstraction layer on top of the modem drivers written for Mbed OS; they can be overridden in a derived class to perform custom power controls in a particular board configuration. In many boards this will be a no-op if there is no separate power supply control circuitry.
Implemented in AT_CellularDevice, TELIT_ME310, TELIT_ME910, and QUECTEL_EC2X.
|
pure virtual |
Initialize cellular device must be called right after the module is ready.
For example, when multiple cellular modules are supported in a single driver this function detects and adapts to an actual module at runtime.
Implemented in AT_CellularDevice, GEMALTO_CINTERION, UBLOX_AT, QUECTEL_BC95, UBLOX_N2XX, TELIT_ME310, TELIT_ME910, TELIT_HE910, and RM1000_AT.
|
pure virtual |
Check whether the device is ready to accept commands.
Implemented in AT_CellularDevice.
|
pure virtual |
Turn modem debug traces on.
on | set true to enable debug traces |
Implemented in AT_CellularDevice.
|
pure virtual |
Create new CellularInformation interface.
fh | file handle used in communication to modem. This can be, for example, UART handle. If null, then the default file handle is used. |
Implemented in AT_CellularDevice.
|
pure virtual |
Create new CellularNetwork interface.
fh | file handle used in communication to modem. This can be, for example, UART handle. If null, then the default file handle is used. |
Implemented in AT_CellularDevice.
|
pure virtual |
Create new CellularSMS interface.
fh | file handle used in communication to modem. This can be, for example, UART handle. If null, then the default file handle is used. |
nsapi_error_t register_to_network | ( | ) |
Start the interface.
Attempts to register the device to cellular network. API is asynchronous. Application can get results from CellularContext callback, which is set with attach(...), or callback, which is set by attach(...), in this class.
|
pure virtual |
Sets cellular modem to given baud rate.
baud_rate |
Implemented in AT_CellularDevice.
nsapi_error_t set_device_ready | ( | ) |
Start the interface.
Initializes the modem for communication. API is asynchronous. Application can get results from CellularContext callback, which is set with attach(...), or callback, which is set by attach(...), in this class.
|
pure virtual |
Open the SIM card by setting the pin code for SIM.
sim_pin | PIN for the SIM card |
Implemented in AT_CellularDevice, and UBLOX_N2XX.
void set_plmn | ( | const char * | plmn | ) |
Plmn to use when registering to cellular network.
If plmn is set, then registering is forced to this plmn. If plmn is not set, then automatic registering is used when registering to a cellular network. It doesn't start any operations.
plmn | plmn used when registering to cellular network |
|
pure virtual |
Set power save mode.
periodic_time | in seconds to enable power save, or zero to disable |
active_time | in seconds to wait before entering power save mode |
Implemented in AT_CellularDevice, and SARA4_PPP.
|
pure virtual |
Set callback function to listen when device is ready.
callback | function to call on device ready, or NULL to remove callback. |
Implemented in AT_CellularDevice, and QUECTEL_BG96.
void set_retry_timeout_array | ( | const uint16_t | timeout[], |
int | array_len | ||
) |
Set an array of timeouts to wait before CellularStateMachine retries after failure.
To disable retry behavior completely use set_retry_timeout_array(NULL, 0)
. CellularContext callback event cell_callback_data_t.final_try
indicates true when all retries have failed.
set_retry_timeout_array
for CellularStateMachine to wait before it retries again after failure, this is useful to send repetitive requests when don't know exactly when modem is ready to accept requests. Use set_timeout
for timeout how long to wait for a response from modem for each request, this is useful if modem can accept requests but processing takes long time before sending response.timeout | timeout array using seconds |
array_len | length of the array |
void set_sim_pin | ( | const char * | sim_pin | ) |
Set the pin code for SIM card.
sim_pin | PIN for the SIM card |
nsapi_error_t set_sim_ready | ( | ) |
Start the interface.
Attempts to open the sim. API is asynchronous. Application can get results from CellularContext callback, which is set with attach(...), or callback, which is set by attach(...), in this class.
|
pure virtual |
Set the default response timeout.
timeout
.timeout | milliseconds to wait response from modem |
Implemented in AT_CellularDevice.
|
virtual |
Shutdown cellular device to minimum functionality.
Actual functionality is modem specific, for example UART may is not be responsive without explicit wakeup signal (such as RTS) after shutdown.
Reimplemented in AT_CellularDevice, and QUECTEL_M26.
|
pure virtual |
Powers down the modem.
This is equivalent to turning off the modem by button press.
Implemented in AT_CellularDevice, STModCellular, TELIT_ME310, TELIT_ME910, QUECTEL_BG96, and QUECTEL_EC2X.
|
pure virtual |
Powers up the modem.
This is equivalent to pressing the "power button" to activate or reset the modem and usually implemented as a short pulse on a dedicated GPIO signal. It is expected to be present to make it possible to reset the modem. The driver may repeat this if the modem is not responsive to AT commands.
Implemented in AT_CellularDevice, STModCellular, TELIT_ME310, TELIT_ME910, QUECTEL_BG96, ALT1250_PPP, and QUECTEL_EC2X.