Store and restore time after reboot nrf9160

Hi,

I have a idea but at the moment not the right approach to do it, thats why I ask here. 

I want to store the current time somehow on the device so it survives a reboot. I am aware of the fact it will be offset because there is a not specified time between reboot and next time sync. but the offset will be something 30 sec to 120 sec which is fine for our tasks. At the moment the time gets sync after nbiot connect but if there is no network we are kind of "blind".

so my idea 1: Every time I trigger a reboot I can also store a time object im memory and load this on next boot. So I will have a average time after boot and after some time I even can sync with LTE and make it more precise. Downside is here the usage of flash which has limited cycles. Also this approach does not capture unexpexted reboots.

idea 2: same as 1 but store as a job every X minutes/hours. Problem here is also the offset will be undefined after boot because I dont really know when was the last sync to memory

idea 3: maybe there is some area in memory that will survive a reboot and I can capture the time stamp from there. If so, it would be nice if we can develop something like this.

okay idea 1 and 2 I can do but its far away from a good workflow. Idea 3 I dont have the knowlege so maybe someone here can help. Also maybe there is a idea 4 I did not think about.

Thanks for your help and best regards

Daniel

Related