@@ -445,9 +445,10 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeDeviceTopic()
445445 return State::ConnectPhy;
446446 }
447447
448- unsigned long reconnection_retry_delay = (1 << _last_device_subscribe_cnt) * AIOT_CONFIG_RECONNECTION_RETRY_DELAY_ms;
449- reconnection_retry_delay = min (reconnection_retry_delay, static_cast <unsigned long >(AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms));
450- _next_device_subscribe_attempt_tick = millis () + reconnection_retry_delay;
448+ /* No device configuration reply. Wait: 5s -> 10s -> 20s -> 30s */
449+ unsigned long subscribe_retry_delay = (1 << _last_device_subscribe_cnt) * AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms;
450+ subscribe_retry_delay = min (subscribe_retry_delay, static_cast <unsigned long >(AIOT_CONFIG_MAX_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms));
451+ _next_device_subscribe_attempt_tick = millis () + subscribe_retry_delay;
451452 _last_device_subscribe_cnt++;
452453
453454 return State::WaitDeviceConfig;
@@ -496,14 +497,10 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
496497
497498 if (deviceNotAttached ())
498499 {
499- /* start long timeout counter
500- * return return State::SubscribeThingTopics
501- * if long timeout expired unsubscribe and
502- * return State::SubscribeDeviceTopic
503- */
504- unsigned long reconnection_retry_delay = (1 << _last_device_subscribe_cnt) * AIOT_CONFIG_RECONNECTION_RETRY_DELAY_ms * 10000 ;
505- reconnection_retry_delay = min (reconnection_retry_delay, static_cast <unsigned long >(AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms));
506- _next_device_subscribe_attempt_tick = millis () + reconnection_retry_delay;
500+ /* Configuration received but device not attached. Wait: 40s */
501+ unsigned long subscribe_retry_delay = (1 << _last_device_subscribe_cnt) * AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms * 10 ;
502+ subscribe_retry_delay = min (subscribe_retry_delay, static_cast <unsigned long >(AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms * 10 ));
503+ _next_device_subscribe_attempt_tick = millis () + subscribe_retry_delay;
507504 _last_device_subscribe_cnt++;
508505 return State::WaitDeviceConfig;
509506 }
0 commit comments