Skip to content

Cellular: Non-IP socket and PDP context for EPS control plane data de… #9121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(unittest-includes ${unittest-includes}
../features/cellular/framework/common
../features/cellular/framework/AT
../features/cellular/framework/device
../features/netsocket/cellular
)

# Source files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set(unittest-includes ${unittest-includes}
../features/frameworks/mbed-client-randlib/mbed-client-randlib
../drivers
../hal
../features/netsocket/cellular
)

# Source files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(unittest-includes ${unittest-includes}
/features/cellular/framework/device/cellulardevice
../features/cellular/framework/device
../features/cellular/framework/common
../features/netsocket/cellular
)

# Source files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(unittest-includes ${unittest-includes}
/features/cellular/framework/device/cellularstatemachine
../features/cellular/framework/device
../features/cellular/framework/common
../features/netsocket/cellular
)

# Source files
Expand Down
2 changes: 2 additions & 0 deletions UNITTESTS/stubs/AT_CellularBase_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ intptr_t AT_CellularBase::get_property(CellularProperty key)
return AT_CellularNetwork::RegistrationModeEnable;
} else if (key == PROPERTY_AT_CGAUTH) {
return true;
} else if (key == PROPERTY_IPV4_PDP_TYPE) {
return true;
}

return AT_CellularBase_stub::supported_bool;
Expand Down
59 changes: 42 additions & 17 deletions UNITTESTS/stubs/AT_CellularContext_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

using namespace mbed;

AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn) :
AT_CellularBase(at), _ip_stack_type_requested(DEFAULT_STACK), _is_connected(false), _is_blocking(true),
_current_op(OP_INVALID), _device(device), _nw(0), _fh(0)
AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn, bool cp_req, bool nonip_req) :
AT_CellularBase(at), _is_blocking(true), _is_connected(false),
_current_op(OP_INVALID), _device(device), _nw(0), _fh(0), _cp_req(cp_req), _nonip_req(nonip_req), _cp_in_use(false), _cp_netif(NULL)
{
_stack = NULL;
_ip_stack_type = DEFAULT_STACK;
_pdp_type = DEFAULT_PDP_TYPE;
_authentication_type = CellularContext::CHAP;
_connect_status = NSAPI_STATUS_DISCONNECTED;
_is_context_active = false;
Expand Down Expand Up @@ -143,25 +143,23 @@ const char *AT_CellularContext::get_gateway()
return NULL;
}

AT_CellularBase::CellularProperty AT_CellularContext::nsapi_ip_stack_t_to_cellular_property(nsapi_ip_stack_t stack)
AT_CellularBase::CellularProperty AT_CellularContext::pdp_type_t_to_cellular_property(pdp_type_t pdp_type)
{
AT_CellularBase::CellularProperty prop = PROPERTY_IPV4_STACK;
if (stack == IPV6_STACK) {
prop = PROPERTY_IPV6_STACK;
} else if (stack == IPV4V6_STACK) {
prop = PROPERTY_IPV4V6_STACK;
AT_CellularBase::CellularProperty prop = PROPERTY_IPV4_PDP_TYPE;
if (pdp_type == IPV6_PDP_TYPE) {
prop = PROPERTY_IPV6_PDP_TYPE;
} else if (pdp_type == IPV4V6_PDP_TYPE) {
prop = PROPERTY_IPV4V6_PDP_TYPE;
} else if (pdp_type == NON_IP_PDP_TYPE) {
prop = PROPERTY_NON_IP_PDP_TYPE;
}
return prop;
}

nsapi_ip_stack_t AT_CellularContext::get_stack_type()
{
return IPV4V6_STACK;
return prop;
}

nsapi_ip_stack_t AT_CellularContext::string_to_stack_type(const char *pdp_type)
pdp_type_t AT_CellularContext::string_to_pdp_type(const char *pdp_type)
{
return IPV4V6_STACK;
return IPV4V6_PDP_TYPE;
}

// PDP Context handling
Expand Down Expand Up @@ -236,3 +234,30 @@ void AT_CellularContext::cellular_callback(nsapi_event_t ev, intptr_t ptr)
void AT_CellularContext::call_network_cb(nsapi_connection_status_t status)
{
}

ControlPlane_netif *AT_CellularContext::get_cp_netif()
{
return NULL;
}

nsapi_error_t AT_CellularContext::activate_non_ip_context()
{
return NSAPI_ERROR_OK;
}

nsapi_error_t AT_CellularContext::setup_control_plane_opt()
{
return NSAPI_ERROR_OK;
}

void AT_CellularContext::deactivate_ip_context()
{
}

void AT_CellularContext::deactivate_non_ip_context()
{
}

void AT_CellularContext::set_disconnect()
{
}
6 changes: 3 additions & 3 deletions UNITTESTS/stubs/AT_CellularDevice_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void AT_CellularDevice::release_at_handler(ATHandler *at_handler)
}

CellularContext *AT_CellularDevice::create_context(UARTSerial *serial, const char *const apn, PinName dcd_pin,
bool active_high)
bool active_high, bool cp_req, bool nonip_req)
{
}

Expand Down Expand Up @@ -113,12 +113,12 @@ CellularContext *AT_CellularDevice::get_context_list() const
return NULL;
}

