From ce673b29395da9906d9e739cb7a1eb1beea4bb60 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Thu, 26 Sep 2024 20:57:26 +0200 Subject: [PATCH] [SX127x] Fix missing CRC mismatch error (#1236) --- src/modules/SX127x/SX127x.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index b43bf6f3..1397e57c 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -672,12 +672,11 @@ int16_t SX127x::readData(uint8_t* data, size_t len) { // CRC is disabled according to packet header and enabled according to user // most likely damaged packet header state = RADIOLIB_ERR_LORA_HEADER_DAMAGED; - } else { - // set FIFO read pointer to the start of the current packet - state = this->mod->SPIgetRegValue(RADIOLIB_SX127X_REG_FIFO_RX_CURRENT_ADDR); - if (state >= 0) { - state = this->mod->SPIsetRegValue(RADIOLIB_SX127X_REG_FIFO_ADDR_PTR, state); - } + } + // set FIFO read pointer to the start of the current packet + int16_t addr = this->mod->SPIgetRegValue(RADIOLIB_SX127X_REG_FIFO_RX_CURRENT_ADDR); + if (addr >= 0) { + this->mod->SPIsetRegValue(RADIOLIB_SX127X_REG_FIFO_ADDR_PTR, addr); } } else if(modem == RADIOLIB_SX127X_FSK_OOK) {