[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
This commit is contained in:
1 parent
33ea56bf12
commit
9219ff928c
1 file changed
+12
-4
+12
-4
@@ -2027,6 +2027,8 @@ bool checkForUpdates() {
|
|||||||
if (jsondata.containsKey("latest_version")) {
|
if (jsondata.containsKey("latest_version")) {
|
||||||
jsondata["installed_version"] = OMG_VERSION;
|
jsondata["installed_version"] = OMG_VERSION;
|
||||||
jsondata["entity_picture"] = ENTITY_PICTURE;
|
jsondata["entity_picture"] = ENTITY_PICTURE;
|
||||||
|
if (!jsondata.containsKey("release_summary"))
|
||||||
|
jsondata["release_summary"] = "";
|
||||||
latestVersion = jsondata["latest_version"].as<String>();
|
latestVersion = jsondata["latest_version"].as<String>();
|
||||||
pub(subjectSYStoMQTT, jsondata);
|
pub(subjectSYStoMQTT, jsondata);
|
||||||
Log.trace(F("Update file found on server" CR));
|
Log.trace(F("Update file found on server" CR));
|
||||||
@@ -2065,6 +2067,9 @@ void MQTTHttpsFWUpdate(char* topicOri, JsonObject& HttpsFwUpdateData) {
|
|||||||
# endif
|
# endif
|
||||||
# ifdef ESP32
|
# ifdef ESP32
|
||||||
} else if (strcmp(version, "latest") == 0) {
|
} else if (strcmp(version, "latest") == 0) {
|
||||||
|
# if defined(ZgatewayBT)
|
||||||
|
stopProcessing();
|
||||||
|
# endif
|
||||||
if (!checkForUpdates())
|
if (!checkForUpdates())
|
||||||
return;
|
return;
|
||||||
systemUrl = RELEASE_LINK + latestVersion + "/" + ENV_NAME + "-firmware.bin";
|
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));
|
Log.warning(F("Starting firmware update" CR));
|
||||||
SendReceiveIndicatorON();
|
SendReceiveIndicatorON();
|
||||||
ErrorIndicatorON();
|
ErrorIndicatorON();
|
||||||
|
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
|
||||||
# if defined(ZgatewayBT) && defined(ESP32)
|
JsonObject jsondata = jsonBuffer.to<JsonObject>();
|
||||||
stopProcessing();
|
jsondata["release_summary"] = "Update in progress ...";
|
||||||
# endif
|
pub(subjectSYStoMQTT, jsondata);
|
||||||
|
|
||||||
const char* ota_cert = HttpsFwUpdateData["server_cert"];
|
const char* ota_cert = HttpsFwUpdateData["server_cert"];
|
||||||
if (!ota_cert) {
|
if (!ota_cert) {
|
||||||
@@ -2169,6 +2174,9 @@ void MQTTHttpsFWUpdate(char* topicOri, JsonObject& HttpsFwUpdateData) {
|
|||||||
|
|
||||||
case HTTP_UPDATE_OK:
|
case HTTP_UPDATE_OK:
|
||||||
Log.notice(F("HTTP_UPDATE_OK" CR));
|
Log.notice(F("HTTP_UPDATE_OK" CR));
|
||||||
|
jsondata["release_summary"] = "Update success !";
|
||||||
|
jsondata["installed_version"] = latestVersion;
|
||||||
|
pub(subjectSYStoMQTT, jsondata);
|
||||||
ota_server_cert = ota_cert;
|
ota_server_cert = ota_cert;
|
||||||
# ifndef ESPWifiManualSetup
|
# ifndef ESPWifiManualSetup
|
||||||
saveMqttConfig();
|
saveMqttConfig();
|
||||||
|
|||||||
Reference in new issue
Block a user