Skip to content

Commit b0d6092

Browse files
committed
TCP: do not disconnect if ota client is connected
1 parent eddc451 commit b0d6092

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

Diff for: src/ArduinoIoTCloudTCP.cpp

+15-13
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,22 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
319319

320320
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
321321
{
322-
if (!_mqttClient.connected() || !_thing.connected() || !_device.connected())
323-
{
324-
return State::Disconnect;
322+
#if OTA_ENABLED
323+
if(_get_ota_confirmation != nullptr &&
324+
_ota.getState() == OTACloudProcessInterface::State::OtaAvailable &&
325+
_get_ota_confirmation()) {
326+
_ota.approveOta();
327+
}
328+
_ota.update();
329+
330+
if (!_otaClient.connected()) {
331+
#endif
332+
if (!_mqttClient.connected() || !_thing.connected() || !_device.connected()) {
333+
return State::Disconnect;
334+
}
335+
#if OTA_ENABLED
325336
}
337+
#endif
326338

327339
/* Check for new data from the MQTT client. */
328340
_mqttClient.poll();
@@ -338,16 +350,6 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
338350
/* Call CloudDevice process to get configuration */
339351
_device.update();
340352

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-
351353

352354
if (_device.isAttached()) {
353355
/* Call CloudThing process to synchronize properties */

0 commit comments

Comments
 (0)