mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-11 22:16:56 +03:00
Add CPU Temp to log - add sysinfo handler
This commit is contained in:
@@ -411,6 +411,35 @@ esp_err_t handler_prevalue(httpd_req_t *req)
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
@@ -437,6 +466,10 @@ void task_autodoFlow(void *pvParameter)
|
||||
}
|
||||
|
||||
LogFile.WriteToFile("task_autodoFlow - round done");
|
||||
//CPU Temp
|
||||
float cputmp = temperatureRead();
|
||||
LogFile.WriteToFile("CPU Temperature: %.2f", cputmp);
|
||||
printf("CPU Temperature: %.2f\n", cputmp);
|
||||
fr_delta_ms = (esp_timer_get_time() - fr_start) / 1000;
|
||||
const TickType_t xDelay = (auto_intervall - fr_delta_ms) / portTICK_PERIOD_MS;
|
||||
printf("Autoflow: sleep for : %ldms\n", (long) xDelay);
|
||||
@@ -485,4 +518,9 @@ 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user