matthijskooijman / arduino-lmic

:warning: This library is deprecated, see the README for alternatives.
705 stars 651 forks source link

Check if send queue is empty #249

Closed NullP0int closed 4 years ago

NullP0int commented 4 years ago

Hi everyone,

I would like to enable the deepsleep mode from the esp32 after all packets were send so I know when it's time to enable the deepslee mode?. In this case it doesn't matter if the packets received successfully from the gateway. Is there a way to check this in a fine way?

Thanks a lot, Wish you the best!

matthijskooijman commented 4 years ago

There is no elegant way for this, but you can look at the LMIC.opmode variable. This is a bitmask of various flags, and in particular OP_TXRXPEND indicates whether a packet is still pending. There might be other flags that are relevant, see https://github.com/matthijskooijman/arduino-lmic/blob/master/src/lmic/lmic.h#L114-L129

Alternatively, you could wait for the TXCOMPLETE event to happen and sleep after that (either in the event handler itself, or by setting a variable and then checking that in the mainloop).