Skip to content

Commit

Permalink
Fire TXdone when TLM forced off too
Browse files Browse the repository at this point in the history
  • Loading branch information
CapnBry committed Jun 13, 2024
1 parent 8b606e1 commit 6b31c4b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
5 changes: 4 additions & 1 deletion src/lib/LBT/LBT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ void ICACHE_RAM_ATTR SetClearChannelAssessmentTime(void)

SX12XX_Radio_Number_t ICACHE_RAM_ATTR ChannelIsClear(SX12XX_Radio_Number_t radioNumber)
{
if (radioNumber == SX12XX_Radio_NONE)
return SX12XX_Radio_NONE;

LBTSuccessCalc.inc(); // Increment count for every channel check

if (!LBTEnabled)
Expand Down Expand Up @@ -161,7 +164,7 @@ SX12XX_Radio_Number_t ICACHE_RAM_ATTR ChannelIsClear(SX12XX_Radio_Number_t radio
clearChannelsMask |= SX12XX_Radio_2;
}
}

// Useful to debug if and how long the rssi wait is, and rssi threshold rssiCutOff
// DBGLN("wait: %d, cutoff: %d, rssi: %d %d, %s", validRSSIdelayUs - elapsed, rssiCutOff, rssiInst1, rssiInst2, clearChannelsMask ? "clear" : "in use");

Expand Down
32 changes: 18 additions & 14 deletions src/src/rx_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,27 +507,31 @@ bool ICACHE_RAM_ATTR HandleSendTelemetryResponse()

OtaGeneratePacketCrc(&otaPkt);

SX12XX_Radio_Number_t transmittingRadio = geminiMode ? SX12XX_Radio_All : Radio.GetLastSuccessfulPacketRadio();

SX12XX_Radio_Number_t transmittingRadio;
if (config.GetForceTlmOff())
{
transmittingRadio = SX12XX_Radio_NONE;
}
else if (geminiMode)
{
transmittingRadio = SX12XX_Radio_All;
}
else
{
transmittingRadio = Radio.GetLastSuccessfulPacketRadio();
}
#if defined(Regulatory_Domain_EU_CE_2400)
transmittingRadio &= ChannelIsClear(transmittingRadio); // weed out the radio(s) if channel in use
#endif

Radio.TXnb((uint8_t*)&otaPkt, ExpressLRS_currAirRate_Modparams->PayloadLength, transmittingRadio);

if (transmittingRadio == SX12XX_Radio_NONE)
{
// No packet will be sent due to LBT.
// No packet will be sent due to LBT / Telem forced off.
// Defer TXdoneCallback() to prepare for TLM when the IRQ is normally triggered.
deferExecutionMicros(ExpressLRS_currAirRate_RFperfParams->TOA, []() {
Radio.TXdoneCallback();
});
deferExecutionMicros(ExpressLRS_currAirRate_RFperfParams->TOA, Radio.TXdoneCallback);
}
#endif

if (config.GetForceTlmOff())
{
transmittingRadio = SX12XX_Radio_NONE;
}

Radio.TXnb((uint8_t*)&otaPkt, ExpressLRS_currAirRate_Modparams->PayloadLength, transmittingRadio);

return true;
}
Expand Down

0 comments on commit 6b31c4b

Please sign in to comment.