Skip to content

Commit

Permalink
[SX126x][SX128x][LR11x0] Don't report CRC mismatch if valid header re…
Browse files Browse the repository at this point in the history
…ceived (#1203)

* Enable `HEADER_VALID` IRQ flags by default for receiving

* [SX126x] Don't report CRC mismatch if valid header received

* [SX128x] Don't report CRC mismatch if valid header received

* [LR11x0] Don't report CRC mismatch if valid header received
  • Loading branch information
GUVWAF authored Sep 1, 2024
1 parent bc801c7 commit eda4ec2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/modules/LR11x0/LR11x0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ int16_t LR11x0::readData(uint8_t* data, size_t len) {
// check integrity CRC
uint32_t irq = getIrqStatus();
int16_t crcState = RADIOLIB_ERR_NONE;
if((irq & RADIOLIB_LR11X0_IRQ_CRC_ERR) || (irq & RADIOLIB_LR11X0_IRQ_HEADER_ERR)) {
// Report CRC mismatch when there's a payload CRC error, or a header error and no valid header (to avoid false alarm from previous packet)
if((irq & RADIOLIB_LR11X0_IRQ_CRC_ERR) || ((irq & RADIOLIB_LR11X0_IRQ_HEADER_ERR) && !(irq & RADIOLIB_LR11X0_IRQ_SYNC_WORD_HEADER_VALID))) {
crcState = RADIOLIB_ERR_CRC_MISMATCH;
}

Expand Down
3 changes: 2 additions & 1 deletion src/modules/SX126x/SX126x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,8 @@ int16_t SX126x::readData(uint8_t* data, size_t len) {
// check integrity CRC
uint16_t irq = getIrqFlags();
int16_t crcState = RADIOLIB_ERR_NONE;
if((irq & RADIOLIB_SX126X_IRQ_CRC_ERR) || (irq & RADIOLIB_SX126X_IRQ_HEADER_ERR)) {
// Report CRC mismatch when there's a payload CRC error, or a header error and no valid header (to avoid false alarm from previous packet)
if((irq & RADIOLIB_SX126X_IRQ_CRC_ERR) || ((irq & RADIOLIB_SX126X_IRQ_HEADER_ERR) && !(irq & RADIOLIB_SX126X_IRQ_HEADER_VALID))) {
crcState = RADIOLIB_ERR_CRC_MISMATCH;
}

Expand Down
3 changes: 2 additions & 1 deletion src/modules/SX128x/SX128x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,8 @@ int16_t SX128x::readData(uint8_t* data, size_t len) {
// check integrity CRC
uint16_t irq = getIrqStatus();
int16_t crcState = RADIOLIB_ERR_NONE;
if((irq & RADIOLIB_SX128X_IRQ_CRC_ERROR) || (irq & RADIOLIB_SX128X_IRQ_HEADER_ERROR)) {
// Report CRC mismatch when there's a payload CRC error, or a header error and no valid header (to avoid false alarm from previous packet)
if((irq & RADIOLIB_SX128X_IRQ_CRC_ERROR) || ((irq & RADIOLIB_SX128X_IRQ_HEADER_ERROR) && !(irq & RADIOLIB_SX128X_IRQ_HEADER_VALID))) {
crcState = RADIOLIB_ERR_CRC_MISMATCH;
}

Expand Down
2 changes: 1 addition & 1 deletion src/protocols/PhysicalLayer/PhysicalLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enum RadioLibIrqType_t {
};

// some commonly used default values - defined here to ensure all modules have the same default behavior
#define RADIOLIB_IRQ_RX_DEFAULT_FLAGS ((1UL << RADIOLIB_IRQ_RX_DONE) | (1UL << RADIOLIB_IRQ_TIMEOUT) | (1UL << RADIOLIB_IRQ_CRC_ERR) | (1UL << RADIOLIB_IRQ_HEADER_ERR))
#define RADIOLIB_IRQ_RX_DEFAULT_FLAGS ((1UL << RADIOLIB_IRQ_RX_DONE) | (1UL << RADIOLIB_IRQ_TIMEOUT) | (1UL << RADIOLIB_IRQ_CRC_ERR) | (1UL << RADIOLIB_IRQ_HEADER_VALID) | (1UL << RADIOLIB_IRQ_HEADER_ERR))
#define RADIOLIB_IRQ_RX_DEFAULT_MASK ((1UL << RADIOLIB_IRQ_RX_DONE))
#define RADIOLIB_IRQ_CAD_DEFAULT_FLAGS ((1UL << RADIOLIB_IRQ_CAD_DETECTED) | (1UL << RADIOLIB_IRQ_CAD_DONE))
#define RADIOLIB_IRQ_CAD_DEFAULT_MASK ((1UL << RADIOLIB_IRQ_CAD_DETECTED) | (1UL << RADIOLIB_IRQ_CAD_DONE))
Expand Down

0 comments on commit eda4ec2

Please sign in to comment.