17#ifndef _CELLULARCONTEXT_H_
18#define _CELLULARCONTEXT_H_
21#include "netsocket/CellularInterface.h"
23#include "CellularUtil.h"
50 static const int PDP_CONTEXT_COUNT = 4;
53 enum AuthenticationType {
61 enum RateControlExceptionReports {
62 NotAllowedToBeSent = 0,
67 enum RateControlUplinkTimeUnit {
77 char apn[MAX_ACCESSPOINT_NAME_LENGTH + 1];
78 char local_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
79 char local_subnet_mask[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
80 char gateway_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
81 char dns_primary_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
82 char dns_secondary_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
83 char p_cscf_prim_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
84 char p_cscf_sec_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
87 int im_signalling_flag;
93 int serving_plmn_rate_control_value;
100 local_subnet_mask[0] =
'\0';
101 gateway_addr[0] =
'\0';
102 dns_primary_addr[0] =
'\0';
103 dns_secondary_addr[0] =
'\0';
104 p_cscf_prim_addr[0] =
'\0';
105 p_cscf_sec_addr[0] =
'\0';
108 im_signalling_flag = -1;
109 lipa_indication = -1;
114 serving_plmn_rate_control_value = -1;
128#if !NSAPI_PPP_AVAILABLE
159 const char *pwd = 0) = 0;
160 virtual void set_credentials(
const char *apn,
const char *uname = 0,
const char *pwd = 0) = 0;
249 CellularContext::RateControlUplinkTimeUnit &time_unit,
int &uplink_rate) = 0;
270#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
306 enum ContextOperation {
317 DEFAULT_PDP_TYPE = DEFAULT_STACK,
318 IPV4_PDP_TYPE = IPV4_STACK,
319 IPV6_PDP_TYPE = IPV6_STACK,
320 IPV4V6_PDP_TYPE = IPV4V6_STACK,
377 pdp_type_t _pdp_type;
378 CellularContext::AuthenticationType _authentication_type;
379 nsapi_connection_status_t _connect_status;
381 Callback<void(nsapi_event_t, intptr_t)> _status_cb;
383 bool _new_context_set;
384 bool _is_context_active;
385 bool _is_context_activated;
391 uint16_t _retry_timeout_array[CELLULAR_RETRY_ARRAY_SIZE];
392 int _retry_array_length;
Implements support for data transfer using Control Plane CIoT EPS optimization.
Common interface that is shared between cellular interfaces.
Callback class based on template specialization.
CellularContext is CellularInterface/NetworkInterface with extensions for cellular connectivity.
virtual void set_plmn(const char *plmn)=0
Set the plmn.
virtual void set_sim_pin(const char *sim_pin)=0
Set the PIN code for SIM card.
void validate_ip_address()
After we have connected successfully we must check that we have a valid IP address.
virtual nsapi_error_t get_ip_address(SocketAddress *address)=0
Get the local IP address.
virtual nsapi_error_t configure_hup(PinName dcd_pin=NC, bool active_high=false)=0
Enable or disable hang-up detection.
virtual bool is_connected()=0
Check if the connection is currently established.
CellularDevice * get_device() const
Get pointer to CellularDevice instance.
virtual ControlPlane_netif * get_cp_netif()=0
Returns the control plane AT command interface.
virtual void do_connect_with_retry()
Retry logic after device attached to network.
CellularContext::pdp_type_t string_to_pdp_type(const char *pdp_type)
Converts the given pdp type in char format to enum pdp_type_t.
virtual nsapi_error_t get_apn_backoff_timer(int &backoff_timer)=0
Get backoff timer value.
static CellularContext * get_default_instance()
Same as NetworkInterface::get_default_instance()
void set_authentication_type(AuthenticationType type)
Set the authentication type to be used in user authentication if user name and password are defined.
virtual const char * get_nonip_context_type_str()=0
Return PDP type string for Non-IP if modem uses other than standard "Non-IP".
virtual nsapi_error_t get_rate_control(CellularContext::RateControlExceptionReports &reports, CellularContext::RateControlUplinkTimeUnit &time_unit, int &uplink_rate)=0
Get APN rate control.
virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr)=0
The CellularDevice calls the status callback function on status changes on the network or CellularDev...
virtual void set_credentials(const char *apn, const char *uname=0, const char *pwd=0)=0
Set the cellular network credentials.
virtual nsapi_error_t connect()=0
Attempt to connect to a cellular network.
virtual nsapi_error_t register_to_network()=0
Start the interface.
virtual nsapi_error_t set_sim_ready()=0
Start the interface.
virtual nsapi_error_t connect(const char *sim_pin, const char *apn=0, const char *uname=0, const char *pwd=0)=0
Attempt to connect to a cellular network with a PIN and credentials.
virtual void attach(mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb)=0
Register callback for status reporting.
virtual nsapi_error_t set_device_ready()=0
Start the interface.
virtual nsapi_error_t attach_to_network()=0
Start the interface.
void cp_data_received()
Triggers control plane's operations needed when control plane data is received, like socket event,...
void call_network_cb(nsapi_connection_status_t status)
Helper method to call callback function if it is provided.
static CellularContext * get_default_nonip_instance()
Instantiates a default Non-IP cellular interface.
virtual nsapi_error_t set_blocking(bool blocking)=0
Set asynchronous operation of connect() and disconnect() calls.
virtual nsapi_error_t get_pdpcontext_params(pdpContextList_t ¶ms_list)=0
Get the relevant information for an active nonsecondary PDP context.
virtual void do_connect()
Find and activate pdp context or in case of PPP find correct pdp context and open data channel.
virtual nsapi_error_t disconnect()=0
Stop the interface.
int get_cid() const
Get the pdp context id associated with this context.
An abstract interface for connecting to a network and getting information from it.
Implements support for data transfer using Control Plane CIoT EPS optimization specified in 3GPP 23....
signed int nsapi_error_t
Type used to represent error codes.