build(boards): xpython板卡执行 npm run build:prod

This commit is contained in:
王立帮
2025-12-14 21:18:41 +08:00
parent 26bae5da89
commit 0ff5878d5f
416 changed files with 12404 additions and 48341 deletions

View File

@@ -6,21 +6,27 @@ import ustruct as struct
# NTP_DELTA (date(2000, 1, 1) - date(1900, 1, 1)).days * 24*60*60
NTP_DELTA=3155673600
def time(host="pool.ntp.org", utc=28800):
NTP_QUERY = bytearray(48)
NTP_QUERY[0] = 0x1B
addr = socket.getaddrinfo(host, 123)[0][-1]
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
s.settimeout(1)
res = s.sendto(NTP_QUERY, addr)
msg = s.recv(48)
finally:
del addr
s.close()
gc.collect()
val = struct.unpack("!I", msg[40:44])[0]
return utime.gmtime(val - NTP_DELTA + utc)
def time(host="pool.ntp.org", utc=28800, times=5):
for _ in range(times):
try:
NTP_QUERY = bytearray(48)
NTP_QUERY[0] = 0x1B
addr = socket.getaddrinfo(host, 123)[0][-1]
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
s.settimeout(1)
res = s.sendto(NTP_QUERY, addr)
msg = s.recv(48)
finally:
del addr
s.close()
gc.collect()
val = struct.unpack("!I", msg[40:44])[0]
return utime.gmtime(val - NTP_DELTA + utc)
except Exception as e:
error = e
utime.sleep(0.1)
raise OSError('Error fetching network time', error)
# There's currently no timezone support in MicroPython, and the RTC is set in UTC time.
def settime(times):