Skip to content

Commit 2af12ae

Browse files
author
Cruz Monrreal
authored
Merge pull request #9121 from mirelachirica/feature-cellular-refactor_nonip
Cellular: Non-IP socket and PDP context for EPS control plane data de…
2 parents a7f4388 + 8129f78 commit 2af12ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1214
-198
lines changed

UNITTESTS/features/cellular/framework/AT/at_cellularcontext/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set(unittest-includes ${unittest-includes}
99
../features/cellular/framework/common
1010
../features/cellular/framework/AT
1111
../features/cellular/framework/device
12+
../features/netsocket/cellular
1213
)
1314

1415
# Source files

UNITTESTS/features/cellular/framework/AT/at_cellulardevice/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ set(unittest-includes ${unittest-includes}
1212
../features/frameworks/mbed-client-randlib/mbed-client-randlib
1313
../drivers
1414
../hal
15+
../features/netsocket/cellular
1516
)
1617

1718
# Source files

UNITTESTS/features/cellular/framework/device/cellulardevice/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(unittest-includes ${unittest-includes}
88
/features/cellular/framework/device/cellulardevice
99
../features/cellular/framework/device
1010
../features/cellular/framework/common
11+
../features/netsocket/cellular
1112
)
1213

1314
# Source files

UNITTESTS/features/cellular/framework/device/cellularstatemachine/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(unittest-includes ${unittest-includes}
88
/features/cellular/framework/device/cellularstatemachine
99
../features/cellular/framework/device
1010
../features/cellular/framework/common
11+
../features/netsocket/cellular
1112
)
1213

1314
# Source files

UNITTESTS/stubs/AT_CellularBase_stub.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ intptr_t AT_CellularBase::get_property(CellularProperty key)
4848
return AT_CellularNetwork::RegistrationModeEnable;
4949
} else if (key == PROPERTY_AT_CGAUTH) {
5050
return true;
51+
} else if (key == PROPERTY_IPV4_PDP_TYPE) {
52+
return true;
5153
}
5254

5355
return AT_CellularBase_stub::supported_bool;

UNITTESTS/stubs/AT_CellularContext_stub.cpp

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
using namespace mbed;
2121

22-
AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn) :
23-
AT_CellularBase(at), _ip_stack_type_requested(DEFAULT_STACK), _is_connected(false), _is_blocking(true),
24-
_current_op(OP_INVALID), _device(device), _nw(0), _fh(0)
22+
AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn, bool cp_req, bool nonip_req) :
23+
AT_CellularBase(at), _is_blocking(true), _is_connected(false),
24+
_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)
2525
{
2626
_stack = NULL;
27-
_ip_stack_type = DEFAULT_STACK;
27+
_pdp_type = DEFAULT_PDP_TYPE;
2828
_authentication_type = CellularContext::CHAP;
2929
_connect_status = NSAPI_STATUS_DISCONNECTED;
3030
_is_context_active = false;
@@ -143,25 +143,23 @@ const char *AT_CellularContext::get_gateway()
143143
return NULL;
144144
}
145145

146-
AT_CellularBase::CellularProperty AT_CellularContext::nsapi_ip_stack_t_to_cellular_property(nsapi_ip_stack_t stack)
146+
AT_CellularBase::CellularProperty AT_CellularContext::pdp_type_t_to_cellular_property(pdp_type_t pdp_type)
147147
{
148-
AT_CellularBase::CellularProperty prop = PROPERTY_IPV4_STACK;
149-
if (stack == IPV6_STACK) {
150-
prop = PROPERTY_IPV6_STACK;
151-
} else if (stack == IPV4V6_STACK) {
152-
prop = PROPERTY_IPV4V6_STACK;
148+
AT_CellularBase::CellularProperty prop = PROPERTY_IPV4_PDP_TYPE;
149+
if (pdp_type == IPV6_PDP_TYPE) {
150+
prop = PROPERTY_IPV6_PDP_TYPE;
151+
} else if (pdp_type == IPV4V6_PDP_TYPE) {
152+
prop = PROPERTY_IPV4V6_PDP_TYPE;
153+
} else if (pdp_type == NON_IP_PDP_TYPE) {
154+
prop = PROPERTY_NON_IP_PDP_TYPE;
153155
}
154-
return prop;
155-
}
156156

157-
nsapi_ip_stack_t AT_CellularContext::get_stack_type()
158-
{
159-
return IPV4V6_STACK;
157+
return prop;
160158
}
161159

162-
nsapi_ip_stack_t AT_CellularContext::string_to_stack_type(const char *pdp_type)
160+
pdp_type_t AT_CellularContext::string_to_pdp_type(const char *pdp_type)
163161
{
164-
return IPV4V6_STACK;
162+
return IPV4V6_PDP_TYPE;
165163
}
166164

167165
// PDP Context handling
@@ -236,3 +234,30 @@ void AT_CellularContext::cellular_callback(nsapi_event_t ev, intptr_t ptr)
236234
void AT_CellularContext::call_network_cb(nsapi_connection_status_t status)
237235
{
238236
}
237+
238+
ControlPlane_netif *AT_CellularContext::get_cp_netif()
239+
{
240+
return NULL;
241+
}
242+
243+
nsapi_error_t AT_CellularContext::activate_non_ip_context()
244+
{
245+
return NSAPI_ERROR_OK;
246+
}
247+
248+
nsapi_error_t AT_CellularContext::setup_control_plane_opt()
249+
{
250+
return NSAPI_ERROR_OK;
251+
}
252+
253+
void AT_CellularContext::deactivate_ip_context()
254+
{
255+
}
256+
257+
void AT_CellularContext::deactivate_non_ip_context()
258+
{
259+
}
260+
261+
void AT_CellularContext::set_disconnect()
262+
{
263+
}

UNITTESTS/stubs/AT_CellularDevice_stub.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void AT_CellularDevice::release_at_handler(ATHandler *at_handler)
5858
}
5959

