Skip to content

Commit 8c2ad14

Browse files
author
Nir Sonnenschein
authored
Merge pull request #9568 from ARMmbed/feature-cellular-refactor
Merge feature cellular refactor
2 parents 5ef9499 + b2d30d4 commit 8c2ad14

File tree

202 files changed

+5901
-6630
lines changed

Some content is hidden

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

202 files changed

+5901
-6630
lines changed

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

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "gtest/gtest.h"
1919
#include "AT_CellularBase.h"
2020
#include "EventQueue.h"
21-
#include "AT_CellularBase.h"
21+
#include "AT_CellularNetwork.h"
2222
#include "ATHandler_stub.h"
2323
#include "FileHandle_stub.h"
2424
#include <string.h>
@@ -33,28 +33,25 @@ class my_base : public AT_CellularBase {
3333
}
3434
bool check_not_supported()
3535
{
36-
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
37-
AT_CellularBase::AT_CGSN_WITH_TYPE,
38-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
36+
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
37+
AT_CellularNetwork::RegistrationModeDisable,// C_EREG
38+
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
39+
AT_CellularNetwork::RegistrationModeLAC, // C_REG
40+
0, // AT_CGSN_WITH_TYPE
41+
1, // AT_CGDATA
42+
1, // AT_CGAUTH
43+
1, // PROPERTY_IPV4_STACK
44+
0, // PROPERTY_IPV6_STACK
45+
0, // PROPERTY_IPV4V6_STACK
3946
};
40-
set_unsupported_features(unsupported_features);
41-
return is_supported(AT_CGSN_WITH_TYPE);
42-
}
4347

44-
bool check_supported()
45-
{
46-
set_unsupported_features(NULL);
47-
return is_supported(AT_CGSN_WITH_TYPE);
48+
set_cellular_properties(cellular_properties);
49+
return get_property(PROPERTY_AT_CGSN_WITH_TYPE);
4850
}
4951

50-
bool check_supported_not_found()
52+
bool check_supported()
5153
{
52-
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
53-
AT_CellularBase::AT_CGSN_WITH_TYPE,
54-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
55-
};
56-
set_unsupported_features(unsupported_features);
57-
return is_supported(SUPPORTED_FEATURE_END_MARK);
54+
return get_property(PROPERTY_AT_CGDATA);
5855
}
5956
};
6057

@@ -109,19 +106,25 @@ TEST_F(TestAT_CellularBase, test_AT_CellularBase_get_device_error)
109106
ATHandler_stub::device_err_value.errCode = 0;
110107
}
111108

112-
TEST_F(TestAT_CellularBase, test_AT_CellularBase_set_unsupported_features)
109+
TEST_F(TestAT_CellularBase, test_AT_CellularBase_set_cellular_properties)
113110
{
114111
EventQueue eq;
115112
FileHandle_stub fh;
116113
ATHandler ah(&fh, eq, 0, ",");
117114
AT_CellularBase at(ah);
118115

119-
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
120-
AT_CellularBase::AT_CGSN_WITH_TYPE,
121-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
116+
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
117+
AT_CellularNetwork::RegistrationModeDisable,// C_EREG
118+
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
119+
AT_CellularNetwork::RegistrationModeLAC, // C_REG
120+
0, // AT_CGSN_WITH_TYPE
121+
1, // AT_CGDATA
122+
1, // AT_CGAUTH
123+
1, // PROPERTY_IPV4_STACK
124+
0, // PROPERTY_IPV6_STACK
125+
0, // PROPERTY_IPV4V6_STACK
122126
};
123-
124-
at.set_unsupported_features(unsupported_features);
127+
at.set_cellular_properties(cellular_properties);
125128
}
126129

127130
TEST_F(TestAT_CellularBase, test_AT_CellularBase_is_supported)
@@ -131,7 +134,6 @@ TEST_F(TestAT_CellularBase, test_AT_CellularBase_is_supported)
131134
ATHandler ah(&fh, eq, 0, ",");
132135
my_base my_at(ah);
133136

134-
EXPECT_TRUE(true == my_at.check_supported());
135-
EXPECT_TRUE(true == my_at.check_supported_not_found());
136-
EXPECT_TRUE(false == my_at.check_not_supported());
137+
EXPECT_EQ(true, my_at.check_supported());
138+
EXPECT_EQ(false, my_at.check_not_supported());
137139
}

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

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

3232
using namespace mbed;
3333
using namespace events;
@@ -115,12 +115,12 @@ class my_stack : public AT_CellularStack {
115115
class my_AT_CTX : public AT_CellularContext {
116116
public:
117117
my_AT_CTX(ATHandler &at, CellularDevice *device, const char *apn = MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN) :
118-
AT_CellularContext(at, device, apn), _st(at) {}
119-
virtual ~my_AT_CTX() {}
120-
virtual bool stack_type_supported(nsapi_ip_stack_t stack_type)
118+
AT_CellularContext(at, device, apn), _st(at)
121119
{
122-
return false;
120+
AT_CellularBase_stub::supported_bool = false;
123121
}
122+
virtual ~my_AT_CTX() {}
123+
124124
virtual NetworkStack *get_stack()
125125
{
126126
return &_st;
@@ -142,10 +142,6 @@ class my_AT_CTXIPV6 : public AT_CellularContext {
142142
my_AT_CTXIPV6(ATHandler &at, CellularDevice *device, const char *apn = MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN) :
143143
AT_CellularContext(at, device, apn), _st(at) {}
144144
virtual ~my_AT_CTXIPV6() {}
145-
virtual bool stack_type_supported(nsapi_ip_stack_t stack_type)
146-
{
147-
return true;
148-
}
149145
virtual NetworkStack *get_stack()
150146
{
151147
return &_st;
@@ -528,7 +524,7 @@ TEST_F(TestAT_CellularContext, set_sim_ready)
528524
cell_callback_data_t data;
529525
data.error = NSAPI_ERROR_OK;
530526
ctx.cellular_callback((nsapi_event_t)CellularDeviceReady, (intptr_t)&data);
531-
data.status_data = CellularSIM::SimStateReady;
527+
data.status_data = CellularDevice::SimStateReady;
532528
ctx.cellular_callback((nsapi_event_t)CellularSIMStatusChanged, (intptr_t)&data);
533529
}
534530

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

Lines changed: 4 additions & 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
@@ -33,8 +34,11 @@ set(unittest-test-sources
3334
stubs/FileHandle_stub.cpp
3435
stubs/mbed_assert_stub.c
3536
stubs/NetworkInterface_stub.cpp
37+
stubs/NetworkInterfaceDefaults_stub.cpp
3638
stubs/NetworkStack_stub.cpp
3739
stubs/randLIB_stub.cpp
3840
stubs/Semaphore_stub.cpp
3941
stubs/us_ticker_stub.cpp
42+
stubs/UARTSerial_stub.cpp
43+
stubs/SerialBase_stub.cpp
4044
)

0 commit comments

Comments
 (0)