cjhdev / lora_device_lib

A LoRaWAN Device Library
https://ldl.readthedocs.io/en/latest/
MIT License
33 stars 8 forks source link

UplinkDwellTime not correctly applied on AU915 #55

Open gonzabrusco opened 9 months ago

gonzabrusco commented 9 months ago

When the node receives the command TXParamSetupReq the network defines if the node has to limit the uplink and downlink time to 400ms (a.k.a. dwell time)

What you actually do in the current version of this library, is limit the datarate to 2 (0 and 1 do not comply with the dwell time limitation). But the function LDL_Region_convertRate does not take the dwell time into account when it should. The maximum payload allowable is dependent on the dwell time too.

image

gonzabrusco commented 9 months ago

This is where you apply the uplink dwell: https://github.com/cjhdev/lora_device_lib/blob/e017b222d1ef3cb21b982d19cb7a5c0f3dfe95cb/src/ldl_mac.c#L1726

But you don't apply the uplink dwell limitation to the MTU: https://github.com/cjhdev/lora_device_lib/blob/e017b222d1ef3cb21b982d19cb7a5c0f3dfe95cb/src/ldl_mac.c#L1730

What I did is add another parameter to LDL_Region_convertRate to tell the function if the dwell should be applied or not. If you are interested I can make a Pull Request for you to review.