From 07d354fa02e7d9843fac8d22d4db9027165a0044 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Thu, 23 Oct 2025 12:42:36 +0200 Subject: [PATCH] Move airtime calculation to when Tx is complete (#8427) --- src/mesh/RadioLibInterface.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index 2567d9e7f..80e51b8bc 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -289,12 +289,7 @@ void RadioLibInterface::onNotify(uint32_t notification) // actual transmission as short as possible txp = txQueue.dequeue(); assert(txp); - bool sent = startSend(txp); - if (sent) { - // Packet has been sent, count it toward our TX airtime utilization. - uint32_t xmitMsec = getPacketTime(txp); - airTime->logAirtime(TX_LOG, xmitMsec); - } + startSend(txp); LOG_DEBUG("%d packets remain in the TX queue", txQueue.getMaxLen() - txQueue.getFree()); } } @@ -413,6 +408,10 @@ void RadioLibInterface::completeSending() sendingPacket = NULL; if (p) { + // Packet has been sent, count it toward our TX airtime utilization. + uint32_t xmitMsec = getPacketTime(p); + airTime->logAirtime(TX_LOG, xmitMsec); + txGood++; if (!isFromUs(p)) txRelay++;