Moderator: igrr
WiFiUdp.h
WiFiUdp.cpp
UdpContext.h (in include directory)
Thanks for posting this code, in the main it works for me.
I do have one problem though; on some iterations the time seems 'stuck' and I get the previous value.
See this :-
WiFi connected
IP address:
192.168.1.85
Starting UDP
Local port: 2390
Iteration no : 1 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800811 : Unix time = 1438812011 The UTC time is 22:00:11
Iteration no : 2 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800811 : Unix time = 1438812011 The UTC time is 22:00:11
Iteration no : 3 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800811 : Unix time = 1438812011 The UTC time is 22:00:11
Iteration no : 4 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800822 : Unix time = 1438812022 The UTC time is 22:00:22
Iteration no : 5 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800822 : Unix time = 1438812022 The UTC time is 22:00:22
Iteration no : 6 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800844 : Unix time = 1438812044 The UTC time is 22:00:44
Iteration no : 7 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800844 : Unix time = 1438812044 The UTC time is 22:00:44
Iteration no : 8 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800855 : Unix time = 1438812055 The UTC time is 22:00:55
Iteration no : 9 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800866 : Unix time = 1438812066 The UTC time is 22:01:06
Iteration no : 10 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800877 : Unix time = 1438812077 The UTC time is 22:01:17
Iteration no : 11 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800899 : Unix time = 1438812099 The UTC time is 22:01:39
Iteration no : 12 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800899 : Unix time = 1438812099 The UTC time is 22:01:39
Iteration no : 13 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800910 : Unix time = 1438812110 The UTC time is 22:01:50
Iteration no : 14 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800932 : Unix time = 1438812132 The UTC time is 22:02:12
Iteration no : 15 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800932 : Unix time = 1438812132 The UTC time is 22:02:12
Iteration no : 16 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800943 : Unix time = 1438812143 The UTC time is 22:02:23
Iteration no : 17 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800965 : Unix time = 1438812165 The UTC time is 22:02:45
Iteration no : 18 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800965 : Unix time = 1438812165 The UTC time is 22:02:45
Iteration no : 19 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800976 : Unix time = 1438812176 The UTC time is 22:02:56
As you can see I can keep getting the previous value.
I have changed the NTP server group to a UK one with the same result.
Changing the delay to 30 seconds makes no difference.
Any idea what is happening?
But is there any reason to request NTP every 30 secs ?
Maybe you should do the request one time per 24hrs, just to be synchronized, and rely on Time library for the rest of the day.