From 125eb2b7849233fafb8f931d18db03124fcdec62 Mon Sep 17 00:00:00 2001 From: Jm Date: Sun, 17 Jan 2021 00:11:26 -0800 Subject: [PATCH 1/4] Fix for build fail on NRF --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 1f962a8d9..2033b2faf 100644 --- a/platformio.ini +++ b/platformio.ini @@ -185,7 +185,7 @@ build_type = debug ; I'm debugging with ICE a lot now build_flags = ${arduino_base.build_flags} -Wno-unused-variable -Isrc/nrf52 - -Isdk-nrfxlib/crypto/nrf_oberon/include -Lsdk-nrfxlib/crypto/nrf_oberon/lib/cortex-m4/hard-float/ -lliboberon_3.0.3 + -Isdk-nrfxlib/crypto/nrf_oberon/include -Lsdk-nrfxlib/crypto/nrf_oberon/lib/cortex-m4/hard-float/ -lliboberon_3.0.7 ;-DCFG_DEBUG=3 src_filter = ${arduino_base.src_filter} - - - - From 8e8264efb08a39000c635ace9fb676ca09ab56c4 Mon Sep 17 00:00:00 2001 From: Jm Date: Sun, 17 Jan 2021 00:29:29 -0800 Subject: [PATCH 2/4] #635 - Added memory usage statistics --- src/mesh/http/WebServer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index 1c1b5a825..50330ca27 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -1169,8 +1169,18 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) res->println("},"); + res->println("\"memory\": {"); + res->printf("\"heap_total\": %u,\n", ESP.getHeapSize()); + res->printf("\"heap_free\": %u,\n", ESP.getFreeHeap()); + res->printf("\"psram_total\": %s,\n", ESP.getPsramSize()); + res->printf("\"psram_free\": %s,\n", ESP.getFreePsram()); + res->print("\"spiffs_total\" : " + String(SPIFFS.totalBytes()) + ","); + res->print("\"spiffs_used\" : " + String(SPIFFS.usedBytes()) + ","); + res->print("\"spiffs_free\" : " + String(SPIFFS.totalBytes() - SPIFFS.usedBytes())); + res->println("},"); + res->println("\"power\": {"); -#define BoolToString(x) ((x)?"true":"false") +#define BoolToString(x) ((x) ? "true" : "false") res->printf("\"battery_percent\": %u,\n", powerStatus->getBatteryChargePercent()); res->printf("\"battery_voltage_mv\": %u,\n", powerStatus->getBatteryVoltageMv()); res->printf("\"has_battery\": %s,\n", BoolToString(powerStatus->getHasBattery())); From c0d27e2ce99cde4bae5540f324872d75ec92778f Mon Sep 17 00:00:00 2001 From: Jm Date: Sun, 17 Jan 2021 10:30:34 -0800 Subject: [PATCH 3/4] #635 Added web_request_count and fixed printf of psram --- src/mesh/http/WebServer.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index 50330ca27..193508b7e 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -80,6 +80,8 @@ bool isCertReady = 0; uint32_t timeSpeedUp = 0; +uint32_t numberOfRequests = 0; + // We need to specify some content-type mapping, so the resources get delivered with the // right content type and are displayed correctly in the browser char contentTypes[][2][32] = {{".txt", "text/plain"}, {".html", "text/html"}, @@ -337,6 +339,8 @@ void middlewareSpeedUp240(HTTPRequest *req, HTTPResponse *res, std::function next) @@ -355,6 +359,8 @@ void middlewareSpeedUp160(HTTPRequest *req, HTTPResponse *res, std::functionprintln("\"wifi\": {"); + res->printf("\"web_request_count\": %d,\n", numberOfRequests); res->println("\"rssi\": " + String(WiFi.RSSI()) + ","); if (radioConfig.preferences.wifi_ap_mode || isSoftAPForced()) { @@ -1170,13 +1177,13 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) res->println("},"); res->println("\"memory\": {"); - res->printf("\"heap_total\": %u,\n", ESP.getHeapSize()); - res->printf("\"heap_free\": %u,\n", ESP.getFreeHeap()); - res->printf("\"psram_total\": %s,\n", ESP.getPsramSize()); - res->printf("\"psram_free\": %s,\n", ESP.getFreePsram()); - res->print("\"spiffs_total\" : " + String(SPIFFS.totalBytes()) + ","); - res->print("\"spiffs_used\" : " + String(SPIFFS.usedBytes()) + ","); - res->print("\"spiffs_free\" : " + String(SPIFFS.totalBytes() - SPIFFS.usedBytes())); + res->printf("\"heap_total\": %d,\n", ESP.getHeapSize()); + res->printf("\"heap_free\": %d,\n", ESP.getFreeHeap()); + res->printf("\"psram_total\": %d,\n", ESP.getPsramSize()); + res->printf("\"psram_free\": %d,\n", ESP.getFreePsram()); + res->println("\"spiffs_total\" : " + String(SPIFFS.totalBytes()) + ","); + res->println("\"spiffs_used\" : " + String(SPIFFS.usedBytes()) + ","); + res->println("\"spiffs_free\" : " + String(SPIFFS.totalBytes() - SPIFFS.usedBytes())); res->println("},"); res->println("\"power\": {"); From fa8cc741418c7ca7251ad278c6a7fda119eed28a Mon Sep 17 00:00:00 2001 From: Jm Date: Sun, 17 Jan 2021 15:40:25 -0800 Subject: [PATCH 4/4] Update to Serial Plugin to make it easy to override the device configuration --- src/plugins/SerialPlugin.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index 236b29f94..7e764ee8b 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -66,6 +66,17 @@ char serialStringChar[Constants_DATA_PAYLOAD_LEN]; int32_t SerialPlugin::runOnce() { #ifndef NO_ESP32 + + /* + Uncomment the preferences below if you want to use the plugin + without having to configure it from the PythonAPI or WebUI. + */ + + // radioConfig.preferences.serialplugin_enabled = 1; + // radioConfig.preferences.serialplugin_rxd = 35; + // radioConfig.preferences.serialplugin_txd = 15; + // radioConfig.preferences.serialplugin_timeout = 1000; + if (radioConfig.preferences.serialplugin_enabled) { if (firstTime) { @@ -147,8 +158,8 @@ bool SerialPluginRadio::handleReceived(const MeshPacket &mp) if (radioConfig.preferences.serialplugin_enabled) { auto &p = mp.decoded.data; - // DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", nodeDB.getNodeNum(), - // mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes); + // DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", + // nodeDB.getNodeNum(), mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes); if (mp.from == nodeDB.getNodeNum()) {