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 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/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"); diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 4f2f0ce4..6d57fe06 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -82,7 +82,9 @@ esp_err_t info_get_handler(httpd_req_t *req) if (_task.compare("GitBaseBranch") == 0) { - httpd_resp_sendstr_chunk(req, git_base_branch()); + 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; } @@ -285,7 +287,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 +303,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 5b1ee98f..0456cd9e 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,14 +16,6 @@ extern "C" #include "Helper.h" #include -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) { @@ -43,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; @@ -53,8 +48,10 @@ 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; -} \ No newline at end of file +} + +#endif // _VERSION_H \ No newline at end of file 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... + + diff --git a/sd-card/html/info.html b/sd-card/html/info.html index 2324a114..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; @@ -93,22 +93,22 @@ div { - Git-Base-Branch: + Git-Tag:
- +
- Git-Version: + Git-Revision:
- +
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