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