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