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("");
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);
}

View File

@ -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

View File

@ -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);