Skip to content

Commit 0c9130e

Browse files
Teppo JärvelinAri Parkkila
authored andcommitted
Cellular: change stack_type_supported to get_property
Change usage of AT_CellularContext::stack_type_supported to AT_CellularBase::get_property. This way we can rid of targets overriding stack_type_supported and delete unnecessary classes and simplify new targets.
1 parent 7c9f9d4 commit 0c9130e

Some content is hidden

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

41 files changed

+111
-446
lines changed

UNITTESTS/features/cellular/framework/AT/at_cellularbase/at_cellularbasetest.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class my_base : public AT_CellularBase {
4040
0, // AT_CGSN_WITH_TYPE
4141
1, // AT_CGDATA
4242
1, // AT_CGAUTH
43+
1, // PROPERTY_IPV4_STACK
44+
0, // PROPERTY_IPV6_STACK
45+
0, // PROPERTY_IPV4V6_STACK
4346
};
4447

4548
set_cellular_properties(cellular_properties);
@@ -116,7 +119,10 @@ TEST_F(TestAT_CellularBase, test_AT_CellularBase_set_cellular_properties)
116119
AT_CellularNetwork::RegistrationModeLAC, // C_REG
117120
0, // AT_CGSN_WITH_TYPE
118121
1, // AT_CGDATA
119-
1 // AT_CGAUTH
122+
1, // AT_CGAUTH
123+
1, // PROPERTY_IPV4_STACK
124+
0, // PROPERTY_IPV6_STACK
125+
0, // PROPERTY_IPV4V6_STACK
120126
};
121127
at.set_cellular_properties(cellular_properties);
122128
}

UNITTESTS/features/cellular/framework/AT/at_cellularcontext/at_cellularcontexttest.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "Semaphore_stub.h"
2828
#include "CellularDevice_stub.h"
2929
#include "equeue_stub.h"
30+
#include "AT_CellularBase_stub.h"
3031

