diff --git a/boot.py b/boot.py index b17015e..d1a7115 100644 --- a/boot.py +++ b/boot.py @@ -4,11 +4,23 @@ # Copy config.example.py to config.py and modify to your needs first! 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 os import dupterm uart = UART(0, 115200) 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)