Class AT_CellularDevice. More...
#include <AT_CellularDevice.h>
Public Member Functions | |
virtual nsapi_error_t | hard_power_on () |
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 () |
Sets the modem in unplugged state. More... | |
virtual nsapi_error_t | soft_power_on () |
Powers up the modem. More... | |
virtual nsapi_error_t | soft_power_off () |
Powers down the modem. More... | |
virtual nsapi_error_t | set_pin (const char *sim_pin) |
Open the SIM card by setting the pin code for SIM. More... | |
virtual nsapi_error_t | get_sim_state (SimState &state) |
Get SIM card's state. More... | |
virtual CellularContext * | create_context (FileHandle *fh=NULL, const char *apn=NULL, bool cp_req=false, bool nonip_req=false) |
Creates a new CellularContext interface. More... | |
virtual CellularContext * | create_context (UARTSerial *serial, const char *const apn, PinName dcd_pin=NC, bool active_high=false, bool cp_req=false, bool nonip_req=false) |
Creates a new CellularContext interface. More... | |
virtual void | delete_context (CellularContext *context) |
Deletes the given CellularContext instance. More... | |
virtual CellularNetwork * | open_network (FileHandle *fh=NULL) |
Create new CellularNetwork interface. More... | |
virtual CellularSMS * | open_sms (FileHandle *fh=NULL) |
Create new CellularSMS interface. More... | |
virtual CellularInformation * | open_information (FileHandle *fh=NULL) |
Create new CellularInformation interface. More... | |
virtual void | close_network () |
Closes the opened CellularNetwork by deleting the CellularNetwork instance. More... | |
virtual void | close_sms () |
Closes the opened CellularSMS by deleting the CellularSMS instance. More... | |
virtual void | close_information () |
Closes the opened CellularInformation by deleting the CellularInformation instance. More... | |
virtual void | set_timeout (int timeout) |
Set the default response timeout. More... | |
virtual void | modem_debug_on (bool on) |
Turn modem debug traces on. More... | |
virtual nsapi_error_t | init () |
Initialize cellular device must be called right after the module is ready. More... | |
virtual nsapi_error_t | shutdown () |
Shutdown cellular device to minimum functionality. More... | |
virtual nsapi_error_t | is_ready () |
Check whether the device is ready to accept commands. More... | |
virtual void | set_ready_cb (Callback< void()> callback) |
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) |
Set power save mode. More... | |
virtual ATHandler * | get_at_handler () |
Get the current ATHandler instance in use for debug purposes etc. More... | |
virtual nsapi_error_t | release_at_handler (ATHandler *at_handler) |
Releases the given at_handler. More... | |
virtual AT_CellularContext * | create_context_impl (ATHandler &at, const char *apn, bool cp_req=false, bool nonip_req=false) |
Creates new instance of AT_CellularContext or if overridden, modem specific implementation. More... | |
virtual AT_CellularNetwork * | open_network_impl (ATHandler &at) |
Create new instance of AT_CellularNetwork or if overridden, modem specific implementation. More... | |
virtual AT_CellularSMS * | open_sms_impl (ATHandler &at) |
Create new instance of AT_CellularSMS or if overridden, modem specific implementation. More... | |
virtual AT_CellularInformation * | open_information_impl (ATHandler &at) |
Create new instance of AT_CellularInformation or if overridden, modem specific implementation. More... | |
virtual CellularContext * | get_context_list () const |
Get the linked list of CellularContext instances. More... | |
void | stop () |
Stop the current operation. More... | |
FileHandle & | get_file_handle () const |
Get the current FileHandle item used when communicating with the modem. More... | |
virtual events::EventQueue * | get_queue () |
Get event queue that can be chained to main event queue. 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 AT_CellularDevice.
A class defines opening and closing of cellular interfaces. Deleting/Closing of opened interfaces can be done only through this class.
Definition at line 37 of file AT_CellularDevice.h.
|
inherited |
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. |
|
inherited |
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 from CellularDevice.
|
virtual |
Closes the opened CellularInformation by deleting the CellularInformation instance.
Implements CellularDevice.
|
virtual |
Closes the opened CellularNetwork by deleting the CellularNetwork instance.
Implements CellularDevice.
|
virtual |
Closes the opened CellularSMS by deleting the CellularSMS instance.
Implements CellularDevice.
|
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 |
Implements CellularDevice.
|
virtual |
Creates a new CellularContext interface.
This API should be used if serial is UART and PPP mode used. CellularContext created will use data carrier detect to be able to detect disconnection much faster in PPP mode. UARTSerial usually is the same which was given for the CellularDevice.
serial | UARTSerial used in communication to modem. If null then the default file handle is used. |
apn | access point to use with context, can be null. |
dcd_pin | Pin used to set data carrier detect on/off for the given UART |
active_high | a boolean set to true if DCD polarity is active low |
cp_req | Flag indicating if EPS control plane optimization is required |
nonip_req | Flag indicating if this context is required to be Non-IP |
Implements CellularDevice.
|
virtual |
Creates new instance of AT_CellularContext or if overridden, modem specific implementation.
at | ATHandler reference for communication with the modem. |
apn | access point to use with context |
cp_req | flag indicating if control plane EPS optimization needs to be setup |
nonip_req | flag indicating if PDP context needs to be Non-IP |
|
virtual |
Deletes the given CellularContext instance.
context | CellularContext to delete |
Implements CellularDevice.
|
virtual |
Get the current ATHandler instance in use for debug purposes etc.
Once use has been finished call to release_at_handler() has to be made
Implements CellularDevice.
|
virtual |
Get the linked list of CellularContext instances.
Reimplemented from CellularDevice.
|
staticinherited |
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.
|
inherited |
Get the current FileHandle item used when communicating with the modem.
|
virtualinherited |
Get event queue that can be chained to main event queue.
|
protectedinherited |
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 |
|
virtual |
Get SIM card's state.
state | current state of SIM |
Implements CellularDevice.
|
staticinherited |
Return target onboard instance of CellularDevice.
|
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.
Implements CellularDevice.
|
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.
Implements CellularDevice.
|
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.
Implements CellularDevice.
|
virtual |
Check whether the device is ready to accept commands.
Implements CellularDevice.
|
virtual |
|
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. |
Implements CellularDevice.
|
virtual |
Create new instance of AT_CellularInformation or if overridden, modem specific implementation.
at | ATHandler reference for communication with the modem. |
|
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. |
Implements CellularDevice.
|
virtual |
Create new instance of AT_CellularNetwork or if overridden, modem specific implementation.
at | ATHandler reference for communication with the modem. |
|
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. |
Implements CellularDevice.
|
virtual |
Create new instance of AT_CellularSMS or if overridden, modem specific implementation.
at | ATHandler reference for communication with the modem. |
|
inherited |
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.
|
virtual |
Releases the given at_handler.
If last reference to at_hander then it's deleted.
at_handler |
Implements CellularDevice.
|
inherited |
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.
|
virtual |
Open the SIM card by setting the pin code for SIM.
sim_pin | PIN for the SIM card |
Implements CellularDevice.
|
inherited |
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 |
|
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 |
Implements CellularDevice.
|
virtual |
Set callback function to listen when device is ready.
callback | function to call on device ready, or NULL to remove callback. |
Implements CellularDevice.
|
inherited |
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 |
|
inherited |
Set the pin code for SIM card.
sim_pin | PIN for the SIM card |
|
inherited |
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.
|
virtual |
Set the default response timeout.
timeout
.timeout | milliseconds to wait response from modem |
Implements 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 from CellularDevice.
|
virtual |
Powers down the modem.
This is equivalent to turning off the modem by button press.
Implements CellularDevice.
|
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.
Implements CellularDevice.
|
inherited |
Stop the current operation.
Operations: set_device_ready, set_sim_ready, register_to_network, attach_to_network