rx_boost state is undefined at boot (minor fix)

every LBT-retried flood packet loses its priority (fixed)
witching between LBT and non-LBT mode (or any cad.mode change) could silently skip full reconfiguration and leave the radio in the wrong mode (fixed)
This commit is contained in:
liquidraver
2026-05-08 09:50:52 +02:00
parent 66f7b8508f
commit 6919c3511c
5 changed files with 36 additions and 3 deletions
+7 -2
View File
@@ -28,6 +28,7 @@ Dispatcher::Dispatcher(Radio &radio, MillisecondClock &ms, PacketManager &mgr)
: _radio(&radio), _ms(&ms), _mgr(&mgr)
{
outbound = nullptr;
outbound_priority = 0;
total_air_time = rx_air_time = 0;
next_tx_time = 0;
cad_busy_start = 0;
@@ -410,6 +411,10 @@ void Dispatcher::checkSend()
}
cad_busy_start = 0;
/* Snapshot the priority of the packet we're about to dequeue so it
* can be preserved if the send attempt fails and we need to re-queue.
* Must be called before getNextOutbound() removes the entry. */
outbound_priority = _mgr->peekNextOutboundPriority(now);
outbound = _mgr->getNextOutbound(now);
if (outbound) {
uint8_t raw[MAX_TRANS_UNIT];
@@ -460,7 +465,7 @@ void Dispatcher::checkSend()
LOG_DBG("checkSend: final gate blocked TX (isReceiving=%d, isRadioReady=%d, inRecvMode=%d)",
(int)final_is_receiving, (int)final_is_radio_ready,
(int)_radio->isInRecvMode());
_mgr->queueOutbound(outbound, 0, futureMillis((int)retry));
_mgr->queueOutbound(outbound, outbound_priority, futureMillis((int)retry));
outbound = nullptr;
if (_tx_queued_cb) {
_tx_queued_cb(retry, _tx_queued_user_data);
@@ -473,7 +478,7 @@ void Dispatcher::checkSend()
uint32_t retry = getCADFailRetryDelay();
LOG_ERR("checkSend: startSendRaw failed! re-queuing delay=%u", retry);
logTxFail(outbound, outbound->getRawLength());
_mgr->queueOutbound(outbound, 0, futureMillis((int)retry));
_mgr->queueOutbound(outbound, outbound_priority, futureMillis((int)retry));
outbound = nullptr;
if (_tx_queued_cb) {
_tx_queued_cb(retry, _tx_queued_user_data);
+16
View File
@@ -96,6 +96,17 @@ struct PacketQueue {
return (i < _num) ? _schedule_table[i] : 0;
}
/* Priority of the next packet that get(now) would return, without
* removing it. Returns 0xFF if no due packet exists. */
uint8_t peekPriority(uint32_t now) const {
uint8_t best = 0xFF;
for (int j = 0; j < _num; j++) {
if ((int32_t)(_schedule_table[j] - now) > 0) continue;
if (_pri_table[j] < best) best = _pri_table[j];
}
return best;
}
bool reschedule(int i, uint32_t new_scheduled_for) {
if (i >= _num) return false;
_schedule_table[i] = new_scheduled_for;
@@ -193,6 +204,11 @@ bool StaticPoolPacketManager::rescheduleOutbound(int i, uint32_t new_scheduled_f
return _send_queue.reschedule(i, new_scheduled_for);
}
uint8_t StaticPoolPacketManager::peekNextOutboundPriority(uint32_t now) const
{
return _send_queue.peekPriority(now);
}
void StaticPoolPacketManager::queueInbound(Packet *packet, uint32_t scheduled_for)
{
if (!_rx_queue.add(packet, 0, scheduled_for)) {