mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
examples: Update all networking scripts.
* Remove non-standard timeout arg and use isconnected.
This commit is contained in:
parent
5e8ba825ed
commit
11194954cb
@ -8,12 +8,13 @@ SSID='' # Network SSID
|
|||||||
KEY='' # Network key
|
KEY='' # Network key
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect. Note this may take a while...")
|
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -8,12 +8,13 @@ SSID='' # Network SSID
|
|||||||
KEY='' # Network key
|
KEY='' # Network key
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect. Note this may take a while...")
|
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -10,12 +10,13 @@ PORT = 80
|
|||||||
HOST = "www.google.com"
|
HOST = "www.google.com"
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect. Note this may take a while...")
|
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -9,12 +9,13 @@ PORT = 443
|
|||||||
HOST = "www.google.com"
|
HOST = "www.google.com"
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect. Note this may take a while...")
|
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -16,11 +16,13 @@ sensor.set_framesize(sensor.QVGA)
|
|||||||
sensor.set_pixformat(sensor.RGB565)
|
sensor.set_pixformat(sensor.RGB565)
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect... (This may take a while)...")
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -14,12 +14,13 @@ SSID='' # Network SSID
|
|||||||
KEY='' # Network key
|
KEY='' # Network key
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect. Note this may take a while...")
|
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -14,12 +14,13 @@ SSID='' # Network SSID
|
|||||||
KEY='' # Network key
|
KEY='' # Network key
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect. Note this may take a while...")
|
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -12,9 +12,13 @@ TIMESTAMP = 2208988800+946684800
|
|||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect... (This may take a while)...")
|
print("Trying to connect... (This may take a while)...")
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
import time, network
|
import time, network
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
|
|
||||||
print("Scanning...")
|
print("Scanning...")
|
||||||
|
|||||||
@ -10,13 +10,16 @@ KEY='' # Network key
|
|||||||
TIMESTAMP = 2208988800+946684800
|
TIMESTAMP = 2208988800+946684800
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect... (This may take a while)...")
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
|
|
||||||
# ifconfig must be called before connect()
|
# ifconfig must be called before connect()
|
||||||
wlan.ifconfig(('192.168.1.200', '255.255.255.0', '192.168.1.1', '192.168.1.1'))
|
wlan.ifconfig(('192.168.1.200', '255.255.255.0', '192.168.1.1', '192.168.1.1'))
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# Create new socket
|
# Create new socket
|
||||||
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
|||||||
@ -8,12 +8,13 @@ SSID='' # Network SSID
|
|||||||
KEY='' # Network key
|
KEY='' # Network key
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect. Note this may take a while...")
|
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -8,12 +8,13 @@ SSID='' # Network SSID
|
|||||||
KEY='' # Network key
|
KEY='' # Network key
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect. Note this may take a while...")
|
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -10,12 +10,13 @@ PORT = 80
|
|||||||
HOST = "www.google.com"
|
HOST = "www.google.com"
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect. Note this may take a while...")
|
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -9,12 +9,13 @@ PORT = 443
|
|||||||
HOST = "www.google.com"
|
HOST = "www.google.com"
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect. Note this may take a while...")
|
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -16,11 +16,13 @@ sensor.set_framesize(sensor.QVGA)
|
|||||||
sensor.set_pixformat(sensor.GRAYSCALE)
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect... (This may take a while)...")
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -14,12 +14,13 @@ SSID='' # Network SSID
|
|||||||
KEY='' # Network key
|
KEY='' # Network key
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect. Note this may take a while...")
|
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -14,12 +14,13 @@ SSID='' # Network SSID
|
|||||||
KEY='' # Network key
|
KEY='' # Network key
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect. Note this may take a while...")
|
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|||||||
@ -10,11 +10,14 @@ KEY='' # Network key
|
|||||||
TIMESTAMP = 2208988800+946684800
|
TIMESTAMP = 2208988800+946684800
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect... (This may take a while)...")
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# We should have a valid IP now via DHCP
|
# We should have a valid IP now via DHCP
|
||||||
print("WiFi Connected ", wlan.ifconfig())
|
print("WiFi Connected ", wlan.ifconfig())
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
import time, network
|
import time, network
|
||||||
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
|
|
||||||
print("Scanning...")
|
print("Scanning...")
|
||||||
|
|||||||
@ -10,13 +10,16 @@ KEY='' # Network key
|
|||||||
TIMESTAMP = 2208988800+946684800
|
TIMESTAMP = 2208988800+946684800
|
||||||
|
|
||||||
# Init wlan module and connect to network
|
# Init wlan module and connect to network
|
||||||
print("Trying to connect... (This may take a while)...")
|
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.deinit()
|
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
|
|
||||||
# ifconfig must be called before connect()
|
# ifconfig must be called before connect()
|
||||||
wlan.ifconfig(('192.168.1.200', '255.255.255.0', '192.168.1.1', '192.168.1.1'))
|
wlan.ifconfig(('192.168.1.200', '255.255.255.0', '192.168.1.1', '192.168.1.1'))
|
||||||
wlan.connect(SSID, KEY, timeout=30000)
|
wlan.connect(SSID, KEY)
|
||||||
|
|
||||||
|
while not wlan.isconnected():
|
||||||
|
print("Trying to connect to \"{:s}\"...".format(SSID))
|
||||||
|
time.sleep_ms(1000)
|
||||||
|
|
||||||
# Create new socket
|
# Create new socket
|
||||||
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user