Skip to content

WISE_1570 greentea tests #7840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion features/cellular/TESTS/api/cellular_information/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

#include "mbed.h"


#include "AT_CellularInformation.h"
#include "CellularConnectionFSM.h"
#include "CellularDevice.h"
#include "../../cellular_tests_common.h"
Expand Down Expand Up @@ -81,7 +83,9 @@ static void test_information_interface()
TEST_ASSERT(info->get_manufacturer(buf, kbuf_size) == NSAPI_ERROR_OK);
TEST_ASSERT(info->get_model(buf, kbuf_size) == NSAPI_ERROR_OK);
TEST_ASSERT(info->get_revision(buf, kbuf_size) == NSAPI_ERROR_OK);
TEST_ASSERT(info->get_serial_number(buf, kbuf_size, CellularInformation::SN) == NSAPI_ERROR_OK);
TEST_ASSERT((info->get_serial_number(buf, kbuf_size, CellularInformation::SN) == NSAPI_ERROR_OK) ||
((((AT_CellularInformation *)info)->get_device_error().errType == 3) && // 3 == CME error from the modem
(((AT_CellularInformation *)info)->get_device_error().errCode == 4))); // 4 == "operation not supported"

nsapi_error_t err = info->get_serial_number(buf, kbuf_size, CellularInformation::IMEI);
TEST_ASSERT(err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);
Expand Down
38 changes: 23 additions & 15 deletions features/cellular/TESTS/api/cellular_network/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ static void test_other()
if (strcmp(devi, "QUECTEL_BG96") != 0 && strcmp(devi, "TELIT_HE910") != 0) { // QUECTEL_BG96 does not give any specific reason for device error
if (err == NSAPI_ERROR_DEVICE_ERROR) {
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
}
}

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

// scanning of operators requires some delay before operation is allowed(seen with WISE_1570)
wait(5);
// scanning of operators might take a long time
cellular.get_device()->set_timeout(240 * 1000);
CellularNetwork::operList_t operators;
Expand All @@ -264,8 +266,9 @@ static void test_other()
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
if (err == NSAPI_ERROR_DEVICE_ERROR) {
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
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 100) || // 100 == unknown command for modem
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
}
} else {
// should have some values, only not optional are apn and bearer id
Expand All @@ -278,8 +281,9 @@ static void test_other()
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
if (err == NSAPI_ERROR_DEVICE_ERROR) {
if (strcmp(devi, "QUECTEL_BG96") != 0 && strcmp(devi, "TELIT_HE910") != 0) {// QUECTEL_BG96 does not give any specific reason for device error
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 100) || // 100 == unknown command for modem
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
}
} else {
// we should have some values which are not optional
Expand All @@ -291,9 +295,10 @@ static void test_other()
err = nw->get_signal_quality(rssi, ber);
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
if (err == NSAPI_ERROR_DEVICE_ERROR) {
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
} else {
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 100) || // 100 == unknown command for modem
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
} else {
// test for values
TEST_ASSERT(rssi >= 0);
TEST_ASSERT(ber >= 0);
Expand Down Expand Up @@ -321,8 +326,9 @@ static void test_other()
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
if (err == NSAPI_ERROR_DEVICE_ERROR) {
// if device error then we must check was that really device error or that modem/network does not support the commands
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 4 // 4 == NOT SUPPORTED BY THE MODEM
&& ((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 4) || // 4 == NOT SUPPORTED BY THE MODEM
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
} else {
CellularNetwork::operator_names_t *opn = op_names.get_head();
TEST_ASSERT(strlen(opn->numeric) > 0);
Expand All @@ -338,8 +344,9 @@ static void test_other()
if (err == NSAPI_ERROR_DEVICE_ERROR) {
// if device error then we must check was that really device error or that modem/network does not support the commands
if (!(strcmp(devi, "TELIT_HE910") == 0 || strcmp(devi, "QUECTEL_BG96") == 0)) {
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 100) || // 100 == unknown command for modem
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
}
} else {
TEST_ASSERT(supported_opt != CellularNetwork::SUPPORTED_UE_OPT_MAX);
Expand All @@ -351,8 +358,9 @@ static void test_other()
if (err == NSAPI_ERROR_DEVICE_ERROR) {
// if device error then we must check was that really device error or that modem/network does not support the commands
if (!(strcmp(devi, "TELIT_HE910") == 0 || strcmp(devi, "QUECTEL_BG96") == 0)) {
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 100) || // 100 == unknown command for modem
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions features/cellular/TESTS/api/cellular_sim/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,20 @@ static void test_sim_interface()
// change pin and change it back
wait(1);
err = sim->change_pin(MBED_CONF_APP_CELLULAR_SIM_PIN, pin);
TEST_ASSERT(err == NSAPI_ERROR_OK);
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);

wait(1);
err = sim->change_pin(pin, MBED_CONF_APP_CELLULAR_SIM_PIN);
TEST_ASSERT(err == NSAPI_ERROR_OK);
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);

// 3. test set_pin_query
wait(1);
err = sim->set_pin_query(MBED_CONF_APP_CELLULAR_SIM_PIN, false);
TEST_ASSERT(err == NSAPI_ERROR_OK);
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);

wait(1);
err = sim->set_pin_query(MBED_CONF_APP_CELLULAR_SIM_PIN, true);
TEST_ASSERT(err == NSAPI_ERROR_OK);
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);

wait(1);
// 4. test get_sim_state
Expand Down
29 changes: 26 additions & 3 deletions features/cellular/framework/AT/AT_CellularNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,34 @@ nsapi_error_t AT_CellularNetwork::disconnect()
return err;
#else
_at.lock();
_at.cmd_start("AT+CGACT=0,");
_at.write_int(_cid);

_is_context_active = false;
size_t active_contexts_count = 0;
_at.cmd_start("AT+CGACT?");
_at.cmd_stop();
_at.resp_start();
_at.resp_start("+CGACT:");
while (_at.info_resp()) {
int context_id = _at.read_int();
int context_activation_state = _at.read_int();
if (context_activation_state == 1) {
active_contexts_count++;
if (context_id == _cid) {
_is_context_active = true;
}
}
}
_at.resp_stop();

// 3GPP TS 27.007:
// For EPS, if an attempt is made to disconnect the last PDN connection, then the MT responds with ERROR
if (_is_context_active && (_current_act < RAT_E_UTRAN || active_contexts_count > 1)) {
_at.cmd_start("AT+CGACT=0,");
_at.write_int(_cid);
_at.cmd_stop();
_at.resp_start();
_at.resp_stop();
}

_at.restore_at_timeout();

_at.remove_urc_handler("+CGEV:", callback(this, &AT_CellularNetwork::urc_cgev));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ nsapi_error_t QUECTEL_BC95_CellularPower::set_at_mode()
{
_at.lock();
_at.flush();
_at.cmd_start("AT");
_at.cmd_stop();
_at.resp_start();
_at.resp_stop();

_at.cmd_start("AT+CMEE="); // verbose responses
_at.write_int(1);
_at.cmd_stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,13 @@ nsapi_error_t QUECTEL_BC95_CellularSIM::get_iccid(char *buf, size_t buf_size)
_at.resp_stop();
return _at.unlock_return_error();
}

nsapi_error_t QUECTEL_BC95_CellularSIM::change_pin(const char *sim_pin, const char *new_pin)
{
return NSAPI_ERROR_UNSUPPORTED;
}

nsapi_error_t QUECTEL_BC95_CellularSIM::set_pin_query(const char *sim_pin, bool query_pin)
{
return NSAPI_ERROR_UNSUPPORTED;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class QUECTEL_BC95_CellularSIM : public AT_CellularSIM {
public: //from CellularSIM
virtual nsapi_error_t get_sim_state(SimState &state);
virtual nsapi_error_t get_iccid(char *buf, size_t buf_size);
virtual nsapi_error_t change_pin(const char *sim_pin, const char *new_pin);
virtual nsapi_error_t set_pin_query(const char *sim_pin, bool query_pin);
};

} // namespace mbed
Expand Down