mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 12:36:52 +03:00
Update info page (#1420)
* consolidate info page * use new REST API * . * . * . * . * . * . * . * Make sure after the reboot we go to the overview page * . * Update server_main.cpp
This commit is contained in:
@@ -615,7 +615,7 @@ esp_err_t handler_reboot(httpd_req_t *req)
|
||||
|
||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "handler_reboot");
|
||||
ESP_LOGI(TAG, "!!! System will restart within 5 sec!!!");
|
||||
const char* resp_str = "<body style='font-family: arial'> <h3 id=t></h3></body><script>var h='Rebooting!<br>The page will automatically reload in around 25..60s - in case of firmware update up to 180s.<br>'; document.getElementById('t').innerHTML=h; setInterval(function (){h +='.'; document.getElementById('t').innerHTML=h; fetch(window.location.hostname,{mode: 'no-cors'}).then(r=>{parent.location.href=('/index.html');})}, 1000);</script>";
|
||||
const char* resp_str = "<body style='font-family: arial'> <h3 id=t></h3></body><script>var h='Rebooting!<br>The page will automatically reload in around 25..60s<br>(in case of a firmware update it can take up to 180s).<br>'; document.getElementById('t').innerHTML=h; setInterval(function (){h +='.'; document.getElementById('t').innerHTML=h; fetch(window.location.hostname,{mode: 'no-cors'}).then(r=>{parent.location.href=('/index.html');})}, 1000);</script>";
|
||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||
|
||||
doReboot();
|
||||
|
||||
@@ -39,7 +39,12 @@ 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_TAG}, ${GIT_REV}${GIT_DIFF}")
|
||||
|
||||
if ("${GIT_TAG}" STREQUAL "") # Tag not set, show branch
|
||||
set(VERSION_HTML "Development-Branch: ${GIT_BRANCH} (Commit: ${GIT_REV}${GIT_DIFF})")
|
||||
else() # Tag is set, ignore branch
|
||||
set(VERSION_HTML "Release: ${GIT_TAG} (Commit: ${GIT_REV}${GIT_DIFF})")
|
||||
endif()
|
||||
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp)
|
||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp VERSION_)
|
||||
|
||||
@@ -58,50 +58,45 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
if (_task.compare("GitTag") == 0)
|
||||
else if (_task.compare("GitTag") == 0)
|
||||
{
|
||||
httpd_resp_sendstr_chunk(req, libfive_git_version());
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (_task.compare("GitRevision") == 0)
|
||||
else if (_task.compare("GitRevision") == 0)
|
||||
{
|
||||
httpd_resp_sendstr_chunk(req, libfive_git_revision());
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("BuildTime") == 0)
|
||||
else if (_task.compare("BuildTime") == 0)
|
||||
{
|
||||
httpd_resp_sendstr_chunk(req, build_time());
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("GitBaseBranch") == 0)
|
||||
else if (_task.compare("FirmwareVersion") == 0)
|
||||
{
|
||||
string buf = "Branch: '" + std::string(GIT_BRANCH) + "', Tag: '" + std::string(GIT_TAG) + \
|
||||
"', Revision: " + std::string(GIT_REV);
|
||||
string buf;
|
||||
if (std::string(GIT_TAG) == "") { // Tag not set, show branch
|
||||
buf = "Development-Branch: " + std::string(GIT_BRANCH);
|
||||
}
|
||||
else { // Tag is set, ignore branch
|
||||
buf = "Release: " + std::string(GIT_TAG);
|
||||
}
|
||||
buf = buf + " (Commit: " + std::string(GIT_REV) + ")";
|
||||
httpd_resp_sendstr_chunk(req, buf.c_str());
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("HTMLVersion") == 0)
|
||||
else if (_task.compare("HTMLVersion") == 0)
|
||||
{
|
||||
// std::string zw;
|
||||
// zw = std::string(getHTMLversion());
|
||||
httpd_resp_sendstr_chunk(req, getHTMLversion());
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("Hostname") == 0)
|
||||
else if (_task.compare("Hostname") == 0)
|
||||
{
|
||||
std::string zw;
|
||||
zw = std::string(hostname);
|
||||
@@ -109,8 +104,7 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("IP") == 0)
|
||||
else if (_task.compare("IP") == 0)
|
||||
{
|
||||
std::string *zw;
|
||||
zw = getIPAddress();
|
||||
@@ -118,8 +112,7 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("SSID") == 0)
|
||||
else if (_task.compare("SSID") == 0)
|
||||
{
|
||||
std::string *zw;
|
||||
zw = getSSID();
|
||||
@@ -127,8 +120,7 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("FlowStatus") == 0)
|
||||
else if (_task.compare("FlowStatus") == 0)
|
||||
{
|
||||
std::string zw;
|
||||
zw = std::string("FlowStatus");
|
||||
@@ -136,8 +128,7 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("SDCardPartitionSize") == 0)
|
||||
else if (_task.compare("SDCardPartitionSize") == 0)
|
||||
{
|
||||
std::string zw;
|
||||
zw = getSDCardPartitionSize();
|
||||
@@ -145,8 +136,7 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("SDCardFreePartitionSpace") == 0)
|
||||
else if (_task.compare("SDCardFreePartitionSpace") == 0)
|
||||
{
|
||||
std::string zw;
|
||||
zw = getSDCardFreePartitionSpace();
|
||||
@@ -154,8 +144,7 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("SDCardPartitionAllocationSize") == 0)
|
||||
else if (_task.compare("SDCardPartitionAllocationSize") == 0)
|
||||
{
|
||||
std::string zw;
|
||||
zw = getSDCardPartitionAllocationSize();
|
||||
@@ -163,8 +152,7 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("SDCardManufacturer") == 0)
|
||||
else if (_task.compare("SDCardManufacturer") == 0)
|
||||
{
|
||||
std::string zw;
|
||||
zw = getSDCardManufacturer();
|
||||
@@ -172,8 +160,7 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("SDCardName") == 0)
|
||||
else if (_task.compare("SDCardName") == 0)
|
||||
{
|
||||
std::string zw;
|
||||
zw = getSDCardName();
|
||||
@@ -181,8 +168,7 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("SDCardCapacity") == 0)
|
||||
else if (_task.compare("SDCardCapacity") == 0)
|
||||
{
|
||||
std::string zw;
|
||||
zw = getSDCardCapacity();
|
||||
@@ -190,8 +176,7 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("SDCardSectorSize") == 0)
|
||||
else if (_task.compare("SDCardSectorSize") == 0)
|
||||
{
|
||||
std::string zw;
|
||||
zw = getSDCardSectorSize();
|
||||
@@ -200,8 +185,6 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -394,7 +377,7 @@ esp_err_t sysinfo_handler(httpd_req_t *req)
|
||||
void register_server_main_uri(httpd_handle_t server, const char *base_path)
|
||||
{
|
||||
httpd_uri_t info_get_handle = {
|
||||
.uri = "/version", // Match all URIs of type /path/to/file
|
||||
.uri = "/info", // Match all URIs of type /path/to/file
|
||||
.method = HTTP_GET,
|
||||
.handler = info_get_handler,
|
||||
.user_ctx = (void*) base_path // Pass server data as context
|
||||
|
||||
@@ -38,7 +38,7 @@ const char* libfive_git_branch(void)
|
||||
}
|
||||
|
||||
|
||||
char _char_getHTMLversion[50]="NaN\0";
|
||||
char _char_getHTMLversion[100]="?\0";
|
||||
|
||||
const char* getHTMLversion(void){
|
||||
FILE* pFile;
|
||||
|
||||
@@ -58,7 +58,7 @@ function doBackup() {
|
||||
// Get hostname
|
||||
try {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.open("GET", "/version?type=Hostname", false);
|
||||
xhttp.open("GET", "/info?type=Hostname", false);
|
||||
xhttp.send();
|
||||
hostname = xhttp.responseText;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ function LoadHostname() {
|
||||
|
||||
// var xhttp = new XMLHttpRequest();
|
||||
try {
|
||||
url = _basepath + '/version?type=Hostname';
|
||||
url = _basepath + '/info?type=Hostname';
|
||||
xhttp.open("GET", url, true);
|
||||
xhttp.send();
|
||||
|
||||
@@ -52,7 +52,7 @@ function LoadFwVersion() {
|
||||
});
|
||||
|
||||
try {
|
||||
url = _basepath + '/version?type=GitBaseBranch';
|
||||
url = _basepath + '/info?type=FirmwareVersion';
|
||||
xhttp.open("GET", url, true);
|
||||
xhttp.send();
|
||||
}
|
||||
@@ -78,7 +78,7 @@ function LoadWebUiVersion() {
|
||||
});
|
||||
|
||||
try {
|
||||
url = _basepath + '/version?type=HTMLVersion';
|
||||
url = _basepath + '/info?type=HTMLVersion';
|
||||
xhttp.open("GET", url, true);
|
||||
xhttp.send();
|
||||
}
|
||||
|
||||
@@ -25,20 +25,55 @@ div {
|
||||
</head>
|
||||
|
||||
<body style="font-family: arial; padding: 0px 10px;">
|
||||
<h3>Current</h3>
|
||||
<h3>Runtime Information</h3>
|
||||
<table style="font-family: arial">
|
||||
<tr>
|
||||
<td>
|
||||
Last restart:
|
||||
</td>
|
||||
<td>
|
||||
<div id="gitbranch">
|
||||
<div id="starttime">
|
||||
<object data="/starttime"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Build Info</h3>
|
||||
<table style="font-family: arial">
|
||||
<tr>
|
||||
<td>
|
||||
Firmware Version:
|
||||
</td>
|
||||
<td>
|
||||
<div id="firmware" style="width: 700px">
|
||||
<object data="/info?type=FirmwareVersion" style="width: 700px"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Firmware Build Time:
|
||||
</td>
|
||||
<td>
|
||||
<div id="build-time">
|
||||
<object data="/info?type=BuildTime"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
Web Interface Version:
|
||||
</td>
|
||||
<td>
|
||||
<div id="web-ui" style="width: 700px">
|
||||
<object data="/info?type=HTMLVersion" style="width: 700px"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h3>Host Info</h3>
|
||||
<table style="font-family: arial">
|
||||
@@ -47,8 +82,8 @@ div {
|
||||
Hostname:
|
||||
</td>
|
||||
<td>
|
||||
<div id="gitbranch">
|
||||
<object data="/version?type=Hostname"></object>
|
||||
<div id="Hostname">
|
||||
<object data="/info?type=Hostname"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -57,8 +92,8 @@ div {
|
||||
IP-Address:
|
||||
</td>
|
||||
<td>
|
||||
<div id="gitbranch">
|
||||
<object data="/version?type=IP"></object>
|
||||
<div id="IP">
|
||||
<object data="/info?type=IP"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -67,71 +102,13 @@ div {
|
||||
WLan-SSID:
|
||||
</td>
|
||||
<td>
|
||||
<div id="gitbranch">
|
||||
<object data="/version?type=SSID"></object>
|
||||
<div id="SSID">
|
||||
<object data="/info?type=SSID"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Version Info</h3>
|
||||
<table style="font-family: arial">
|
||||
<tr>
|
||||
<td>
|
||||
Git-Branch:
|
||||
</td>
|
||||
<td>
|
||||
<div id="gitbranch">
|
||||
<object data="/version?type=GitBranch"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
Git-Tag:
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<object data="/version?type=GitTag"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
Git-Revision:
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<object data="/version?type=GitRevision"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
Build Time:
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<object data="/version?type=BuildTime"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
HTML Version:
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<object data="/version?type=HTMLVersion"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>SD Card Info</h3>
|
||||
<table style="font-family: arial">
|
||||
<tr>
|
||||
@@ -140,7 +117,7 @@ div {
|
||||
</td>
|
||||
<td>
|
||||
<div id="SDCardManufacturer">
|
||||
<object data="/version?type=SDCardManufacturer"></object>
|
||||
<object data="/info?type=SDCardManufacturer"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -150,7 +127,7 @@ div {
|
||||
</td>
|
||||
<td>
|
||||
<div id="SDCardName">
|
||||
<object data="/version?type=SDCardName"></object>
|
||||
<object data="/info?type=SDCardName"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -160,7 +137,7 @@ div {
|
||||
</td>
|
||||
<td>
|
||||
<div id="SDCardCapacity">
|
||||
<object data="/version?type=SDCardCapacity"></object>
|
||||
<object data="/info?type=SDCardCapacity"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -170,7 +147,7 @@ div {
|
||||
</td>
|
||||
<td>
|
||||
<div id="SDCardSectorSize">
|
||||
<object data="/version?type=SDCardSectorSize"></object>
|
||||
<object data="/info?type=SDCardSectorSize"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -180,7 +157,7 @@ div {
|
||||
</td>
|
||||
<td>
|
||||
<div id="SDPartitionSize">
|
||||
<object data="/version?type=SDCardPartitionSize"></object>
|
||||
<object data="/info?type=SDCardPartitionSize"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -190,7 +167,7 @@ div {
|
||||
</td>
|
||||
<td>
|
||||
<div id="SDFreePartitionSpace">
|
||||
<object data="/version?type=SDCardFreePartitionSpace"></object>
|
||||
<object data="/info?type=SDCardFreePartitionSpace"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -200,7 +177,7 @@ div {
|
||||
</td>
|
||||
<td>
|
||||
<div id="SDCardPartitionAllocationSize">
|
||||
<object data="/version?type=SDCardPartitionAllocationSize"></object>
|
||||
<object data="/info?type=SDCardPartitionAllocationSize"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -89,7 +89,7 @@ function init(){
|
||||
|
||||
|
||||
function doRebootAfterUpdate() {
|
||||
if (confirm("Update completed!\nThe ESP32 will reboot now!")) {
|
||||
if (confirm("Upload completed!\nThe device will reboot now and complete the update.\nThis will take up to 180s!")) {
|
||||
var stringota = "/reboot";
|
||||
window.location = stringota;
|
||||
window.location.href = stringota;
|
||||
@@ -132,7 +132,7 @@ function prepareOnServer() {
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById("status").innerText = "Status: Preparations on ESP32";
|
||||
document.getElementById("status").innerText = "Status: Preparations on device";
|
||||
document.getElementById("doUpdate").disabled = true;
|
||||
|
||||
var xhttp = new XMLHttpRequest();
|
||||
@@ -199,7 +199,7 @@ function upload() {
|
||||
|
||||
|
||||
function extract() {
|
||||
document.getElementById("status").innerText = "Status: Processing on ESP32 (takes up to 3 minutes)...";
|
||||
document.getElementById("status").innerText = "Status: Processing on device (takes up to 3 minutes)...";
|
||||
|
||||
var xhttp = new XMLHttpRequest();
|
||||
/* first delete the old firmware */
|
||||
@@ -210,6 +210,7 @@ function extract() {
|
||||
document.getElementById("status").innerText = "Status: Update completed!";
|
||||
document.getElementById("doUpdate").disabled = true;
|
||||
document.getElementById("newfile").disabled = false;
|
||||
document.cookie = "overview.html"; // Make sure after the reboot we go to the overview page
|
||||
|
||||
if (xhttp.responseText.startsWith("reboot"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user