Closed rei-vilo closed 6 years ago
The IP address used in the Sketch is no longer associated with time.nist.gov and hence it fails since there is no NTP server at that address. Since we have DNS lookup all examples should use domain names rather than IP addresses where possible. I will go through the examples of the WiFi and Ethernet library and change the ip addresses to domain names if possible. Below is the diff to make it work again.
diff --git a/libraries/WiFi/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino b/libraries/WiFi/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino
index 5d92bf0..b9f538a 100644
--- a/libraries/WiFi/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino
+++ b/libraries/WiFi/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino
@@ -32,7 +32,7 @@ char password[] = "launchpad";
unsigned int localPort = 2390; // local port to listen for UDP packets
-IPAddress timeServer(206,246,122,250); // time.nist.gov NTP server
+char timeServer[] = "time.nist.gov"; // time.nist.gov NTP server
const int NTP_PACKET_SIZE = 48; // NTP time stamp is in the first 48 bytes of the message
@@ -128,7 +128,7 @@ void loop()
}
// send an NTP request to the time server at the given address
-unsigned long sendNTPpacket(IPAddress& address)
+unsigned long sendNTPpacket(const char *address)
{
//Serial.println("1");
// set all bytes in the buffer to 0
Once issue #19 has been patched with the suggested solution, the
WiFiUdpNtpClient.ino
example fails to get time.WiFiUDP::parsePacket()
exits at line 277.Any idea?