From 207d421fca1f0200628a1dd21cc120f3da88c072 Mon Sep 17 00:00:00 2001 From: Andre K Date: Tue, 6 Jun 2023 19:33:51 -0300 Subject: [PATCH] refactor tx delay calculation for routers and non-routers (#2542) --- src/mesh/RadioInterface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 1eee86c8e..00af93e15 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -232,7 +232,8 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr) delay = random(0, 2 * CWsize) * slotTimeMsec; LOG_DEBUG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay); } else { - delay = random(0, pow(2, CWsize)) * slotTimeMsec; + // offset the maximum delay for routers: (2 * CWmax * slotTimeMsec) + delay = (2 * CWmax * slotTimeMsec) + random(0, pow(2, CWsize)) * slotTimeMsec; LOG_DEBUG("rx_snr found in packet. Setting tx delay:%d\n", delay); }