From ec049b52c0f12b30ee2249728836b9a46ae26049 Mon Sep 17 00:00:00 2001 From: jimmy Date: Mon, 19 May 2025 19:35:29 +1200 Subject: [PATCH] Only check wifi settings if not connected --- src/wifi.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wifi.py b/src/wifi.py index 919b819..2ca86aa 100644 --- a/src/wifi.py +++ b/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)