Skip to content

Commit 9fb8302

Browse files
author
Teppo Järvelin
committed
Changed CellularContext to inherit from CellularBase instead of NetworkInterface. \n Changed Device constructor to take Filehandle instead of eventqueue.
1 parent dbbe2dd commit 9fb8302

File tree

53 files changed

+380
-854
lines changed

Some content is hidden

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

53 files changed

+380
-854
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ class my_stack : public AT_CellularStack {
8484

8585
class my_AT_CTX : public AT_CellularContext {
8686
public:
87-
my_AT_CTX(ATHandler &at, CellularDevice *device, const char *apn = MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN,
88-
nsapi_ip_stack_t stack = DEFAULT_STACK) : AT_CellularContext(at, device, apn, stack) {}
87+
my_AT_CTX(ATHandler &at, CellularDevice *device, const char *apn = MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN) :
88+
AT_CellularContext(at, device, apn) {}
8989
virtual ~my_AT_CTX() {}
9090
};
9191

9292
class my_AT_CTXIPV6 : public AT_CellularContext {
9393
public:
94-
my_AT_CTXIPV6(ATHandler &at, CellularDevice *device, const char *apn = MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN,
95-
nsapi_ip_stack_t stack = DEFAULT_STACK) : AT_CellularContext(at, device, apn, stack) {}
94+
my_AT_CTXIPV6(ATHandler &at, CellularDevice *device, const char *apn = MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN) :
95+
AT_CellularContext(at, device, apn) {}
9696
virtual ~my_AT_CTXIPV6() {}
9797
};
9898

UNITTESTS/features/cellular/framework/AT/at_cellulardevice/at_cellulardevicetest.cpp

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,21 @@ class TestAT_CellularDevice : public testing::Test {
3737

3838
TEST_F(TestAT_CellularDevice, Create)
3939
{
40-
EventQueue que;
41-
AT_CellularDevice dev(que);
40+
FileHandle_stub fh1;
41+
AT_CellularDevice dev(&fh1);
4242

43-
CellularDevice *dev2 = new AT_CellularDevice(que);
43+
CellularDevice *dev2 = new AT_CellularDevice(&fh1);
4444

4545
EXPECT_TRUE(dev2 != NULL);
4646
delete dev2;
4747
}
4848

4949
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_get_at_handler)
5050
{
51-
EventQueue que;
52-
AT_CellularDevice dev(que);
5351
FileHandle_stub fh1;
5452
FileHandle_stub fh2;
5553
FileHandle_stub fh3;
54+
AT_CellularDevice dev(&fh1);
5655

5756
EXPECT_TRUE(dev.open_network(&fh1));
5857
EXPECT_TRUE(dev.open_sms(&fh2));
@@ -66,9 +65,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_get_at_handler)
6665

6766
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_network)
6867
{
69-
EventQueue que;
70-
AT_CellularDevice dev(que);
7168
FileHandle_stub fh1;
69+
AT_CellularDevice dev(&fh1);
7270

7371
CellularNetwork *nw = dev.open_network(NULL);
7472
CellularNetwork *nw1 = dev.open_network(&fh1);
@@ -80,9 +78,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_network)
8078

8179
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_sms)
8280
{
83-
EventQueue que;
84-
AT_CellularDevice dev(que);
8581
FileHandle_stub fh1;
82+
AT_CellularDevice dev(&fh1);
8683

8784
CellularSMS *sms = dev.open_sms(NULL);
8885
CellularSMS *sms1 = dev.open_sms(&fh1);
@@ -94,9 +91,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_sms)
9491

9592
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_power)
9693
{
97-
EventQueue que;
98-
AT_CellularDevice dev(que);
9994
FileHandle_stub fh1;
95+
AT_CellularDevice dev(&fh1);
10096

10197
CellularPower *pwr = dev.open_power(NULL);
10298
CellularPower *pwr1 = dev.open_power(&fh1);
@@ -108,9 +104,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_power)
108104

