stepper-clock/boot.py
2020-03-21 21:25:23 +01:00

23 lines
763 B
Python

import network
import webrepl
webrepl.start()
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
if sta_if.status() != network.STAT_GOT_IP:
availableNetworkSSIDs = [s[0].decode() for s in sta_if.scan()]
print(availableNetworkSSIDs)
#load wifi credentials from file
with open("wifi-credentials","r") as f:
while sta_if.status() != network.STAT_GOT_IP:
ssid = f.readline()
password = f.readline()#
if not ssid or not password:
break
ssid = ssid.replace("\n","")
password = password.replace("\n","")
if ssid in availableNetworkSSIDs:
print("Connecting to",ssid)
sta_if.connect(ssid,password)
break