3132
using namespace mbed;
3233
using namespace events;
@@ -114,12 +115,12 @@ class my_stack : public AT_CellularStack {
114115
class my_AT_CTX : public AT_CellularContext {
115116
public:
116117
my_AT_CTX(ATHandler &at, CellularDevice *device, const char *apn = MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN) :
117-
AT_CellularContext(at, device, apn), _st(at) {}
118-
virtual ~my_AT_CTX() {}
119-
virtual bool stack_type_supported(nsapi_ip_stack_t stack_type)
118+
AT_CellularContext(at, device, apn), _st(at)
120119
{
121-
return false;
120+
AT_CellularBase_stub::supported_bool = false;
122121
}
122+
virtual ~my_AT_CTX() {}
123+
123124
virtual NetworkStack *get_stack()
124125
{
125126
return &_st;

UNITTESTS/stubs/AT_CellularBase_stub.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ intptr_t AT_CellularBase::get_property(CellularProperty key)
4747
return AT_CellularNetwork::RegistrationModeDisable;
4848
} else if (key == PROPERTY_C_REG || key == PROPERTY_C_EREG) {
4949
return AT_CellularNetwork::RegistrationModeEnable;
50+
} else if (key == PROPERTY_AT_CGAUTH) {
51+
return true;
5052
}
5153

5254
return AT_CellularBase_stub::supported_bool;

UNITTESTS/stubs/AT_CellularContext_stub.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,15 @@ const char *AT_CellularContext::get_gateway()
135135
return NULL;
136136
}
137137

138-
bool AT_CellularContext::stack_type_supported(nsapi_ip_stack_t stack_type)
139-
{
140-
return true;
138+
AT_CellularBase::CellularProperty AT_CellularContext::nsapi_ip_stack_t_to_cellular_property(nsapi_ip_stack_t stack)
139+
{
140+
AT_CellularBase::CellularProperty prop = PROPERTY_IPV4_STACK;
141+
if (stack == IPV6_STACK) {
142+
prop = PROPERTY_IPV6_STACK;
143+
} else if (stack == IPV4V6_STACK) {
144+
prop = PROPERTY_IPV4V6_STACK;
145+
}
146+
return prop;
141147
}
142148

143149
nsapi_ip_stack_t AT_CellularContext::get_stack_type()

features/cellular/framework/AT/AT_CellularBase.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ class AT_CellularBase {
4343
device_err_t get_device_error() const;
4444

4545
enum CellularProperty {
46-
PROPERTY_C_EREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
47-
PROPERTY_C_GREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
48-
PROPERTY_C_REG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
49-
PROPERTY_AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN.
50-
PROPERTY_AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***<cid>#
51-
PROPERTY_AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported
46+
PROPERTY_C_EREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
47+
PROPERTY_C_GREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
48+
PROPERTY_C_REG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
49+
PROPERTY_AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN.
50+
PROPERTY_AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***<cid>#
51+
PROPERTY_AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported
52+
PROPERTY_IPV4_STACK, // 0 = not supported, 1 = supported
53+
PROPERTY_IPV6_STACK, // 0 = not supported, 1 = supported
54+
PROPERTY_IPV4V6_STACK, // 0 = not supported, 1 = supported
5255
PROPERTY_MAX
5356
};
5457

features/cellular/framework/AT/AT_CellularContext.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,6 @@ void AT_CellularContext::set_credentials(const char *apn, const char *uname, con
239239
_pwd = pwd;
240240
}
241241

242-
bool AT_CellularContext::stack_type_supported(nsapi_ip_stack_t stack_type)
243-
{
244-
if (stack_type == _ip_stack_type) {
245-
return true;
246-
} else {
247-
return false;
248-
}
249-
}
250-
251242
nsapi_ip_stack_t AT_CellularContext::get_stack_type()
252243
{
253244
return _ip_stack_type;
@@ -306,6 +297,17 @@ nsapi_error_t AT_CellularContext::do_user_authentication()
306297
return NSAPI_ERROR_OK;
307298
}
308299

300+
AT_CellularBase::CellularProperty AT_CellularContext::nsapi_ip_stack_t_to_cellular_property(nsapi_ip_stack_t stack)
301+
{
302+
AT_CellularBase::CellularProperty prop = PROPERTY_IPV4_STACK;
303+
if (stack == IPV6_STACK) {
304+
prop = PROPERTY_IPV6_STACK;
305+
} else if (stack == IPV4V6_STACK) {
306+
prop = PROPERTY_IPV4V6_STACK;
307+
}
308+
return prop;
309+
}
310+
309311
bool AT_CellularContext::get_context()
310312
{
311313
_at.cmd_start("AT+CGDCONT?");
@@ -316,8 +318,8 @@ bool AT_CellularContext::get_context()
316318
char apn[MAX_ACCESSPOINT_NAME_LENGTH];
317319
int apn_len = 0;
318320

319-
bool modem_supports_ipv6 = stack_type_supported(IPV6_STACK);
320-
bool modem_supports_ipv4 = stack_type_supported(IPV4_STACK);
321+
bool modem_supports_ipv6 = get_property(PROPERTY_IPV6_STACK);
322+
bool modem_supports_ipv4 = get_property(PROPERTY_IPV4_STACK);
321323

322324
while (_at.info_resp()) {
323325
int cid = _at.read_int();
@@ -334,7 +336,8 @@ bool AT_CellularContext::get_context()
334336
}
335337
nsapi_ip_stack_t pdp_stack = string_to_stack_type(pdp_type_from_context);
336338
// Accept dual PDP context for IPv4/IPv6 only modems
337-
if (pdp_stack != DEFAULT_STACK && (stack_type_supported(pdp_stack) || pdp_stack == IPV4V6_STACK)) {
339+
if (pdp_stack != DEFAULT_STACK && (get_property(nsapi_ip_stack_t_to_cellular_property(pdp_stack))
340+
|| pdp_stack == IPV4V6_STACK)) {
338341
if (_ip_stack_type_requested == IPV4_STACK) {
339342
if (pdp_stack == IPV4_STACK || pdp_stack == IPV4V6_STACK) {
340343
_ip_stack_type = _ip_stack_type_requested;
@@ -399,8 +402,8 @@ bool AT_CellularContext::set_new_context(int cid)
399402
nsapi_ip_stack_t tmp_stack = _ip_stack_type_requested;
400403

401404
if (tmp_stack == DEFAULT_STACK) {
402-
bool modem_supports_ipv6 = stack_type_supported(IPV6_STACK);
403-
bool modem_supports_ipv4 = stack_type_supported(IPV4_STACK);
405+
bool modem_supports_ipv6 = get_property(PROPERTY_IPV6_STACK);
406+
bool modem_supports_ipv4 = get_property(PROPERTY_IPV4_STACK);
404407

405408
if (modem_supports_ipv6 && modem_supports_ipv4) {
406409
tmp_stack = IPV4V6_STACK;

features/cellular/framework/AT/AT_CellularContext.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ class AT_CellularContext : public CellularContext, public AT_CellularBase {
7575
*/
7676
virtual void do_connect();
7777

78-
/** Check if modem supports the given stack type. Can be overridden by the modem.
79-
*
80-
* @return true if supported
81-
*/
82-
virtual bool stack_type_supported(nsapi_ip_stack_t stack_type);
83-
8478
/** Get the operation specific timeout. Used in synchronous mode when setting the maximum
8579
* waiting time. Modem specific implementation can override this to provide different timeouts.
8680
*
@@ -107,6 +101,7 @@ class AT_CellularContext : public CellularContext, public AT_CellularBase {
107101
nsapi_ip_stack_t string_to_stack_type(const char *pdp_type);
108102
nsapi_ip_stack_t get_stack_type();
109103
nsapi_error_t check_operation(nsapi_error_t err, ContextOperation op);
104+
AT_CellularBase::CellularProperty nsapi_ip_stack_t_to_cellular_property(nsapi_ip_stack_t stack);
110105

111106
private:
112107
nsapi_ip_stack_t _ip_stack_type_requested;

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ static const char *const rat_str[AT_CellularNetwork::RAT_MAX] = {
7171

7272

7373
AT_CellularNetwork::AT_CellularNetwork(ATHandler &atHandler) : AT_CellularBase(atHandler),
74-
_connection_status_cb(NULL), _op_act(RAT_UNKNOWN), _connect_status(NSAPI_STATUS_DISCONNECTED),
75-
_ciotopt_network_support_cb(NULL), _supported_network_opt(CIOT_OPT_MAX)
74+
_connection_status_cb(NULL), _ciotopt_network_support_cb(NULL), _op_act(RAT_UNKNOWN),
75+
_connect_status(NSAPI_STATUS_DISCONNECTED), _supported_network_opt(CIOT_OPT_MAX)
7676
{
7777

7878
_urc_funcs[C_EREG] = callback(this, &AT_CellularNetwork::urc_cereg);

features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ void GEMALTO_CINTERION::init_module_bgs2()
9595
0, // AT_CGSN_WITH_TYPE
9696
1, // AT_CGDATA
9797
1, // AT_CGAUTH
98+
1, // PROPERTY_IPV4_STACK
99+
0, // PROPERTY_IPV6_STACK
100+
0, // PROPERTY_IPV4V6_STACK
98101
};
99102
AT_CellularBase::set_cellular_properties(cellular_properties);
100103
_module = ModuleBGS2;
@@ -110,6 +113,9 @@ void GEMALTO_CINTERION::init_module_els61()
110113
0, // AT_CGSN_WITH_TYPE
111114
1, // AT_CGDATA
112115
1, // AT_CGAUTH
116+
1, // PROPERTY_IPV4_STACK
117+
1, // PROPERTY_IPV6_STACK
118+
0, // PROPERTY_IPV4V6_STACK
113119
};
114120
AT_CellularBase::set_cellular_properties(cellular_properties);
115121
_module = ModuleELS61;
@@ -125,6 +131,9 @@ void GEMALTO_CINTERION::init_module_ems31()
125131
1, // AT_CGSN_WITH_TYPE
126132
1, // AT_CGDATA
127133
1, // AT_CGAUTH
134+
1, // PROPERTY_IPV4_STACK
135+
1, // PROPERTY_IPV6_STACK
136+
1, // PROPERTY_IPV4V6_STACK
128137
};
129138
AT_CellularBase::set_cellular_properties(cellular_properties);
130139
_module = ModuleEMS31;

features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717
#include "GEMALTO_CINTERION_CellularContext.h"
1818
#include "GEMALTO_CINTERION_CellularStack.h"
19-
#include "GEMALTO_CINTERION.h"
2019

2120
namespace mbed {
2221

@@ -39,12 +38,4 @@ NetworkStack *GEMALTO_CINTERION_CellularContext::get_stack()
3938
}
4039
#endif // NSAPI_PPP_AVAILABLE
4140

42-
bool GEMALTO_CINTERION_CellularContext::stack_type_supported(nsapi_ip_stack_t requested_stack)
43-
{
44-
if (GEMALTO_CINTERION::get_module() == GEMALTO_CINTERION::ModuleBGS2) {
45-
return (requested_stack == IPV4_STACK);
46-
}
47-
return (requested_stack == IPV4_STACK || requested_stack == IPV6_STACK);
48-
}
49-
5041
} /* namespace mbed */

0 commit comments

Comments
 (0)