Help in the code

Submitted by Elangovan on Tue, 06/18/2019 - 18:36

Hie, i am having problem in understanding some part of the code. 

RTC_DATA_ATTR static time_t last;       

RTC_DATA_ATTR static uint32_t bootcount;

What is RTC_DATA_ATTR mean here.? and why are we using it?

 

when you define a global variable with RTC_DATA_ATTR attribute, the variable will be placed into RTC_SLOW_MEM memory. So the structure declared as RTC_DATA_ATTR and copy the dynamic memory to this structure before a deep sleep helps recovering this into dynamic memory after wake up. In simple words we are saving the time in static memory from dynamic memory to recover it again after a deep sleep. Here the two variables are defined. The ‘last’ is used to get the last time when the ESP32 went to deep sleep and bootcount is used count number of resets.

I would suggest to post  the complete code and then we can clear a bit more. 

  Joined January 21, 2019      42
Monday at 12:12 PM