Skip to content

Commit f7a42f1

Browse files
wificonf: don't activate wifi if nothing is configured
1 parent c23d51f commit f7a42f1

File tree

1 file changed

+10
-8
lines changed
  • internal_filesystem/builtin/apps/com.example.wificonf/assets

1 file changed

+10
-8
lines changed

internal_filesystem/builtin/apps/com.example.wificonf/assets/auto_connect.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ def attempt_connecting(ssid,password):
7676
print("auto_connect.py running...")
7777
load_config()
7878

79-
wlan=network.WLAN(network.STA_IF)
80-
wlan.active(False) # restart WiFi hardware in case it's in a bad state
81-
wlan.active(True)
82-
83-
if auto_connect():
84-
print("auto_connect.py managed to connect.")
79+
if len(access_points):
80+
wlan=network.WLAN(network.STA_IF)
81+
wlan.active(False) # restart WiFi hardware in case it's in a bad state
82+
wlan.active(True)
83+
if auto_connect():
84+
print("auto_connect.py managed to connect.")
85+
else:
86+
print("auto_connect.py did not manage to connect.")
87+
wlan.active(False) # disable to conserve power
8588
else:
86-
print("auto_connect.py did not manage to connect.")
87-
wlan.active(False) # disable to conserve power
89+
print("auto_connect.py: not access points configured, exiting...")

0 commit comments

Comments
 (0)