mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-14 14:31:24 +00:00
Pass meshtastic_MeshPacket down into startTransmitTimerRebroadcast and getTxDelayMsecWeighted
This commit is contained in:
parent
7e00054fd7
commit
3cc2b70e4f
@ -315,7 +315,7 @@ uint32_t RadioInterface::getTxDelayMsecWeightedWorst(float snr)
|
||||
}
|
||||
|
||||
/** 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)
|
||||
// low SNR = small CW size (Short Delay)
|
||||
|
@ -181,7 +181,7 @@ class RadioInterface
|
||||
uint32_t getTxDelayMsecWeightedWorst(float 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 */
|
||||
virtual void clampToLateRebroadcastWindow(NodeNum from, PacketId id) { return; }
|
||||
|
@ -310,7 +310,7 @@ void RadioLibInterface::setTransmitDelay()
|
||||
// So we want to make sure the other side has had a chance to reconfigure its radio.
|
||||
|
||||
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();
|
||||
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);
|
||||
@ -323,7 +323,7 @@ void RadioLibInterface::setTransmitDelay()
|
||||
} else {
|
||||
// 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);
|
||||
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 (!txQueue.empty()) {
|
||||
uint32_t delay = getTxDelayMsecWeighted(snr);
|
||||
uint32_t delay = getTxDelayMsecWeighted(snr, p);
|
||||
notifyLater(delay, TRANSMIT_DELAY_COMPLETED, false); // This will implicitly enable
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ class RadioLibInterface : public RadioInterface, protected concurrency::Notified
|
||||
* timer scaled to SNR of to be flooded packet
|
||||
* @return Timestamp after which the packet may be sent
|
||||
*/
|
||||
void startTransmitTimerRebroadcast(float snr);
|
||||
void startTransmitTimerRebroadcast(float snr, meshtastic_MeshPacket *p);
|
||||
|
||||
void handleTransmitInterrupt();
|
||||
void handleReceiveInterrupt();
|
||||
|
@ -43,7 +43,7 @@ void SimRadio::setTransmitDelay()
|
||||
} else {
|
||||
// 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);
|
||||
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 (!txQueue.empty()) {
|
||||
uint32_t delayMsec = getTxDelayMsecWeighted(snr);
|
||||
uint32_t delayMsec = getTxDelayMsecWeighted(snr, p);
|
||||
// LOG_DEBUG("xmit timer %d", delay);
|
||||
notifyLater(delayMsec, TRANSMIT_DELAY_COMPLETED, false);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class SimRadio : public RadioInterface, protected concurrency::NotifiedWorkerThr
|
||||
void startTransmitTimer(bool withDelay = true);
|
||||
|
||||
/** timer scaled to SNR of to be flooded packet */
|
||||
void startTransmitTimerRebroadcast(float snr);
|
||||
void startTransmitTimerRebroadcast(float snr, meshtastic_MeshPacket *p);
|
||||
|
||||
void handleTransmitInterrupt();
|
||||
void handleReceiveInterrupt();
|
||||
|
Loading…
Reference in New Issue
Block a user