Pass meshtastic_MeshPacket down into startTransmitTimerRebroadcast and getTxDelayMsecWeighted

This commit is contained in:
Mike Robbins 2025-09-05 13:53:59 -07:00
parent 7e00054fd7
commit 3cc2b70e4f
6 changed files with 11 additions and 11 deletions

View File

@ -315,7 +315,7 @@ uint32_t RadioInterface::getTxDelayMsecWeightedWorst(float snr)
} }
/** The delay to use when we want to flood a message */ /** The delay to use when we want to flood a message */
uint32_t RadioInterface::getTxDelayMsecWeighted(float snr) uint32_t RadioInterface::getTxDelayMsecWeighted(float snr, meshtastic_MeshPacket *p)
{ {
// high SNR = large CW size (Long Delay) // high SNR = large CW size (Long Delay)
// low SNR = small CW size (Short Delay) // low SNR = small CW size (Short Delay)

View File

@ -181,7 +181,7 @@ class RadioInterface
uint32_t getTxDelayMsecWeightedWorst(float snr); uint32_t getTxDelayMsecWeightedWorst(float snr);
/** The delay to use when we want to flood a message. Use a weighted scale based on SNR */ /** The delay to use when we want to flood a message. Use a weighted scale based on SNR */
uint32_t getTxDelayMsecWeighted(float snr); uint32_t getTxDelayMsecWeighted(float snr, meshtastic_MeshPacket *p);
/** If the packet is not already in the late rebroadcast window, move it there */ /** If the packet is not already in the late rebroadcast window, move it there */
virtual void clampToLateRebroadcastWindow(NodeNum from, PacketId id) { return; } virtual void clampToLateRebroadcastWindow(NodeNum from, PacketId id) { return; }

View File

@ -310,7 +310,7 @@ void RadioLibInterface::setTransmitDelay()
// So we want to make sure the other side has had a chance to reconfigure its radio. // So we want to make sure the other side has had a chance to reconfigure its radio.
if (p->tx_after) { if (p->tx_after) {
unsigned long add_delay = p->rx_rssi ? getTxDelayMsecWeighted(p->rx_snr) : getTxDelayMsec(); unsigned long add_delay = p->rx_rssi ? getTxDelayMsecWeighted(p->rx_snr, p) : getTxDelayMsec();
unsigned long now = millis(); unsigned long now = millis();
p->tx_after = min(max(p->tx_after + add_delay, now + add_delay), now + 2 * getTxDelayMsecWeightedWorst(p->rx_snr)); p->tx_after = min(max(p->tx_after + add_delay, now + add_delay), now + 2 * getTxDelayMsecWeightedWorst(p->rx_snr));
notifyLater(p->tx_after - now, TRANSMIT_DELAY_COMPLETED, false); notifyLater(p->tx_after - now, TRANSMIT_DELAY_COMPLETED, false);
@ -323,7 +323,7 @@ void RadioLibInterface::setTransmitDelay()
} else { } else {
// If there is a SNR, start a timer scaled based on that SNR. // If there is a SNR, start a timer scaled based on that SNR.
LOG_DEBUG("rx_snr found. hop_limit:%d rx_snr:%f", p->hop_limit, p->rx_snr); LOG_DEBUG("rx_snr found. hop_limit:%d rx_snr:%f", p->hop_limit, p->rx_snr);
startTransmitTimerRebroadcast(p->rx_snr); startTransmitTimerRebroadcast(p->rx_snr, p);
} }
} }
@ -336,11 +336,11 @@ void RadioLibInterface::startTransmitTimer(bool withDelay)
} }
} }
void RadioLibInterface::startTransmitTimerRebroadcast(float snr) void RadioLibInterface::startTransmitTimerRebroadcast(float snr, meshtastic_MeshPacket *p)
{ {
// If we have work to do and the timer wasn't already scheduled, schedule it now // If we have work to do and the timer wasn't already scheduled, schedule it now
if (!txQueue.empty()) { if (!txQueue.empty()) {
uint32_t delay = getTxDelayMsecWeighted(snr); uint32_t delay = getTxDelayMsecWeighted(snr, p);
notifyLater(delay, TRANSMIT_DELAY_COMPLETED, false); // This will implicitly enable notifyLater(delay, TRANSMIT_DELAY_COMPLETED, false); // This will implicitly enable
} }
} }

View File

@ -161,7 +161,7 @@ class RadioLibInterface : public RadioInterface, protected concurrency::Notified
* timer scaled to SNR of to be flooded packet * timer scaled to SNR of to be flooded packet
* @return Timestamp after which the packet may be sent * @return Timestamp after which the packet may be sent
*/ */
void startTransmitTimerRebroadcast(float snr); void startTransmitTimerRebroadcast(float snr, meshtastic_MeshPacket *p);
void handleTransmitInterrupt(); void handleTransmitInterrupt();
void handleReceiveInterrupt(); void handleReceiveInterrupt();

View File

@ -43,7 +43,7 @@ void SimRadio::setTransmitDelay()
} else { } else {
// If there is a SNR, start a timer scaled based on that SNR. // If there is a SNR, start a timer scaled based on that SNR.
LOG_DEBUG("rx_snr found. hop_limit:%d rx_snr:%f", p->hop_limit, p->rx_snr); LOG_DEBUG("rx_snr found. hop_limit:%d rx_snr:%f", p->hop_limit, p->rx_snr);
startTransmitTimerRebroadcast(p->rx_snr); startTransmitTimerRebroadcast(p->rx_snr, p);
} }
} }
@ -57,11 +57,11 @@ void SimRadio::startTransmitTimer(bool withDelay)
} }
} }
void SimRadio::startTransmitTimerRebroadcast(float snr) void SimRadio::startTransmitTimerRebroadcast(float snr, meshtastic_MeshPacket *p)
{ {
// If we have work to do and the timer wasn't already scheduled, schedule it now // If we have work to do and the timer wasn't already scheduled, schedule it now
if (!txQueue.empty()) { if (!txQueue.empty()) {
uint32_t delayMsec = getTxDelayMsecWeighted(snr); uint32_t delayMsec = getTxDelayMsecWeighted(snr, p);
// LOG_DEBUG("xmit timer %d", delay); // LOG_DEBUG("xmit timer %d", delay);
notifyLater(delayMsec, TRANSMIT_DELAY_COMPLETED, false); notifyLater(delayMsec, TRANSMIT_DELAY_COMPLETED, false);
} }

View File

@ -64,7 +64,7 @@ class SimRadio : public RadioInterface, protected concurrency::NotifiedWorkerThr
void startTransmitTimer(bool withDelay = true); void startTransmitTimer(bool withDelay = true);
/** timer scaled to SNR of to be flooded packet */ /** timer scaled to SNR of to be flooded packet */
void startTransmitTimerRebroadcast(float snr); void startTransmitTimerRebroadcast(float snr, meshtastic_MeshPacket *p);
void handleTransmitInterrupt(); void handleTransmitInterrupt();
void handleReceiveInterrupt(); void handleReceiveInterrupt();