Hello,
When i use localtime_r (...) function, i get the values 01/01/1970 00:00:00.
I get the timestamp with the SNTP protocol and normally I should be able to use the settimeofday (..) function to update the date and time in the OS.
Unfortunately this function does not exist in time.h !
Does anyone know the solution to update the date and time in the system ?
WGM160P: micrium OS, how to initialize date and time
Hello,
When i use localtime_r (...) function, i get the values 01/01/1970 00:00:00.
I get the timestamp with the SNTP protocol and normally I should be able to use the settimeofday (..) function to update the date and time in the OS.
Unfortunately this function does not exist in time.h !
Does anyone know the solution to update the date and time in the system ?
In my project, I defined SL_SLEEPTIMER_WALLCLOCK_CONFIG as 1 to enable "wall clock" APIs for tracking date/time.
I'm using sl_sleeptimer_set_datetime() to set the time based on an sl_sleeptimer_date_t structure similar to "struct tm". You can also use sl_sleeptimer_set_time() to set the time using the number of seconds since the Unix epoch (1/1/1970).
Look through sl_sleeptimer.h for additional APIs related to time/date.
Ultimately this is the right solution for me.
thanks for the help
Hi Tom,
It's right way to go with wall clock, thanks for your input this is the right solution for me too.
I have a question how to keep wall clock running without going back to default date something like year from 1970 after power cycle or reset chip ?
Thanks in advance
Jason
Jason, you should post that as a separate question, instead of an answer to an answered question.
I don’t know which board you’re running, but if you have battery backup it might be possible to go into a low-power sleep mode that just keeps the RTC (real-time clock) running when the main power source goes down. But that won’t survive a hardware reset — you’d need some sort of external battery-backed RTC for that.
In many cases, you can just have your device not know the time/date until it has network connectivity and can acquire that information from an external source.
Hi Tom,
My board : WGM160P Wi-Fi Module Radio Board (BRD4321A Rev A04) : EFM32GG11B820F2048GM64
Will do separate question next time
Thank you very much!
Jason