mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Tried to emulate Arduino's 11 folders... I'd perfer to have all the shield scripts in one folder... but, that might not make sense. I don't really want one script per folder however. So, I might merge some more stuff in the future. I have a grand idea here that will become evident as I work though the examples. Anyway, the current structure is not final. It will be in flux for a little while. As for Git History, folder history is the best we're going to get. Git and GitHub don't seem to deal with moves too well.
31 lines
675 B
Python
31 lines
675 B
Python
# Simple NTP client
|
|
import time, pyb, network, usocket
|
|
|
|
# AP info
|
|
SSID='' # Network SSID
|
|
KEY='' # Network key
|
|
|
|
# Init wlan module and connect to network
|
|
wlan = network.WINC()
|
|
wlan.connect(SSID, key=KEY, security=wlan.WPA_PSK)
|
|
|
|
# We should have a valid IP now via DHCP
|
|
print(wlan.ifconfig())
|
|
|
|
# Get addr info via DNS
|
|
addr = usocket.getaddrinfo("www.google.com", 80)[0][4]
|
|
|
|
# Create a new socket and connect to addr
|
|
client = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
|
|
client.connect(addr)
|
|
|
|
# Set timeout to 1s
|
|
client.settimeout(1.0)
|
|
|
|
# Send HTTP request and recv response
|
|
client.send("GET / HTTP/1.0\r\n\r\n")
|
|
print(client.recv(1024))
|
|
|
|
# Close socket
|
|
client.close()
|