@@ -369,6 +369,29 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SendDeviceProperties()
369369 return State::WaitDeviceConfig;
370370}
371371
372+ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_WaitDeviceConfig ()
373+ {
374+ if (!_mqttClient.connected ())
375+ {
376+ return State::Disconnect;
377+ }
378+
379+ bool const is_retry_attempt = (_last_device_subscribe_cnt > 0 );
380+ if (is_retry_attempt && (millis () > _next_device_subscribe_attempt_tick))
381+ {
382+ /* Configuration not received or device not attached to a valid thing. Try to resubscribe */
383+ if (_mqttClient.unsubscribe (_deviceTopicIn))
384+ {
385+ DEBUG_ERROR (" ArduinoIoTCloudTCP::%s device waiting for valid thing_id %d" , __FUNCTION__, _time_service.getTime ());
386+ }
387+ }
388+
389+ if (!is_retry_attempt || (is_retry_attempt && (millis () > _next_device_subscribe_attempt_tick)))
390+ return State::SubscribeDeviceTopic;
391+
392+ return State::WaitDeviceConfig;
393+ }
394+
372395ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeDeviceTopic ()
373396{
374397 if (!_mqttClient.connected ())
@@ -404,29 +427,6 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeDeviceTopic()
404427 return State::WaitDeviceConfig;
405428}
406429
407- ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_WaitDeviceConfig ()
408- {
409- if (!_mqttClient.connected ())
410- {
411- return State::Disconnect;
412- }
413-
414- bool const is_retry_attempt = (_last_device_subscribe_cnt > 0 );
415- if (is_retry_attempt && (millis () > _next_device_subscribe_attempt_tick))
416- {
417- /* Configuration not received or device not attached to a valid thing. Try to resubscribe */
418- if (_mqttClient.unsubscribe (_deviceTopicIn))
419- {
420- DEBUG_ERROR (" ArduinoIoTCloudTCP::%s device waiting for valid thing_id %d" , __FUNCTION__, _time_service.getTime ());
421- }
422- }
423-
424- if (!is_retry_attempt || (is_retry_attempt && (millis () > _next_device_subscribe_attempt_tick)))
425- return State::SubscribeDeviceTopic;
426-
427- return State::WaitDeviceConfig;
428- }
429-
430430ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig ()
431431{
432432 if (!_mqttClient.connected ())
0 commit comments