sandeepmistry / arduino-LoRa

An Arduino library for sending and receiving data using LoRa radios.
MIT License
1.61k stars 620 forks source link

Corrupted header may let corrupted packets to go through even CRC is enable? #443

Open IoTThinks opened 3 years ago

IoTThinks commented 3 years ago

I realized even I enableCrc(), visibble corrupted packets are still received. Possible reason is due to corrupted header.

    // check packet header integrity
    if(_crcEnabled && (_mod->SPIgetRegValue(SX127X_REG_HOP_CHANNEL, 6, 6)) == 0) {
      // CRC is disabled according to packet header and enabled according to user
      // most likely damaged packet header
      clearIRQFlags();
      return(ERR_LORA_HEADER_DAMAGED);
    }

Ref: https://github.com/jgromes/RadioLib/pull/111#issuecomment-725713815 https://github.com/jgromes/RadioLib/issues/200

engeen-nl commented 2 years ago

Nice find! However, how do we implement this in the current LoRa.cpp? Can we add another condition on line 237?

if ((irqFlags & IRQ_RX_DONE_MASK) && (irqFlags & IRQ_PAYLOAD_CRC_ERROR_MASK) == 0) {
    // received a packet