Only check wifi settings if not connected

This commit is contained in:
jimmy 2025-05-19 19:35:29 +12:00
parent a009ea85bc
commit ec049b52c0
1 changed files with 6 additions and 5 deletions

View File

@ -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)