6060
CellularContext *AT_CellularDevice::create_context(UARTSerial *serial, const char *const apn, PinName dcd_pin,
61-
bool active_high)
61+
bool active_high, bool cp_req, bool nonip_req)
6262
{
6363
}
6464

@@ -113,12 +113,12 @@ CellularContext *AT_CellularDevice::get_context_list() const
113113
return NULL;
114114
}
115115

116-
CellularContext *AT_CellularDevice::create_context(FileHandle *fh, const char *apn)
116+
CellularContext *AT_CellularDevice::create_context(FileHandle *fh, const char *apn, bool cp_req, bool nonip_req)
117117
{
118118
return NULL;
119119
}
120120

121-
AT_CellularContext *AT_CellularDevice::create_context_impl(ATHandler &at, const char *apn)
121+
AT_CellularContext *AT_CellularDevice::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req)
122122
{
123123
return NULL;
124124
}

UNITTESTS/stubs/CellularDevice_stub.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,6 @@ nsapi_error_t CellularDevice::shutdown()
103103
return NSAPI_ERROR_OK;
104104
}
105105

106+
void CellularDevice::cellular_callback(nsapi_event_t ev, intptr_t ptr)
107+
{
108+
}

UNITTESTS/target_h/myCellularDevice.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ class myCellularDevice : public CellularDevice {
5353
}
5454

5555
virtual CellularContext *create_context(UARTSerial *serial, const char *const apn, PinName dcd_pin,
56-
bool active_high)
56+
bool active_high, bool cp_req = false, bool nonip_req = false)
5757
{
5858
return NULL;
5959
}
6060

61-
virtual CellularContext *create_context(FileHandle *fh = NULL, const char *apn = NULL)
61+
virtual CellularContext *create_context(FileHandle *fh = NULL, const char *apn = NULL, bool cp_req = false, bool nonip_req = false)
6262
{
6363
EventQueue que;
6464
FileHandle_stub fh1;

features/cellular/framework/API/CellularContext.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,22 @@
1919

2020
#include "CellularBase.h"
2121
#include "CellularDevice.h"
22+
#include "ControlPlane_netif.h"
2223

2324
namespace mbed {
2425

26+
typedef enum pdp_type {
27+
DEFAULT_PDP_TYPE = DEFAULT_STACK,
28+
IPV4_PDP_TYPE = IPV4_STACK,
29+
IPV6_PDP_TYPE = IPV6_STACK,
30+
IPV4V6_PDP_TYPE = IPV4V6_STACK,
31+
NON_IP_PDP_TYPE
32+
} pdp_type_t;
33+
2534
class CellularContext : public CellularBase {
2635

2736
public:
37+
2838
// max simultaneous PDP contexts active
2939
static const int PDP_CONTEXT_COUNT = 4;
3040

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

232+
/** Returns the control plane AT command interface
233+
*/
234+
virtual ControlPlane_netif *get_cp_netif() = 0;
235+
222236
protected: // Device specific implementations might need these so protected
223237
enum ContextOperation {
224238
OP_INVALID = -1,
@@ -249,7 +263,7 @@ class CellularContext : public CellularBase {
249263

250264
// member variables needed in target override methods
251265
NetworkStack *_stack; // must be pointer because of PPP
252-
nsapi_ip_stack_t _ip_stack_type;
266+
pdp_type_t _pdp_type;
253267
CellularContext::AuthenticationType _authentication_type;
254268
nsapi_connection_status_t _connect_status;
255269
cell_callback_data_t _cb_data;

features/cellular/framework/API/CellularDevice.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ class CellularDevice {
8787

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

99101
/** Creates a new CellularContext interface. This API should be used if serial is UART and PPP mode used.
100102
* CellularContext created will use data carrier detect to be able to detect disconnection much faster in PPP mode.
@@ -104,12 +106,14 @@ class CellularDevice {
104106
* @param apn access point to use with context, can be null.
105107
* @param dcd_pin Pin used to set data carrier detect on/off for the given UART
106108
* @param active_high a boolean set to true if DCD polarity is active low
109+
* @param cp_req Flag indicating if EPS control plane optimisation is required
110+
* @param nonip_req Flag indicating if this context is required to be Non-IP
107111
*
108112
* @return new instance of class CellularContext or NULL in case of failure
109113
*
110114
*/
111115
virtual CellularContext *create_context(UARTSerial *serial, const char *apn, PinName dcd_pin = NC,
112-
bool active_high = false) = 0;
116+
bool active_high = false, bool cp_req = false, bool nonip_req = false) = 0;
113117

114118
/** Deletes the given CellularContext instance
115119
*

features/cellular/framework/AT/AT_CellularBase.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ class AT_CellularBase {
4949
PROPERTY_AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN.
5050
PROPERTY_AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***<cid>#
5151
PROPERTY_AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported
52-
PROPERTY_IPV4_STACK, // 0 = not supported, 1 = supported. Does modem support IPV4?
53-
PROPERTY_IPV6_STACK, // 0 = not supported, 1 = supported. Does modem support IPV6?
54-
PROPERTY_IPV4V6_STACK, // 0 = not supported, 1 = supported. Does modem support dual stack IPV4V6?
52+
PROPERTY_IPV4_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4?
53+
PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6?
54+
PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support dual stack IPV4V6?
55+
PROPERTY_NON_IP_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support Non-IP?
5556
PROPERTY_MAX
5657
};
5758

0 commit comments

Comments
 (0)