From f87d2aaeca18bd217083210a08a663cbc886ff99 Mon Sep 17 00:00:00 2001 From: Marcel Peterkau Date: Thu, 2 Mar 2023 23:35:41 +0100 Subject: [PATCH] more Versioninfo for easier identification --- Software/data_src/index.htm | 4 ++++ Software/src/common.h | 3 --- Software/src/debugger.cpp | 4 ++-- Software/src/globals.h | 15 +++++++++++++++ Software/src/webui.cpp | 17 ++++++++++++++--- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/Software/data_src/index.htm b/Software/data_src/index.htm index 9c289ff..43db8d8 100644 --- a/Software/data_src/index.htm +++ b/Software/data_src/index.htm @@ -645,6 +645,10 @@ Flash Version %FS_VERSION% + + Git Revision + %GIT_REV% +

diff --git a/Software/src/common.h b/Software/src/common.h index 727f087..f59a5a9 100644 --- a/Software/src/common.h +++ b/Software/src/common.h @@ -32,9 +32,6 @@ #define HOST_NAME "ChainLube_%06X" // Use printf-Formatting - Chip-ID (uin32_t) will be added #endif -#define SW_VERSION 1.4 -#define FLASH_FS_VERSION 1.4 - #ifndef OTA_DELAY #define OTA_DELAY 50 // ticks -> 10ms / tick #endif diff --git a/Software/src/debugger.cpp b/Software/src/debugger.cpp index 859d700..75985a8 100644 --- a/Software/src/debugger.cpp +++ b/Software/src/debugger.cpp @@ -140,8 +140,8 @@ void RemotDebug_printSystemInfo() : ideMode == FM_DOUT ? "DOUT" : "UNKNOWN")); Debug_pushMessage("OTA-Pass: %s", QUOTE(ADMIN_PASSWORD)); - Debug_pushMessage("Git-Revison: %s", GIT_REV); - Debug_pushMessage("Sw-Version: %s", QUOTE(SW_VERSION)); + Debug_pushMessage("Git-Revison: %s", constants.GitHash); + Debug_pushMessage("Sw-Version: %d.%02d", constants.FW_Version_major, constants.FW_Version_minor); } void Debug_dumpConfig() diff --git a/Software/src/globals.h b/Software/src/globals.h index 6933c59..347ac7d 100644 --- a/Software/src/globals.h +++ b/Software/src/globals.h @@ -43,6 +43,21 @@ typedef struct Globals_s extern Globals_t globals; +typedef struct Constants_s +{ + uint8_t FW_Version_major; + uint8_t FW_Version_minor; + uint8_t Flash_Version_major; + uint8_t Flash_Version_minor; + char GitHash[11]; +} Constants_t; + +const Constants_t constants PROGMEM = { + 1,4, // Firmware_Version + 1,4, // Flash Version + GIT_REV // Git-Hash-String +}; + void initGlobals(); #endif \ No newline at end of file diff --git a/Software/src/webui.cpp b/Software/src/webui.cpp index ab5426f..643dc55 100644 --- a/Software/src/webui.cpp +++ b/Software/src/webui.cpp @@ -33,7 +33,9 @@ void initWebUI() GetFlashVersion(globals.FlashVersion, sizeof(globals.FlashVersion)); - if (strcmp(globals.FlashVersion, QUOTE(FLASH_FS_VERSION))) + char buffer[6]; + snprintf(buffer, sizeof(buffer), "%d.%d", constants.FW_Version_major, constants.FW_Version_minor); + if (strcmp(globals.FlashVersion, buffer)) { MaintainDTC(DTC_FLASHFS_VERSION_ERROR, DTC_WARN, true); } @@ -244,13 +246,20 @@ String processor(const String &var) if (var == "SYSTEM_STATUS") return String(globals.systemStatustxt); + if (var == "SW_VERSION") { - return String(QUOTE(SW_VERSION)); + char buffer[6]; + snprintf(buffer,sizeof(buffer), "%d.%02d", constants.FW_Version_major, constants.FW_Version_minor); + return String(buffer); } + if (var == "FS_VERSION") return String(globals.FlashVersion); + if (var == "GIT_REV") + return String(constants.GitHash); + if (var == "PLACEHOLDER") return "placeholder"; @@ -499,8 +508,10 @@ void WebServerEEJSON_Callback(AsyncWebServerRequest *request) char buffer[16]; fwinfo["DeviceName"] = globals.DeviceName; - fwinfo["FW-Version"] = QUOTE(SW_VERSION); + sprintf(buffer, "%d.%02d", constants.Flash_Version_major, constants.Flash_Version_minor); + fwinfo["FW-Version"] = buffer; fwinfo["FS-Version"] = globals.FlashVersion; + fwinfo["Git-Hash"] = constants.GitHash; JsonObject config = json.createNestedObject("config");