25
25
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_INFO
26
26
#endif
27
27
28
- // timeout to wait for AT responses
29
- #define TIMEOUT_POWER_ON (1 *1000 )
30
- #define TIMEOUT_SIM_PIN (1 *1000 )
31
- #define TIMEOUT_NETWORK (10 *1000 )
32
- #define TIMEOUT_CONNECT (60 *1000 )
33
- #define TIMEOUT_REGISTRATION (180 *1000 )
34
-
35
28
// maximum time when retrying network register, attach and connect in seconds ( 20minutes )
36
29
#define TIMEOUT_NETWORK_MAX (20 *60 )
37
30
@@ -299,8 +292,10 @@ void CellularStateMachine::retry_state_or_fail()
299
292
300
293
void CellularStateMachine::state_init ()
301
294
{
302
- _cellularDevice.set_timeout (TIMEOUT_POWER_ON);
303
- tr_info (" Start connecting (timeout %d s)" , TIMEOUT_POWER_ON / 1000 );
295
+ #if MBED_CONF_CELLULAR_TIMEOUT_POWER_ON
296
+ _cellularDevice.set_timeout (MBED_CONF_CELLULAR_TIMEOUT_POWER_ON);
297
+ tr_debug (" Wait for modem response (timeout %d s)" , MBED_CONF_CELLULAR_TIMEOUT_POWER_ON / 1000 );
298
+ #endif
304
299
_cb_data.error = _cellularDevice.is_ready ();
305
300
_status = _cb_data.error ? 0 : DEVICE_READY;
306
301
if (_cb_data.error != NSAPI_ERROR_OK) {
@@ -316,8 +311,10 @@ void CellularStateMachine::state_init()
316
311
317
312
void CellularStateMachine::state_power_on ()
318
313
{
319
- _cellularDevice.set_timeout (TIMEOUT_POWER_ON);
320
- tr_info (" Modem power ON (timeout %d s)" , TIMEOUT_POWER_ON / 1000 );
314
+ #if MBED_CONF_CELLULAR_TIMEOUT_POWER_ON
315
+ _cellularDevice.set_timeout (MBED_CONF_CELLULAR_TIMEOUT_POWER_ON);
316
+ tr_debug (" Modem power ON (timeout %d s)" , MBED_CONF_CELLULAR_TIMEOUT_POWER_ON / 1000 );
317
+ #endif
321
318
if (power_on ()) {
322
319
enter_to_state (STATE_DEVICE_READY);
323
320
} else {
@@ -354,7 +351,9 @@ bool CellularStateMachine::device_ready()
354
351
355
352
void CellularStateMachine::state_device_ready ()
356
353
{
357
- _cellularDevice.set_timeout (TIMEOUT_POWER_ON);
354
+ #if MBED_CONF_CELLULAR_TIMEOUT_POWER_ON
355
+ _cellularDevice.set_timeout (MBED_CONF_CELLULAR_TIMEOUT_POWER_ON);
356
+ #endif
358
357
if (!(_status & DEVICE_READY)) {
359
358
tr_debug (" Device was not ready, calling soft_power_on()" );
360
359
_cb_data.error = _cellularDevice.soft_power_on ();
@@ -378,8 +377,10 @@ void CellularStateMachine::state_device_ready()
378
377
379
378
void CellularStateMachine::state_sim_pin ()
380
379
{
381
- _cellularDevice.set_timeout (TIMEOUT_SIM_PIN);
382
- tr_info (" Setup SIM (timeout %d s)" , TIMEOUT_SIM_PIN / 1000 );
380
+ #if MBED_CONF_CELLULAR_TIMEOUT_SIM_PIN
381
+ _cellularDevice.set_timeout (MBED_CONF_CELLULAR_TIMEOUT_SIM_PIN);
382
+ tr_debug (" Setup SIM (timeout %d s)" , MBED_CONF_CELLULAR_TIMEOUT_SIM_PIN / 1000 );
383
+ #endif
383
384
if (open_sim ()) {
384
385
bool success = false ;
385
386
for (int type = 0 ; type < CellularNetwork::C_MAX; type++) {
@@ -412,8 +413,9 @@ void CellularStateMachine::state_sim_pin()
412
413
413
414
void CellularStateMachine::state_registering ()
414
415
{
415
- _cellularDevice.set_timeout (TIMEOUT_NETWORK);
416
- tr_info (" Network registration (timeout %d s)" , TIMEOUT_REGISTRATION / 1000 );
416
+ #if MBED_CONF_CELLULAR_TIMEOUT_NETWORK_ATTACH
417
+ _cellularDevice.set_timeout (MBED_CONF_CELLULAR_TIMEOUT_NETWORK_ATTACH);
418
+ #endif
417
419
if (is_registered ()) {
418
420
if (_cb_data.status_data != CellularNetwork::RegisteredHomeNetwork &&
419
421
_cb_data.status_data != CellularNetwork::RegisteredRoaming && _status) {
@@ -425,7 +427,10 @@ void CellularStateMachine::state_registering()
425
427
// we are already registered, go to attach
426
428
enter_to_state (STATE_ATTACHING_NETWORK);
427
429
} else {
428
- _cellularDevice.set_timeout (TIMEOUT_REGISTRATION);
430
+ #if MBED_CONF_CELLULAR_TIMEOUT_NETWORK_SELECTION
431
+ _cellularDevice.set_timeout (MBED_CONF_CELLULAR_TIMEOUT_NETWORK_SELECTION);
432
+ tr_debug (" Network selection (timeout %d s)" , MBED_CONF_CELLULAR_TIMEOUT_NETWORK_SELECTION / 1000 );
433
+ #endif
429
434
if (!_command_success && !_plmn) { // don't call set_registration twice for manual registration
430
435
_cb_data.error = _network->set_registration (_plmn);
431
436
_command_success = (_cb_data.error == NSAPI_ERROR_OK);
@@ -436,8 +441,10 @@ void CellularStateMachine::state_registering()
436
441
437
442
void CellularStateMachine::state_attaching ()
438
443
{
439
- _cellularDevice.set_timeout (TIMEOUT_CONNECT);
440
- tr_info (" Attaching network (timeout %d s)" , TIMEOUT_CONNECT / 1000 );
444
+ #if MBED_CONF_CELLULAR_TIMEOUT_NETWORK_CONNECT
445
+ _cellularDevice.set_timeout (MBED_CONF_CELLULAR_TIMEOUT_NETWORK_CONNECT);
446
+ tr_debug (" Attaching network (timeout %d s)" , MBED_CONF_CELLULAR_TIMEOUT_NETWORK_CONNECT / 1000 );
447
+ #endif
441
448
if (_status != ATTACHED_TO_NETWORK) {
442
449
_cb_data.error = _network->set_attach ();
443
450
}
0 commit comments