made EEPROM-Format on WebUI more "secure"

This commit is contained in:
Marcel Peterkau 2022-08-22 14:49:14 +02:00
parent 984affb5a7
commit c7f26bee32
4 changed files with 33 additions and 17 deletions

View File

@ -312,14 +312,14 @@
<div class="form-group">
<div class="col-xs-offset-5 col-xs-7">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="reset_ee_cfg_check">
<label class="form-check-label" for="reset_ee_cfg_check">
<input class="form-check-input" type="checkbox" value="" id="reset_ee_cfg">
<label class="form-check-label" for="reset_ee_cfg">
JA, EEPROM-Bereich "CFG" formatieren und Konfiguration zurück setzen
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="reset_ee_pds_check">
<label class="form-check-label" for="reset_ee_pds_check">
<input class="form-check-input" type="checkbox" value="" id="reset_ee_pds">
<label class="form-check-label" for="reset_ee_pds">
JA, EEPROM-Bereich "PDS" formatieren und Betriebsdaten zurück setzen
</label>
</div>

View File

@ -15,15 +15,11 @@ boolean checkEEPROMavailable();
void InitEEPROM()
{
ee.begin();
if (!checkEEPROMavailable())
{
return;
}
checkEEPROMavailable();
}
void EEPROM_Process()
{
switch (globals.requestEEAction)
{
case EE_CFG_SAVE:
@ -34,6 +30,11 @@ void EEPROM_Process()
GetConfig_EEPROM();
globals.requestEEAction = EE_IDLE;
break;
case EE_CFG_FORMAT:
FormatConfig_EEPROM();
globals.requestEEAction = EE_IDLE;
globals.systemStatus = sysStat_Shutdown;
break;
case EE_PDS_SAVE:
StorePersistence_EEPROM();
globals.requestEEAction = EE_IDLE;
@ -42,6 +43,15 @@ void EEPROM_Process()
GetPersistence_EEPROM();
globals.requestEEAction = EE_IDLE;
break;
case EE_PDS_FORMAT:
FormatPersistence_EEPROM();
globals.requestEEAction = EE_IDLE;
break;
case EE_FORMAT_ALL:
FormatConfig_EEPROM();
FormatPersistence_EEPROM();
globals.requestEEAction = EE_IDLE;
break;
case EE_ALL_SAVE:
StorePersistence_EEPROM();
StoreConfig_EEPROM();
@ -76,7 +86,6 @@ void GetConfig_EEPROM()
if (Checksum_EEPROM((uint8_t *)&LubeConfig, sizeof(LubeConfig)) != checksum)
{
MaintainDTC(DTC_EEPROM_CFG_BAD, DTC_CRITICAL, true);
FormatConfig_EEPROM();
}
LubeConfig.checksum = checksum;
}

View File

@ -22,6 +22,7 @@ typedef enum eEERequest
EE_PDS_SAVE,
EE_PDS_LOAD,
EE_PDS_FORMAT,
EE_FORMAT_ALL,
EE_ALL_SAVE
} tEERequest;

View File

@ -308,15 +308,21 @@ void WebserverPOST_Callback(AsyncWebServerRequest *request)
PersistenceData.tankRemain_µl = LubeConfig.tankCapacity_ml * 1000;
globals.requestEEAction = EE_PDS_SAVE;
}
if (p->name() == "reset_ee_cfg")
if (p->name() == "reset_ee_btn")
{
globals.requestEEAction = EE_CFG_FORMAT;
}
if (p->name() == "reset_ee_pds")
if (request->hasParam("reset_ee_pds"))
{
globals.requestEEAction = EE_PDS_FORMAT;
AsyncWebParameter *param = request->getParam("reset_ee_pds");
if (param->value() == "checked")
globals.requestEEAction = globals.requestEEAction == EE_CFG_FORMAT ? EE_FORMAT_ALL : EE_PDS_FORMAT;
}
if (request->hasParam("reset_ee_cfg"))
{
AsyncWebParameter *param = request->getParam("reset_ee_cfg");
if (param->value() == "checked")
globals.requestEEAction = globals.requestEEAction == EE_PDS_FORMAT ? EE_FORMAT_ALL : EE_CFG_FORMAT;
}
}
// end: POST Form Maintenance
}
}