Fixed factory reset

This commit is contained in:
Gunnar Skjold
2020-09-05 20:03:06 +02:00
parent a2c1c8fc61
commit 644a3fa40b
3 changed files with 11 additions and 4 deletions

View File

@@ -84,6 +84,7 @@ void AmsConfiguration::clearWifi() {
setWifiSsid(""); setWifiSsid("");
setWifiPassword(""); setWifiPassword("");
setWifiHostname(""); setWifiHostname("");
setMdnsEnable(true);
clearWifiIp(); clearWifiIp();
} }
@@ -305,12 +306,14 @@ void AmsConfiguration::setSendUnknown(bool sendUnknown) {
} }
void AmsConfiguration::clearMeter() { 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); setMeterType(0);
setDistributionSystem(0); setDistributionSystem(0);
setMainFuse(0); setMainFuse(0);
setProductionCapacity(0); setProductionCapacity(0);
setMeterEncryptionKey(nullptr); setMeterEncryptionKey(blankKey);
setMeterAuthenticationKey(nullptr); setMeterAuthenticationKey(blankKey);
setSubstituteMissing(false); setSubstituteMissing(false);
setSendUnknown(false); setSendUnknown(false);
} }

View File

@@ -327,8 +327,8 @@ private:
0, // Distribution system 0, // Distribution system
0, // Main fuse 0, // Main fuse
0, // Production capacity 0, // Production capacity
{}, // Encryption key { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // Encryption key
{}, // Authentication key { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // Authentication key
false, // Substitute false, // Substitute
false, // Send unknown false, // Send unknown
false, // Debug telnet false, // Debug telnet

View File

@@ -1403,9 +1403,13 @@ void AmsWebServer::factoryResetHtml() {
} }
void AmsWebServer::factoryResetPost() { void AmsWebServer::factoryResetPost() {
printD("Performing factory reset");
if(server.hasArg("perform") && server.arg("perform") == "true") { if(server.hasArg("perform") && server.arg("perform") == "true") {
printD("Formatting SPIFFS");
SPIFFS.format(); SPIFFS.format();
printD("Clearing configuration");
config->clear(); config->clear();
printD("Setting restart flag and redirecting");
performRestart = true; performRestart = true;
server.sendHeader("Location","/restart-wait"); server.sendHeader("Location","/restart-wait");
server.send(303); server.send(303);