From 0a4641ed1138df2c4d7ffe0dfadecf60c6e9d255 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 23 Jul 2020 12:56:49 +0200 Subject: [PATCH] OTA logic should be called at start of update --- src/ArduinoIoTCloudTCP.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ArduinoIoTCloudTCP.cpp b/src/ArduinoIoTCloudTCP.cpp index b39640c55..10999e584 100644 --- a/src/ArduinoIoTCloudTCP.cpp +++ b/src/ArduinoIoTCloudTCP.cpp @@ -166,6 +166,15 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort) void ArduinoIoTCloudTCP::update() { +#if OTA_ENABLED + /* If a _ota_logic object has been instantiated then we are spinning its + * 'update' method here in order to process incoming data and generally + * to transition to the OTA logic update states. + */ + OTAError const err = _ota_logic.update(); + _ota_error = static_cast(err); +#endif /* OTA_ENABLED */ + /* Run through the state machine. */ State next_state = _state; switch (_state) @@ -182,15 +191,6 @@ void ArduinoIoTCloudTCP::update() /* Check for new data from the MQTT client. */ if (_mqttClient.connected()) _mqttClient.poll(); - -#if OTA_ENABLED - /* If a _ota_logic object has been instantiated then we are spinning its - * 'update' method here in order to process incoming data and generally - * to transition to the OTA logic update states. - */ - OTAError const err = _ota_logic.update(); - _ota_error = static_cast(err); -#endif /* OTA_ENABLED */ } int ArduinoIoTCloudTCP::connected()