Page 1 of 1
Keep Coaps DTLS session during deep sleep
Posted: Wed Sep 04, 2019 12:53 pm
by sajadgh
Hi,
I'm trying to use coaps protocol, I want esp32 goes to deep sleep without closing the current DTLS session. I have no idea if it is possible in deep sleep mode or not?
I have to say that I succeeded keeping the DTLS session alive during light sleep and it works as expected.
can any one guide me for deep sleep mode?
Re: Keep Coaps DTLS session during deep sleep
Posted: Wed Sep 04, 2019 4:36 pm
by ESP_Mahavir
Please refer to
https://docs.espressif.com/projects/esp ... modes.html
In deep sleep mode, CPUs, most of the RAM, and all the digital peripherals which are clocked from APB_CLK are powered off. The only parts of the chip which can still be powered on are: RTC controller, RTC peripherals (including ULP coprocessor), and RTC memories (slow and fast). Hence, it is unlikely that DTLS session can be kept active. (In addition, please also note that exit from deep-sleep is equivalent to reset, firmware will start executing as if system reset has happened)
Re: Keep Coaps DTLS session during deep sleep
Posted: Wed Sep 04, 2019 10:49 pm
by WiFive
It should be possible if you save your DTLS context into rtc ram and restore it after boot and use the same port number and assuming the server doesn't kill the session.
Re: Keep Coaps DTLS session during deep sleep
Posted: Thu Sep 05, 2019 8:07 am
by sajadgh
ESP-MJ wrote: ↑Wed Sep 04, 2019 4:36 pm
Please refer to
https://docs.espressif.com/projects/esp ... modes.html
In deep sleep mode, CPUs, most of the RAM, and all the digital peripherals which are clocked from APB_CLK are powered off. The only parts of the chip which can still be powered on are: RTC controller, RTC peripherals (including ULP coprocessor), and RTC memories (slow and fast). Hence, it is unlikely that DTLS session can be kept active. (In addition, please also note that exit from deep-sleep is equivalent to reset, firmware will start executing as if system reset has happened)
I think so too, but I was hoping to keep it alive by saving the session in RTC memory.
WiFive wrote: ↑Wed Sep 04, 2019 10:49 pm
It should be possible if you save your DTLS context into rtc ram and restore it after boot and use the same port number and assuming the server doesn't kill the session.
I saved almost everything in the RTC-MEMORY, but esp32 crashed and reset every time.
I guess this happens because of some static variable inside libraries but Im not sure.
Re: Keep Coaps DTLS session during deep sleep
Posted: Thu Sep 05, 2019 9:34 am
by WiFive
Not sure what you tried but you will have to at least recreate the socket and insert it into the saved session. You should try to get it working first without deepsleep.