@@ -452,9 +452,10 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeDeviceTopic()
452
452
return State::ConnectPhy;
453
453
}
454
454
455
- unsigned long reconnection_retry_delay = (1 << _last_device_subscribe_cnt) * AIOT_CONFIG_RECONNECTION_RETRY_DELAY_ms;
456
- reconnection_retry_delay = min (reconnection_retry_delay, static_cast <unsigned long >(AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms));
457
- _next_device_subscribe_attempt_tick = millis () + reconnection_retry_delay;
455
+ /* No device configuration reply. Wait: 5s -> 10s -> 20s -> 30s */
456
+ unsigned long subscribe_retry_delay = (1 << _last_device_subscribe_cnt) * AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms;
457
+ subscribe_retry_delay = min (subscribe_retry_delay, static_cast <unsigned long >(AIOT_CONFIG_MAX_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms));
458
+ _next_device_subscribe_attempt_tick = millis () + subscribe_retry_delay;
458
459
_last_device_subscribe_cnt++;
459
460
460
461
return State::WaitDeviceConfig;
@@ -492,7 +493,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
492
493
493
494
if (_deviceSubscribedToThing == true )
494
495
{
495
- /* Unsubscribe from old things topics and go oi with a new subsctiption */
496
+ /* Unsubscribe from old things topics and go on with a new subsctiption */
496
497
_mqttClient.unsubscribe (_shadowTopicIn);
497
498
_mqttClient.unsubscribe (_dataTopicIn);
498
499
@@ -503,14 +504,10 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
503
504
504
505
if (deviceNotAttached ())
505
506
{
506
- /* start long timeout counter
507
- * return return State::SubscribeThingTopics
508
- * if long timeout expired unsubscribe and
509
- * return State::SubscribeDeviceTopic
510
- */
511
- unsigned long reconnection_retry_delay = (1 << _last_device_subscribe_cnt) * AIOT_CONFIG_RECONNECTION_RETRY_DELAY_ms * 10000 ;
512
- reconnection_retry_delay = min (reconnection_retry_delay, static_cast <unsigned long >(AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms));
513
- _next_device_subscribe_attempt_tick = millis () + reconnection_retry_delay;
507
+ /* Configuration received but device not attached. Wait: 40s */
508
+ unsigned long subscribe_retry_delay = (1 << _last_device_subscribe_cnt) * AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms * 10 ;
509
+ subscribe_retry_delay = min (subscribe_retry_delay, static_cast <unsigned long >(AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms * 10 ));
510
+ _next_device_subscribe_attempt_tick = millis () + subscribe_retry_delay;
514
511
_last_device_subscribe_cnt++;
515
512
return State::WaitDeviceConfig;
516
513
}
0 commit comments