diff --git a/code/main/CMakeLists.txt b/code/main/CMakeLists.txt index 5ab3ebd9..4776f371 100644 --- a/code/main/CMakeLists.txt +++ b/code/main/CMakeLists.txt @@ -41,9 +41,9 @@ const char* GIT_BRANCH=\"${GIT_BRANCH}\"; const char* BUILD_TIME=\"${BUILD_TIME}\";") if ("${GIT_TAG}" STREQUAL "") # Tag not set, show branch - set(VERSION_HTML "Development-Branch: ${GIT_BRANCH} (Commit: ${GIT_REV}${GIT_DIFF})") + set(VERSION_HTML "Development-Branch: ${GIT_BRANCH} (Commit: ${GIT_REV}${GIT_DIFF})\n${GIT_REV}") else() # Tag is set, ignore branch - set(VERSION_HTML "Release: ${GIT_TAG} (Commit: ${GIT_REV}${GIT_DIFF})") + set(VERSION_HTML "Release: ${GIT_TAG} (Commit: ${GIT_REV}${GIT_DIFF})\n${GIT_REV}") endif() if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp) diff --git a/code/main/main.cpp b/code/main/main.cpp index 1ca173ae..546bbf79 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -35,7 +35,8 @@ extern const char* GIT_REV; extern const char* GIT_BRANCH; extern const char* BUILD_TIME; -extern const char* getHTMLversion(void); +extern std::string getHTMLversion(void); +extern std::string getHTMLcommit(void); #define __HIDE_PASSWORD @@ -234,8 +235,8 @@ extern "C" void app_main(void) LogFile.WriteToFile(ESP_LOG_INFO, TAG, versionFormated); LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Reset reason: " + getResetReason()); - if (std::string(getHTMLversion()) != std::string(GIT_REV)) { - LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Web UI version does not match firmware version!"); + if (getHTMLcommit() != std::string(GIT_REV)) { + LogFile.WriteToFile(ESP_LOG_WARN, TAG, std::string("Web UI version (") + getHTMLcommit() + ") does not match firmware version (" + std::string(GIT_REV) + ") !"); } std::string zw = gettimestring("%Y%m%d-%H%M%S"); diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 7bbfa5e7..8532b963 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -92,7 +92,7 @@ esp_err_t info_get_handler(httpd_req_t *req) } else if (_task.compare("HTMLVersion") == 0) { - httpd_resp_sendstr_chunk(req, getHTMLversion()); + httpd_resp_sendstr_chunk(req, getHTMLversion().c_str()); httpd_resp_sendstr_chunk(req, NULL); return ESP_OK; } diff --git a/code/main/version.h b/code/main/version.h index a3acd61f..2ea44ac4 100644 --- a/code/main/version.h +++ b/code/main/version.h @@ -38,20 +38,35 @@ const char* libfive_git_branch(void) } -char _char_getHTMLversion[100]="?\0"; - -const char* getHTMLversion(void){ +std::string getHTMLversion(void){ + char buf[100]="?\0"; FILE* pFile; string fn = FormatFileName("/sdcard/html/version.txt"); pFile = fopen(fn.c_str(), "r"); if (pFile == NULL) - return _char_getHTMLversion; + return std::string(buf); - fgets(_char_getHTMLversion, sizeof(_char_getHTMLversion), pFile); + fgets(buf, sizeof(buf), pFile); // Line 1: Version fclose(pFile); - return _char_getHTMLversion; + return std::string(buf); +} + +std::string getHTMLcommit(void){ + char buf[100]="?\0"; + FILE* pFile; + string fn = FormatFileName("/sdcard/html/version.txt"); + pFile = fopen(fn.c_str(), "r"); + + if (pFile == NULL) + return std::string(buf); + + fgets(buf, sizeof(buf), pFile); // Line 1: Version -> ignored + fgets(buf, sizeof(buf), pFile); // Line 2: Commit + fclose(pFile); + + return std::string(buf); } #endif // _VERSION_H \ No newline at end of file diff --git a/sd-card/html/common.js b/sd-card/html/common.js index a6cea459..70b1fb98 100644 --- a/sd-card/html/common.js +++ b/sd-card/html/common.js @@ -100,6 +100,6 @@ function compareVersions() { console.log("FW Hash: " + fWGitHash + ", Web UI Hash: " + webUiHash); if (fWGitHash != webUiHash) { - alert("The Version of the Web Interface does not match the Firmware Version! It is suggested to keep them on the same version!"); + alert("The Version of the Web Interface (" + webUiHash + ") does not match the Firmware Version (" + fWGitHash + ")! It is suggested to keep them on the same version!"); } }