From bcbc2f229dadf8c8e2e7d2c4232cb74942a58e02 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Sat, 10 Feb 2024 00:36:16 +0100 Subject: [PATCH] Only cancel packet in Tx queue if it was already sent out via LoRa (#3191) To avoid canceling a transmission if it was already ACKed via MQTT Co-authored-by: Ben Meadors --- src/mesh/ReliableRouter.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mesh/ReliableRouter.cpp b/src/mesh/ReliableRouter.cpp index 946a669cc0..a1e9f281df 100644 --- a/src/mesh/ReliableRouter.cpp +++ b/src/mesh/ReliableRouter.cpp @@ -168,10 +168,14 @@ bool ReliableRouter::stopRetransmission(GlobalPacketId key) auto p = old->packet; auto numErased = pending.erase(key); assert(numErased == 1); - // remove the 'original' (identified by originator and packet->id) from the txqueue and free it - cancelSending(getFrom(p), p->id); - // now free the pooled copy for retransmission too - packetPool.release(p); + /* Only when we already transmitted a packet via LoRa, we will cancel the packet in the Tx queue + to avoid canceling a transmission if it was ACKed super fast via MQTT */ + if (old->numRetransmissions < NUM_RETRANSMISSIONS - 1) { + // remove the 'original' (identified by originator and packet->id) from the txqueue and free it + cancelSending(getFrom(p), p->id); + // now free the pooled copy for retransmission too + packetPool.release(p); + } return true; } else return false;