I'm trying to retain my MQTT connection through deep-sleeps to avoid re-authentication on every wake up.
I therefore attempt to write the PubSubClient object to the RTC memory...
I'm able to write/read to memory, but I have an issue with the object and the addressing of it...
Are you sure that an object of the PubSubClient class is trivially copyable? Does it contain any pointers to objects in memory that are not maintained during deep sleep?
gfvalvo:
Are you sure that an object of the PubSubClient class is trivially copyable? Does it contain any pointers to objects in memory that are not maintained during deep sleep?
Good question, I honestly have no clue...
If the esp8266 is not using deep sleep, one single connect is sufficient to do lots of publish afterwards. So I guess there are states maintained in that PubSubClient object.
My goal is to store that within the memory so I can publish across deep sleep cycles.
(during deep sleep, the flash memory on zsp is turned off, therefore any state is lost. Only solution to keep state across deep-sleep cycles is the RTC memory)
BTW, "RTC Memory" is the terminology used in the ESP8266 documentation. No clue why they named it as such.
I've never used PubSubClient nor deep sleep on ESP8266. But, my guess is that the answer lies in having a clue regarding that. Or, perhaps, the behavior of the WiFi subsystem and connections to servers during deep sleep.