changed network connecting
This commit is contained in:
parent
533bb1bd0d
commit
08610f2c70
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
wifi-credentials
|
||||
.uploaded
|
||||
uP-cheatsheet
|
||||
.vscode/
|
14
boot.py
14
boot.py
@ -6,9 +6,15 @@ sta_if = network.WLAN(network.STA_IF)
|
||||
sta_if.active(True)
|
||||
|
||||
availableNetworkSSIDs = [s[0].decode() for s in sta_if.scan()]
|
||||
print(availableNetworkSSIDs)
|
||||
#load wifi credentials from file
|
||||
with open("wifi-credentials","r") as f:
|
||||
ssid = f.readline().replace("\n","")
|
||||
password = f.readline().replace("\n","")
|
||||
if ssid in availableNetworkSSIDs:
|
||||
sta_if.connect(ssid,password)
|
||||
while True:
|
||||
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:
|
||||
sta_if.connect(ssid,password)
|
||||
|
Loading…
x
Reference in New Issue
Block a user