Skip to content

Commit

Permalink
[SX126x] Added option to read data even after CRC error
Browse files Browse the repository at this point in the history
  • Loading branch information
jgromes committed Jan 21, 2020
1 parent 75335bd commit 58640e2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/modules/SX126x/SX126x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down

0 comments on commit 58640e2

Please sign in to comment.