File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -240,6 +240,24 @@ void ArduinoIoTCloudTCP::update()
240240#if defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_MBED)
241241 watchdog_reset ();
242242#endif
243+
244+ #if OTA_ENABLED
245+ /* OTA FSM needs to reach the Idle state before being able to run independently from
246+ * the mqttClient. The state can be reached only after the mqttClient is connected to
247+ * the broker.
248+ */
249+ if ((_ota.getState () != OTACloudProcessInterface::Resume &&
250+ _ota.getState () != OTACloudProcessInterface::OtaBegin) ||
251+ _mqttClient.connected ()) {
252+ _ota.update ();
253+ }
254+
255+ if (_get_ota_confirmation != nullptr &&
256+ _ota.getState () == OTACloudProcessInterface::State::OtaAvailable &&
257+ _get_ota_confirmation ()) {
258+ _ota.approveOta ();
259+ }
260+ #endif // OTA_ENABLED
243261}
244262
245263int ArduinoIoTCloudTCP::connected ()
@@ -338,16 +356,6 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
338356 /* Call CloudDevice process to get configuration */
339357 _device.update ();
340358
341- #if OTA_ENABLED
342- if (_get_ota_confirmation != nullptr &&
343- _ota.getState () == OTACloudProcessInterface::State::OtaAvailable &&
344- _get_ota_confirmation ()) {
345- _ota.approveOta ();
346- }
347-
348- _ota.update ();
349- #endif // OTA_ENABLED
350-
351359
352360 if (_device.isAttached ()) {
353361 /* Call CloudThing process to synchronize properties */
You can’t perform that action at this time.
0 commit comments