Preserve new SX126x reception after a stale ESP32 interrupt

This commit is contained in:
mikecarper committed 2026-10-22 01:32:48 -07:00
1 parent 3bae811ecd
commit a5293fa50b
2 files changed
+161 -5

No files matched your search

+11 -1
View File
@@ -2344,7 +2344,8 @@ int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) {
#endif
if (claimRadioInterrupt()) {
last_radio_interrupt_millis = millis(); // ISR fired -> radio hardware is alive
if (isPacketReady()) {
const bool packet_ready = isPacketReady();
if (packet_ready) {
#if defined(USE_LR2021)
// The LR2021 base reader clears FIFO/IRQs while otherwise staying in
// continuous RX. Freeze reception before taking length/status/FIFO
@@ -2384,6 +2385,15 @@ int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) {
}
// Retry a transient IRQ-status probe before rearming/clearing hardware.
if (_loop_event_pending) return 0;
#if defined(ESP32_PLATFORM) && (MESH_RADIO_PROFILE_CHIP == 1262 \
|| MESH_RADIO_PROFILE_CHIP == 1268 || MESH_RADIO_PROFILE_CHIP == 68)
// DIO may reveal RX_DONE before its edge ISR publishes. Servicing that
// packet can leave a late software event for an already-cleared IRQ.
// Its bounded empty probes must not restart RX over a newer packet.
// Keep the normal activity timeouts and inactive/error rearm behavior.
if (!packet_ready && state == STATE_RX && !_rx_ps_armed
&& !isChipBusy() && isReceivingPacket()) return 0;
#endif
#if defined(USE_LR2021)
// An early FIFO/SPI failure must not leave RX_DONE asserted. Standby also
// covers spurious events for which no packet was read. No new hardware RX