Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
CellularNetwork Class Reference
Class CellularNetwork. More...
#include <CellularNetwork.h>
Inherits NetworkInterface.
Inherited by AT_CellularNetwork.
Public Member Functions | |
virtual nsapi_error_t | set_registration (const char *plmn=0)=0 |
Request registering to network. | |
virtual nsapi_error_t | get_registration_status (RegistrationType type, RegistrationStatus &status)=0 |
Gets the network registration status. | |
virtual nsapi_error_t | set_credentials (const char *apn, const char *username=0, const char *password=0)=0 |
Set the cellular network APN and credentials. | |
virtual nsapi_error_t | set_credentials (const char *apn, AuthenticationType type, const char *username=0, const char *password=0)=0 |
Set the cellular network APN and credentials. | |
virtual nsapi_error_t | set_attach (int timeout=10 *1000)=0 |
Request attach to network. | |
virtual nsapi_error_t | get_attach (AttachStatus &status)=0 |
Request attach status from network. | |
virtual nsapi_error_t | get_rate_control (CellularNetwork::RateControlExceptionReports &reports, CellularNetwork::RateControlUplinkTimeUnit &time_unit, int &uplink_rate)=0 |
Get APN rate control. | |
virtual nsapi_error_t | get_apn_backoff_timer (int &backoff_timer)=0 |
Get backoff timer value. | |
virtual nsapi_error_t | set_access_technology (operator_t::RadioAccessTechnology op_rat)=0 |
Sets radio access technology. | |
virtual nsapi_error_t | scan_plmn (operList_t &operators, int &ops_count)=0 |
Scans for operators module can reach. | |
virtual nsapi_error_t | set_ciot_optimization_config (Supported_UE_Opt supported_opt, Preferred_UE_Opt preferred_opt)=0 |
Set CIoT optimizations. | |
virtual nsapi_error_t | get_ciot_optimization_config (Supported_UE_Opt &supported_opt, Preferred_UE_Opt &preferred_opt)=0 |
Get CIoT optimizations. | |
virtual nsapi_error_t | connect ()=0 |
Start the interface. | |
virtual nsapi_error_t | connect (const char *apn, const char *username=0, const char *password=0)=0 |
Start the interface. | |
virtual nsapi_error_t | set_stack_type (nsapi_ip_stack_t stack_type)=0 |
Set the pdn type to be used. | |
virtual nsapi_ip_stack_t | get_stack_type ()=0 |
Get the pdn type in use. | |
virtual nsapi_error_t | get_pdpcontext_params (pdpContextList_t ¶ms_list)=0 |
Get the relevant information for an active non secondary PDP context. | |
virtual nsapi_error_t | get_extended_signal_quality (int &rxlev, int &ber, int &rscp, int &ecno, int &rsrq, int &rsrp)=0 |
Get extended signal quality parameters. | |
virtual nsapi_error_t | get_signal_quality (int &rssi, int &ber)=0 |
Get signal quality parameters. | |
virtual nsapi_error_t | get_cell_id (int &cell_id)=0 |
Get cell id. | |
virtual int | get_3gpp_error ()=0 |
Get the last 3GPP error code. | |
virtual nsapi_error_t | get_operator_params (int &format, operator_t &operator_params)=0 |
Get the operator parameters. | |
virtual void | attach (mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb)=0 |
Register callback for status reporting. | |
virtual nsapi_connection_status_t | get_connection_status () const =0 |
Get the connection status. | |
virtual nsapi_error_t | set_blocking (bool blocking)=0 |
Set blocking status of connect() which by default should be blocking. | |
virtual const char * | get_mac_address () |
Get the local MAC address. | |
virtual const char * | get_ip_address () |
Get the local IP address. | |
virtual const char * | get_netmask () |
Get the local network mask. | |
virtual const char * | get_gateway () |
Get the local gateway. | |
virtual nsapi_error_t | set_network (const char *ip_address, const char *netmask, const char *gateway) |
Set a static IP address. | |
virtual nsapi_error_t | set_dhcp (bool dhcp) |
Enable or disable DHCP on the network. | |
virtual nsapi_error_t | disconnect ()=0 |
Stop the interface. | |
virtual nsapi_error_t | gethostbyname (const char *host, SocketAddress *address, nsapi_version_t version=NSAPI_UNSPEC) |
Translates a hostname to an IP address with specific version. | |
virtual nsapi_error_t | add_dns_server (const SocketAddress &address) |
Add a domain name server to list of servers to query. | |
Protected Member Functions | |
virtual | ~CellularNetwork () |
virtual Destructor | |
virtual NetworkStack * | get_stack ()=0 |
Provide access to the NetworkStack object. | |
Friends | |
class | Socket |
class | UDPSocket |
class | TCPSocket |
Detailed Description
Class CellularNetwork.
An abstract interface for connecting to a network and getting information from it.
Definition at line 38 of file CellularNetwork.h.
Constructor & Destructor Documentation
virtual ~CellularNetwork | ( | ) | [protected, virtual] |
virtual Destructor
Definition at line 47 of file CellularNetwork.h.
Member Function Documentation
nsapi_error_t add_dns_server | ( | const SocketAddress & | address ) | [virtual, inherited] |
Add a domain name server to list of servers to query.
- Parameters:
-
address Destination for the host address
- Returns:
- 0 on success, negative error code on failure
Definition at line 60 of file NetworkInterface_stub.cpp.
virtual void attach | ( | mbed::Callback< void(nsapi_event_t, intptr_t)> | status_cb ) | [pure virtual] |
Register callback for status reporting.
The specified status callback function will be called on status changes on the network. The parameters on the callback are the event type and event-type dependent reason parameter.
- Parameters:
-
status_cb The callback for status changes
virtual nsapi_error_t connect | ( | ) | [pure virtual] |
Start the interface.
Attempts to connect to a cellular network.
- Returns:
- 0 on success, negative error code on failure
Implemented in AT_CellularNetwork.
virtual nsapi_error_t connect | ( | const char * | apn, |
const char * | username = 0 , |
||
const char * | password = 0 |
||
) | [pure virtual] |
Start the interface.
Attempts to connect to a cellular network.
- Parameters:
-
apn Optional name of the network to connect to username Optional username for your APN password Optional password for your APN
- Returns:
- 0 on success, negative error code on failure
Implemented in AT_CellularNetwork.
virtual nsapi_error_t disconnect | ( | ) | [pure virtual, inherited] |
Stop the interface.
- Returns:
- 0 on success, negative error code on failure
virtual int get_3gpp_error | ( | ) | [pure virtual] |
Get the last 3GPP error code.
- Returns:
- see 3GPP TS 27.007 error codes
Implemented in AT_CellularNetwork.
virtual nsapi_error_t get_apn_backoff_timer | ( | int & | backoff_timer ) | [pure virtual] |
Get backoff timer value.
- Parameters:
-
backoff_timer Backoff timer value associated with PDP APN in seconds
- Returns:
- zero on success
Implemented in AT_CellularNetwork.
virtual nsapi_error_t get_attach | ( | AttachStatus & | status ) | [pure virtual] |
Request attach status from network.
- Parameters:
-
status see AttachStatus values
- Returns:
- zero on success
Implemented in AT_CellularNetwork.
virtual nsapi_error_t get_cell_id | ( | int & | cell_id ) | [pure virtual] |
Get cell id.
- Parameters:
-
cell_id cell id
- Returns:
- NSAPI_ERROR_OK on success, negative error code on failure
Implemented in AT_CellularNetwork.
virtual nsapi_error_t get_ciot_optimization_config | ( | Supported_UE_Opt & | supported_opt, |
Preferred_UE_Opt & | preferred_opt | ||
) | [pure virtual] |
Get CIoT optimizations.
- Parameters:
-
supported_opt Supported CIoT EPS optimizations. preferred_opt Preferred CIoT EPS optimizations.
- Returns:
- zero on success
Implemented in AT_CellularNetwork.
virtual nsapi_connection_status_t get_connection_status | ( | ) | const [pure virtual] |
Get the connection status.
- Returns:
- The connection status according to ConnectionStatusType
Implemented in AT_CellularNetwork.
virtual nsapi_error_t get_extended_signal_quality | ( | int & | rxlev, |
int & | ber, | ||
int & | rscp, | ||
int & | ecno, | ||
int & | rsrq, | ||
int & | rsrp | ||
) | [pure virtual] |
Get extended signal quality parameters.
- Parameters:
-
rxlev signal strength level ber bit error rate rscp signal code power ecno ratio of the received energy per PN chip to the total received power spectral density rsrq signal received quality rsrp signal received power
- Returns:
- NSAPI_ERROR_OK on success, negative error code on failure
Implemented in AT_CellularNetwork.
const char * get_gateway | ( | ) | [virtual, inherited] |
Get the local gateway.
- Returns:
- Null-terminated representation of the local gateway or null if no network mask has been received
Definition at line 39 of file NetworkInterface_stub.cpp.
const char * get_ip_address | ( | ) | [virtual, inherited] |
Get the local IP address.
- Returns:
- Null-terminated representation of the local IP address or null if no IP address has been received
Definition at line 29 of file NetworkInterface_stub.cpp.
const char * get_mac_address | ( | ) | [virtual, inherited] |
Get the local MAC address.
Provided MAC address is intended for info or debug purposes and may not be provided if the underlying network interface does not provide a MAC address
- Returns:
- Null-terminated representation of the local MAC address or null if no MAC address is available
Definition at line 24 of file NetworkInterface_stub.cpp.
const char * get_netmask | ( | ) | [virtual, inherited] |
Get the local network mask.
- Returns:
- Null-terminated representation of the local network mask or null if no network mask has been received
Definition at line 34 of file NetworkInterface_stub.cpp.
virtual nsapi_error_t get_operator_params | ( | int & | format, |
operator_t & | operator_params | ||
) | [pure virtual] |
Get the operator parameters.
- Parameters:
-
format format of the operator field operator_params applicable operator param fields filled
- Returns:
- NSAPI_ERROR_OK on success, negative error code on failure
Implemented in AT_CellularNetwork.
virtual nsapi_error_t get_pdpcontext_params | ( | pdpContextList_t & | params_list ) | [pure virtual] |
Get the relevant information for an active non secondary PDP context.
- Remarks:
- optional params are not updated if not received from network.
- Parameters:
-
params_list reference to linked list which is filled on successful call
- Returns:
- 0 on success, negative error code on failure
Implemented in AT_CellularNetwork.
virtual nsapi_error_t get_rate_control | ( | CellularNetwork::RateControlExceptionReports & | reports, |
CellularNetwork::RateControlUplinkTimeUnit & | time_unit, | ||
int & | uplink_rate | ||
) | [pure virtual] |
Get APN rate control.
- Remarks:
- optional params are not updated if not received from network, so use good defaults
- Parameters:
-
reports Additional exception reports at maximum rate reached are allowed to be sent [optional] time_unit Uplink time unit with values 0=unrestricted, 1=minute, 2=hour, 3=day, 4=week [optional] uplink_rate Maximum number of messages per timeUnit [optional]
- Returns:
- zero on success
Implemented in AT_CellularNetwork.
virtual nsapi_error_t get_registration_status | ( | RegistrationType | type, |
RegistrationStatus & | status | ||
) | [pure virtual] |
Gets the network registration status.
- Parameters:
-
type see RegistrationType values status see RegistrationStatus values
- Returns:
- zero on success
virtual nsapi_error_t get_signal_quality | ( | int & | rssi, |
int & | ber | ||
) | [pure virtual] |
Get signal quality parameters.
- Parameters:
-
rssi signal strength level ber bit error rate
- Returns:
- NSAPI_ERROR_OK on success, negative error code on failure
Implemented in AT_CellularNetwork.
virtual NetworkStack* get_stack | ( | ) | [protected, pure virtual, inherited] |
Provide access to the NetworkStack object.
- Returns:
- The underlying NetworkStack object
virtual nsapi_ip_stack_t get_stack_type | ( | ) | [pure virtual] |
nsapi_error_t gethostbyname | ( | const char * | host, |
SocketAddress * | address, | ||
nsapi_version_t | version = NSAPI_UNSPEC |
||
) | [virtual, inherited] |
Translates a hostname to an IP address with specific version.
The hostname may be either a domain name or an IP address. If the hostname is an IP address, no network transactions will be performed.
If no stack-specific DNS resolution is provided, the hostname will be resolve using a UDP socket on the stack.
- Parameters:
-
address Destination for the host SocketAddress host Hostname to resolve version IP version of address to resolve, NSAPI_UNSPEC indicates version is chosen by the stack (defaults to NSAPI_UNSPEC)
- Returns:
- 0 on success, negative error code on failure
Definition at line 55 of file NetworkInterface_stub.cpp.
virtual nsapi_error_t scan_plmn | ( | operList_t & | operators, |
int & | ops_count | ||
) | [pure virtual] |
Scans for operators module can reach.
- Parameters:
-
operators Container of reachable operators and their access technologies ops_count Number of found operators
- Returns:
- zero on success
Implemented in AT_CellularNetwork.
virtual nsapi_error_t set_access_technology | ( | operator_t::RadioAccessTechnology | op_rat ) | [pure virtual] |
Sets radio access technology.
- Parameters:
-
op_rat Radio access technology
- Returns:
- zero on success
virtual nsapi_error_t set_attach | ( | int | timeout = 10 *1000 ) |
[pure virtual] |
Request attach to network.
- Parameters:
-
timeout milliseconds to wait for attach response
- Returns:
- zero on success
Implemented in AT_CellularNetwork.
virtual nsapi_error_t set_blocking | ( | bool | blocking ) | [pure virtual] |
Set blocking status of connect() which by default should be blocking.
- Parameters:
-
blocking true if connect is blocking
- Returns:
- 0 on success, negative error code on failure
Implemented in AT_CellularNetwork.
virtual nsapi_error_t set_ciot_optimization_config | ( | Supported_UE_Opt | supported_opt, |
Preferred_UE_Opt | preferred_opt | ||
) | [pure virtual] |
Set CIoT optimizations.
- Parameters:
-
supported_opt Supported CIoT EPS optimizations. preferred_opt Preferred CIoT EPS optimizations.
- Returns:
- zero on success
Implemented in AT_CellularNetwork.
virtual nsapi_error_t set_credentials | ( | const char * | apn, |
const char * | username = 0 , |
||
const char * | password = 0 |
||
) | [pure virtual] |
Set the cellular network APN and credentials.
- Parameters:
-
apn Optional name of the network to connect to username Optional username for the APN password Optional password fot the APN
- Returns:
- 0 on success, negative error code on failure
Implemented in AT_CellularNetwork.
virtual nsapi_error_t set_credentials | ( | const char * | apn, |
AuthenticationType | type, | ||
const char * | username = 0 , |
||
const char * | password = 0 |
||
) | [pure virtual] |
Set the cellular network APN and credentials.
- Parameters:
-
apn Name of the network to connect to type Authentication type to use username Optional username for the APN password Optional password fot the APN
- Returns:
- 0 on success, negative error code on failure
nsapi_error_t set_dhcp | ( | bool | dhcp ) | [virtual, inherited] |
Enable or disable DHCP on the network.
Enables DHCP on connecting the network. Defaults to enabled unless a static IP address has been assigned. Requires that the network is disconnected.
- Parameters:
-
dhcp True to enable DHCP
- Returns:
- 0 on success, negative error code on failure
Definition at line 49 of file NetworkInterface_stub.cpp.
nsapi_error_t set_network | ( | const char * | ip_address, |
const char * | netmask, | ||
const char * | gateway | ||
) | [virtual, inherited] |
Set a static IP address.
Configures this network interface to use a static IP address. Implicitly disables DHCP, which can be enabled in set_dhcp. Requires that the network is disconnected.
- Parameters:
-
ip_address Null-terminated representation of the local IP address netmask Null-terminated representation of the local network mask gateway Null-terminated representation of the local gateway
- Returns:
- 0 on success, negative error code on failure
Definition at line 44 of file NetworkInterface_stub.cpp.
virtual nsapi_error_t set_registration | ( | const char * | plmn = 0 ) |
[pure virtual] |
Request registering to network.
- Parameters:
-
plmn format is in numeric format or 0 for automatic network registration
- Returns:
- zero on success
Implemented in AT_CellularNetwork.
virtual nsapi_error_t set_stack_type | ( | nsapi_ip_stack_t | stack_type ) | [pure virtual] |
Set the pdn type to be used.
- Parameters:
-
stack_type the stack type to be used.
- Returns:
- NSAPI_ERROR_OK on success
Implemented in AT_CellularNetwork.
Generated on Tue Jul 12 2022 14:27:12 by
