From f7a42f1da8d7541e5c089890e46fbe725ac7626e Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Tue, 13 May 2025 13:21:52 +0200 Subject: [PATCH] wificonf: don't activate wifi if nothing is configured --- .../assets/auto_connect.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/internal_filesystem/builtin/apps/com.example.wificonf/assets/auto_connect.py b/internal_filesystem/builtin/apps/com.example.wificonf/assets/auto_connect.py index c367ec16..7cebabc7 100644 --- a/internal_filesystem/builtin/apps/com.example.wificonf/assets/auto_connect.py +++ b/internal_filesystem/builtin/apps/com.example.wificonf/assets/auto_connect.py @@ -76,12 +76,14 @@ def attempt_connecting(ssid,password): print("auto_connect.py running...") load_config() -wlan=network.WLAN(network.STA_IF) -wlan.active(False) # restart WiFi hardware in case it's in a bad state -wlan.active(True) - -if auto_connect(): - print("auto_connect.py managed to connect.") +if len(access_points): + wlan=network.WLAN(network.STA_IF) + wlan.active(False) # restart WiFi hardware in case it's in a bad state + wlan.active(True) + if auto_connect(): + print("auto_connect.py managed to connect.") + else: + print("auto_connect.py did not manage to connect.") + wlan.active(False) # disable to conserve power else: - print("auto_connect.py did not manage to connect.") - wlan.active(False) # disable to conserve power + print("auto_connect.py: not access points configured, exiting...")