mcci-catena / arduino-lmic

LoraWAN-MAC-in-C library, adapted to run under the Arduino environment
https://forum.mcci.io/c/device-software/arduino-lmic/
MIT License
645 stars 211 forks source link

Wrap-around of globalDutyAvail is blocking transmission in case of long transmission intervals #934

Open uhi22 opened 1 year ago

uhi22 commented 1 year ago

Describe the bug

If the application triggers a transmission in very slow interval (multiple hours, or even days), and the device sleeps in between, the transmission hangs up. Identified the root cause: The point in time, when transmission is allowed again, is controlled by globalDutyAvail. This is intended to be a value in the future, if we want to wait, and it is a time in the past, when it is allowed to transmit. But if we have for several hours no transmission, then the globalDutyAvail will be back in the past more and more, and at about 9hours it will wrap-around, and the transmission will be forbidden, because it looks like that the globalDutyAvail is in the future.

Possible bug fix: We need to avoid that globalDutyAvail is too far in the past. This can be reached by cyclically checking and correction of the global globalDutyAvail, and also the band-specific avail times.

Environment

To Reproduce

Trigger a transmission or multiple. Wait, until globalDutyAvail turns from "future" into "past", and after several hours it wraps-around into "future". Try a transmission, this is blocked because the globalDutyAvail is seems as "not yet reached".

Expected behavior

No matter how long are the gaps between two transmissions, the globalDutyAvail shall never wrap around from the past to the future.

Additional context

I prepared and tested a fix, see https://github.com/uhi22/arduino-lmic-uhi/commit/c9b6bd6b69f28122b6d86ab34e9180fe8f987245

uhi22 commented 1 year ago

Just noticed, that #926 mentions the same issue.