From 6fdf3fe33da048b3a874c9c31d5564be69c4f5c7 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 31 Aug 2024 19:39:40 +0200 Subject: [PATCH] [SX128x] Don't report CRC mismatch if valid header received --- src/modules/SX128x/SX128x.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 6ee188eb..250445a3 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -638,7 +638,8 @@ int16_t SX128x::readData(uint8_t* data, size_t len) { // check integrity CRC uint16_t irq = getIrqStatus(); int16_t crcState = RADIOLIB_ERR_NONE; - if((irq & RADIOLIB_SX128X_IRQ_CRC_ERROR) || (irq & RADIOLIB_SX128X_IRQ_HEADER_ERROR)) { + // 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_SX128X_IRQ_CRC_ERROR) || ((irq & RADIOLIB_SX128X_IRQ_HEADER_ERROR) && !(irq & RADIOLIB_SX128X_IRQ_HEADER_VALID))) { crcState = RADIOLIB_ERR_CRC_MISMATCH; }