LoraWAN frames counter does not work after deepsleep if socket is set to non-blocking
My code on the lopy4 basically does the following after wake-up:
- check wake up reason
- restore lora from nvram (or rejoin if wake up reason is power on wakeup)
- create socket (nonblocking)
- make measurement
- send data to TTN
- store lora configuration in nvram
- receive downlink (if there is one)
If the socket is set to non-blocking the counter does not work (stays 0) if I change this option to blocking the counter works again. Is there any reason for this behaviour?
I want the socket to be non-blocking because of the downlink message which is send sometimes.
@tom You should probably instead do the following
- set socket to blocking
- set socket to non-blocking
- save config
Otherwise you actually try to receive, save, and deep sleep before the packet has actually been (completely) sent.
An alternative is to add a manual
sleep, but remember that the time between send and receive is variable (the network can change the RxDelay).