109105
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_sim)
110106
{
111-
EventQueue que;
112-
AT_CellularDevice dev(que);
113107
FileHandle_stub fh1;
108+
AT_CellularDevice dev(&fh1);
114109

115110
CellularSIM *sim = dev.open_sim(NULL);
116111
CellularSIM *sim1 = dev.open_sim(&fh1);
@@ -122,9 +117,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_sim)
122117

123118
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_information)
124119
{
125-
EventQueue que;
126-
AT_CellularDevice dev(que);
127120
FileHandle_stub fh1;
121+
AT_CellularDevice dev(&fh1);
128122

129123
CellularInformation *info = dev.open_information(NULL);
130124
CellularInformation *info1 = dev.open_information(&fh1);
@@ -136,9 +130,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_information)
136130

137131
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_network)
138132
{
139-
EventQueue que;
140-
AT_CellularDevice dev(que);
141133
FileHandle_stub fh1;
134+
AT_CellularDevice dev(&fh1);
142135
ATHandler_stub::ref_count = 0;
143136

144137
EXPECT_TRUE(dev.open_network(&fh1));
@@ -151,9 +144,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_network)
151144

152145
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_sms)
153146
{
154-
EventQueue que;
155-
AT_CellularDevice dev(que);
156147
FileHandle_stub fh1;
148+
AT_CellularDevice dev(&fh1);
157149
ATHandler_stub::ref_count = 0;
158150

159151
EXPECT_TRUE(dev.open_sms(&fh1));
@@ -166,9 +158,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_sms)
166158

167159
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_power)
168160
{
169-
EventQueue que;
170-
AT_CellularDevice dev(que);
171161
FileHandle_stub fh1;
162+
AT_CellularDevice dev(&fh1);
172163
ATHandler_stub::ref_count = 0;
173164

174165
EXPECT_TRUE(dev.open_power(&fh1));
@@ -181,9 +172,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_power)
181172

182173
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_sim)
183174
{
184-
EventQueue que;
185-
AT_CellularDevice dev(que);
186175
FileHandle_stub fh1;
176+
AT_CellularDevice dev(&fh1);
187177
ATHandler_stub::ref_count = 0;
188178
int ana = 0;
189179

@@ -202,9 +192,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_sim)
202192

203193
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_information)
204194
{
205-
EventQueue que;
206-
AT_CellularDevice dev(que);
207195
FileHandle_stub fh1;
196+
AT_CellularDevice dev(&fh1);
208197
ATHandler_stub::int_value = 0;
209198

210199
EXPECT_TRUE(dev.open_information(&fh1));
@@ -213,6 +202,7 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_information)
213202
AT_CellularBase_stub::handler_value = NULL;
214203
dev.close_information();
215204

205+
EventQueue que;
216206
ATHandler_stub::fh_value = &fh1;
217207
ATHandler at(&fh1, que, 0, ",");
218208
AT_CellularBase_stub::handler_value = &at;
@@ -228,9 +218,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_information)
228218

229219
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_set_timeout)
230220
{
231-
EventQueue que;
232-
AT_CellularDevice dev(que);
233221
FileHandle_stub fh1;
222+
AT_CellularDevice dev(&fh1);
234223
ATHandler_stub::timeout = 0;
235224
ATHandler_stub::default_timeout = false;
236225

@@ -251,9 +240,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_set_timeout)
251240

252241
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_modem_debug_on)
253242
{
254-
EventQueue que;
255-
AT_CellularDevice dev(que);
256243
FileHandle_stub fh1;
244+
AT_CellularDevice dev(&fh1);
257245
ATHandler_stub::debug_on = false;
258246

259247
// no interfaces open so debug toggling should not affect
@@ -271,14 +259,14 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_modem_debug_on)
271259

272260
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_get_send_delay)
273261
{
274-
EventQueue que;
275-
AT_CellularDevice dev(que);
262+
FileHandle_stub fh1;
263+
AT_CellularDevice dev(&fh1);
276264
EXPECT_TRUE(0 == dev.get_send_delay());
277265
}
278266

