From eaa15076cd73ebeb1974b23a6deade49978b7e9f Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Wed, 18 Aug 2021 09:25:17 -0700 Subject: [PATCH] WIP debug logging over TCP --- geeksville-private/TODO.md | 13 ++++++------- src/RedirectablePrint.cpp | 5 +++++ src/main.cpp | 3 ++- src/mesh/PhoneAPI.h | 3 +++ src/mesh/StreamAPI.h | 2 +- src/mesh/wifi/WiFiServerAPI.cpp | 9 +++++++-- src/mesh/wifi/WiFiServerAPI.h | 8 ++++++-- 7 files changed, 30 insertions(+), 13 deletions(-) diff --git a/geeksville-private/TODO.md b/geeksville-private/TODO.md index 4916d94d..65896c00 100644 --- a/geeksville-private/TODO.md +++ b/geeksville-private/TODO.md @@ -2,22 +2,22 @@ You probably don't care about this section - skip to the next one. -* send debug info 'in-band' +* test modem-manager removal +* measure rak4630 power draw and turn off power for GPS most of the time. We should be able to run on the small solar panel. * usb lora dongle from pine64 * turn on watchdog reset if app hangs on nrf52 or esp32 -* list portduino on platformio * pine64 solar board - +* add portduino builds to zip +* * for the matrix gateway? recommended by @sam-uk https://github.com/matrix-org/coap-proxy * figure our wss for mqtt.meshtastic - use cloudflare? 2052 ws, 2053 crypt -* measure rak4630 power draw and turn off power for GPS most of the time. We should be able to run on the small solar panel. * ask for vercel access * finish plan for riot.im * turn on setTx(timeout) and state = setDioIrqParams(SX126X_IRQ_TX_DONE | SX126X_IRQ_TIMEOUT, SX126X_IRQ_TX_DONE | SX126X_IRQ_TIMEOUT); in sx1262 code -* add rak4600 support (with rf95 radio and limited ram) +* NO add rak4600 support (with rf95 radio and limited ram) * store esp32 crashes to flash (and 64KB coredump partition) - https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/core_dump.html * If more nodes appear than the nodedb can hold, delete oldest entries from DB -* Switch to use https://github.com/adafruit/Adafruit_nRF52_Arduino.git when available (see arduino code for examples) +* send debug info 'in-band' * DONE @luxonn reports that after a while the android app stops showing new messages * DONE release android APK - fix recent 1.2.28 crash report * DONE remote admin busted? @@ -30,7 +30,6 @@ You probably don't care about this section - skip to the next one. * DONE tcp stream problem in python+pordtuino, server thinks client dropped when client DID NOT DROP * DONE TCP mode for android, localhost is at 10.0.2.2 * DONE make sure USB still works in android -* add portduino builds to zip * add license to portduino and make announcement * DONE naks are being dropped (though enqueuedLocal) sometimes before phone/PC gets them * DONE have android fill in if local GPS has poor signal diff --git a/src/RedirectablePrint.cpp b/src/RedirectablePrint.cpp index 8cbff969..dc0f3b95 100644 --- a/src/RedirectablePrint.cpp +++ b/src/RedirectablePrint.cpp @@ -2,6 +2,7 @@ #include "RedirectablePrint.h" #include "RTC.h" #include "concurrency/OSThread.h" +// #include "wifi/WiFiServerAPI.h" #include #include #include @@ -25,6 +26,10 @@ size_t RedirectablePrint::write(uint8_t c) SEGGER_RTT_PutChar(SEGGER_STDOUT_CH, c); #endif + // FIXME - clean this up, the whole relationship of this class to SerialConsole to TCP/bluetooth debug log output is kinda messed up. But for now, just have this hack to + // optionally send chars to TCP also + //WiFiServerPort::debugOut(c); + dest->write(c); return 1; // We always claim one was written, rather than trusting what the // serial port said (which could be zero) diff --git a/src/main.cpp b/src/main.cpp index 4efd4f42..a1de8dc6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,9 +25,10 @@ #include // #include +#include "mesh/http/WiFiAPClient.h" + #ifndef NO_ESP32 #include "mesh/http/WebServer.h" -#include "mesh/http/WiFiAPClient.h" #include "nimble/BluetoothUtil.h" #endif diff --git a/src/mesh/PhoneAPI.h b/src/mesh/PhoneAPI.h index 90a8c4d1..e818bba5 100644 --- a/src/mesh/PhoneAPI.h +++ b/src/mesh/PhoneAPI.h @@ -81,6 +81,9 @@ class PhoneAPI bool isConnected() { return state != STATE_SEND_NOTHING; } + /// emit a debugging log character, FIXME - implement + void debugOut(char c) { } + protected: /// Our fromradio packet while it is being assembled FromRadio fromRadioScratch; diff --git a/src/mesh/StreamAPI.h b/src/mesh/StreamAPI.h index b33e73ea..58af95b3 100644 --- a/src/mesh/StreamAPI.h +++ b/src/mesh/StreamAPI.h @@ -68,7 +68,7 @@ class StreamAPI : public PhoneAPI, protected concurrency::OSThread void emitRebooted(); virtual void onConnectionChanged(bool connected); - + /// Check the current underlying physical link to see if the client is currently connected virtual bool checkIsConnected() = 0; diff --git a/src/mesh/wifi/WiFiServerAPI.cpp b/src/mesh/wifi/WiFiServerAPI.cpp index 79c749af..6014f832 100644 --- a/src/mesh/wifi/WiFiServerAPI.cpp +++ b/src/mesh/wifi/WiFiServerAPI.cpp @@ -25,8 +25,6 @@ WiFiServerAPI::~WiFiServerAPI() // FIXME - delete this if the client dropps the connection! } - - /// override close to also shutdown the TCP link void WiFiServerAPI::close() { @@ -51,6 +49,13 @@ int32_t WiFiServerAPI::runOnce() } } +/// If an api server is running, we try to spit out debug 'serial' characters there +void WiFiServerPort::debugOut(char c) +{ + if (apiPort && apiPort->openAPI) + apiPort->openAPI->debugOut(c); +} + #define MESHTASTIC_PORTNUM 4403 WiFiServerPort::WiFiServerPort() : WiFiServer(MESHTASTIC_PORTNUM), concurrency::OSThread("ApiServer") {} diff --git a/src/mesh/wifi/WiFiServerAPI.h b/src/mesh/wifi/WiFiServerAPI.h index c1f9b1be..b7b8c335 100644 --- a/src/mesh/wifi/WiFiServerAPI.h +++ b/src/mesh/wifi/WiFiServerAPI.h @@ -21,8 +21,8 @@ class WiFiServerAPI : public StreamAPI virtual void close(); protected: - - /// We override this method to prevent publishing EVENT_SERIAL_CONNECTED/DISCONNECTED for wifi links (we want the board to stay in the POWERED state to prevent disabling wifi) + /// We override this method to prevent publishing EVENT_SERIAL_CONNECTED/DISCONNECTED for wifi links (we want the board to + /// stay in the POWERED state to prevent disabling wifi) virtual void onConnectionChanged(bool connected) {} virtual int32_t runOnce(); // Check for dropped client connections @@ -48,6 +48,10 @@ class WiFiServerPort : public WiFiServer, private concurrency::OSThread void init(); + /// If an api server is running, we try to spit out debug 'serial' characters there + static void debugOut(char c); + + protected: int32_t runOnce(); };