CongducPham / LowCostLoRaGw

Low-cost LoRa IoT & gateway with SX12XX (SX1261/62/68; SX1272/76/77/78/79; SX1280/81), RaspberryPI and Arduino boards
696 stars 352 forks source link

LoRaWAN downlink message frequency/sf/bw #276

Open dolfandringa opened 4 years ago

dolfandringa commented 4 years ago

I am trying to get lorawan support working. I have setup a local chirpstack instance, with chirpstack-network-server chirpstack-application-server and chirpstack-gateway-bridge running. I can send messages using ADP from the node to chirpstack, and I can also enqueue downlink messages for the node in chirpstack. Those messages are received by the scripts/lorawan_stats/lorawan_downlink.py script, and written to downlink.txt. I also see them turn up in the lora_gateway.cpp that shows

LoRaWAN downlink request
Target RX1
downlink send: 2216741
Packet sent, state 0
Normal I/Q: state 0

so it seems to send the packet successfully? But I don't see it turn up in the node. I think this has to do with the frequency/sf/bw for downlink messages. The LoRaWAN frequency plan defines other channels for downlink messages then for uplink messages. https://www.thethingsnetwork.org/docs/lorawan/frequency-plans.html I am using the us915 band and on the node side I use arduino_lmic. I can disable certain channels there so I can make sure the library works for the single channel gateway. So how do I make sure that the lora_gateway indeed switches to the right frequency/sf/bw for the downlink message? The downlink message itself does specify a frequency in the downlink message from the network server:

{"txpk":{"imme":false,"rfch":0,"powe":20,"ant":0,"brd":0,"tmst":2476848556,"freq":926.9,"modu":"LORA","datr":"SF7BW500","codr":"4/5","ipol":true,"size":30,"data":"YHwZBCaAOwAAoRxMHHFcpnLYIu7YMuv8Bli0kHt3"}}

Here it says to switch to 926.9MHz for the downlink message. Is that implemented in the gateway? Or is the gateway using the same frequency/sf/BW as the uplink message to send the downlink message?

CongducPham commented 4 years ago

Hi, unfortunately, we do not support the 900 us band because we do not support the required channel hopping mechanism. Then, for 900 band that are not for US, there are several cases for RX2 depending on the countries so this is not completely implemented. If you look in lora_gateway.cpp on line 1170, you will see that we did not set a frequency for RX2. Now, if RX1 is targeted then AS920-923 and AS923-925 can be easily supported by setting the the downlink to 923.2 - SF10BW125. Hope that helps.