Advanced Users can post their questions and comments here for the not so Newbie crowd.

Moderator: eriksl

User avatar
By davydnorris
#81788 Yes - you could easily instrument my snippet here. The event callback is fired at all the right points. I'll do that once I finally finish this release I'm working on (I just had a week vacation).

I know the SNTP association takes a while because I had to do that with timers and sometimes it takes ages to connect.
User avatar
By eriksl
#81792 BTW do you need real NTP or is SNTP sufficient? Because you're talking of an "association" and SNTP doesn't have a notion of an association. Yesterday I finished my own SNTP implementation. It's about 100 lines of code (or even less) and just works. I send the packet to the NTP server (48 bytes, only a few bits need to be set) and receive a similar packet back containing the current time on the sever, set it, done. I start sending the first packet after the "ip address obtained" callback has arrived, then repeat it every 5 seconds until the first reply arrives. After that, repeat it with a much longer interval of 10 minutes. After re-association or change to the NTP paramters, restart the whole sequence.
User avatar
By eriksl
#81798 Yeah, understandable.

Can't you use one specific server and skip the DNS lookup? I guess you're using something like 0.pool.ntp.org?

OTOH I made the use of an explicit IP address for SNTP mandatory (which is perfectly fine for an indoors environment, I think), which made (LWIP) DNS and MDNS support no longer a requirement, which in turn saved me one or two kilobytes of DRAM.

Is it a requirement to have a quick time sync after boot? Or is it because you want to have actively powered on as short as possible? Otherwise I guess it wouldn't hurt to wait a few seconds for the time to sync?