Commit 225562d9 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

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.
parent 480159ca
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment