mirror of https://github.com/ARMmbed/mbed-os.git
Cellular: fixed greentea tests C027 and BG96.
parent
96cc81412b
commit
5d516f5a0d
|
@ -213,6 +213,7 @@ static void test_credentials()
|
|||
|
||||
static void test_other()
|
||||
{
|
||||
const char* devi = CELLULAR_STRINGIFY(CELLULAR_DEVICE);
|
||||
TEST_ASSERT(nw->get_3gpp_error() == 0);
|
||||
|
||||
CellularNetwork::RateControlExceptionReports reports;
|
||||
|
@ -220,23 +221,24 @@ static void test_other()
|
|||
int uplinkRate;
|
||||
// can't test values as they are optional
|
||||
nsapi_error_t err = nw->get_rate_control(reports, timeUnit, uplinkRate);
|
||||
tr_error("get_rate_control: %d", err);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
#if CELLULAR_DEVICE != QUECTEL_BG96 // QUECTEL_BG96 does not give any specific reason for device error
|
||||
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
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uplinkRate = -1;
|
||||
err = nw->get_apn_backoff_timer(uplinkRate);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR || err == NSAPI_ERROR_PARAMETER);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
#if CELLULAR_DEVICE != QUECTEL_BG96 // QUECTEL_BG96 does not give any specific reason for 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
|
||||
#endif
|
||||
}
|
||||
} else if (err == NSAPI_ERROR_PARAMETER) {
|
||||
TEST_ASSERT(uplinkRate == -1);
|
||||
} else {
|
||||
TEST_ASSERT(uplinkRate >= 0);
|
||||
}
|
||||
|
@ -261,14 +263,13 @@ static void test_other()
|
|||
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
#if CELLULAR_DEVICE != TELIT_HE910 // 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
|
||||
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
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
// should have some values, only not optional are apn and bearer id
|
||||
CellularNetwork::pdpcontext_params_t *params = params_list.get_head();
|
||||
TEST_ASSERT(strlen(params->apn) > 0);
|
||||
TEST_ASSERT(params->bearer_id >= 0)
|
||||
}
|
||||
|
||||
|
@ -276,10 +277,10 @@ static void test_other()
|
|||
err = nw->get_extended_signal_quality(rxlev, ber, rscp, ecno, rsrq, rsrp);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
#if CELLULAR_DEVICE != QUECTEL_BG96 // QUECTEL_BG96 does not give any specific reason for 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
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
// we should have some values which are not optional
|
||||
TEST_ASSERT(rxlev >= 0 && ber >= 0 && rscp >= 0 && ecno >= 0 && rsrq >= 0 && rsrp >= 0);
|
||||
|
@ -305,14 +306,15 @@ static void test_other()
|
|||
int format = -1;
|
||||
CellularNetwork::operator_t operator_params;
|
||||
// all params are optional so can't test operator_params
|
||||
TEST_ASSERT(nw->get_operator_params(format, operator_params) == NSAPI_ERROR_OK);
|
||||
err = nw->get_operator_params(format, operator_params);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK);
|
||||
|
||||
nsapi_connection_status_t st = nw->get_connection_status();
|
||||
TEST_ASSERT(st == NSAPI_STATUS_DISCONNECTED);
|
||||
|
||||
TEST_ASSERT(nw->set_blocking(true) == NSAPI_ERROR_OK);
|
||||
|
||||
#if CELLULAR_DEVICE != QUECTEL_BG96
|
||||
if (strcmp(devi, "QUECTEL_BG96") != 0) {
|
||||
// QUECTEL_BG96 timeouts with this one, tested with 3 minute timeout
|
||||
CellularNetwork::operator_names_list op_names;
|
||||
err = nw->get_operator_names(op_names);
|
||||
|
@ -324,34 +326,35 @@ static void test_other()
|
|||
} else {
|
||||
CellularNetwork::operator_names_t *opn = op_names.get_head();
|
||||
TEST_ASSERT(strlen(opn->numeric) > 0);
|
||||
TEST_ASSERT(strlen(opn->alpha > 0));
|
||||
TEST_ASSERT(strlen(opn->alpha) > 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CELLULAR_DEVICE != TELIT_HE910
|
||||
// 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
|
||||
CellularNetwork::Supported_UE_Opt supported_opt = SUPPORTED_UE_OPT_MAX;
|
||||
CellularNetwork::Preferred_UE_Opt preferred_opt = PREFERRED_UE_OPT_MAX;
|
||||
// TELIT_HE910 and QUECTEL_BG96 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
|
||||
CellularNetwork::Supported_UE_Opt supported_opt = CellularNetwork::SUPPORTED_UE_OPT_MAX;
|
||||
CellularNetwork::Preferred_UE_Opt preferred_opt = CellularNetwork::PREFERRED_UE_OPT_MAX;
|
||||
err = nw->get_ciot_optimization_config(supported_opt, preferred_opt);
|
||||
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
|
||||
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
|
||||
}
|
||||
} else {
|
||||
TEST_ASSERT(supported_opt != SUPPORTED_UE_OPT_MAX);
|
||||
TEST_ASSERT(preferred_opt != PREFERRED_UE_OPT_MAX);
|
||||
TEST_ASSERT(supported_opt != CellularNetwork::SUPPORTED_UE_OPT_MAX);
|
||||
TEST_ASSERT(preferred_opt != CellularNetwork::PREFERRED_UE_OPT_MAX);
|
||||
}
|
||||
|
||||
err = nw->set_ciot_optimization_config(supported_opt, preferred_opt);
|
||||
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
|
||||
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
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void test_disconnect()
|
||||
|
|
|
@ -57,22 +57,26 @@ static void wait_for_power(CellularPower *pwr)
|
|||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
|
||||
|
||||
int sanity_count = 0;
|
||||
while (pwr->is_device_ready() != NSAPI_ERROR_OK) {
|
||||
err = pwr->set_at_mode();
|
||||
while (err != NSAPI_ERROR_OK) {
|
||||
sanity_count++;
|
||||
wait(1);
|
||||
TEST_ASSERT(sanity_count < 20);
|
||||
TEST_ASSERT(sanity_count < 40);
|
||||
err = pwr->set_at_mode();
|
||||
}
|
||||
|
||||
err = pwr->set_at_mode();
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT(pwr->is_device_ready() == NSAPI_ERROR_OK);
|
||||
|
||||
pwr->remove_device_ready_urc_cb(&urc_callback);
|
||||
}
|
||||
|
||||
static void test_power_interface()
|
||||
{
|
||||
const char* devi = CELLULAR_STRINGIFY(CELLULAR_DEVICE);
|
||||
cellular_device = new CELLULAR_DEVICE(queue);
|
||||
cellular_device->set_timeout(5000);
|
||||
CellularPower *pwr = cellular_device->open_power(&cellular_serial);
|
||||
TEST_ASSERT(pwr != NULL);
|
||||
|
||||
nsapi_error_t err = pwr->on();
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
|
||||
|
@ -84,6 +88,24 @@ static void test_power_interface()
|
|||
TEST_ASSERT(err == NSAPI_ERROR_OK);
|
||||
wait_for_power(pwr);
|
||||
|
||||
err = pwr->opt_power_save_mode(0,0);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
if (!(strcmp(devi, "TELIT_HE910") == 0 || strcmp(devi, "QUECTEL_BG96") == 0)) { // TELIT_HE910 and QUECTEL_BG96 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_CellularPower*)pwr)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularPower*)pwr)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
}
|
||||
}
|
||||
|
||||
err = pwr->opt_receive_period(0, CellularPower::EDRXEUTRAN_NB_S1_mode, 3);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
if (!(strcmp(devi, "TELIT_HE910") == 0 || strcmp(devi, "QUECTEL_BG96") == 0)) { // TELIT_HE910 and QUECTEL_BG96 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_CellularPower*)pwr)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularPower*)pwr)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
}
|
||||
}
|
||||
|
||||
err = pwr->off();
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
|
||||
}
|
||||
|
|
|
@ -92,6 +92,9 @@ static void test_sim_interface()
|
|||
CellularSIM *sim = cellular.get_sim();
|
||||
TEST_ASSERT(sim != NULL);
|
||||
|
||||
// set SIM at time out to 3000
|
||||
cellular.get_device()->set_timeout(3000);
|
||||
wait(4); // we need to wait for some time so that SIM interface is working in all modules.
|
||||
// 1. test set_pin
|
||||
nsapi_error_t err = sim->set_pin(MBED_CONF_APP_CELLULAR_SIM_PIN);
|
||||
MBED_ASSERT(err == NSAPI_ERROR_OK);
|
||||
|
@ -105,23 +108,31 @@ 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);
|
||||
|
||||
wait(1);
|
||||
err = sim->change_pin(pin, MBED_CONF_APP_CELLULAR_SIM_PIN);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK);
|
||||
|
||||
// 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);
|
||||
|
||||
wait(1);
|
||||
err = sim->set_pin_query(MBED_CONF_APP_CELLULAR_SIM_PIN, true);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK);
|
||||
|
||||
wait(1);
|
||||
// 4. test get_sim_state
|
||||
CellularSIM::SimState state;
|
||||
err = sim->get_sim_state(state);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT(state == CellularSIM::SimStateReady);
|
||||
|
||||
wait(1);
|
||||
// 5. test get_imsi
|
||||
char imsi[16] = {0};
|
||||
err = sim->get_imsi(imsi);
|
||||
|
|
Loading…
Reference in New Issue