diff --git a/src/helpers/radiolib/CustomLLCC68Wrapper.h b/src/helpers/radiolib/CustomLLCC68Wrapper.h index ae0fe0a2..36cde0f6 100644 --- a/src/helpers/radiolib/CustomLLCC68Wrapper.h +++ b/src/helpers/radiolib/CustomLLCC68Wrapper.h @@ -20,6 +20,11 @@ public: } + bool lastRxHadCRC() override { + bool crc = true; + ((CustomLLCC68 *)_radio)->getLoRaRxHeaderInfo(NULL, &crc); + return crc; + } bool isReceivingPacket() override { return ((CustomLLCC68 *)_radio)->isReceiving(); } diff --git a/src/helpers/radiolib/CustomLR1110Wrapper.h b/src/helpers/radiolib/CustomLR1110Wrapper.h index e7aaeb93..66bcb3b4 100644 --- a/src/helpers/radiolib/CustomLR1110Wrapper.h +++ b/src/helpers/radiolib/CustomLR1110Wrapper.h @@ -19,6 +19,11 @@ public: ((CustomLR1110 *)_radio)->setMaxPayloadMillis(pm.payloadMillis); } + bool lastRxHadCRC() override { + bool crc = true; + ((CustomLR1110 *)_radio)->getLoRaRxHeaderInfo(NULL, &crc); + return crc; + } bool isReceivingPacket() override { return ((CustomLR1110 *)_radio)->isReceiving(); } diff --git a/src/helpers/radiolib/CustomLR1121Wrapper.h b/src/helpers/radiolib/CustomLR1121Wrapper.h index 5a754cee..70912f1e 100644 --- a/src/helpers/radiolib/CustomLR1121Wrapper.h +++ b/src/helpers/radiolib/CustomLR1121Wrapper.h @@ -20,6 +20,11 @@ public: } void doResetAGC() override { lr11x0ResetAGC((LR11x0 *)_radio, ((CustomLR1121 *)_radio)->getFreqMHz(), getRxBoostedGainMode()); } + bool lastRxHadCRC() override { + bool crc = true; + ((CustomLR1121 *)_radio)->getLoRaRxHeaderInfo(NULL, &crc); + return crc; + } bool isReceivingPacket() override { return ((CustomLR1121 *)_radio)->isReceiving(); } diff --git a/src/helpers/radiolib/CustomLR2021Wrapper.h b/src/helpers/radiolib/CustomLR2021Wrapper.h index c60bfda3..81c2feac 100644 --- a/src/helpers/radiolib/CustomLR2021Wrapper.h +++ b/src/helpers/radiolib/CustomLR2021Wrapper.h @@ -81,6 +81,11 @@ public: return tSym; } + bool lastRxHadCRC() override { + bool crc = true; + ((CustomLR2021 *)_radio)->getLoRaRxHeaderInfo(NULL, &crc); + return crc; + } bool isReceivingPacket() override { return ((CustomLR2021 *)_radio)->isReceiving(); } diff --git a/src/helpers/radiolib/CustomSTM32WLxWrapper.h b/src/helpers/radiolib/CustomSTM32WLxWrapper.h index a4ba4971..bc93de75 100644 --- a/src/helpers/radiolib/CustomSTM32WLxWrapper.h +++ b/src/helpers/radiolib/CustomSTM32WLxWrapper.h @@ -20,6 +20,11 @@ public: ((CustomSTM32WLx *)_radio)->setMaxPayloadMillis(pm.payloadMillis); } + bool lastRxHadCRC() override { + bool crc = true; + ((CustomSTM32WLx *)_radio)->getLoRaRxHeaderInfo(NULL, &crc); + return crc; + } bool isReceivingPacket() override { return ((CustomSTM32WLx *)_radio)->isReceiving(); } diff --git a/src/helpers/radiolib/CustomSX1262Wrapper.h b/src/helpers/radiolib/CustomSX1262Wrapper.h index f8950f43..ac6f9a7c 100644 --- a/src/helpers/radiolib/CustomSX1262Wrapper.h +++ b/src/helpers/radiolib/CustomSX1262Wrapper.h @@ -23,6 +23,11 @@ public: ((CustomSX1262 *)_radio)->setMaxPayloadMillis(pm.payloadMillis); } + bool lastRxHadCRC() override { + bool crc = true; + ((CustomSX1262 *)_radio)->getLoRaRxHeaderInfo(NULL, &crc); + return crc; + } bool isReceivingPacket() override { return ((CustomSX1262 *)_radio)->isReceiving(); } diff --git a/src/helpers/radiolib/CustomSX1268Wrapper.h b/src/helpers/radiolib/CustomSX1268Wrapper.h index 70f5dabd..ec11f147 100644 --- a/src/helpers/radiolib/CustomSX1268Wrapper.h +++ b/src/helpers/radiolib/CustomSX1268Wrapper.h @@ -23,6 +23,11 @@ public: ((CustomSX1268 *)_radio)->setMaxPayloadMillis(pm.payloadMillis); } + bool lastRxHadCRC() override { + bool crc = true; + ((CustomSX1268 *)_radio)->getLoRaRxHeaderInfo(NULL, &crc); + return crc; + } bool isReceivingPacket() override { return ((CustomSX1268 *)_radio)->isReceiving(); } diff --git a/src/helpers/radiolib/RadioLibWrappers.cpp b/src/helpers/radiolib/RadioLibWrappers.cpp index 6818badf..63ce8a62 100644 --- a/src/helpers/radiolib/RadioLibWrappers.cpp +++ b/src/helpers/radiolib/RadioLibWrappers.cpp @@ -173,6 +173,9 @@ int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) { if (len > 0) { if (len > sz) { len = sz; } int err = _radio->readData(bytes, len); + if (err == RADIOLIB_ERR_NONE && !lastRxHadCRC()) { + err = RADIOLIB_ERR_LORA_HEADER_DAMAGED; // header says no CRC, so the payload was never checked + } if (err != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("RadioLibWrapper: error: readData(%d)", err); len = 0; diff --git a/src/helpers/radiolib/RadioLibWrappers.h b/src/helpers/radiolib/RadioLibWrappers.h index 6b818c72..33462e3f 100644 --- a/src/helpers/radiolib/RadioLibWrappers.h +++ b/src/helpers/radiolib/RadioLibWrappers.h @@ -31,6 +31,7 @@ protected: #endif float packetScoreInt(float snr, int sf, int packet_len); virtual bool isReceivingPacket() =0; + virtual bool lastRxHadCRC() { return true; } virtual void doResetAGC(); public: