From 6f2370ff8c3c02e8f511171f06efe704a1ee1294 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 31 Aug 2024 19:39:52 +0200 Subject: [PATCH] [LR11x0] Don't report CRC mismatch if valid header received --- src/modules/LR11x0/LR11x0.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/LR11x0/LR11x0.cpp b/src/modules/LR11x0/LR11x0.cpp index 1a0ac5a2..3deac1c5 100644 --- a/src/modules/LR11x0/LR11x0.cpp +++ b/src/modules/LR11x0/LR11x0.cpp @@ -530,7 +530,8 @@ int16_t LR11x0::readData(uint8_t* data, size_t len) { // check integrity CRC uint32_t irq = getIrqStatus(); int16_t crcState = RADIOLIB_ERR_NONE; - if((irq & RADIOLIB_LR11X0_IRQ_CRC_ERR) || (irq & RADIOLIB_LR11X0_IRQ_HEADER_ERR)) { + // Report CRC mismatch when there's a payload CRC error, or a header error and no valid header (to avoid false alarm from previous packet) + if((irq & RADIOLIB_LR11X0_IRQ_CRC_ERR) || ((irq & RADIOLIB_LR11X0_IRQ_HEADER_ERR) && !(irq & RADIOLIB_LR11X0_IRQ_SYNC_WORD_HEADER_VALID))) { crcState = RADIOLIB_ERR_CRC_MISMATCH; }