例程讲解14-WiFi-Shield->ntp 获取当前时间
import network, usocket, ustruct, utime
SSID=''
KEY=''
TIMESTAMP = 2208988800+946684800
print("Trying to connect... (may take a while)...")
wlan = network.WINC()
wlan.connect(SSID, key=KEY, security=wlan.WPA_PSK)
print(wlan.ifconfig())
client = usocket.socket(usocket.AF_INET, usocket.SOCK_DGRAM)
addr = usocket.getaddrinfo("pool.ntp.org", 123)[0][4]
client.sendto('\x1b' + 47 * '\0', addr)
data, address = client.recvfrom(1024)
t = ustruct.unpack(">IIIIIIIIIIII", data)[10] - TIMESTAMP
print ("Year:%d Month:%d Day:%d Time: %d:%d:%d" % (utime.localtime(t)[0:6]))
星瞳科技OpenMV官方中文文档函数讲解:
星瞳科技OpenMV官方中文文档函数讲解:
星瞳科技OpenMV官方中文文档函数讲解: