Skip to content

Commit 582b414

Browse files
authored
Merge pull request #7840 from mirelachirica/wise_1570_greentea_tests
WISE_1570 greentea tests
2 parents 871d7e7 + 9ef2d0d commit 582b414

File tree

7 files changed

+75
-23
lines changed

7 files changed

+75
-23
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
#include "mbed.h"
3939

40+
41+
#include "AT_CellularInformation.h"
4042
#include "CellularConnectionFSM.h"
4143
#include "CellularDevice.h"
4244
#include "../../cellular_tests_common.h"
@@ -81,7 +83,9 @@ static void test_information_interface()
8183
TEST_ASSERT(info->get_manufacturer(buf, kbuf_size) == NSAPI_ERROR_OK);
8284
TEST_ASSERT(info->get_model(buf, kbuf_size) == NSAPI_ERROR_OK);
8385
TEST_ASSERT(info->get_revision(buf, kbuf_size) == NSAPI_ERROR_OK);
84-
TEST_ASSERT(info->get_serial_number(buf, kbuf_size, CellularInformation::SN) == NSAPI_ERROR_OK);
86+
TEST_ASSERT((info->get_serial_number(buf, kbuf_size, CellularInformation::SN) == NSAPI_ERROR_OK) ||
87+
((((AT_CellularInformation *)info)->get_device_error().errType == 3) && // 3 == CME error from the modem
88+
(((AT_CellularInformation *)info)->get_device_error().errCode == 4))); // 4 == "operation not supported"
8589

8690
nsapi_error_t err = info->get_serial_number(buf, kbuf_size, CellularInformation::IMEI);
8791
TEST_ASSERT(err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);

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

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ static void test_other()
225225
if (strcmp(devi, "QUECTEL_BG96") != 0 && strcmp(devi, "TELIT_HE910") != 0) { // QUECTEL_BG96 does not give any specific reason for device error
226226
if (err == NSAPI_ERROR_DEVICE_ERROR) {
227227
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
228-
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
228+
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
229229
}
230230
}
231231

@@ -235,7 +235,7 @@ static void test_other()
235235
if (err == NSAPI_ERROR_DEVICE_ERROR) {
236236
if (strcmp(devi, "QUECTEL_BG96") != 0 && strcmp(devi, "TELIT_HE910") != 0) { // QUECTEL_BG96 does not give any specific reason for device error
237237
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
238-
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
238+
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
239239
}
240240
} else if (err == NSAPI_ERROR_PARAMETER) {
241241
TEST_ASSERT(uplinkRate == -1);
@@ -246,6 +246,8 @@ static void test_other()
246246
err = nw->set_access_technology(CellularNetwork::RAT_GSM);
247247
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
248248

249+
// scanning of operators requires some delay before operation is allowed(seen with WISE_1570)
250+
wait(5);
249251
// scanning of operators might take a long time
250252
cellular.get_device()->set_timeout(240 * 1000);
251253
CellularNetwork::operList_t operators;
@@ -264,8 +266,9 @@ static void test_other()
264266
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
265267
if (err == NSAPI_ERROR_DEVICE_ERROR) {
266268
if (strcmp(devi, "TELIT_HE910") != 0) { // TELIT_HE910 just gives an error and no specific error number so we can't know is this real error or that modem/network does not support the command
267-
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
268-
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
269+
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
270+
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 100) || // 100 == unknown command for modem
271+
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
269272
}
270273
} else {
271274
// should have some values, only not optional are apn and bearer id
@@ -278,8 +281,9 @@ static void test_other()
278281
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
279282
if (err == NSAPI_ERROR_DEVICE_ERROR) {
280283
if (strcmp(devi, "QUECTEL_BG96") != 0 && strcmp(devi, "TELIT_HE910") != 0) {// QUECTEL_BG96 does not give any specific reason for device error
281-
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
282-
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
284+
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
285+
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 100) || // 100 == unknown command for modem
286+
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
283287
}
284288
} else {
285289
// we should have some values which are not optional
@@ -291,9 +295,10 @@ static void test_other()
291295
err = nw->get_signal_quality(rssi, ber);
292296
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
293297
if (err == NSAPI_ERROR_DEVICE_ERROR) {
294-
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
295-
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
296-
} else {
298+
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
299+
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 100) || // 100 == unknown command for modem
300+
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
301+
} else {
297302
// test for values
298303
TEST_ASSERT(rssi >= 0);
299304
TEST_ASSERT(ber >= 0);
@@ -321,8 +326,9 @@ static void test_other()
321326
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
322327
if (err == NSAPI_ERROR_DEVICE_ERROR) {
323328
// if device error then we must check was that really device error or that modem/network does not support the commands
324-
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 4 // 4 == NOT SUPPORTED BY THE MODEM
325-
&& ((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
329+
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
330+
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 4) || // 4 == NOT SUPPORTED BY THE MODEM
331+
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
326332
} else {
327333
CellularNetwork::operator_names_t *opn = op_names.get_head();
328334
TEST_ASSERT(strlen(opn->numeric) > 0);
@@ -338,8 +344,9 @@ static void test_other()
338344
if (err == NSAPI_ERROR_DEVICE_ERROR) {
339345
// if device error then we must check was that really device error or that modem/network does not support the commands
340346
if (!(strcmp(devi, "TELIT_HE910") == 0 || strcmp(devi, "QUECTEL_BG96") == 0)) {
341-
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
342-
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
347+
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
348+
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 100) || // 100 == unknown command for modem
349+
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
343350
}
344351
} else {
345352
TEST_ASSERT(supported_opt != CellularNetwork::SUPPORTED_UE_OPT_MAX);
@@ -351,8 +358,9 @@ static void test_other()
351358
if (err == NSAPI_ERROR_DEVICE_ERROR) {
352359
// if device error then we must check was that really device error or that modem/network does not support the commands
353360
if (!(strcmp(devi, "TELIT_HE910") == 0 || strcmp(devi, "QUECTEL_BG96") == 0)) {
354-
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
355-
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
361+
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
362+
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 100) || // 100 == unknown command for modem
363+
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
356364
}
357365
}
358366
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ static void test_sim_interface()
110110
// change pin and change it back
111111
wait(1);
112112
err = sim->change_pin(MBED_CONF_APP_CELLULAR_SIM_PIN, pin);
113-
TEST_ASSERT(err == NSAPI_ERROR_OK);
113+
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
114114

115115
wait(1);
116116
err = sim->change_pin(pin, MBED_CONF_APP_CELLULAR_SIM_PIN);
117-
TEST_ASSERT(err == NSAPI_ERROR_OK);
117+
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
118118

119119
// 3. test set_pin_query
120120
wait(1);
121121
err = sim->set_pin_query(MBED_CONF_APP_CELLULAR_SIM_PIN, false);
122-
TEST_ASSERT(err == NSAPI_ERROR_OK);
122+
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
123123

124124
wait(1);
125125
err = sim->set_pin_query(MBED_CONF_APP_CELLULAR_SIM_PIN, true);
126-
TEST_ASSERT(err == NSAPI_ERROR_OK);
126+
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
127127

128128
wait(1);
129129
// 4. test get_sim_state

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,34 @@ nsapi_error_t AT_CellularNetwork::disconnect()
421421
return err;
422422
#else
423423
_at.lock();
424-
_at.cmd_start("AT+CGACT=0,");
425-
_at.write_int(_cid);
424+
425+
_is_context_active = false;
426+
size_t active_contexts_count = 0;
427+
_at.cmd_start("AT+CGACT?");
426428
_at.cmd_stop();
427-
_at.resp_start();
429+
_at.resp_start("+CGACT:");
430+
while (_at.info_resp()) {
431+
int context_id = _at.read_int();
432+
int context_activation_state = _at.read_int();
433+
if (context_activation_state == 1) {
434+
active_contexts_count++;
435+
if (context_id == _cid) {
436+
_is_context_active = true;
437+
}
438+
}
439+
}
428440
_at.resp_stop();
441+
442+
// 3GPP TS 27.007:
443+
// For EPS, if an attempt is made to disconnect the last PDN connection, then the MT responds with ERROR
444+
if (_is_context_active && (_current_act < RAT_E_UTRAN || active_contexts_count > 1)) {
445+
_at.cmd_start("AT+CGACT=0,");
446+
_at.write_int(_cid);
447+
_at.cmd_stop();
448+
_at.resp_start();
449+
_at.resp_stop();
450+
}
451+
429452
_at.restore_at_timeout();
430453

431454
_at.remove_urc_handler("+CGEV:", callback(this, &AT_CellularNetwork::urc_cgev));

features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularPower.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ nsapi_error_t QUECTEL_BC95_CellularPower::set_at_mode()
3333
{
3434
_at.lock();
3535
_at.flush();
36+
_at.cmd_start("AT");
37+
_at.cmd_stop();
38+
_at.resp_start();
39+
_at.resp_stop();
40+
3641
_at.cmd_start("AT+CMEE="); // verbose responses
3742
_at.write_int(1);
3843
_at.cmd_stop();

features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularSIM.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,13 @@ nsapi_error_t QUECTEL_BC95_CellularSIM::get_iccid(char *buf, size_t buf_size)
5858
_at.resp_stop();
5959
return _at.unlock_return_error();
6060
}
61+
62+
nsapi_error_t QUECTEL_BC95_CellularSIM::change_pin(const char *sim_pin, const char *new_pin)
63+
{
64+
return NSAPI_ERROR_UNSUPPORTED;
65+
}
66+
67+
nsapi_error_t QUECTEL_BC95_CellularSIM::set_pin_query(const char *sim_pin, bool query_pin)
68+
{
69+
return NSAPI_ERROR_UNSUPPORTED;
70+
}

features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularSIM.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class QUECTEL_BC95_CellularSIM : public AT_CellularSIM {
3030
public: //from CellularSIM
3131
virtual nsapi_error_t get_sim_state(SimState &state);
3232
virtual nsapi_error_t get_iccid(char *buf, size_t buf_size);
33+
virtual nsapi_error_t change_pin(const char *sim_pin, const char *new_pin);
34+
virtual nsapi_error_t set_pin_query(const char *sim_pin, bool query_pin);
3335
};
3436

3537
} // namespace mbed

0 commit comments

Comments
 (0)