lnlp / LMIC-node

LMIC-node | One example to rule them all. LMIC-node is an example LoRaWAN application for a node that can be used with The Things Network. It demonstrates how to send uplink messages, how to receive downlink messages, how to implement a downlink command and it provides useful status information. With LMIC-node it is easy to get a working node quickly up and running. LMIC-node supports many popular (LoRa) development boards out of the box. It uses the Arduino framework, the LMIC LoRaWAN library and PlatformIO.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: How to properly include deepsleep functionality instead of timed rescheduling?

drfritz142 opened this issue · comments

Dear Leonel,

thanks first and foremost for this very comprehensive software. I could get it running on a bluepill/rfm95 within a few minutes. Just wonderful.

Now I would like to include a deepsleep function. Most of the time my sensor will be in deepsleep to save battery. Previously, I have just "hacked" that deepsleep call into the code right at the end of the EV_TXCOMPLETE event. But this seems nothing but brutal in your code. I bet there could be a place where it would be properly called within a wrapper function perhaps which every board then could specify out by itself. But where would that call be and how would one properly stop the timed rescheduling? Essentially, this should be replaced: instead of rescheduling after x seconds, the MC should sleep and when waking up, start the next roundtrip.

Could you be so kind as to let me know where I can implement this properly?
Thanks,
Andreas

Of course, this is not an issue but a question. But somehow I didn't find a way to select this ...

Hi,

Thanks for your feedback.

Deep sleep support is a much wanted feature and very relevant for battery powered LoRaWAN devices.

Unfortunately LMIC-node currently does not include any deep sleep support.

The first (and main) reason is that the (MCCI) LMIC library still does not provide any support / hooks for deep sleep.
Support for functions like e.g. saveLmicState() and restoreLmicState() have yet to be added to the LMIC library (user will need to provide the actual implementation).
Another issue is that the timers that LMIC depends on, need to updated after deep sleep. This is essential because LMIC needs to manage radio time i.e. it keeps track/manages which channels it is allowed to transmit on when. The LMIC library currently does not provide support for this. A 'redo from start' approach would bypass proper radio time management and will very probably conflict with LoRaWAN and/or regional radio frequency regulations.

A second reason why LMIC-node currently does not support deep sleep is that deep sleep behaves differently on different MCU platforms (e.g. ESP32 actually resets when waking up from deep sleep while other platform preserve all state). Without any generic support from the LMIC library this would be quite complex (and much work) to implement for all MCU platforms that LMIC-node currently supports.

For you, how to implement this properly depends on your MCU platform and you will need to solve the issues described above for your platform and hardware.

I think it's an understatement, that deepsleep is very relevant - I believe it's essential!

It definitely is. Therefore it's sad that the LMIC library still doesn't provide any type of support for it.

I found a solution which was realized for an ESP32

Be aware that the dutycycle correction which that solution implements works for EU band plans (eu868) only.

which ... forgets EVERYTHING during deepsleep

Well, almost everything: contents of RTC memory is preserved during deep sleep (see ESP32 memory types).

BR