MJD YYMMDD HHMMSS DST LS H ADV MISC 49010 93-01-23 22:01:22 00 0 0 50.0 UTC(NIST) *DST is the daylight saving time flag. LS is the leap second flag. H is server health and ADV is the variable time advance of the transmission (in milliseconds) to compensate for the delay.
see: http://www.nist.gov/...8/grp40/its.cfm
To use it,
In main(),
Dim Nist_time as DaytimeNIST = New New DaytimeNIST("time-a.nist.gov", -8) NIST_Time.getTimeNIST() Debug.Print("Clock set: " & NIST_Time.successful) Debug.Print("Server used: " & NIST_Time.TimeServer) Debug.Print("Time from NIST " & NIST_Time.networkDateTime) Debug.Print("Current time set from DayTimeNIST: " & DateTime.Now.ToString)
The Netduino Plus clock is now set and running with local time corrected for UTC offset and standard/daylight savings time. The parameters are the server and the UTC offset. The example server is usually always busy on Daytime, but will demonstrate the internal selection of servers in getTimeNIST. It will try to connect to the instantiated server 3 times after waiting 5 sec. each try (per NIST instructions) and then select a new server. The internal servers are almost always reliable so you can strip out all of this for a more lightweight class.
I have incorporated this class into my port of Nevyn's webserver and it seems to work just fine getting and setting time through the browser. Commands,
http://192.168.0.106...nd.html?settime
http://192.168.0.106...nd.html?gettime
In command processor,
Case "gettime" Send(client, "Time from Netduino: " & DateTime.Now.ToString) Case "settime" Dim NIST_Time As DaytimeNIST = New DaytimeNIST("time-a.nist.gov", -8) NIST_Time.getTimeNIST() Dim newTime As String = DateTime.Now.ToString NIST_Time = Nothing Send(client, "<html><body><p>" & "Set Time " & newTime & "</p></body></html>")
N.B. I had to add this statement at the very beginning of processRequest to stop a periodic exception,
If (request Is Nothing) Then Exit Sub
There is some strange interaction I haven't tracked down yet. I am getting a request from the router address in Listen (sometimes) after issuing the command settime from the browser.
Baxter