Skip to content

Commit d89f294

Browse files
committed
Reorder functions implementation
1 parent d5239eb commit d89f294

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/ArduinoIoTCloudTCP.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
372395
ArduinoIoTCloudTCP::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-
430430
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
431431
{
432432
if (!_mqttClient.connected())

0 commit comments

Comments
 (0)