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
638 stars 208 forks source link

Different events for explicit and implicit joins #882

Open dajtxx opened 2 years ago

dajtxx commented 2 years ago

Description

If you call LMIC_startJoining, wait for the join, then call LMIC_setTxData2 you get the following sequence of events:

11:45:05.153 -> EV_JOINING
11:45:07.688 -> EV_TXSTART
11:45:13.502 -> EV_JOINED
...
11:45:20.768 -> EV_TXSTART
11:45:26.250 -> EV_TXCOMPLETE

whereas if you only call LMIC_setTxData2 and cause an implicit join to happen, these events are emitted:

11:41:56.778 -> EV_JOINING
11:41:57.176 -> EV_TXSTART
11:42:03.019 -> EV_JOINED
11:42:03.019 -> EV_TXCOMPLETE

where the TXCOMPLETE event is from the join, not for the data uplink.

The event list is cut short in the second example because our firmware was using TXCOMPLETE as the signal to stop calling os_runloop_once, so we dropped out of LMIC processing right after the join and before the uplink was started.

We've changed our firmware but it feels like a bug to have different events emitted depending on whether the join was explicitly started or implicitly started.

Environment

LMIC 4.1.1 TTN AS923 Feather M0

Expected behavior

Probably the explicit join should not emit the TXCOMPLETE event, and perhaps there should not be a TXSTART after a JOINING?