rgot-org / TheThingsNetwork_esp32

82 stars 24 forks source link

Question on how to restore a session #22

Closed fcar12 closed 3 years ago

fcar12 commented 3 years ago

Hi,

I was looking at https://github.com/rgot-org/TheThingsNetwork_esp32/issues/8 and I couldn't understand how the session is being stored/restored. When I run the sleep example, after waking up the device (reset) it always performs a network join. Also, it seems that storeSession() and storeFrameCounter() methods are never called, which would avoid this. Shouldn't those methods be called somewhere so the logic in join() would reuse the session and avoid multiple joins? Am I missing something here?

Debug output is always:

[checkKeys] provisioned, no session 
[checkKeys] provisioned, no session 
Using stored keys to join
3333: [Event] JOINING

cc: @enwi

Cheers

fcar12 commented 3 years ago

Nevermind, this is caused by using reset to wakeup the esp32. When I waited for the timer it resumed the session properly. So probably reset is erasing stuff from memory.

fcar12 commented 3 years ago

After further testing with esp_sleep_enable_ext0_wakeup() and esp_sleep_enable_timer_wakeup() and I'm getting some random behaviours: sometimes the session is restored (few), other it isn't (majority). Any ideas?

fcar12 commented 3 years ago

Ok, it seems that you have to actually call sendData() in the example in order for the session to be stored and everything work.