From 644a3fa40b7858dc8f9cbd66da53c7f26f0a1486 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Sat, 5 Sep 2020 20:03:06 +0200 Subject: [PATCH] Fixed factory reset --- src/AmsConfiguration.cpp | 7 +++++-- src/AmsConfiguration.h | 4 ++-- src/web/AmsWebServer.cpp | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/AmsConfiguration.cpp b/src/AmsConfiguration.cpp index 508b6dcd..5e4dec92 100644 --- a/src/AmsConfiguration.cpp +++ b/src/AmsConfiguration.cpp @@ -84,6 +84,7 @@ void AmsConfiguration::clearWifi() { setWifiSsid(""); setWifiPassword(""); setWifiHostname(""); + setMdnsEnable(true); clearWifiIp(); } @@ -305,12 +306,14 @@ void AmsConfiguration::setSendUnknown(bool sendUnknown) { } void AmsConfiguration::clearMeter() { + uint8_t blankKey[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + setMeterType(0); setDistributionSystem(0); setMainFuse(0); setProductionCapacity(0); - setMeterEncryptionKey(nullptr); - setMeterAuthenticationKey(nullptr); + setMeterEncryptionKey(blankKey); + setMeterAuthenticationKey(blankKey); setSubstituteMissing(false); setSendUnknown(false); } diff --git a/src/AmsConfiguration.h b/src/AmsConfiguration.h index 721f224b..c0ce1783 100644 --- a/src/AmsConfiguration.h +++ b/src/AmsConfiguration.h @@ -327,8 +327,8 @@ private: 0, // Distribution system 0, // Main fuse 0, // Production capacity - {}, // Encryption key - {}, // Authentication key + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // Encryption key + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // Authentication key false, // Substitute false, // Send unknown false, // Debug telnet diff --git a/src/web/AmsWebServer.cpp b/src/web/AmsWebServer.cpp index f56d4889..3a0bdc60 100644 --- a/src/web/AmsWebServer.cpp +++ b/src/web/AmsWebServer.cpp @@ -1403,9 +1403,13 @@ void AmsWebServer::factoryResetHtml() { } void AmsWebServer::factoryResetPost() { + printD("Performing factory reset"); if(server.hasArg("perform") && server.arg("perform") == "true") { + printD("Formatting SPIFFS"); SPIFFS.format(); + printD("Clearing configuration"); config->clear(); + printD("Setting restart flag and redirecting"); performRestart = true; server.sendHeader("Location","/restart-wait"); server.send(303);