mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-14 15:36:56 +03:00
Merge pull request #33 from phlupp/rolling
Add HTML Version / modify Sysinfo / move Sysinfo to server_main
This commit is contained in:
BIN
code/.DS_Store
vendored
Normal file
BIN
code/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#include "esp_wifi.h"
|
||||
|
||||
|
||||
httpd_handle_t server = NULL;
|
||||
|
||||
@@ -83,6 +85,14 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (_task.compare("HTMLVersion") == 0)
|
||||
{
|
||||
std::string zw;
|
||||
zw = std::string(getHTMLversion());
|
||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -155,8 +165,6 @@ esp_err_t hello_main_handler(httpd_req_t *req)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
esp_err_t img_tmp_handler(httpd_req_t *req)
|
||||
{
|
||||
char filepath[50];
|
||||
@@ -197,7 +205,45 @@ esp_err_t img_tmp_handler(httpd_req_t *req)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t sysinfo_handler(httpd_req_t *req)
|
||||
{
|
||||
const char* resp_str;
|
||||
std::string zw;
|
||||
std::string cputemp = std::to_string(temperatureRead());
|
||||
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 htmlversion = getHTMLversion();
|
||||
|
||||
tcpip_adapter_ip_info_t ip_info;
|
||||
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
|
||||
const char *hostname;
|
||||
ESP_ERROR_CHECK(tcpip_adapter_get_hostname(TCPIP_ADAPTER_IF_STA, &hostname));
|
||||
|
||||
zw = "[\
|
||||
{\
|
||||
\"firmware\" : \"" + gitversion + "\",\
|
||||
\"buildtime\" : \"" + buildtime + "\",\
|
||||
\"gitbranch\" : \"" + gitbranch + "\",\
|
||||
\"gitbasebranch\" : \"" + gitbasebranch + "\",\
|
||||
\"html\" : \"" + htmlversion + "\",\
|
||||
\"cputemp\" : \"" + cputemp + "\",\
|
||||
\"hostname\" : \"" + hostname + "\",\
|
||||
\"IPv4\" : \"" + ip4addr_ntoa(&ip_info.ip) + "\"\
|
||||
}\
|
||||
]";
|
||||
|
||||
|
||||
resp_str = zw.c_str();
|
||||
|
||||
httpd_resp_set_type(req, "application/json");
|
||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||
/* Respond with an empty chunk to signal HTTP response completion */
|
||||
httpd_resp_send_chunk(req, NULL, 0);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void register_server_main_uri(httpd_handle_t server, const char *base_path)
|
||||
{
|
||||
@@ -209,6 +255,13 @@ void register_server_main_uri(httpd_handle_t server, const char *base_path)
|
||||
};
|
||||
httpd_register_uri_handler(server, &info_get_handle);
|
||||
|
||||
httpd_uri_t sysinfo_handle = {
|
||||
.uri = "/sysinfo", // Match all URIs of type /path/to/file
|
||||
.method = HTTP_GET,
|
||||
.handler = sysinfo_handler,
|
||||
.user_ctx = (void*) base_path // Pass server data as context
|
||||
};
|
||||
httpd_register_uri_handler(server, &sysinfo_handle);
|
||||
|
||||
httpd_uri_t starttime_tmp_handle = {
|
||||
.uri = "/starttime", // Match all URIs of type /path/to/file
|
||||
@@ -235,6 +288,7 @@ void register_server_main_uri(httpd_handle_t server, const char *base_path)
|
||||
.user_ctx = (void*) base_path // Pass server data as context
|
||||
};
|
||||
httpd_register_uri_handler(server, &main_rest_handle);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -410,36 +410,6 @@ esp_err_t handler_prevalue(httpd_req_t *req)
|
||||
return ESP_OK;
|
||||
};
|
||||
|
||||
|
||||
esp_err_t handler_sysinfo(httpd_req_t *req)
|
||||
{
|
||||
LogFile.WriteToFile("handler_sysinfo");
|
||||
const char* resp_str;
|
||||
string zw;
|
||||
string cputemp = std::to_string(temperatureRead());
|
||||
|
||||
zw = "[\
|
||||
{\
|
||||
\"firmware\" : \"2.0.0\",\
|
||||
\"html\" : \"1.0.1\",\
|
||||
\"cputemp\" : \"" + cputemp + "\",\
|
||||
\"hostname\" : \"host\",\
|
||||
\"IPv4\" : \"IP\"\
|
||||
}\
|
||||
]";
|
||||
|
||||
|
||||
resp_str = zw.c_str();
|
||||
|
||||
httpd_resp_set_type(req, "application/json");
|
||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||
/* Respond with an empty chunk to signal HTTP response completion */
|
||||
httpd_resp_send_chunk(req, NULL, 0);
|
||||
|
||||
return ESP_OK;
|
||||
};
|
||||
|
||||
|
||||
void task_autodoFlow(void *pvParameter)
|
||||
{
|
||||
int64_t fr_start, fr_delta_ms;
|
||||
@@ -518,9 +488,5 @@ void register_server_tflite_uri(httpd_handle_t server)
|
||||
camuri.handler = handler_wasserzaehler;
|
||||
camuri.user_ctx = (void*) "Wasserzaehler";
|
||||
httpd_register_uri_handler(server, &camuri);
|
||||
|
||||
camuri.uri = "/sysinfo";
|
||||
camuri.handler = handler_sysinfo;
|
||||
camuri.user_ctx = (void*) "Sysinfo";
|
||||
httpd_register_uri_handler(server, &camuri);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const char* GIT_REV="bafd67b";
|
||||
const char* GIT_REV="5d2e22c+";
|
||||
const char* GIT_TAG="";
|
||||
const char* GIT_BRANCH="master";
|
||||
const char* BUILD_TIME="2020-09-28 19:57";
|
||||
const char* GIT_BRANCH="rolling";
|
||||
const char* BUILD_TIME="2020-09-29 02:43";
|
||||
@@ -8,6 +8,11 @@ extern "C"
|
||||
extern const char* BUILD_TIME;
|
||||
}
|
||||
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include "Helper.h"
|
||||
#include <fstream>
|
||||
|
||||
const char* GIT_BASE_BRANCH = "master - v2.1.1 - 2020-09-28";
|
||||
|
||||
|
||||
@@ -35,4 +40,23 @@ const char* libfive_git_revision(void)
|
||||
const char* libfive_git_branch(void)
|
||||
{
|
||||
return GIT_BRANCH;
|
||||
}
|
||||
|
||||
std::string getHTMLversion(void){
|
||||
|
||||
string line = "";
|
||||
|
||||
FILE* pFile;
|
||||
string fn = FormatFileName("/sdcard/html/version.txt");
|
||||
pFile = fopen(fn.c_str(), "r");
|
||||
|
||||
if (pFile == NULL)
|
||||
return std::string("NAN");
|
||||
|
||||
char zw[1024];
|
||||
fgets(zw, 1024, pFile);
|
||||
line = std::string(trim(zw));
|
||||
fclose(pFile);
|
||||
|
||||
return line;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
const char* GIT_REV="bafd67b";
|
||||
const char* GIT_REV="5d2e22c+";
|
||||
const char* GIT_TAG="";
|
||||
const char* GIT_BRANCH="master";
|
||||
const char* BUILD_TIME="2020-09-28 19:57";
|
||||
const char* GIT_BRANCH="rolling";
|
||||
const char* BUILD_TIME="2020-09-29 02:43";
|
||||
BIN
firmware/.DS_Store
vendored
Normal file
BIN
firmware/.DS_Store
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
sd-card/.DS_Store
vendored
Normal file
BIN
sd-card/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
sd-card/html/.DS_Store
vendored
Normal file
BIN
sd-card/html/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>Set PreValue</title>
|
||||
<meta charset="utf-8">
|
||||
|
||||
|
||||
<style>
|
||||
h1 {font-size: 2em;}
|
||||
h2 {font-size: 1.5em;}
|
||||
@@ -16,11 +16,11 @@ div {
|
||||
border: 1px solid #ccc;
|
||||
font-family: arial;
|
||||
font-size: 16px;
|
||||
max-height: 35px;
|
||||
max-height: 35px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ div {
|
||||
<object data="/version?type=GitBranch"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
@@ -49,7 +49,7 @@ div {
|
||||
<object data="/version?type=GitBaseBranch"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
@@ -60,7 +60,7 @@ div {
|
||||
<object data="/version?type=GitVersion"></object>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
@@ -71,9 +71,20 @@ 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>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
1
sd-card/html/version.txt
Normal file
1
sd-card/html/version.txt
Normal file
@@ -0,0 +1 @@
|
||||
1.0.0
|
||||
Reference in New Issue
Block a user