@@ -213,30 +213,32 @@ static void test_credentials()
213
213
214
214
static void test_other ()
215
215
{
216
+ const char * devi = CELLULAR_STRINGIFY (CELLULAR_DEVICE);
216
217
TEST_ASSERT (nw->get_3gpp_error () == 0 );
217
218
218
219
CellularNetwork::RateControlExceptionReports reports;
219
220
CellularNetwork::RateControlUplinkTimeUnit timeUnit;
220
221
int uplinkRate;
221
222
// can't test values as they are optional
222
223
nsapi_error_t err = nw->get_rate_control (reports, timeUnit, uplinkRate);
223
- tr_error (" get_rate_control: %d" , err);
224
224
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
+ }
229
230
}
230
- #endif
231
231
232
232
uplinkRate = -1 ;
233
233
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 );
235
235
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 );
240
242
} else {
241
243
TEST_ASSERT (uplinkRate >= 0 );
242
244
}
@@ -261,25 +263,24 @@ static void test_other()
261
263
262
264
TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
263
265
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
+ }
268
270
} else {
269
271
// should have some values, only not optional are apn and bearer id
270
272
CellularNetwork::pdpcontext_params_t *params = params_list.get_head ();
271
- TEST_ASSERT (strlen (params->apn ) > 0 );
272
273
TEST_ASSERT (params->bearer_id >= 0 )
273
274
}
274
275
275
276
int rxlev = -1 , ber = -1 , rscp = -1 , ecno = -1 , rsrq = -1 , rsrp = -1 ;
276
277
err = nw->get_extended_signal_quality (rxlev, ber, rscp, ecno, rsrq, rsrp);
277
278
TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
278
279
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
+ }
283
284
} else {
284
285
// we should have some values which are not optional
285
286
TEST_ASSERT (rxlev >= 0 && ber >= 0 && rscp >= 0 && ecno >= 0 && rsrq >= 0 && rsrp >= 0 );
@@ -305,53 +306,55 @@ static void test_other()
305
306
int format = -1 ;
306
307
CellularNetwork::operator_t operator_params;
307
308
// 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);
309
311
310
312
nsapi_connection_status_t st = nw->get_connection_status ();
311
313
TEST_ASSERT (st == NSAPI_STATUS_DISCONNECTED);
312
314
313
315
TEST_ASSERT (nw->set_blocking (true ) == NSAPI_ERROR_OK);
314
316
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
+ }
328
331
}
329
- #endif
330
332
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;
335
336
err = nw->get_ciot_optimization_config (supported_opt, preferred_opt);
336
337
TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
337
338
if (err == NSAPI_ERROR_DEVICE_ERROR) {
338
339
// 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
+ }
341
344
} 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);
344
347
}
345
348
346
349
err = nw->set_ciot_optimization_config (supported_opt, preferred_opt);
347
350
TEST_ASSERT (err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
348
351
if (err == NSAPI_ERROR_DEVICE_ERROR) {
349
352
// 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
+ }
352
357
}
353
- #endif
354
-
355
358
}
356
359
357
360
static void test_disconnect ()
0 commit comments