Skip to content

TCP: do not disconnect if ota client is connected #532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions src/ArduinoIoTCloudTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,24 @@ void ArduinoIoTCloudTCP::update()
#if defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_MBED)
watchdog_reset();
#endif

#if OTA_ENABLED
/* OTA FSM needs to reach the Idle state before being able to run independently from
* the mqttClient. The state can be reached only after the mqttClient is connected to
* the broker.
*/
if((_ota.getState() != OTACloudProcessInterface::Resume &&
_ota.getState() != OTACloudProcessInterface::OtaBegin) ||
_mqttClient.connected()) {
_ota.update();
}

if(_get_ota_confirmation != nullptr &&
_ota.getState() == OTACloudProcessInterface::State::OtaAvailable &&
_get_ota_confirmation()) {
_ota.approveOta();
}
#endif // OTA_ENABLED
}

int ArduinoIoTCloudTCP::connected()
Expand Down Expand Up @@ -338,16 +356,6 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
/* Call CloudDevice process to get configuration */
_device.update();

#if OTA_ENABLED
if(_get_ota_confirmation != nullptr &&
_ota.getState() == OTACloudProcessInterface::State::OtaAvailable &&
_get_ota_confirmation()) {
_ota.approveOta();
}

_ota.update();
#endif // OTA_ENABLED


if (_device.isAttached()) {
/* Call CloudThing process to synchronize properties */
Expand Down
Loading