jgromes/RadioLib

LoRaWAN: maxPayLen calculation for downlink is incorrect

Closed this issue · 3 comments

tve commented

The calculation of the maxPayLen https://github.com/jgromes/RadioLib/blob/master/src/protocols/LoRaWAN/LoRaWAN.cpp#L1401 is incorrect: it uses the uplink DR instead of the downlink DR. This makes a big difference in the US915 region where, for example, a JOIN uplink at DR0 with max 19 bytes is followed by a JOIN ACCEPT at DR10 with max 250 bytes payload. This was preventing my device from joining 'cause the join accept was 33 bytes long and maxPayLen was set to 32 (19+13).
The correct calculation as far as I can tell is:

  uint8_t maxPayLen = this->band->payloadLenMax[dlChannels[window].dr];

Hi @tve, that is indeed a problem, thanks for reporting and finding the actual problem! Just this weekend, I finally got my hands on a 915-gateway which means that I will now be able to verify stuff much easier (instead of going through a remote shell, flashing someone else's device without physical access and with resetting connections). I hope to do a proper testing round this or next week, and will start by fixing this. If you don't mind, I'll leave this issue open until then.

Had a couple of hours spare tonight, thanks and fixed @tve.

I'm very sorry, but this commit introduces a failure at least in EU868. After a view uplinks (the number of uplinks working is not always the same - ranges from four to seven or eight) node.sendReceive returns with error -12.

[LoRaWAN] Constructing uplink
[LoRaWAN] Sending: 48.264775,14.441480,263.100000,2.890000
Error in sendReceive(-12)

Going back one commit and everything is fine!

Currently, I didn't have enough resources to debug this issue myself, thus I stay at 33ab117.