How to get and sync time with sntp?
Posted: Mon Jan 06, 2020 5:53 am
I'm not sure where in azure or outside of it the sntp is called but here is a snippet of my boot message that includes the announcement that time was obtained:
So essentially the sntp server has been possibly started by azure client. I don't know which code is using the "platform" tag.
I just wish to obtain epoch time. Is there a function I can call to get that?
A second question: once sntp server started, is there any need to call some function once in a while to synchronize or is done in the background?
I found this example but it is quite confusing. Not a hello world type of simplicity.
https://github.com/espressif/esp-idf/bl ... ple_main.c
So apparently only after wifi is connected the sntp was initialized. I check the code where wifi is started, there is no sntp call. It calls to start azure client, which calls a function to start connection to azure server. I bet that is where sntp got started. I did some digging but the azure stuff is jut too deep to find anything useful.I (4660) event: sta ip: 192.168.0.103, mask: 255.255.255.0, gw: 192.168.0.1
I (4660) azure: SYSTEM_EVENT_STA_GOT_IP
I (4660) azure: Got IP: '192.168.0.103'
I (4670) azure: Connected to AP success!
Initializing SNTP
ESP platform sntp inited!
I (4680) platform: The current date/time is: Mon Jan 6 05:16:06 2020
So essentially the sntp server has been possibly started by azure client. I don't know which code is using the "platform" tag.
I just wish to obtain epoch time. Is there a function I can call to get that?
A second question: once sntp server started, is there any need to call some function once in a while to synchronize or is done in the background?
I found this example but it is quite confusing. Not a hello world type of simplicity.
https://github.com/espressif/esp-idf/bl ... ple_main.c