Move some actions to after startTransmit() (#5383)

To minimize the time between channel scan and actual transmit
This commit is contained in:
GUVWAF 2024-11-17 17:51:01 +01:00 committed by GitHub
parent 1a06f88dfb
commit 0d1f9e915f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View File

@ -601,8 +601,6 @@ size_t RadioInterface::beginSending(meshtastic_MeshPacket *p)
// LOG_DEBUG("Send queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)", rf95.txGood(), rf95.rxGood(), rf95.rxBad()); // LOG_DEBUG("Send queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)", rf95.txGood(), rf95.rxGood(), rf95.rxBad());
assert(p->which_payload_variant == meshtastic_MeshPacket_encrypted_tag); // It should have already been encoded by now assert(p->which_payload_variant == meshtastic_MeshPacket_encrypted_tag); // It should have already been encoded by now
lastTxStart = millis();
radioBuffer.header.from = p->from; radioBuffer.header.from = p->from;
radioBuffer.header.to = p->to; radioBuffer.header.to = p->to;
radioBuffer.header.id = p->id; radioBuffer.header.id = p->id;

View File

@ -278,7 +278,8 @@ void RadioLibInterface::onNotify(uint32_t notification)
startReceive(); // try receiving this packet, afterwards we'll be trying to transmit again startReceive(); // try receiving this packet, afterwards we'll be trying to transmit again
setTransmitDelay(); setTransmitDelay();
} else { } else {
// Send any outgoing packets we have ready // Send any outgoing packets we have ready as fast as possible to keep the time between channel scan and
// actual transmission as short as possible
meshtastic_MeshPacket *txp = txQueue.dequeue(); meshtastic_MeshPacket *txp = txQueue.dequeue();
assert(txp); assert(txp);
bool sent = startSend(txp); bool sent = startSend(txp);
@ -470,7 +471,8 @@ void RadioLibInterface::setStandby()
/** start an immediate transmit */ /** start an immediate transmit */
bool RadioLibInterface::startSend(meshtastic_MeshPacket *txp) bool RadioLibInterface::startSend(meshtastic_MeshPacket *txp)
{ {
printPacket("Start low level send", txp); /* NOTE: Minimize the actions before startTransmit() to keep the time between
channel scan and actual transmit as low as possible to avoid collisions. */
if (disabled || !config.lora.tx_enabled) { if (disabled || !config.lora.tx_enabled) {
LOG_WARN("Drop Tx packet because LoRa Tx disabled"); LOG_WARN("Drop Tx packet because LoRa Tx disabled");
packetPool.release(txp); packetPool.release(txp);
@ -489,6 +491,9 @@ bool RadioLibInterface::startSend(meshtastic_MeshPacket *txp)
completeSending(); completeSending();
powerMon->clearState(meshtastic_PowerMon_State_Lora_TXOn); // Transmitter off now powerMon->clearState(meshtastic_PowerMon_State_Lora_TXOn); // Transmitter off now
startReceive(); // Restart receive mode (because startTransmit failed to put us in xmit mode) startReceive(); // Restart receive mode (because startTransmit failed to put us in xmit mode)
} else {
lastTxStart = millis();
printPacket("Started Tx", txp);
} }
// Must be done AFTER, starting transmit, because startTransmit clears (possibly stale) interrupt pending register // Must be done AFTER, starting transmit, because startTransmit clears (possibly stale) interrupt pending register