Added DTC for LittleFS-Image Version mismatch
This commit is contained in:
		| @@ -29,6 +29,8 @@ | |||||||
| #define SW_VERSION_MAJOR 1 | #define SW_VERSION_MAJOR 1 | ||||||
| #define SW_VERSION_MINOR 1 | #define SW_VERSION_MINOR 1 | ||||||
|  |  | ||||||
|  | #define FLASH_FS_VERSION 1.1 | ||||||
|  |  | ||||||
| #ifndef OTA_DELAY | #ifndef OTA_DELAY | ||||||
| #define OTA_DELAY 50 // ticks -> 10ms / tick | #define OTA_DELAY 50 // ticks -> 10ms / tick | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ typedef enum DTCNums_e | |||||||
|   DTC_EEPROM_PDSADRESS_BAD, |   DTC_EEPROM_PDSADRESS_BAD, | ||||||
|   DTC_EEPROM_VERSION_BAD, |   DTC_EEPROM_VERSION_BAD, | ||||||
|   DTC_FLASHFS_ERROR, |   DTC_FLASHFS_ERROR, | ||||||
|  |   DTC_FLASHFS_VERSION_ERROR, | ||||||
| #ifdef FEATURE_ENABLE_GPS | #ifdef FEATURE_ENABLE_GPS | ||||||
|   DTC_NO_GPS_SERIAL, |   DTC_NO_GPS_SERIAL, | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -18,9 +18,12 @@ typedef enum eEERequest | |||||||
|   EE_IDLE, |   EE_IDLE, | ||||||
|   EE_CFG_SAVE, |   EE_CFG_SAVE, | ||||||
|   EE_CFG_LOAD, |   EE_CFG_LOAD, | ||||||
|  |   EE_CFG_FORMAT, | ||||||
|   EE_PDS_SAVE, |   EE_PDS_SAVE, | ||||||
|   EE_PDS_LOAD, |   EE_PDS_LOAD, | ||||||
|  |   EE_PDS_FORMAT, | ||||||
|   EE_ALL_SAVE |   EE_ALL_SAVE | ||||||
|  |  | ||||||
| } tEERequest; | } tEERequest; | ||||||
|  |  | ||||||
| typedef struct Globals_s | typedef struct Globals_s | ||||||
| @@ -31,7 +34,7 @@ typedef struct Globals_s | |||||||
|   uint16_t purgePulses = 0; |   uint16_t purgePulses = 0; | ||||||
|   eEERequest requestEEAction = EE_IDLE; |   eEERequest requestEEAction = EE_IDLE; | ||||||
|   char DeviceName[33]; |   char DeviceName[33]; | ||||||
|   uint32_t FlashVersion; |   char FlashVersion[5]; | ||||||
|   uint16_t eePersistanceAdress; |   uint16_t eePersistanceAdress; | ||||||
|   uint8_t TankPercentage; |   uint8_t TankPercentage; | ||||||
|   bool hasDTC; |   bool hasDTC; | ||||||
|   | |||||||
| @@ -20,7 +20,12 @@ void initWebUI() | |||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   globals.FlashVersion = GetFlashVersion(); |   GetFlashVersion(globals.FlashVersion, sizeof(globals.FlashVersion)); | ||||||
|  |  | ||||||
|  |   if (!strcmp(globals.FlashVersion, QUOTE(FLASH_FS_VERSION)) | ||||||
|  |   { | ||||||
|  |     MaintainDTC(DTC_FLASHFS_VERSION_ERROR, DTC_WARN, true); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   MDNS.begin(globals.DeviceName); |   MDNS.begin(globals.DeviceName); | ||||||
|   MDNS.addService("telnet", "tcp", 23); |   MDNS.addService("telnet", "tcp", 23); | ||||||
| @@ -312,20 +317,21 @@ void WebserverNotFound_Callback(AsyncWebServerRequest *request) | |||||||
|   request->send(404, "text/html", "Not found"); |   request->send(404, "text/html", "Not found"); | ||||||
| } | } | ||||||
|  |  | ||||||
| uint32_t GetFlashVersion() | void GetFlashVersion(char *buff, size_t buff_size) | ||||||
| { | { | ||||||
|     char buffer[20]; |  | ||||||
|   File this_file = LittleFS.open("version", "r"); |   File this_file = LittleFS.open("version", "r"); | ||||||
|   if (!this_file) |   if (!this_file) | ||||||
|   { // failed to open the file, retrn empty result |   { // failed to open the file, retrn empty result | ||||||
|       return 0; |     buff[0] = '\0'; | ||||||
|  |     return; | ||||||
|   } |   } | ||||||
|   if (this_file.available()) |   if (this_file.available()) | ||||||
|   { |   { | ||||||
|       this_file.readBytesUntil('\r', buffer, sizeof(buffer)); |     int bytes_read; | ||||||
|  |     bytes_read = this_file.readBytesUntil('\r', buff, buff_size-1); | ||||||
|  |     buff[bytes_read] = '\0'; | ||||||
|   } |   } | ||||||
|   this_file.close(); |   this_file.close(); | ||||||
|   return atoi(buffer); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void WebserverFirmwareUpdate_Callback(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final) | void WebserverFirmwareUpdate_Callback(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user