show uptime on overview page, moved labels from firmware to Web UI (#1543)

* show uptime on overview page, moved labels from firmware to Web UI

* show uptime on info page

* also use formated time in log

Co-authored-by: CaCO3 <caco@ruinelli.ch>
This commit is contained in:
CaCO3
2022-12-12 08:54:46 +01:00
committed by GitHub
parent b85e3b11a9
commit 6863e637aa
6 changed files with 101 additions and 15 deletions

View File

@@ -614,7 +614,7 @@ esp_err_t handler_cputemp(httpd_req_t *req)
const char* resp_str;
char cputemp[20];
sprintf(cputemp, "CPU Temp: %4.1f°C", temperatureRead());
sprintf(cputemp, "%4.1f°C", temperatureRead());
resp_str = cputemp;
@@ -639,7 +639,7 @@ esp_err_t handler_rssi(httpd_req_t *req)
const char* resp_str;
char rssi[20];
sprintf(rssi, "RSSI: %idBm", get_WIFI_RSSI());
sprintf(rssi, "%idBm", get_WIFI_RSSI());
resp_str = rssi;
@@ -655,6 +655,34 @@ esp_err_t handler_rssi(httpd_req_t *req)
return ESP_OK;
};
esp_err_t handler_uptime(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_uptime - Start");
#endif
const char* resp_str;
std::string formatedUptime = getFormatedUptime(false);
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
httpd_resp_send(req, formatedUptime.c_str(), strlen(formatedUptime.c_str()));
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_uptime - End");
#endif
return ESP_OK;
}
esp_err_t handler_prevalue(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
@@ -721,6 +749,7 @@ void task_autodoFlow(void *pvParameter)
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Restarted due to an Exception/panic! Postponing first round start by 5 minutes to allow for an OTA or to fetch the log!");
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Setting logfile level to DEBUG until the next reboot!");
LogFile.setLogLevel(ESP_LOG_DEBUG);
//MQTTPublish(GetMQTTMainTopic() + "/" + "status", "Postponing first round", false);
vTaskDelay(60*5000 / portTICK_RATE_MS); // Wait 5 minutes to give time to do an OTA or fetch the log
}
@@ -873,6 +902,11 @@ void register_server_tflite_uri(httpd_handle_t server)
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/uptime";
camuri.handler = handler_uptime;
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/editflow";
camuri.handler = handler_editflow;
camuri.user_ctx = (void*) "EditFlow";