279267
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_init_module)
280268
{
281-
EventQueue que;
282-
AT_CellularDevice dev(que);
283-
EXPECT_TRUE(NSAPI_ERROR_OK == dev.init_module(NULL));
269+
FileHandle_stub fh1;
270+
AT_CellularDevice dev(&fh1);
271+
EXPECT_TRUE(NSAPI_ERROR_OK == dev.init_module());
284272
}

UNITTESTS/stubs/AT_CellularContext_stub.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
using namespace mbed;
2121

22-
AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn, nsapi_ip_stack_t stack) :
22+
AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn) :
2323
AT_CellularBase(at), _ip_stack_type_requested(DEFAULT_STACK), _is_connected(false), _is_blocking(true),
2424
_current_op(OP_INVALID), _device(device), _nw(0), _fh(0)
2525
{
@@ -105,14 +105,29 @@ nsapi_error_t AT_CellularContext::set_blocking(bool blocking)
105105
{
106106
return NSAPI_ERROR_OK;
107107
}
108+
void AT_CellularContext::set_sim_pin(const char *sim_pin)
109+
{
110+
}
108111

109-
void AT_CellularContext::set_apn_credentials(const char *uname, const char *pwd,
110-
CellularContext::AuthenticationType type) {
112+
nsapi_error_t AT_CellularContext::connect(const char *sim_pin, const char *apn, const char *uname,
113+
const char *pwd)
114+
{
115+
return NSAPI_ERROR_OK;
111116
}
112117

113-
void AT_CellularContext::set_apn_credentials(const char* apn, const char *uname, const char *pwd,
114-
CellularContext::AuthenticationType type)
118+
void AT_CellularContext::set_credentials(const char *apn, const char *uname, const char *pwd)
115119
{
120+
121+
}
122+
123+
const char *AT_CellularContext::get_netmask()
124+
{
125+
return NULL;
126+
}
127+
128+
const char *AT_CellularContext::get_gateway()
129+
{
130+
return NULL;
116131
}
117132

118133
bool AT_CellularContext::stack_type_supported(nsapi_ip_stack_t stack_type)

UNITTESTS/stubs/CellularDevice_stub.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ MBED_WEAK CellularDevice *CellularDevice::get_default_instance()
2626
return NULL;
2727
}
2828

29-
CellularDevice::CellularDevice() : _network_ref_count(0), _sms_ref_count(0), _power_ref_count(0), _sim_ref_count(0),
30-
_info_ref_count(0), _fh(0), _error(0), _state_machine(0), _nw(0)
29+
CellularDevice::CellularDevice(FileHandle *fh) : _network_ref_count(0), _sms_ref_count(0),_power_ref_count(0), _sim_ref_count(0),
30+
_info_ref_count(0), _fh(fh), _queue(5 * EVENTS_EVENT_SIZE), _state_machine(0), _nw(0)
3131
{
3232
}
3333

@@ -36,11 +36,15 @@ CellularDevice::~CellularDevice()
3636

3737
}
3838

39-
events::EventQueue *CellularDevice::get_queue() const
39+
events::EventQueue *CellularDevice::get_queue()
4040
{
4141
return NULL;
4242
}
4343

44+
void CellularDevice::set_sim_pin(char const*)
45+
{
46+
}
47+
4448
CellularContext *CellularDevice::get_context_list() const
4549
{
4650
return NULL;

features/cellular/TESTS/api/cellular_information/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void test_information_interface()
7878
{
7979
CellularInformation *info = cellular.get_device()->open_information(&cellular_serial);
8080
const int kbuf_size = 100;
81-
char *buf = (char *)malloc(sizeof(char) * kbuf_size);
81+
char *buf = new char[kbuf_size];
8282

8383
TEST_ASSERT(info->get_manufacturer(buf, kbuf_size) == NSAPI_ERROR_OK);
8484
TEST_ASSERT(info->get_model(buf, kbuf_size) == NSAPI_ERROR_OK);
@@ -98,7 +98,7 @@ static void test_information_interface()
9898

9999
cellular.get_device()->close_information();
100100

101-
free(buf);
101+
delete [] buf;
102102
}
103103

104104
using namespace utest::v1;

0 commit comments

Comments
 (0)