Only check wifi settings if not connected
This commit is contained in:
parent
a009ea85bc
commit
ec049b52c0
11
src/wifi.py
11
src/wifi.py
|
@ -2,14 +2,15 @@ import network
|
|||
from time import sleep
|
||||
|
||||
def connect(ssid, password, ip, gateway):
|
||||
if ssid == "" or password == "":
|
||||
print("Missing ssid or password")
|
||||
return None
|
||||
|
||||
try:
|
||||
sta_if = network.WLAN(network.STA_IF)
|
||||
if ip != "" and gateway != "":
|
||||
sta_if.ifconfig((ip, '255.255.255.0', gateway, '1.1.1.1'))
|
||||
if not sta_if.isconnected():
|
||||
if ssid == "" or password == "":
|
||||
print("Missing ssid or password")
|
||||
return None
|
||||
if ip != "" and gateway != "":
|
||||
sta_if.ifconfig((ip, '255.255.255.0', gateway, '1.1.1.1'))
|
||||
print('connecting to network...')
|
||||
sta_if.active(True)
|
||||
sta_if.connect(ssid, password)
|
||||
|
|
Loading…
Reference in New Issue