@@ -213,30 +213,32 @@ static void test_credentials()
213213
214214static void test_other ()
215215{
216+ const char * devi = CELLULAR_STRINGIFY (CELLULAR_DEVICE);
216217 TEST_ASSERT (nw->get_3gpp_error () == 0 );
217218
218219 CellularNetwork::RateControlExceptionReports reports;
219220 CellularNetwork::RateControlUplinkTimeUnit timeUnit;
220221 int uplinkRate;
221222 // can't test values as they are optional
222223 nsapi_error_t err = nw->get_rate_control (reports, timeUnit, uplinkRate);
223- tr_error (" get_rate_control: %d" , err);
224224 TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
225- #if CELLULAR_DEVICE != QUECTEL_BG96 // QUECTEL_BG96 does not give any specific reason for device error
226- if (err == NSAPI_ERROR_DEVICE_ERROR) {
227- 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
225+ if (strcmp (devi, " QUECTEL_BG96" ) != 0 && strcmp (devi, " TELIT_HE910" ) != 0 ) { // QUECTEL_BG96 does not give any specific reason for device error
226+ if (err == NSAPI_ERROR_DEVICE_ERROR) {
227+ 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
229+ }
229230 }
230- #endif
231231
232232 uplinkRate = -1 ;
233233 err = nw->get_apn_backoff_timer (uplinkRate);
234- TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
234+ TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR || err == NSAPI_ERROR_PARAMETER );
235235 if (err == NSAPI_ERROR_DEVICE_ERROR) {
236- #if CELLULAR_DEVICE != QUECTEL_BG96 // QUECTEL_BG96 does not give any specific reason for device error
237- 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
239- #endif
236+ if (strcmp (devi, " QUECTEL_BG96" ) != 0 && strcmp (devi, " TELIT_HE910" ) != 0 ) { // QUECTEL_BG96 does not give any specific reason for device error
237+ 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
239+ }
240+ } else if (err == NSAPI_ERROR_PARAMETER) {
241+ TEST_ASSERT (uplinkRate == -1 );
240242 } else {
241243 TEST_ASSERT (uplinkRate >= 0 );
242244 }
@@ -261,25 +263,24 @@ static void test_other()
261263
262264 TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
263265 if (err == NSAPI_ERROR_DEVICE_ERROR) {
264- # 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
265- TEST_ASSERT (((AT_CellularNetwork *)nw)->get_device_error ().errCode == 100 && // 100 == unknown command for modem
266- ((AT_CellularNetwork *)nw)->get_device_error ().errType == 3 ); // 3 == CME error from the modem
267- # endif
266+ 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+ }
268270 } else {
269271 // should have some values, only not optional are apn and bearer id
270272 CellularNetwork::pdpcontext_params_t *params = params_list.get_head ();
271- TEST_ASSERT (strlen (params->apn ) > 0 );
272273 TEST_ASSERT (params->bearer_id >= 0 )
273274 }
274275
275276 int rxlev = -1 , ber = -1 , rscp = -1 , ecno = -1 , rsrq = -1 , rsrp = -1 ;
276277 err = nw->get_extended_signal_quality (rxlev, ber, rscp, ecno, rsrq, rsrp);
277278 TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
278279 if (err == NSAPI_ERROR_DEVICE_ERROR) {
279- # if CELLULAR_DEVICE != QUECTEL_BG96 // QUECTEL_BG96 does not give any specific reason for device error
280- TEST_ASSERT (((AT_CellularNetwork *)nw)->get_device_error ().errCode == 100 && // 100 == unknown command for modem
281- ((AT_CellularNetwork *)nw)->get_device_error ().errType == 3 ); // 3 == CME error from the modem
282- # endif
280+ 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
283+ }
283284 } else {
284285 // we should have some values which are not optional
285286 TEST_ASSERT (rxlev >= 0 && ber >= 0 && rscp >= 0 && ecno >= 0 && rsrq >= 0 && rsrp >= 0 );
@@ -305,53 +306,55 @@ static void test_other()
305306 int format = -1 ;
306307 CellularNetwork::operator_t operator_params;
307308 // all params are optional so can't test operator_params
308- TEST_ASSERT (nw->get_operator_params (format, operator_params) == NSAPI_ERROR_OK);
309+ err = nw->get_operator_params (format, operator_params);
310+ TEST_ASSERT (err == NSAPI_ERROR_OK);
309311
310312 nsapi_connection_status_t st = nw->get_connection_status ();
311313 TEST_ASSERT (st == NSAPI_STATUS_DISCONNECTED);
312314
313315 TEST_ASSERT (nw->set_blocking (true ) == NSAPI_ERROR_OK);
314316
315- #if CELLULAR_DEVICE != QUECTEL_BG96
316- // QUECTEL_BG96 timeouts with this one, tested with 3 minute timeout
317- CellularNetwork::operator_names_list op_names;
318- err = nw->get_operator_names (op_names);
319- TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
320- if (err == NSAPI_ERROR_DEVICE_ERROR) {
321- // if device error then we must check was that really device error or that modem/network does not support the commands
322- TEST_ASSERT (((AT_CellularNetwork *)nw)->get_device_error ().errCode == 4 // 4 == NOT SUPPORTED BY THE MODEM
323- && ((AT_CellularNetwork *)nw)->get_device_error ().errType == 3 ); // 3 == CME error from the modem
324- } else {
325- CellularNetwork::operator_names_t *opn = op_names.get_head ();
326- TEST_ASSERT (strlen (opn->numeric ) > 0 );
327- TEST_ASSERT (strlen (opn->alpha > 0 ));
317+ if (strcmp (devi, " QUECTEL_BG96" ) != 0 ) {
318+ // QUECTEL_BG96 timeouts with this one, tested with 3 minute timeout
319+ CellularNetwork::operator_names_list op_names;
320+ err = nw->get_operator_names (op_names);
321+ TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
322+ if (err == NSAPI_ERROR_DEVICE_ERROR) {
323+ // 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
326+ } else {
327+ CellularNetwork::operator_names_t *opn = op_names.get_head ();
328+ TEST_ASSERT (strlen (opn->numeric ) > 0 );
329+ TEST_ASSERT (strlen (opn->alpha ) > 0 );
330+ }
328331 }
329- #endif
330332
331- #if CELLULAR_DEVICE != TELIT_HE910
332- // 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
333- CellularNetwork::Supported_UE_Opt supported_opt = SUPPORTED_UE_OPT_MAX;
334- CellularNetwork::Preferred_UE_Opt preferred_opt = PREFERRED_UE_OPT_MAX;
333+ // 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
334+ CellularNetwork::Supported_UE_Opt supported_opt = CellularNetwork::SUPPORTED_UE_OPT_MAX;
335+ CellularNetwork::Preferred_UE_Opt preferred_opt = CellularNetwork::PREFERRED_UE_OPT_MAX;
335336 err = nw->get_ciot_optimization_config (supported_opt, preferred_opt);
336337 TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
337338 if (err == NSAPI_ERROR_DEVICE_ERROR) {
338339 // if device error then we must check was that really device error or that modem/network does not support the commands
339- TEST_ASSERT (((AT_CellularNetwork *)nw)->get_device_error ().errCode == 100 && // 100 == unknown command for modem
340- ((AT_CellularNetwork *)nw)->get_device_error ().errType == 3 ); // 3 == CME error from the modem
340+ 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
343+ }
341344 } else {
342- TEST_ASSERT (supported_opt != SUPPORTED_UE_OPT_MAX);
343- TEST_ASSERT (preferred_opt != PREFERRED_UE_OPT_MAX);
345+ TEST_ASSERT (supported_opt != CellularNetwork:: SUPPORTED_UE_OPT_MAX);
346+ TEST_ASSERT (preferred_opt != CellularNetwork:: PREFERRED_UE_OPT_MAX);
344347 }
345348
346349 err = nw->set_ciot_optimization_config (supported_opt, preferred_opt);
347350 TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
348351 if (err == NSAPI_ERROR_DEVICE_ERROR) {
349352 // if device error then we must check was that really device error or that modem/network does not support the commands
350- TEST_ASSERT (((AT_CellularNetwork *)nw)->get_device_error ().errCode == 100 && // 100 == unknown command for modem
351- ((AT_CellularNetwork *)nw)->get_device_error ().errType == 3 ); // 3 == CME error from the modem
353+ 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
356+ }
352357 }
353- #endif
354-
355358}
356359
357360static void test_disconnect ()
0 commit comments