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
|
from time import sleep
|
||||||
|
|
||||||
def connect(ssid, password, ip, gateway):
|
def connect(ssid, password, ip, gateway):
|
||||||
if ssid == "" or password == "":
|
|
||||||
print("Missing ssid or password")
|
|
||||||
return None
|
|
||||||
try:
|
try:
|
||||||
sta_if = network.WLAN(network.STA_IF)
|
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 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...')
|
print('connecting to network...')
|
||||||
sta_if.active(True)
|
sta_if.active(True)
|
||||||
sta_if.connect(ssid, password)
|
sta_if.connect(ssid, password)
|
||||||
|
|
Loading…
Reference in New Issue