From c22df18e2819ae92f158a32830d5bf62bbc81aff Mon Sep 17 00:00:00 2001 From: geeksville Date: Mon, 6 Apr 2020 09:39:44 -0700 Subject: [PATCH] fix collision avoidance for transmit - substantially improves lora tx success --- docs/software/TODO.md | 1 + platformio.ini | 2 +- src/CustomRF95.cpp | 7 ++++--- src/main.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/software/TODO.md b/docs/software/TODO.md index 38523a33..040c3fe4 100644 --- a/docs/software/TODO.md +++ b/docs/software/TODO.md @@ -17,6 +17,7 @@ Items to complete soon (next couple of alpha releases). Items to complete before the first beta release. +- Use the RFM95 sequencer to stay in idle mode most of the time, then automatically go to receive mode and automatically go from transmit to receive mode. See 4.2.8.2 of manual. - possibly switch to https://github.com/SlashDevin/NeoGPS for gps comms - good source of battery/signal/gps icons https://materialdesignicons.com/ - research and implement better mesh algorithm - investigate changing routing to https://github.com/sudomesh/LoRaLayer2 ? diff --git a/platformio.ini b/platformio.ini index 7eb59d9c..c59700dc 100644 --- a/platformio.ini +++ b/platformio.ini @@ -60,7 +60,7 @@ debug_tool = jlink debug_init_break = tbreak setup lib_deps = - https://github.com/meshtastic/RadioHead.git#a87518beacfff53bc2eec5ae33c607713e9596e6 + https://github.com/meshtastic/RadioHead.git#d32df52f8c80eb2525d3774adc1fe36bb4c32952 https://github.com/meshtastic/esp8266-oled-ssd1306.git ; ESP8266_SSD1306 AXP202X_Library SPI diff --git a/src/CustomRF95.cpp b/src/CustomRF95.cpp index 75830fc3..6e158cf8 100644 --- a/src/CustomRF95.cpp +++ b/src/CustomRF95.cpp @@ -19,8 +19,9 @@ CustomRF95::CustomRF95(MemoryPool &_pool, PointerQueue & bool CustomRF95::canSleep() { // We allow initializing mode, because sometimes while testing we don't ever call init() to turn on the hardware - DEBUG_MSG("canSleep, mode=%d, isRx=%d, txEmpty=%d, txGood=%d\n", _mode, _isReceiving, txQueue.isEmpty(), _txGood); - return (_mode == RHModeInitialising || _mode == RHModeIdle || _mode == RHModeRx) && !_isReceiving && txQueue.isEmpty(); + bool isRx = isReceiving(); + DEBUG_MSG("canSleep, mode=%d, isRx=%d, txEmpty=%d, txGood=%d\n", _mode, isRx, txQueue.isEmpty(), _txGood); + return (_mode == RHModeInitialising || _mode == RHModeIdle || _mode == RHModeRx) && !isRx && txQueue.isEmpty(); } bool CustomRF95::sleep() @@ -47,7 +48,7 @@ ErrorCode CustomRF95::send(MeshPacket *p) // We wait _if_ we are partially though receiving a packet (rather than just merely waiting for one). // To do otherwise would be doubly bad because not only would we drop the packet that was on the way in, // we almost certainly guarantee no one outside will like the packet we are sending. - if (_mode == RHModeIdle || (_mode == RHModeRx && !_isReceiving)) { + if (_mode == RHModeIdle || (_mode == RHModeRx && !isReceiving())) { // if the radio is idle, we can send right away DEBUG_MSG("immedate send on mesh (txGood=%d,rxGood=%d,rxBad=%d)\n", txGood(), rxGood(), rxBad()); startSend(p); diff --git a/src/main.cpp b/src/main.cpp index 794020f7..910d45cf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -355,7 +355,7 @@ void loop() loopBLE(); // for debug printing - // service.radio.rf95.canSleep(); + // service.radio.radioIf.canSleep(); #ifdef PMU_IRQ if (pmu_irq) {