Added DTC for LittleFS-Image Version mismatch

This commit is contained in:
Marcel Peterkau 2022-08-22 14:26:37 +02:00
parent bd4c1d9d53
commit 6ffe239cae
4 changed files with 27 additions and 15 deletions

View File

@ -29,6 +29,8 @@
#define SW_VERSION_MAJOR 1
#define SW_VERSION_MINOR 1
#define FLASH_FS_VERSION 1.1
#ifndef OTA_DELAY
#define OTA_DELAY 50 // ticks -> 10ms / tick
#endif

View File

@ -15,6 +15,7 @@ typedef enum DTCNums_e
DTC_EEPROM_PDSADRESS_BAD,
DTC_EEPROM_VERSION_BAD,
DTC_FLASHFS_ERROR,
DTC_FLASHFS_VERSION_ERROR,
#ifdef FEATURE_ENABLE_GPS
DTC_NO_GPS_SERIAL,
#endif

View File

@ -18,9 +18,12 @@ typedef enum eEERequest
EE_IDLE,
EE_CFG_SAVE,
EE_CFG_LOAD,
EE_CFG_FORMAT,
EE_PDS_SAVE,
EE_PDS_LOAD,
EE_PDS_FORMAT,
EE_ALL_SAVE
} tEERequest;
typedef struct Globals_s
@ -31,7 +34,7 @@ typedef struct Globals_s
uint16_t purgePulses = 0;
eEERequest requestEEAction = EE_IDLE;
char DeviceName[33];
uint32_t FlashVersion;
char FlashVersion[5];
uint16_t eePersistanceAdress;
uint8_t TankPercentage;
bool hasDTC;

View File

@ -20,7 +20,12 @@ void initWebUI()
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.addService("telnet", "tcp", 23);
@ -312,20 +317,21 @@ void WebserverNotFound_Callback(AsyncWebServerRequest *request)
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");
if (!this_file)
{ // failed to open the file, retrn empty result
return 0;
}
if (this_file.available())
{
this_file.readBytesUntil('\r', buffer, sizeof(buffer));
}
this_file.close();
return atoi(buffer);
File this_file = LittleFS.open("version", "r");
if (!this_file)
{ // failed to open the file, retrn empty result
buff[0] = '\0';
return;
}
if (this_file.available())
{
int bytes_read;
bytes_read = this_file.readBytesUntil('\r', buff, buff_size-1);
buff[bytes_read] = '\0';
}
this_file.close();
}
void WebserverFirmwareUpdate_Callback(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final)