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:

    1. check wake up reason
    2. restore lora from nvram (or rejoin if wake up reason is power on wakeup)
    3. create socket (nonblocking)
    4. make measurement
    5. send data to TTN
    6. store lora configuration in nvram
    7. receive downlink (if there is one)
    8. deepsleep

    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
    • send
    • set socket to non-blocking
    • receive
    • 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).



Pycom on Twitter