From 225562d915a9563f25225f9c8ec1764b2fbb3613 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 30 May 2016 19:16:05 +0300 Subject: [PATCH] esp8266/scripts/ntptime: Allow to override NTP server. This is not part of public API, variable name may change, or it can be replaced with a function. --- esp8266/scripts/ntptime.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esp8266/scripts/ntptime.py b/esp8266/scripts/ntptime.py index 650cc2e85b..a97e08e60d 100644 --- a/esp8266/scripts/ntptime.py +++ b/esp8266/scripts/ntptime.py @@ -10,10 +10,12 @@ except: # (date(2000, 1, 1) - date(1900, 1, 1)).days * 24*60*60 NTP_DELTA = 3155673600 +host = "pool.ntp.org" + def time(): NTP_QUERY = bytearray(48) NTP_QUERY[0] = 0x1b - addr = socket.getaddrinfo('pool.ntp.org', 123)[0][-1] + addr = socket.getaddrinfo(host, 123)[0][-1] s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.settimeout(1) res = s.sendto(NTP_QUERY, addr)