From 1c5b7fe1b99faa2e6f1fb0ea9173918a9b193b85 Mon Sep 17 00:00:00 2001 From: proddy Date: Tue, 1 Sep 2020 13:48:22 +0200 Subject: [PATCH] small changes to migration --- src/system.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/system.cpp b/src/system.cpp index 59842bd21..53056cd58 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -617,6 +617,7 @@ bool System::check_upgrade() { file1.close(); file2.close(); SPIFFS.end(); + Serial.end(); return false; // can't open files } @@ -628,18 +629,19 @@ bool System::check_upgrade() { error = deserializeJson(doc1, file1); if (error) { - Serial.printf("Error. Failed to deserialize json, doc1, error %s", error.c_str()); + Serial.printf(PSTR("Error. Failed to deserialize json, doc1, error %s"), error.c_str()); failed = true; } error = deserializeJson(doc2, file2); if (error) { - Serial.printf("Error. Failed to deserialize json, doc2, error %s", error.c_str()); + Serial.printf(PSTR("Error. Failed to deserialize json, doc2, error %s"), error.c_str()); failed = true; } file1.close(); file2.close(); SPIFFS.end(); + Serial.end(); if (failed) { return false; // parse error @@ -675,10 +677,11 @@ bool System::check_upgrade() { }, "local"); + // ignoring publish_time EMSESP::esp8266React.getMqttSettingsService()->update( [&](MqttSettings & mqttSettings) { mqttSettings.host = mqtt["ip"] | FACTORY_MQTT_HOST; - mqttSettings.mqtt_format = (mqtt["nestedjson"] ? 2 : 1); + mqttSettings.mqtt_format = (mqtt["nestedjson"] ? MQTT_format::NESTED : MQTT_format::SINGLE); mqttSettings.mqtt_qos = mqtt["qos"] | 0; mqttSettings.username = mqtt["user"] | ""; mqttSettings.password = mqtt["password"] | ""; @@ -718,7 +721,8 @@ bool System::check_upgrade() { "local"); Serial.println(F("Restarting...")); - Serial.end(); + Serial.flush(); + delay(2000); restart(); // force a restart, nice and tidy return true; #else