From fdc9bf57839600e5b3aae296eeec42ac26025808 Mon Sep 17 00:00:00 2001 From: Charles Crossan Date: Mon, 11 Jan 2021 20:25:02 -0500 Subject: [PATCH 1/6] add power statistics for #635 --- src/mesh/wifi/WebServer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mesh/wifi/WebServer.cpp b/src/mesh/wifi/WebServer.cpp index 8eb88808..385d57e6 100644 --- a/src/mesh/wifi/WebServer.cpp +++ b/src/mesh/wifi/WebServer.cpp @@ -1,6 +1,7 @@ #include "mesh/wifi/WebServer.h" #include "NodeDB.h" #include "PowerFSM.h" +#include "power.h" #include "airtime.h" #include "main.h" #include "mesh/wifi/ContentHelper.h" @@ -1169,7 +1170,14 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) res->println("},"); - res->println("\"test\": 123"); + res->println("\"power\": {"); +#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())); + res->printf("\"has_usb\": %s,\n", BoolToString(powerStatus->getHasUSB())); + res->printf("\"is_charging\": %s\n", BoolToString(powerStatus->getIsCharging())); + res->println("}"); res->println("},"); From 0f573901d520ad0e7b176fbaba272a41114d0fdb Mon Sep 17 00:00:00 2001 From: Charles Crossan Date: Mon, 11 Jan 2021 20:28:09 -0500 Subject: [PATCH 2/6] didn't need power.h --- src/mesh/wifi/WebServer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesh/wifi/WebServer.cpp b/src/mesh/wifi/WebServer.cpp index 385d57e6..2f263e21 100644 --- a/src/mesh/wifi/WebServer.cpp +++ b/src/mesh/wifi/WebServer.cpp @@ -1,7 +1,6 @@ #include "mesh/wifi/WebServer.h" #include "NodeDB.h" #include "PowerFSM.h" -#include "power.h" #include "airtime.h" #include "main.h" #include "mesh/wifi/ContentHelper.h" From 95c502c658be2c425246d826aaec2af351ae0092 Mon Sep 17 00:00:00 2001 From: Charles Crossan Date: Mon, 11 Jan 2021 20:30:02 -0500 Subject: [PATCH 3/6] fix typo --- src/PowerStatus.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PowerStatus.h b/src/PowerStatus.h index e9c192fb..a276be59 100644 --- a/src/PowerStatus.h +++ b/src/PowerStatus.h @@ -11,7 +11,7 @@ namespace meshtastic */ enum OptionalBool { OptFalse = 0, OptTrue = 1, OptUnknown = 2 }; -/// Describes the state of the GPS system. +/// Describes the state of the Power system. class PowerStatus : public Status { From 3598c91c296f535b324da956da9da4e8be42578f Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Fri, 15 Jan 2021 13:21:33 +0800 Subject: [PATCH 4/6] fix @mc-hamster build to work on linux/nrf52 --- platformio.ini | 4 ++-- src/graphics/EInkDisplay.cpp | 1 - src/graphics/Screen.cpp | 2 +- src/main.cpp | 4 ++-- src/mesh/NodeDB.cpp | 2 +- src/mesh/{wifi => http}/ContentHelper.cpp | 2 +- src/mesh/{wifi => http}/ContentHelper.h | 0 src/mesh/{wifi => http}/ContentStatic.h | 0 src/mesh/{wifi => http}/WebServer.cpp | 8 ++++---- src/mesh/{wifi => http}/WebServer.h | 0 src/mesh/{wifi => http}/WiFiAPClient.cpp | 6 +++--- src/mesh/{wifi => http}/WiFiAPClient.h | 0 src/nimble/BluetoothUtil.cpp | 2 +- 13 files changed, 15 insertions(+), 16 deletions(-) rename src/mesh/{wifi => http}/ContentHelper.cpp (91%) rename src/mesh/{wifi => http}/ContentHelper.h (100%) rename src/mesh/{wifi => http}/ContentStatic.h (100%) rename src/mesh/{wifi => http}/WebServer.cpp (99%) rename src/mesh/{wifi => http}/WebServer.h (100%) rename src/mesh/{wifi => http}/WiFiAPClient.cpp (99%) rename src/mesh/{wifi => http}/WiFiAPClient.h (100%) diff --git a/platformio.ini b/platformio.ini index 67199199..1f962a8d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -188,7 +188,7 @@ build_flags = -Isdk-nrfxlib/crypto/nrf_oberon/include -Lsdk-nrfxlib/crypto/nrf_oberon/lib/cortex-m4/hard-float/ -lliboberon_3.0.3 ;-DCFG_DEBUG=3 src_filter = - ${arduino_base.src_filter} - - - - + ${arduino_base.src_filter} - - - - lib_ignore = BluetoothOTA monitor_port = /dev/ttyACM1 @@ -315,7 +315,7 @@ lib_deps = ; The Portduino based sim environment on top of linux [env:linux] platform = https://github.com/geeksville/platform-portduino.git -src_filter = ${env.src_filter} - - - - +src_filter = ${env.src_filter} - - - - build_flags = ${arduino_base.build_flags} -O0 framework = arduino board = linux_x86_64 diff --git a/src/graphics/EInkDisplay.cpp b/src/graphics/EInkDisplay.cpp index 0d5e8307..2b530c0c 100644 --- a/src/graphics/EInkDisplay.cpp +++ b/src/graphics/EInkDisplay.cpp @@ -4,7 +4,6 @@ #include "EInkDisplay.h" #include "SPILock.h" #include "epd1in54.h" // Screen specific library -#include "graphics/configs.h" #include #include // Graphics library and Sprite class diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 97b24df3..6f022943 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -36,7 +36,7 @@ along with this program. If not, see . #include "utils.h" #ifndef NO_ESP32 -#include "mesh/wifi/WiFiAPClient.h" +#include "mesh/http/WiFiAPClient.h" #endif using namespace meshtastic; /** @todo remove */ diff --git a/src/main.cpp b/src/main.cpp index 605b9196..b63c193a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,8 +27,8 @@ // #include #ifndef NO_ESP32 -#include "mesh/wifi/WebServer.h" -#include "mesh/wifi/WiFiAPClient.h" +#include "mesh/http/WebServer.h" +#include "mesh/http/WiFiAPClient.h" #include "nimble/BluetoothUtil.h" #endif diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index a2a1e316..dc13bc42 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -20,7 +20,7 @@ #include #ifndef NO_ESP32 -#include "mesh/wifi/WiFiAPClient.h" +#include "mesh/http/WiFiAPClient.h" #endif NodeDB nodeDB; diff --git a/src/mesh/wifi/ContentHelper.cpp b/src/mesh/http/ContentHelper.cpp similarity index 91% rename from src/mesh/wifi/ContentHelper.cpp rename to src/mesh/http/ContentHelper.cpp index 96dec5d9..249dcbde 100644 --- a/src/mesh/wifi/ContentHelper.cpp +++ b/src/mesh/http/ContentHelper.cpp @@ -1,4 +1,4 @@ -#include "mesh/wifi/ContentHelper.h" +#include "mesh/http/ContentHelper.h" //#include //#include "main.h" diff --git a/src/mesh/wifi/ContentHelper.h b/src/mesh/http/ContentHelper.h similarity index 100% rename from src/mesh/wifi/ContentHelper.h rename to src/mesh/http/ContentHelper.h diff --git a/src/mesh/wifi/ContentStatic.h b/src/mesh/http/ContentStatic.h similarity index 100% rename from src/mesh/wifi/ContentStatic.h rename to src/mesh/http/ContentStatic.h diff --git a/src/mesh/wifi/WebServer.cpp b/src/mesh/http/WebServer.cpp similarity index 99% rename from src/mesh/wifi/WebServer.cpp rename to src/mesh/http/WebServer.cpp index 2f263e21..e22ebb27 100644 --- a/src/mesh/wifi/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -1,11 +1,11 @@ -#include "mesh/wifi/WebServer.h" +#include "mesh/http/WebServer.h" #include "NodeDB.h" #include "PowerFSM.h" #include "airtime.h" #include "main.h" -#include "mesh/wifi/ContentHelper.h" -#include "mesh/wifi/ContentStatic.h" -#include "mesh/wifi/WiFiAPClient.h" +#include "mesh/http/ContentHelper.h" +#include "mesh/http/ContentStatic.h" +#include "mesh/http/WiFiAPClient.h" #include "sleep.h" #include #include diff --git a/src/mesh/wifi/WebServer.h b/src/mesh/http/WebServer.h similarity index 100% rename from src/mesh/wifi/WebServer.h rename to src/mesh/http/WebServer.h diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/http/WiFiAPClient.cpp similarity index 99% rename from src/mesh/wifi/WiFiAPClient.cpp rename to src/mesh/http/WiFiAPClient.cpp index 32989b2b..3ecd7235 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/http/WiFiAPClient.cpp @@ -1,9 +1,9 @@ -#include "mesh/wifi/WiFiAPClient.h" +#include "mesh/http/WiFiAPClient.h" #include "NodeDB.h" -#include "mesh/wifi/WiFiServerAPI.h" #include "configuration.h" #include "main.h" -#include "mesh/wifi/WebServer.h" +#include "mesh/http/WebServer.h" +#include "mesh/wifi/WiFiServerAPI.h" #include "target_specific.h" #include #include diff --git a/src/mesh/wifi/WiFiAPClient.h b/src/mesh/http/WiFiAPClient.h similarity index 100% rename from src/mesh/wifi/WiFiAPClient.h rename to src/mesh/http/WiFiAPClient.h diff --git a/src/nimble/BluetoothUtil.cpp b/src/nimble/BluetoothUtil.cpp index 86cd2074..f5f1f77e 100644 --- a/src/nimble/BluetoothUtil.cpp +++ b/src/nimble/BluetoothUtil.cpp @@ -14,7 +14,7 @@ #include #ifndef NO_ESP32 -#include "mesh/wifi/WiFiAPClient.h" +#include "mesh/http/WiFiAPClient.h" #endif static bool pinShowing; From 4ec8986934756e99afc16579af1a4dad8cf177db Mon Sep 17 00:00:00 2001 From: Jm Date: Thu, 14 Jan 2021 21:45:41 -0800 Subject: [PATCH 5/6] Fixed switching to uint32 from 16 for airtime in json report --- src/mesh/http/WebServer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index e22ebb27..1c1b5a82 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -1110,13 +1110,13 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) res->println("\"airtime\": {"); - uint16_t *logArray; + uint32_t *logArray; res->print("\"tx_log\": ["); logArray = airtimeReport(TX_LOG); for (int i = 0; i < getPeriodsToLog(); i++) { - uint16_t tmp; + uint32_t tmp; tmp = *(logArray + i); res->printf("%d", tmp); if (i != getPeriodsToLog() - 1) { @@ -1129,7 +1129,7 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) logArray = airtimeReport(RX_LOG); for (int i = 0; i < getPeriodsToLog(); i++) { - uint16_t tmp; + uint32_t tmp; tmp = *(logArray + i); res->printf("%d", tmp); if (i != getPeriodsToLog() - 1) { @@ -1142,7 +1142,7 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) logArray = airtimeReport(RX_ALL_LOG); for (int i = 0; i < getPeriodsToLog(); i++) { - uint16_t tmp; + uint32_t tmp; tmp = *(logArray + i); res->printf("%d", tmp); if (i != getPeriodsToLog() - 1) { From bd857362268ed217f370c69af34a2e7a9e7b30f9 Mon Sep 17 00:00:00 2001 From: Jm Date: Thu, 14 Jan 2021 21:59:26 -0800 Subject: [PATCH 6/6] SerialPlugin - Exclude working on non esp32 platforms. --- src/plugins/SerialPlugin.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index cc355c06..82c8baf8 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -37,6 +37,7 @@ to your device. TODO (in this order): + * Add check for esp32 and only build code sections for esp32. * Once protobufs regenerated with the new port, update SerialPlugin.h * Ensure this works on a tbeam * Define a verbose RX mode to report on mesh and packet infomration. @@ -45,6 +46,7 @@ KNOWN PROBLEMS * Until the plugin is initilized by the startup sequence, the TX pin is in a floating state. Device connected to that pin may see this as "noise". + * This will not work on the NRF or Linux target. */ @@ -55,7 +57,7 @@ #define SERIALPLUGIN_STRING_MAX Constants_DATA_PAYLOAD_LEN #define SERIALPLUGIN_TIMEOUT 250 #define SERIALPLUGIN_BAUD 38400 -#define SERIALPLUGIN_ENABLED 1 +#define SERIALPLUGIN_ENABLED 0 #define SERIALPLUGIN_ECHO 0 #define SERIALPLUGIN_ACK 0 @@ -68,6 +70,7 @@ char serialStringChar[Constants_DATA_PAYLOAD_LEN]; int32_t SerialPlugin::runOnce() { +#ifdef NO_ESP32 #if SERIALPLUGIN_ENABLED == 1 @@ -103,6 +106,8 @@ int32_t SerialPlugin::runOnce() return (INT32_MAX); #endif + +#endif } MeshPacket *SerialPluginRadio::allocReply() @@ -129,6 +134,11 @@ void SerialPluginRadio::sendPayload(NodeNum dest, bool wantReplies) bool SerialPluginRadio::handleReceived(const MeshPacket &mp) { + +#ifdef NO_ESP32 + +#if SERIALPLUGIN_ENABLED == 1 + 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); @@ -157,5 +167,12 @@ bool SerialPluginRadio::handleReceived(const MeshPacket &mp) Serial2.printf("%s", p.payload.bytes); } +#else + DEBUG_MSG("Serial Plugin Disabled\n"); + +#endif + +#endif + return true; // Let others look at this message also if they want }