More intelligent wifi management on bootup.
This commit is contained in:
parent
f74fede517
commit
bbb7f72840
20
boot.py
20
boot.py
@ -4,11 +4,23 @@
|
|||||||
# Copy config.example.py to config.py and modify to your needs first!
|
# Copy config.example.py to config.py and modify to your needs first!
|
||||||
import config
|
import config
|
||||||
|
|
||||||
from network import WLAN
|
|
||||||
wifi = WLAN(mode=WLAN.STA)
|
|
||||||
wifi.connect(config.HOME_SSID, auth=(WLAN.WPA, config.HOME_PASSWORD))
|
|
||||||
|
|
||||||
from machine import UART
|
from machine import UART
|
||||||
from os import dupterm
|
from os import dupterm
|
||||||
uart = UART(0, 115200)
|
uart = UART(0, 115200)
|
||||||
dupterm(uart)
|
dupterm(uart)
|
||||||
|
|
||||||
|
from network import WLAN
|
||||||
|
wifi = WLAN()
|
||||||
|
wifi.mode(WLAN.STA)
|
||||||
|
ssids = wifi.scan()
|
||||||
|
found = False
|
||||||
|
for net in ssids:
|
||||||
|
print("Checking %s" % net.ssid)
|
||||||
|
if net.ssid == config.HOME_SSID:
|
||||||
|
print("Found %s!" % net.ssid)
|
||||||
|
wifi.connect(config.HOME_SSID, auth=(WLAN.WPA, config.HOME_PASSWORD))
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
if not found:
|
||||||
|
print("No eligible WiFi found.")
|
||||||
|
wifi.mode(WLAN.AP)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user