From 906915e058a8988405b6a17e79807aceb3392bac Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Sun, 18 Sep 2022 22:14:21 +0200 Subject: [PATCH 1/6] add include guard --- code/main/version.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/main/version.h b/code/main/version.h index 5b1ee98f..3e534ba6 100644 --- a/code/main/version.h +++ b/code/main/version.h @@ -1,3 +1,6 @@ +#ifndef _VERSION_H +#define _VERSION_H + // These variables are autogenerated and compiled // into the library by the version.cmake script extern "C" @@ -13,6 +16,7 @@ extern "C" #include "Helper.h" #include +// todo remove const char* GIT_BASE_BRANCH = "master - v11.3.0 - 2022-09-16"; @@ -57,4 +61,6 @@ const char* getHTMLversion(void){ fclose(pFile); return _char_getHTMLversion; -} \ No newline at end of file +} + +#endif // _VERSION_H \ No newline at end of file From 46dfc757244cb4a1cbad0adc031e383ae6185b06 Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Sun, 18 Sep 2022 22:16:49 +0200 Subject: [PATCH 2/6] show version on startup in loag and on console --- code/main/main.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/code/main/main.cpp b/code/main/main.cpp index 05f0a889..3a9488d2 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -29,6 +29,11 @@ #include "server_camera.h" #include "Helper.h" +extern const char* GIT_TAG; +extern const char* GIT_REV; +extern const char* GIT_BRANCH; +extern const char* BUILD_TIME; + // #include "jomjol_WS2812Slow.h" #include "SmartLeds.h" @@ -133,6 +138,12 @@ void task_NoSDBlink(void *pvParameter) extern "C" void app_main(void) { TickType_t xDelay; + string versionFormated = "Branch: '" + std::string(GIT_BRANCH) + "', Tag: '" + std::string(GIT_TAG) + \ + "', Revision: " + std::string(GIT_REV) +", Date/Time: " + std::string(BUILD_TIME); + + printf("=============================================================================================\n"); + printf("%s\n", versionFormated.c_str()); + printf("=============================================================================================\n"); PowerResetCamera(); esp_err_t cam = Camera.InitCam(); @@ -179,7 +190,8 @@ extern "C" void app_main(void) setBootTime(); LogFile.WriteToFile("============================================================================================="); LogFile.WriteToFile("=================================== Main Started ============================================"); - LogFile.WriteToFile("============================================================================================="); + LogFile.WriteToFile("============================================================================================="); + LogFile.WriteToFile(versionFormated); LogFile.SwitchOnOff(false); std::string zw = gettimestring("%Y%m%d-%H%M%S"); From 3d1d41e36b72b34c7416321efd0ff1e7f340af9d Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Sun, 18 Sep 2022 22:23:23 +0200 Subject: [PATCH 3/6] remove PROJECT_VER. The compiler then automatically uses git to fetch the information, eg. "v11.3.0-12-g46dfc75-dirty" --- code/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 1ecfa657..c0852a05 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.13.4) list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) -set(PROJECT_VER "0.0.9.3") - ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.cpp ${CMAKE_CURRENT_BINARY_DIR}/_version.cpp From 39ec90895e678e714ab610bfa74a2a91c8b13940 Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Sun, 18 Sep 2022 22:37:16 +0200 Subject: [PATCH 4/6] removed GIT_BASE_BRANCH and instead use the autogenerated values in info.html --- code/main/server_main.cpp | 9 ++++++--- code/main/version.h | 9 --------- sd-card/html/info.html | 8 ++++---- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 4f2f0ce4..7579f902 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -80,9 +80,10 @@ esp_err_t info_get_handler(httpd_req_t *req) return ESP_OK; } + // No longer used if (_task.compare("GitBaseBranch") == 0) { - httpd_resp_sendstr_chunk(req, git_base_branch()); + httpd_resp_sendstr_chunk(req, ""); httpd_resp_sendstr_chunk(req, NULL); return ESP_OK; } @@ -285,7 +286,8 @@ esp_err_t sysinfo_handler(httpd_req_t *req) std::string gitversion = libfive_git_version(); std::string buildtime = build_time(); std::string gitbranch = libfive_git_branch(); - std::string gitbasebranch = git_base_branch(); + std::string gittag = libfive_git_version(); + std::string gitrevision = libfive_git_revision(); std::string htmlversion = getHTMLversion(); char freeheapmem[11]; sprintf(freeheapmem, "%zu", esp_get_free_heap_size()); @@ -300,7 +302,8 @@ esp_err_t sysinfo_handler(httpd_req_t *req) \"firmware\" : \"" + gitversion + "\",\ \"buildtime\" : \"" + buildtime + "\",\ \"gitbranch\" : \"" + gitbranch + "\",\ - \"gitbasebranch\" : \"" + gitbasebranch + "\",\ + \"gittag\" : \"" + gittag + "\",\ + \"gitrevision\" : \"" + gitrevision + "\",\ \"html\" : \"" + htmlversion + "\",\ \"cputemp\" : \"" + cputemp + "\",\ \"hostname\" : \"" + hostname + "\",\ diff --git a/code/main/version.h b/code/main/version.h index 3e534ba6..38a8ae99 100644 --- a/code/main/version.h +++ b/code/main/version.h @@ -16,15 +16,6 @@ extern "C" #include "Helper.h" #include -// todo remove -const char* GIT_BASE_BRANCH = "master - v11.3.0 - 2022-09-16"; - - -const char* git_base_branch(void) -{ - return GIT_BASE_BRANCH; -} - const char* build_time(void) { diff --git a/sd-card/html/info.html b/sd-card/html/info.html index 2324a114..28467a03 100644 --- a/sd-card/html/info.html +++ b/sd-card/html/info.html @@ -93,22 +93,22 @@ div { - Git-Base-Branch: + Git-Tag:
- +
- Git-Version: + Git-Revision:
- +
From 2d68f44a40408e347e8b84d0d834d81f0b8e57b9 Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Sun, 18 Sep 2022 23:25:57 +0200 Subject: [PATCH 5/6] show version in index pages --- code/main/server_main.cpp | 5 +++-- sd-card/html/common.js | 25 +++++++++++++++++++++++++ sd-card/html/index.html | 3 +++ sd-card/html/index_configure.html | 4 ++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 7579f902..6d57fe06 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -80,10 +80,11 @@ esp_err_t info_get_handler(httpd_req_t *req) return ESP_OK; } - // No longer used if (_task.compare("GitBaseBranch") == 0) { - httpd_resp_sendstr_chunk(req, ""); + string buf = "Branch: '" + std::string(GIT_BRANCH) + "', Tag: '" + std::string(GIT_TAG) + \ + "', Revision: " + std::string(GIT_REV); + httpd_resp_sendstr_chunk(req, buf.c_str()); httpd_resp_sendstr_chunk(req, NULL); return ESP_OK; } diff --git a/sd-card/html/common.js b/sd-card/html/common.js index 130bda20..9204ac07 100644 --- a/sd-card/html/common.js +++ b/sd-card/html/common.js @@ -29,3 +29,28 @@ function LoadHostname() { // alert("Loading Hostname failed"); } } + + +function LoadVersion() { + _basepath = getbasepath(); + + var xhttp = new XMLHttpRequest(); + xhttp.addEventListener('load', function(event) { + if (xhttp.status >= 200 && xhttp.status < 300) { + version = xhttp.responseText; + document.getElementById("Version").innerHTML = version; + } + else { + console.warn(request.statusText, request.responseText); + } + }); + + try { + url = _basepath + '/version?type=GitBaseBranch'; + xhttp.open("GET", url, true); + xhttp.send(); + + } + catch (error) + {} +} diff --git a/sd-card/html/index.html b/sd-card/html/index.html index abc824b0..bcc47493 100644 --- a/sd-card/html/index.html +++ b/sd-card/html/index.html @@ -151,8 +151,11 @@ li.dropdown { +Loading version... + diff --git a/sd-card/html/index_configure.html b/sd-card/html/index_configure.html index 9fee5888..1f9406b9 100644 --- a/sd-card/html/index_configure.html +++ b/sd-card/html/index_configure.html @@ -152,11 +152,15 @@ li.dropdown { +Loading version... + + From dd8500052e38b1eacc5049b51ac94324902542df Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Mon, 19 Sep 2022 08:22:44 +0200 Subject: [PATCH 6/6] also set HTML version by cmake --- code/main/CMakeLists.txt | 2 ++ code/main/version.h | 4 ++-- sd-card/html/info.html | 2 +- sd-card/html/version.txt | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/code/main/CMakeLists.txt b/code/main/CMakeLists.txt index 9e34818e..44a27eb2 100644 --- a/code/main/CMakeLists.txt +++ b/code/main/CMakeLists.txt @@ -39,6 +39,7 @@ set(VERSION "const char* GIT_REV=\"${GIT_REV}${GIT_DIFF}\"; const char* GIT_TAG=\"${GIT_TAG}\"; const char* GIT_BRANCH=\"${GIT_BRANCH}\"; const char* BUILD_TIME=\"${BUILD_TIME}\";") +set(VERSION_HTML "${GIT_BRANCH}, ${GIT_REV}${GIT_DIFF}, ${GIT_TAG}") if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp) file(READ ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp VERSION_) @@ -48,6 +49,7 @@ endif() if (NOT "${VERSION}" STREQUAL "${VERSION_}") file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp "${VERSION}") + file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/../sd-card/html/version.txt "${VERSION_HTML}") endif() ####################################################################### ####################################################################### diff --git a/code/main/version.h b/code/main/version.h index 38a8ae99..0456cd9e 100644 --- a/code/main/version.h +++ b/code/main/version.h @@ -38,7 +38,7 @@ const char* libfive_git_branch(void) } -char _char_getHTMLversion[20]="NaN\0"; +char _char_getHTMLversion[50]="NaN\0"; const char* getHTMLversion(void){ FILE* pFile; @@ -48,7 +48,7 @@ const char* getHTMLversion(void){ if (pFile == NULL) return _char_getHTMLversion; - fgets(_char_getHTMLversion, 20, pFile); + fgets(_char_getHTMLversion, sizeof(_char_getHTMLversion), pFile); fclose(pFile); return _char_getHTMLversion; diff --git a/sd-card/html/info.html b/sd-card/html/info.html index 28467a03..2ad7c351 100644 --- a/sd-card/html/info.html +++ b/sd-card/html/info.html @@ -12,7 +12,7 @@ h3 {font-size: 1.2em;} p {font-size: 1em;} div { - width: 250px; + width: 350px; padding: 10px 5px; border: 1px solid #ccc; font-family: arial; diff --git a/sd-card/html/version.txt b/sd-card/html/version.txt index 0baffb7e..b2085e73 100644 --- a/sd-card/html/version.txt +++ b/sd-card/html/version.txt @@ -1 +1,2 @@ -16.4.1 +# HTML version +# Do not edit, it will get be updated by cmake! \ No newline at end of file