From 58640e280145dfb58b925b737b83a84b0b2ff362 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 21 Jan 2020 15:29:05 +0100 Subject: [PATCH] [SX126x] Added option to read data even after CRC error --- src/modules/SX126x/SX126x.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index fde974a39..9498544ce 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -534,9 +534,10 @@ int16_t SX126x::readData(uint8_t* data, size_t len) { // check integrity CRC uint16_t irq = getIrqStatus(); + int16_t crcState = ERR_NONE; if((irq & SX126X_IRQ_CRC_ERR) || (irq & SX126X_IRQ_HEADER_ERR)) { clearIrqStatus(); - return(ERR_CRC_MISMATCH); + crcState = ERR_CRC_MISMATCH; } // get packet length @@ -552,6 +553,9 @@ int16_t SX126x::readData(uint8_t* data, size_t len) { // clear interrupt flags state = clearIrqStatus(); + // check if CRC failed - this is done after reading data to give user the option to keep them + RADIOLIB_ASSERT(crcState); + return(state); }