From 235fdb16376883b9d2091409c2f3c0e1da1c84d8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 2 Feb 2020 11:13:23 +0100 Subject: [PATCH] [SX126x] Fixed implicit timeout workaround applied in explicit mode --- src/modules/SX126x/SX126x.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 1f18a617..46d311cb 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -286,9 +286,11 @@ int16_t SX126x::receive(uint8_t* data, size_t len) { } } - // timeout fix is recommended after any reception with active timeout - state = fixImplicitTimeout(); - RADIOLIB_ASSERT(state); + // fix timeout in implicit LoRa mode + if(((_headerType == SX126X_LORA_HEADER_IMPLICIT) && (getPacketType() == SX126X_PACKET_TYPE_LORA))) { + state = fixImplicitTimeout(); + RADIOLIB_ASSERT(state); + } // read the received data return(readData(data, len)); @@ -1402,6 +1404,11 @@ int16_t SX126x::fixImplicitTimeout() { // fixes timeout in implicit header mode // see SX1262/SX1268 datasheet, chapter 15 Known Limitations, section 15.3 for details + //check if we're in implicit LoRa mode + if(!((_headerType == SX126X_LORA_HEADER_IMPLICIT) && (getPacketType() == SX126X_PACKET_TYPE_LORA))) { + return(ERR_WRONG_MODEM); + } + // stop RTC counter uint8_t rtcStop = 0x00; int16_t state = writeRegister(SX126X_REG_RTC_STOP, &rtcStop, 1);