@@ -50,6 +50,7 @@ def connect(network_module=None):
5050 """
5151 Scan for available networks and connect to the first saved network found.
5252 Networks are tried in order of signal strength (strongest first).
53+ Hidden networks are also tried even if they don't appear in the scan.
5354
5455 Args:
5556 network_module: Network module for dependency injection (testing)
@@ -64,9 +65,13 @@ def connect(network_module=None):
6465 # RSSI is at index 3, higher values (less negative) = stronger signal
6566 networks = sorted (networks , key = lambda n : n [3 ], reverse = True )
6667
68+ # Track which SSIDs we've tried (to avoid retrying hidden networks)
69+ tried_ssids = set ()
70+
6771 for n in networks :
6872 ssid = n [0 ].decode ()
6973 rssi = n [3 ]
74+ tried_ssids .add (ssid )
7075 print (f"WifiService: Found network '{ ssid } ' (RSSI: { rssi } dBm)" )
7176
7277 if ssid in WifiService .access_points :
@@ -81,6 +86,18 @@ def connect(network_module=None):
8186 else :
8287 print (f"WifiService: Skipping '{ ssid } ' (not configured)" )
8388
89+ # Try hidden networks that weren't in the scan results
90+ for ssid , config in WifiService .access_points .items ():
91+ if config .get ("hidden" ) and ssid not in tried_ssids :
92+ password = config .get ("password" )
93+ print (f"WifiService: Attempting hidden network '{ ssid } '" )
94+
95+ if WifiService .attempt_connecting (ssid , password , network_module = network_module ):
96+ print (f"WifiService: Connected to hidden network '{ ssid } '" )
97+ return True
98+ else :
99+ print (f"WifiService: Failed to connect to hidden network '{ ssid } '" )
100+
84101 print ("WifiService: No saved networks found or connected" )
85102 return False
86103
0 commit comments