CellularContext *AT_CellularDevice::create_context(FileHandle *fh, const char *apn)
CellularContext *AT_CellularDevice::create_context(FileHandle *fh, const char *apn, bool cp_req, bool nonip_req)
{
return NULL;
}

AT_CellularContext *AT_CellularDevice::create_context_impl(ATHandler &at, const char *apn)
AT_CellularContext *AT_CellularDevice::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req)
{
return NULL;
}
Expand Down
3 changes: 3 additions & 0 deletions UNITTESTS/stubs/CellularDevice_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,6 @@ nsapi_error_t CellularDevice::shutdown()
return NSAPI_ERROR_OK;
}

void CellularDevice::cellular_callback(nsapi_event_t ev, intptr_t ptr)
{
}
4 changes: 2 additions & 2 deletions UNITTESTS/target_h/myCellularDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ class myCellularDevice : public CellularDevice {
}

virtual CellularContext *create_context(UARTSerial *serial, const char *const apn, PinName dcd_pin,
bool active_high)
bool active_high, bool cp_req = false, bool nonip_req = false)
{
return NULL;
}

virtual CellularContext *create_context(FileHandle *fh = NULL, const char *apn = NULL)
virtual CellularContext *create_context(FileHandle *fh = NULL, const char *apn = NULL, bool cp_req = false, bool nonip_req = false)
{
EventQueue que;
FileHandle_stub fh1;
Expand Down
16 changes: 15 additions & 1 deletion features/cellular/framework/API/CellularContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@

#include "CellularBase.h"
#include "CellularDevice.h"
#include "ControlPlane_netif.h"

namespace mbed {

typedef enum pdp_type {
DEFAULT_PDP_TYPE = DEFAULT_STACK,
IPV4_PDP_TYPE = IPV4_STACK,
IPV6_PDP_TYPE = IPV6_STACK,
IPV4V6_PDP_TYPE = IPV4V6_STACK,
NON_IP_PDP_TYPE
} pdp_type_t;

class CellularContext : public CellularBase {

public:

// max simultaneous PDP contexts active
static const int PDP_CONTEXT_COUNT = 4;

Expand Down Expand Up @@ -219,6 +229,10 @@ class CellularContext : public CellularBase {
*/
virtual void set_file_handle(UARTSerial *serial, PinName dcd_pin = NC, bool active_high = false) = 0;

/** Returns the control plane AT command interface
*/
virtual ControlPlane_netif *get_cp_netif() = 0;

protected: // Device specific implementations might need these so protected
enum ContextOperation {
OP_INVALID = -1,
Expand Down Expand Up @@ -249,7 +263,7 @@ class CellularContext : public CellularBase {

// member variables needed in target override methods
NetworkStack *_stack; // must be pointer because of PPP
nsapi_ip_stack_t _ip_stack_type;
pdp_type_t _pdp_type;
CellularContext::AuthenticationType _authentication_type;
nsapi_connection_status_t _connect_status;
cell_callback_data_t _cb_data;
Expand Down
14 changes: 9 additions & 5 deletions features/cellular/framework/API/CellularDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ class CellularDevice {

/** Creates a new CellularContext interface.
*
* @param fh file handle used in communication to modem. Can be for example UART handle. If null then the default
* file handle is used.
* @param apn access point to use with context, can be null.
* @param fh file handle used in communication to modem. Can be for example UART handle. If null then the default
* file handle is used.
* @param apn access point to use with context, can be null.
* @param cp_req flag indicating if EPS control plane optimisation is required
* @param nonip_req flag indicating if this context is required to be Non-IP
*
* @return new instance of class CellularContext or NULL in case of failure
*
*/
virtual CellularContext *create_context(FileHandle *fh = NULL, const char *apn = NULL) = 0;
virtual CellularContext *create_context(FileHandle *fh = NULL, const char *apn = NULL, bool cp_req = false, bool nonip_req = false) = 0;

/** 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.
Expand All @@ -104,12 +106,14 @@ class CellularDevice {
* @param apn access point to use with context, can be null.
* @param dcd_pin Pin used to set data carrier detect on/off for the given UART
* @param active_high a boolean set to true if DCD polarity is active low
* @param cp_req Flag indicating if EPS control plane optimisation is required
* @param nonip_req Flag indicating if this context is required to be Non-IP
*
* @return new instance of class CellularContext or NULL in case of failure
*
*/
virtual CellularContext *create_context(UARTSerial *serial, const char *apn, PinName dcd_pin = NC,
bool active_high = false) = 0;
bool active_high = false, bool cp_req = false, bool nonip_req = false) = 0;

/** Deletes the given CellularContext instance
*
Expand Down
7 changes: 4 additions & 3 deletions features/cellular/framework/AT/AT_CellularBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ class AT_CellularBase {
PROPERTY_AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN.
PROPERTY_AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***<cid>#
PROPERTY_AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported
PROPERTY_IPV4_STACK, // 0 = not supported, 1 = supported. Does modem support IPV4?
PROPERTY_IPV6_STACK, // 0 = not supported, 1 = supported. Does modem support IPV6?
PROPERTY_IPV4V6_STACK, // 0 = not supported, 1 = supported. Does modem support dual stack IPV4V6?
PROPERTY_IPV4_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4?
PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6?
PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support dual stack IPV4V6?
PROPERTY_NON_IP_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support Non-IP?
PROPERTY_MAX
};

Expand Down
Loading