From ade30ee1cea21d1facb0434bb3f9555ad2cd674a Mon Sep 17 00:00:00 2001 From: geeksville Date: Thu, 6 Feb 2020 21:26:40 -0800 Subject: [PATCH] bidir comm works --- TODO.md | 2 ++ lib/RadioHead | 1 + platformio.ini | 7 +++++-- src/MeshRadio.cpp | 3 +-- src/MeshService.cpp | 7 +++++++ src/TypedQueue.h | 4 ++++ src/configuration.h | 12 ++++++------ 7 files changed, 26 insertions(+), 10 deletions(-) create mode 120000 lib/RadioHead diff --git a/TODO.md b/TODO.md index 3773e055..7c3e0117 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,6 @@ # High priority +* check in my radiolib fixes * test raw device access without a manager in the way * sim gps data for nodes that don't have hardware * figure out what is busted with rx @@ -93,3 +94,4 @@ until the phone pulls those packets. Ever so often power on bluetooth just so w * have meshservice periodically send location data on mesh (if device has a GPS) * implement getCurrentTime() - set based off gps but then updated locally * make default owner record have valid usernames +* message loop between node 0x28 and 0x7c diff --git a/lib/RadioHead b/lib/RadioHead new file mode 120000 index 00000000..5e889e35 --- /dev/null +++ b/lib/RadioHead @@ -0,0 +1 @@ +../../RadioHead \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 509c47ba..18747872 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,6 +13,7 @@ [env:esp32] platform = espressif32 board = ttgo-t-beam +; board = heltec_wifi_lora_32_V2 framework = arduino ; customize the partition table @@ -43,7 +44,7 @@ monitor_speed = 115200 # debug_port = /dev/ttyACM0 debug_tool = jlink -; upload_protocol = jlink +;upload_protocol = jlink ; debug_tool = olimex-arm-usb-ocd-h ; upload_protocol = olimex-arm-usb-ocd-h @@ -54,11 +55,13 @@ debug_tool = jlink debug_init_break = tbreak setup lib_deps = - RadioHead + ; RadioHead - I now use a custom build of this library + ; file:///home/kevinh/development/meshtastic/RadioHead TinyGPSPlus ESP8266_SSD1306 AXP202X_Library SPI + CRC32 ; explicitly needed because dependency is missing in the ble ota update lib Wire ; explicitly needed here because the AXP202 library forgets to add it ;[env:tbeam] diff --git a/src/MeshRadio.cpp b/src/MeshRadio.cpp index 72d105cd..de21ff52 100644 --- a/src/MeshRadio.cpp +++ b/src/MeshRadio.cpp @@ -63,6 +63,7 @@ bool MeshRadio::init() // FIXME - can we do this? It seems to be in the Heltec board. rf95.setTxPower(radioConfig.tx_power, false); + DEBUG_MSG("LoRa radio init OK!\n"); return true; @@ -77,8 +78,6 @@ ErrorCode MeshRadio::send(MeshPacket *p) ErrorCode MeshRadio::sendTo(NodeNum dest, const uint8_t *buf, size_t len) { DEBUG_MSG("mesh sendTo %d bytes to 0x%x\n", len, dest); - // FIXME - for now we do all packets as broadcast - dest = NODENUM_BROADCAST; assert(len <= 255); // Make sure we don't overflow the tiny max packet size diff --git a/src/MeshService.cpp b/src/MeshService.cpp index dbbe69ab..be8527c1 100644 --- a/src/MeshService.cpp +++ b/src/MeshService.cpp @@ -74,6 +74,13 @@ void MeshService::loop() } fromNum++; + + if(toPhoneQueue.numFree() == 0) { + DEBUG_MSG("NOTE: tophone queue is full, discarding oldest\n"); + MeshPacket *d = toPhoneQueue.dequeuePtr(0); + if(d) + releaseToPool(d); + } assert(toPhoneQueue.enqueue(mp, 0) == pdTRUE); // FIXME, instead of failing for full queue, delete the oldest mssages } if (oldFromNum != fromNum) // We don't want to generate extra notifies for multiple new packets diff --git a/src/TypedQueue.h b/src/TypedQueue.h index 61c58478..36dd7e21 100644 --- a/src/TypedQueue.h +++ b/src/TypedQueue.h @@ -19,6 +19,10 @@ public: vQueueDelete(h); } + int numFree() { + return uxQueueSpacesAvailable(h); + } + // pdTRUE for success else failure BaseType_t enqueue(T x, TickType_t maxWait = portMAX_DELAY) { return xQueueSendToBack(h, &x, maxWait); diff --git a/src/configuration.h b/src/configuration.h index 523de668..8723e4fa 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -37,18 +37,18 @@ along with this program. If not, see . // ----------------------------------------------------------------------------- // Select which T-Beam board is being used. Only uncomment one. Note: these options now come from platformio standard build file flags -#ifdef ARDUINO_T_Beam +//#ifdef ARDUINO_T_Beam #define T_BEAM_V10 // AKA Rev1 (second board released) -#endif +//#endif -#ifdef ARDUINO_HELTEC_WIFI_LORA_32_V2 -#define HELTEC_LORA32 -#endif +//#ifdef ARDUINO_HELTEC_WIFI_LORA_32_V2 +//#define HELTEC_LORA32 +//#endif // If we are using the JTAG port for debugging, some pins must be left free for that (and things like GPS have to be disabled) // we don't support jtag on the ttgo - access to gpio 12 is a PITA #ifdef HELTEC_LORA32 -#define USE_JTAG +//#define USE_JTAG #endif #define DEBUG_PORT Serial // Serial debug port