mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-09 21:17:06 +03:00
Use only commit hash for comparison instead whole string (#1436)
* Use only commit hash for comparison instead whole string * .
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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!");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user