made EEPROM-Format on WebUI more "secure"
This commit is contained in:
		| @@ -312,14 +312,14 @@ | |||||||
|           <div class="form-group"> |           <div class="form-group"> | ||||||
|             <div class="col-xs-offset-5 col-xs-7"> |             <div class="col-xs-offset-5 col-xs-7"> | ||||||
|               <div class="form-check"> |               <div class="form-check"> | ||||||
|                 <input class="form-check-input" type="checkbox" value="" id="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_check"> |                 <label class="form-check-label" for="reset_ee_cfg"> | ||||||
|                   JA, EEPROM-Bereich "CFG" formatieren und Konfiguration zurück setzen |                   JA, EEPROM-Bereich "CFG" formatieren und Konfiguration zurück setzen | ||||||
|                 </label> |                 </label> | ||||||
|               </div> |               </div> | ||||||
|               <div class="form-check"> |               <div class="form-check"> | ||||||
|                 <input class="form-check-input" type="checkbox" value="" id="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_check"> |                 <label class="form-check-label" for="reset_ee_pds"> | ||||||
|                   JA, EEPROM-Bereich "PDS" formatieren und Betriebsdaten zurück setzen |                   JA, EEPROM-Bereich "PDS" formatieren und Betriebsdaten zurück setzen | ||||||
|                 </label> |                 </label> | ||||||
|               </div> |               </div> | ||||||
|   | |||||||
| @@ -15,15 +15,11 @@ boolean checkEEPROMavailable(); | |||||||
| void InitEEPROM() | void InitEEPROM() | ||||||
| { | { | ||||||
|   ee.begin(); |   ee.begin(); | ||||||
|   if (!checkEEPROMavailable()) |   checkEEPROMavailable(); | ||||||
|   { |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void EEPROM_Process() | void EEPROM_Process() | ||||||
| { | { | ||||||
|  |  | ||||||
|   switch (globals.requestEEAction) |   switch (globals.requestEEAction) | ||||||
|   { |   { | ||||||
|   case EE_CFG_SAVE: |   case EE_CFG_SAVE: | ||||||
| @@ -34,6 +30,11 @@ void EEPROM_Process() | |||||||
|     GetConfig_EEPROM(); |     GetConfig_EEPROM(); | ||||||
|     globals.requestEEAction = EE_IDLE; |     globals.requestEEAction = EE_IDLE; | ||||||
|     break; |     break; | ||||||
|  |   case EE_CFG_FORMAT: | ||||||
|  |     FormatConfig_EEPROM(); | ||||||
|  |     globals.requestEEAction = EE_IDLE; | ||||||
|  |     globals.systemStatus = sysStat_Shutdown; | ||||||
|  |     break; | ||||||
|   case EE_PDS_SAVE: |   case EE_PDS_SAVE: | ||||||
|     StorePersistence_EEPROM(); |     StorePersistence_EEPROM(); | ||||||
|     globals.requestEEAction = EE_IDLE; |     globals.requestEEAction = EE_IDLE; | ||||||
| @@ -42,6 +43,15 @@ void EEPROM_Process() | |||||||
|     GetPersistence_EEPROM(); |     GetPersistence_EEPROM(); | ||||||
|     globals.requestEEAction = EE_IDLE; |     globals.requestEEAction = EE_IDLE; | ||||||
|     break; |     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: |   case EE_ALL_SAVE: | ||||||
|     StorePersistence_EEPROM(); |     StorePersistence_EEPROM(); | ||||||
|     StoreConfig_EEPROM(); |     StoreConfig_EEPROM(); | ||||||
| @@ -76,7 +86,6 @@ void GetConfig_EEPROM() | |||||||
|   if (Checksum_EEPROM((uint8_t *)&LubeConfig, sizeof(LubeConfig)) != checksum) |   if (Checksum_EEPROM((uint8_t *)&LubeConfig, sizeof(LubeConfig)) != checksum) | ||||||
|   { |   { | ||||||
|     MaintainDTC(DTC_EEPROM_CFG_BAD, DTC_CRITICAL, true); |     MaintainDTC(DTC_EEPROM_CFG_BAD, DTC_CRITICAL, true); | ||||||
|     FormatConfig_EEPROM(); |  | ||||||
|   } |   } | ||||||
|   LubeConfig.checksum = checksum; |   LubeConfig.checksum = checksum; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ typedef enum eEERequest | |||||||
|   EE_PDS_SAVE, |   EE_PDS_SAVE, | ||||||
|   EE_PDS_LOAD, |   EE_PDS_LOAD, | ||||||
|   EE_PDS_FORMAT, |   EE_PDS_FORMAT, | ||||||
|  |   EE_FORMAT_ALL, | ||||||
|   EE_ALL_SAVE |   EE_ALL_SAVE | ||||||
|  |  | ||||||
| } tEERequest; | } tEERequest; | ||||||
|   | |||||||
| @@ -308,15 +308,21 @@ void WebserverPOST_Callback(AsyncWebServerRequest *request) | |||||||
|       PersistenceData.tankRemain_µl = LubeConfig.tankCapacity_ml * 1000; |       PersistenceData.tankRemain_µl = LubeConfig.tankCapacity_ml * 1000; | ||||||
|       globals.requestEEAction = EE_PDS_SAVE; |       globals.requestEEAction = EE_PDS_SAVE; | ||||||
|     } |     } | ||||||
|     if (p->name() == "reset_ee_cfg") |     if (p->name() == "reset_ee_btn") | ||||||
|     { |     { | ||||||
|       globals.requestEEAction = EE_CFG_FORMAT; |       if (request->hasParam("reset_ee_pds")) | ||||||
|     } |  | ||||||
|     if (p->name() == "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 |     // end: POST Form Maintenance | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user