ElectronicCats / Beelan-LoRaWAN

A LoRaWAN library for compatible arduino board
https://www.beelan.mx
MIT License
185 stars 75 forks source link

Downlink no longer works #197

Open IoTThinks opened 1 month ago

IoTThinks commented 1 month ago

The device can join LoRaWAN network and I can send a downlink packet. image

The device "hears" something but can not print it.

image

Last year, I tested downlink ok. I suspect the new code broke the downlink. https://github.com/ElectronicCats/Beelan-LoRaWAN/blob/master/src/arduino-rfm/lorawan-arduino-rfm.cpp#L506

Andermutu commented 2 weeks ago

Hi @IoTThinks

I am facing a similar issue, I am unable to receive downlink messages. In my case, I don't even get the "Data received over RX1" message. Is downlink broken? Did you find a solution?

ghost commented 2 weeks ago

I have two things conserning this same type of observation. First, I use TheThingsNetwork TTN V3.

Hardware setup: Heltec WiFi Lora V2 hardware and bare otaa example from lib. Uplink functionality is flawless. However downlink does not work unless two things are changed. First in file LoRa-arduino-rfm.cpp line 115 I have changed: LoRa_Settings.Rx1_Delay = 5000; // Thing stack seems to be 5000 ms (so Rx2_delay 6000 ms) LoRa_Settings.Rx2_Delay = 6000; // Rx2_Delay >= Rx1_Delay + RX1_Window This to be compliant to TTN V3 ( tried to change ttn to 1000 mS but does not work and device will not join network with 1000mS in RX1 delay) Second change: In update() methode //Type A mote transmit receive cycle: if (Buffer_Rx.Counter != 0x00) { bool isConfirmed = ((Message_Rx.MAC_Header & 0xE0)>>5) == 5 ? true : false ; // MType uint8_t fPort = Message_Rx.Frame_Port; if(lora.messageCallback) lora.messageCallback(&Buffer_Rx, isConfirmed, fPort); //Buffer_Rx.Counter = 0x00; // clear counter for the next cycle Rx_Status = NEW_RX; Serial.println("Data received over RX1");

    }

Bold is required change, this is by no means the ’true fix’ but now it works for me. The only part I don’t understand is that the port is not having any effect or reflected in recv event. I would have expected som kind of port to be reflected in readData(outStr,fPort) or similar construction.

Andermutu commented 2 weeks ago

I have two things conserning this same type of observation. First, I use TheThingsNetwork TTN V3.

Hardware setup: Heltec WiFi Lora V2 hardware and bare otaa example from lib. Uplink functionality is flawless. However downlink does not work unless two things are changed. First in file LoRa-arduino-rfm.cpp line 115 I have changed: LoRa_Settings.Rx1_Delay = 5000; // Thing stack seems to be 5000 ms (so Rx2_delay 6000 ms) LoRa_Settings.Rx2_Delay = 6000; // Rx2_Delay >= Rx1_Delay + RX1_Window This to be compliant to TTN V3 ( tried to change ttn to 1000 mS but does not work and device will not join network with 1000mS in RX1 delay) Second change: In update() methode //Type A mote transmit receive cycle: if (Buffer_Rx.Counter != 0x00) { bool isConfirmed = ((Message_Rx.MAC_Header & 0xE0)>>5) == 5 ? true : false ; // MType uint8_t fPort = Message_Rx.Frame_Port; if(lora.messageCallback) lora.messageCallback(&Buffer_Rx, isConfirmed, fPort); //Buffer_Rx.Counter = 0x00; // clear counter for the next cycle Rx_Status = NEW_RX; Serial.println("Data received over RX1");

    }

Bold is required change, this is by no means the ’true fix’ but now it works for me. The only part I don’t understand is that the port is not having any effect or reflected in recv event. I would have expected som kind of port to be reflected in readData(outStr,fPort) or similar construction.

Thank you, that fixes the issue. I have checked the release of July 2023, and the downlinks were working. Buffer_Rx.Counter = 0x00; was reset on the readData function and not on the update function (image of July 2023 release attached). I have also included some modifications to make easier decoding from cayenneLPP to JSON. I can confirm that with this modification the downlinks are working. I think this project is much easier to use and modify compared to LMIC, and should keep improving. Thanks.

Captura desde 2024-06-17 17-15-31

Captura desde 2024-06-17 17-18-11

REGIOIGER commented 5 days ago

Thanks IoTThinks and Andermutu. Your contributions are appreciated and we will continue to work to improve the library.