Skip to content

Commit 0d1f9e9

Browse files
authored
Move some actions to after startTransmit() (#5383)
To minimize the time between channel scan and actual transmit
1 parent 1a06f88 commit 0d1f9e9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/mesh/RadioInterface.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,6 @@ size_t RadioInterface::beginSending(meshtastic_MeshPacket *p)
601601
// LOG_DEBUG("Send queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)", rf95.txGood(), rf95.rxGood(), rf95.rxBad());
602602
assert(p->which_payload_variant == meshtastic_MeshPacket_encrypted_tag); // It should have already been encoded by now
603603

604-
lastTxStart = millis();
605-
606604
radioBuffer.header.from = p->from;
607605
radioBuffer.header.to = p->to;
608606
radioBuffer.header.id = p->id;

src/mesh/RadioLibInterface.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ void RadioLibInterface::onNotify(uint32_t notification)
278278
startReceive(); // try receiving this packet, afterwards we'll be trying to transmit again
279279
setTransmitDelay();
280280
} else {
281-
// Send any outgoing packets we have ready
281+
// Send any outgoing packets we have ready as fast as possible to keep the time between channel scan and
282+
// actual transmission as short as possible
282283
meshtastic_MeshPacket *txp = txQueue.dequeue();
283284
assert(txp);
284285
bool sent = startSend(txp);
@@ -470,7 +471,8 @@ void RadioLibInterface::setStandby()
470471
/** start an immediate transmit */
471472
bool RadioLibInterface::startSend(meshtastic_MeshPacket *txp)
472473
{
473-
printPacket("Start low level send", txp);
474+
/* NOTE: Minimize the actions before startTransmit() to keep the time between
475+
channel scan and actual transmit as low as possible to avoid collisions. */
474476
if (disabled || !config.lora.tx_enabled) {
475477
LOG_WARN("Drop Tx packet because LoRa Tx disabled");
476478
packetPool.release(txp);
@@ -489,6 +491,9 @@ bool RadioLibInterface::startSend(meshtastic_MeshPacket *txp)
489491
completeSending();
490492
powerMon->clearState(meshtastic_PowerMon_State_Lora_TXOn); // Transmitter off now
491493
startReceive(); // Restart receive mode (because startTransmit failed to put us in xmit mode)
494+
} else {
495+
lastTxStart = millis();
496+
printPacket("Started Tx", txp);
492497
}
493498

494499
// Must be done AFTER, starting transmit, because startTransmit clears (possibly stale) interrupt pending register

0 commit comments

Comments
 (0)