From f68bef287735a44c6232b31d15ad10d95d6120d1 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 16 Nov 2022 19:21:52 +0100 Subject: [PATCH] [PHY] Added option to keep received data despite CRC error --- src/protocols/PhysicalLayer/PhysicalLayer.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.cpp b/src/protocols/PhysicalLayer/PhysicalLayer.cpp index 1d414ac4..611425e8 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.cpp +++ b/src/protocols/PhysicalLayer/PhysicalLayer.cpp @@ -83,7 +83,9 @@ int16_t PhysicalLayer::readData(String& str, size_t len) { // read the received data state = readData(data, length); - if(state == RADIOLIB_ERR_NONE) { + // any of the following leads to at least some data being available + // let's leave the decision of whether to keep it or not up to the user + if((state == RADIOLIB_ERR_NONE) || (state == RADIOLIB_ERR_CRC_MISMATCH) || (state == RADIOLIB_ERR_LORA_HEADER_DAMAGED)) { // add null terminator data[length] = 0; @@ -123,7 +125,9 @@ int16_t PhysicalLayer::receive(String& str, size_t len) { // attempt packet reception state = receive(data, length); - if(state == RADIOLIB_ERR_NONE) { + // any of the following leads to at least some data being available + // let's leave the decision of whether to keep it or not up to the user + if((state == RADIOLIB_ERR_NONE) || (state == RADIOLIB_ERR_CRC_MISMATCH) || (state == RADIOLIB_ERR_LORA_HEADER_DAMAGED)) { // read the number of actually received bytes (for unknown packets) if(len == 0) { length = getPacketLength(false);