ElectronicCats / Beelan-LoRaWAN

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

Unable to Receive Join Accept #125

Closed butterken closed 2 years ago

butterken commented 2 years ago

I am using Heltec Wifi LoRa 32 V2 with LoRa Baud AS923. I have chirpstack server to handle join request. I successfully deploy the program to the board and it is able to send join request to server. I can view my join request on chirpstack lorawan frames. The server did show up the join accept frames but my device cannot receive the join accept message. I have tried to use Heltec ESP32 LoRaWAN library (the Heltec library is incompatible to what I want to do and hence, I'm finding other solution) to test and it join noramlly, so the server should works fine.

I have go deep on your library and take a look on LoRaMAC.cpp:539 , LORA_join_Accept function. I add code to the library inorder to print some of the variable for debug. Below is my finding:

In 99% of the time, Message_Status == TIMEOUT and return false. And I find that when the Message_Status == CRC_OK, RFM_Data[0] prints 128, which result skipping the code inside if statement.

Any idea for this issue?

IoTThinks commented 2 years ago

I can join fine in AS923-2.

  1. Likely having frequency mismatch for the first two frequencies (for OTAA).
  2. Double check the pin mapping for DIO0, 1 and 2.
ajmcalvo commented 2 years ago

Read lorawan-arduino-rfm.cpp: join (157-176). It has been established a timeout of 6 seconds. It's recommended by LoRaWAN specification that JOIN_ACCEPT_DELAY1 = 5s and JOIN_ACCEPT_DELAY2 = 6s. So it seems that we are following the rules but, what happens with times of flight (join request and response) and time nedded to process (gateway bridge ->networkserver->application server and back)?. It may be that we get the join accept after the established timeout of 6 seconds. So, as it is guaranteed that we never will receive the join response before 5 s we can add a first timeout. It must be safe any value between 1 - 3 seconds. In line 167 there is a commented delay of 900 ms. I had the same problem but uncommenting that line it works like a charm. You can add more time, cutting down the number of loops (line 170)

chansheunglong commented 2 years ago

Reporting the same issue when joining on AS923 using TTN as the network server, I am able to send a join request and I can confirm TTN received and accepted, as shown below image However, the program is stuck at Joining..., which means the downlink from TTN was never received by the program, the same board function normally with MCCI's LoRaWAN Library so I don't think there's connection issue for me.

xpeqex commented 2 years ago

Hello @butterken! Thank you for contacting ElectronicCats Support Team, To help us to understand your situation, we would like to ask you for the following additional information:

Have a nice day! Kind Regards!

xpeqex commented 2 years ago

Hi @butterken Let us know if the problem remains or if you need more time to test!

Have a nice day!