Keep Coaps DTLS session during deep sleep

sajadgh
Posts: 2
Joined: Wed Sep 04, 2019 12:49 pm

Keep Coaps DTLS session during deep sleep

Postby sajadgh » Wed Sep 04, 2019 12:53 pm

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?

ESP_Mahavir
Posts: 190
Joined: Wed Jan 24, 2018 6:51 am

Re: Keep Coaps DTLS session during deep sleep

Postby ESP_Mahavir » 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)

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Keep Coaps DTLS session during deep sleep

Postby WiFive » 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.

sajadgh
Posts: 2
Joined: Wed Sep 04, 2019 12:49 pm

Re: Keep Coaps DTLS session during deep sleep

Postby sajadgh » Thu Sep 05, 2019 8:07 am

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.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Keep Coaps DTLS session during deep sleep

Postby WiFive » Thu Sep 05, 2019 9:34 am

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.

Who is online

Users browsing this forum: igormoo and 70 guests