From 9219ff928ccad1fd6c89a4f2912ac18a434e1f7e Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 16 Mar 2023 10:01:20 -0500 Subject: [PATCH] [OTA] Improve user feedback and regorganize processing (#1540) To see OTA progress through MQTT messages or controller And change the stopProcessing position so as to reduce chance of collision with other processes --- main/main.ino | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/main/main.ino b/main/main.ino index bf8c55b..01bf2c5 100644 --- a/main/main.ino +++ b/main/main.ino @@ -2027,6 +2027,8 @@ bool checkForUpdates() { if (jsondata.containsKey("latest_version")) { jsondata["installed_version"] = OMG_VERSION; jsondata["entity_picture"] = ENTITY_PICTURE; + if (!jsondata.containsKey("release_summary")) + jsondata["release_summary"] = ""; latestVersion = jsondata["latest_version"].as(); pub(subjectSYStoMQTT, jsondata); Log.trace(F("Update file found on server" CR)); @@ -2065,6 +2067,9 @@ void MQTTHttpsFWUpdate(char* topicOri, JsonObject& HttpsFwUpdateData) { # endif # ifdef ESP32 } else if (strcmp(version, "latest") == 0) { +# if defined(ZgatewayBT) + stopProcessing(); +# endif if (!checkForUpdates()) return; systemUrl = RELEASE_LINK + latestVersion + "/" + ENV_NAME + "-firmware.bin"; @@ -2087,10 +2092,10 @@ void MQTTHttpsFWUpdate(char* topicOri, JsonObject& HttpsFwUpdateData) { Log.warning(F("Starting firmware update" CR)); SendReceiveIndicatorON(); ErrorIndicatorON(); - -# if defined(ZgatewayBT) && defined(ESP32) - stopProcessing(); -# endif + StaticJsonDocument jsonBuffer; + JsonObject jsondata = jsonBuffer.to(); + jsondata["release_summary"] = "Update in progress ..."; + pub(subjectSYStoMQTT, jsondata); const char* ota_cert = HttpsFwUpdateData["server_cert"]; if (!ota_cert) { @@ -2169,6 +2174,9 @@ void MQTTHttpsFWUpdate(char* topicOri, JsonObject& HttpsFwUpdateData) { case HTTP_UPDATE_OK: Log.notice(F("HTTP_UPDATE_OK" CR)); + jsondata["release_summary"] = "Update success !"; + jsondata["installed_version"] = latestVersion; + pub(subjectSYStoMQTT, jsondata); ota_server_cert = ota_cert; # ifndef ESPWifiManualSetup saveMqttConfig();