From 89e405eebad21b3e37a6c76aba903459e2bf73ec Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 8 Jul 2023 09:37:43 +0200 Subject: [PATCH] [LoRaWAN] Fixes for SX127x series --- src/protocols/LoRaWAN/LoRaWAN.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/protocols/LoRaWAN/LoRaWAN.cpp b/src/protocols/LoRaWAN/LoRaWAN.cpp index 734c9b8d..ecaf4465 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.cpp +++ b/src/protocols/LoRaWAN/LoRaWAN.cpp @@ -89,6 +89,7 @@ int16_t LoRaWANNode::beginOTAA(uint64_t appEUI, uint64_t devEUI, uint8_t* nwkKey // start receiving uint32_t start = mod->hal->millis(); + downlinkReceived = false; state = this->phyLayer->startReceive(); RADIOLIB_ASSERT(state); @@ -119,7 +120,11 @@ int16_t LoRaWANNode::beginOTAA(uint64_t appEUI, uint64_t devEUI, uint8_t* nwkKey // read the packet state = this->phyLayer->readData(joinAcceptMsgEnc, lenRx); - RADIOLIB_ASSERT(state); + // downlink frames are sent without CRC, which will raise error on SX127x + // we can ignore that error + if(state != RADIOLIB_ERR_LORA_HEADER_DAMAGED) { + RADIOLIB_ASSERT(state); + } // check reply message type if((joinAcceptMsgEnc[0] & RADIOLIB_LORAWAN_MHDR_MTYPE_MASK) != RADIOLIB_LORAWAN_MHDR_MTYPE_JOIN_ACCEPT) {