Time update and synchronization


#1

Hello,

I am looking for some methods to get mangOH’s RTC updated and synchronized.

  1. How can the time be updated during boot?
  2. Would the onboard GNSS functionality help with this? Does this API - le_pos_GetTime() - help to get the real time?
  3. Other options - SIM or WiFi. How can we get the time info from these?
  4. This is not a solution, but I am just trying out, getting the time from the HTTP server. I believe there is an issue with this time. This will be elapsed time from 1970 and mangOH starts from 1980. Had anyone tried this?

Please share any solutions.

Thanks
Madan


#2

Madan,

GNSS is one way. Assuming you are connecting to a 2G/3G/LTE network you could also use the NITZ messages and while the AT command manual says it does not support it at+ctzu seems to work in updating the RTC.

at+ctzu?
+CTZU: 1

OK
at+cclk?
+cclk: "18/08/22,10:18:18+04"

OK

Regards

Matt


#3

Thank you Matt.
At the minute, I haven’t activated the Sim yet. So, at+cclk returns 1980…time.

Actually, I was trying the positioning service to get GNSS time. It’s not working at the minute. Going through the docs.
Pseudo code…
Connect service
GetDate
Gettime
Disconnect service

Let me know if you have some ideas.


#4

IF your network provides them!


#5

@awneil,

Yes if your network privides them and in the days of 2G it was very hit and miss but most do now with 2G and especially LTE.

@Madan,

Re the pseudo code you would do the following.

  1. start the GNSS engine as per the code here.
  2. When it has a fix read out the time as per the code here.
  3. Then apply it to the RTC on the unit using the relevant Legato API which I am pretty sure isthis one.
    Regards

Matt


#6

Thank you Andy and Matt for your suggestions.
I will try them and post the results.


#7

Hi

I did some experiment with the sample code that @mlw suggested.
I got the gnss enabled, GetDate() and GetTime() also working.

Then, I called the le_rtc_*** functions as per the documentation. Now the app is stuck on connecting to RTC service.
As per the documentation, le_rtc_connectService() is a blocking call. I checked the log and confirmed.

I did check that modemService is running. But it doesn’t go through this call. (checked with sandbox:false and true as well)

Am I missing something? Please suggest.

Here is the snippet of the auto generated code…

// Library initialization function.
// Will be called by the dynamic linker loader when the library is loaded.
attribute((constructor)) void _timeSyncComponent_Init(void)
{
LE_DEBUG(“Initializing timeSyncComponent component library.”);

// Connect client-side IPC interfaces.
le_rtc_ConnectService();
le_pos_ConnectService();
le_posCtrl_ConnectService();
le_gnss_ConnectService();

// Register the component with the Log Daemon.
timeSyncComponent_LogSession = log_RegComponent("timeSyncComponent", &timeSyncComponent_LogLevelFilterPtr);

//Queue the COMPONENT_INIT function to be called by the event loop
event_QueueComponentInit(_timeSyncComponent_COMPONENT_INIT);

}