Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST handler CPU temp / RSSI: Remove units #1908

Merged
merged 3 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions code/components/jomjol_tfliteclass/server_tflite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,15 +689,8 @@ esp_err_t handler_cputemp(httpd_req_t *req)
LogFile.WriteHeapInfo("handler_cputemp - Start");
#endif

const char* resp_str;
char cputemp[20];

sprintf(cputemp, "%4.1f°C", temperatureRead());

resp_str = cputemp;

httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
httpd_resp_send(req, resp_str, HTTPD_RESP_USE_STRLEN);
httpd_resp_send(req, std::to_string((int)temperatureRead()).c_str(), HTTPD_RESP_USE_STRLEN);

#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_cputemp - End");
Expand All @@ -715,15 +708,8 @@ esp_err_t handler_rssi(httpd_req_t *req)

if (getWIFIisConnected())
{
const char* resp_str;
char rssi[20];

sprintf(rssi, "%idBm", get_WIFI_RSSI());

resp_str = rssi;

httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
httpd_resp_send(req, resp_str, HTTPD_RESP_USE_STRLEN);
httpd_resp_send(req, std::to_string(get_WIFI_RSSI()).c_str(), HTTPD_RESP_USE_STRLEN);
}
else
{
Expand Down Expand Up @@ -877,12 +863,12 @@ void task_autodoFlow(void *pvParameter)
}

//CPU Temp -> Logfile
std::stringstream stream;
stream << std::fixed << std::setprecision(1) << temperatureRead();
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CPU Temperature: " + stream.str() + "°C");
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CPU Temperature: " + std::to_string((int)temperatureRead()) + "°C");

// WIFI Signal Strength (RSSI) -> Logfile
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "WIFI Signal (RSSI): " + std::to_string(get_WIFI_RSSI()) + "dBm");


//Round finished -> Logfile
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Round #" + std::to_string(countRounds) +
" completed (" + std::to_string(getUpTime() - roundStartTime) + " seconds)");

Expand Down
11 changes: 2 additions & 9 deletions code/main/server_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,10 @@ esp_err_t img_tmp_virtual_handler(httpd_req_t *req)
}






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 cputemp = std::to_string((int)temperatureRead());
std::string gitversion = libfive_git_version();
std::string buildtime = build_time();
std::string gitbranch = libfive_git_branch();
Expand Down Expand Up @@ -369,10 +364,8 @@ esp_err_t sysinfo_handler(httpd_req_t *req)
"\"freeHeapMem\": \"" + freeheapmem + "\"" +
"}]";

resp_str = zw.c_str();

httpd_resp_set_type(req, "application/json");
httpd_resp_sendstr(req, resp_str);
httpd_resp_send(req, zw.c_str(), zw.length());

return ESP_OK;
}
Expand Down
22 changes: 11 additions & 11 deletions sd-card/html/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var _rsp = xhttp.responseText;
$('#cputemp').html("CPU Temperature: " +_rsp);
$('#cputemp').html("CPU Temperature: " +_rsp + "°C");
}
}
xhttp.open("GET", url, true);
Expand All @@ -154,21 +154,21 @@
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var _rsp = xhttp.responseText;
var _rspVal = _rsp.split("d")[0]
if (_rspVal >= -55) {
$('#rssi').html("WIFI Signal: Excellent (" + _rsp + ")");

if (_rsp >= -55) {
$('#rssi').html("WIFI Signal: Excellent (" + _rsp + "dBm)");
}
else if (_rspVal < -55 && _rspVal >= -67) {
$('#rssi').html("WIFI Signal: Good (" + _rsp + ")");
else if (_rsp < -55 && _rsp >= -67) {
$('#rssi').html("WIFI Signal: Good (" + _rsp + "dBm)");
}
else if (_rspVal < -67 && _rspVal >= -78) {
$('#rssi').html("WIFI Signal: Fair (" + _rsp + ")");
else if (_rsp < -67 && _rsp >= -78) {
$('#rssi').html("WIFI Signal: Fair (" + _rsp + "dBm)");
}
else if (_rspVal < -78 && _rspVal >= -85) {
$('#rssi').html("WIFI Signal: Weak (" + _rsp + ")");
else if (_rsp < -78 && _rsp >= -85) {
$('#rssi').html("WIFI Signal: Weak (" + _rsp + "dBm)");
}
else {
$('#rssi').html("WIFI Signal: Unreliable (" + _rsp + ")");
$('#rssi').html("WIFI Signal: Unreliable (" + _rsp + "dBm)");
}
}
}
Expand Down