mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-10 21:46:55 +03:00
added CPU Temp and RSSI to staus box of webgui.
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
#include "server_GPIO.h"
|
#include "server_GPIO.h"
|
||||||
|
|
||||||
#include "server_file.h"
|
#include "server_file.h"
|
||||||
|
#include "connect_wlan.h"
|
||||||
|
|
||||||
#define DEBUG_DETAIL_ON
|
#define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
@@ -590,6 +591,55 @@ esp_err_t handler_statusflow(httpd_req_t *req)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
esp_err_t handler_cputemp(httpd_req_t *req)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_cputemp - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char* resp_str;
|
||||||
|
char cputemp[20];
|
||||||
|
|
||||||
|
sprintf(resp_str, "CPU Temp: %4.1f°C", temperatureRead());
|
||||||
|
|
||||||
|
resp_str = cputemp;
|
||||||
|
|
||||||
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
|
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);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_cputemp - End");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
};
|
||||||
|
|
||||||
|
esp_err_t handler_rssi(httpd_req_t *req)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_rssi - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char* resp_str;
|
||||||
|
char rssi[20];
|
||||||
|
|
||||||
|
sprintf(rssi, "RSSI: %idBm", get_WIFI_RSSI());
|
||||||
|
|
||||||
|
resp_str = rssi;
|
||||||
|
|
||||||
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
|
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);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_rssi - End");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
};
|
||||||
|
|
||||||
esp_err_t handler_prevalue(httpd_req_t *req)
|
esp_err_t handler_prevalue(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
@@ -643,7 +693,7 @@ esp_err_t handler_prevalue(httpd_req_t *req)
|
|||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_prevalue - Start");
|
LogFile.WriteHeapInfo("handler_prevalue - End");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
@@ -766,6 +816,16 @@ void register_server_tflite_uri(httpd_handle_t server)
|
|||||||
camuri.user_ctx = (void*) "Light Off";
|
camuri.user_ctx = (void*) "Light Off";
|
||||||
httpd_register_uri_handler(server, &camuri);
|
httpd_register_uri_handler(server, &camuri);
|
||||||
|
|
||||||
|
camuri.uri = "/cputemp.html";
|
||||||
|
camuri.handler = handler_cputemp;
|
||||||
|
camuri.user_ctx = (void*) "Light Off";
|
||||||
|
httpd_register_uri_handler(server, &camuri);
|
||||||
|
|
||||||
|
camuri.uri = "/rssi.html";
|
||||||
|
camuri.handler = handler_rssi;
|
||||||
|
camuri.user_ctx = (void*) "Light Off";
|
||||||
|
httpd_register_uri_handler(server, &camuri);
|
||||||
|
|
||||||
camuri.uri = "/editflow.html";
|
camuri.uri = "/editflow.html";
|
||||||
camuri.handler = handler_editflow;
|
camuri.handler = handler_editflow;
|
||||||
camuri.user_ctx = (void*) "EditFlow";
|
camuri.user_ctx = (void*) "EditFlow";
|
||||||
|
|||||||
Binary file not shown.
@@ -57,6 +57,8 @@
|
|||||||
<td class="tg-3">
|
<td class="tg-3">
|
||||||
<div id="timestamp" ></div>
|
<div id="timestamp" ></div>
|
||||||
<div id="statusflow" ></div>
|
<div id="statusflow" ></div>
|
||||||
|
<div id="cputemp" ></div>
|
||||||
|
<div id="rssi" ></div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -83,6 +85,8 @@ function addZero(i) {
|
|||||||
$('#img').html('<img src="/img_tmp/alg_roi.jpg" style="max-height:555px; display:block; margin-left:auto; margin-right:auto;"></img>');
|
$('#img').html('<img src="/img_tmp/alg_roi.jpg" style="max-height:555px; display:block; margin-left:auto; margin-right:auto;"></img>');
|
||||||
$('#timestamp').html("Last Page Refresh:" + (h + ":" + m + ":" + s));
|
$('#timestamp').html("Last Page Refresh:" + (h + ":" + m + ":" + s));
|
||||||
loadStatus();
|
loadStatus();
|
||||||
|
loadCPUTemp();
|
||||||
|
loadRSSI();
|
||||||
refresh();
|
refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -94,10 +98,10 @@ function refresh() {
|
|||||||
var h = addZero(d.getHours());
|
var h = addZero(d.getHours());
|
||||||
var m = addZero(d.getMinutes());
|
var m = addZero(d.getMinutes());
|
||||||
var s = addZero(d.getSeconds());
|
var s = addZero(d.getSeconds());
|
||||||
|
|
||||||
// reassign the url to be like alg_roi.jpg?timestamp=456784512 based on timestamp
|
// reassign the url to be like alg_roi.jpg?timestamp=456784512 based on timestamp
|
||||||
$('#img').html('<img src="/img_tmp/alg_roi.jpg?timestamp='+ timestamp +'"max-height:555px; display:block; margin-left:auto; margin-right:auto;"></img>');
|
$('#img').html('<img src="/img_tmp/alg_roi.jpg?timestamp='+ timestamp +'"max-height:555px; display:block; margin-left:auto; margin-right:auto;"></img>');
|
||||||
$('#timestamp').html("Last Page Refresh:" + (h + ":" + m + ":" + s));
|
$('#timestamp').html("Last Page Refresh:" + (h + ":" + m + ":" + s));
|
||||||
loadStatus();
|
|
||||||
init();
|
init();
|
||||||
refresh();
|
refresh();
|
||||||
}, 300000);
|
}, 300000);
|
||||||
@@ -120,6 +124,32 @@ function refresh() {
|
|||||||
xhttp.send();
|
xhttp.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadCPUTemp() {
|
||||||
|
url = basepath + '/cputemp.html';
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
var _rsp = xhttp.responseText;
|
||||||
|
$('#cputemp').html(_rsp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhttp.open("GET", url, true);
|
||||||
|
xhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadRSSI() {
|
||||||
|
url = basepath + '/rssi.html';
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
var _rsp = xhttp.responseText;
|
||||||
|
$('#rssi').html(_rsp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhttp.open("GET", url, true);
|
||||||
|
xhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
function loadValue(_type, _div, _style) {
|
function loadValue(_type, _div, _style) {
|
||||||
url = basepath + '/wasserzaehler.html?all=true&type=' + _type;
|
url = basepath + '/wasserzaehler.html?all=true&type=' + _type;
|
||||||
var xhttp = new XMLHttpRequest();
|
var xhttp = new XMLHttpRequest();
|
||||||
@@ -167,6 +197,8 @@ function refresh() {
|
|||||||
loadValue("prevalue", "prevalue");
|
loadValue("prevalue", "prevalue");
|
||||||
loadValue("error", "error", "font-size:8px");
|
loadValue("error", "error", "font-size:8px");
|
||||||
loadStatus();
|
loadStatus();
|
||||||
|
loadCPUTemp();
|
||||||
|
loadRSSI();
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|||||||
Reference in New Issue
Block a user