@@ -173,8 +173,9 @@ async def _request_scan(self) -> None:
173173 return
174174 try :
175175 device = NetworkDeviceWireless (self ._device_path , self ._bus )
176+ interface_name = await device .interface
177+ logger .info (f"Requesting WiFi scan on { interface_name } " )
176178 await device .request_scan ({})
177- logger .info ("Requested WiFi scan on new interface" )
178179 except Exception as e :
179180 logger .warning (f"Failed to request scan: { e } " )
180181
@@ -190,13 +191,16 @@ async def _autoscan(self) -> None:
190191
191192 async def get_wifi_available (self ) -> List [ScannedWifiNetwork ]:
192193 if not self ._device_path or not self ._nm :
194+ logger .warning ("get_wifi_available: No device path or NetworkManager" )
193195 return []
194196
195197 try :
196198 device = NetworkDeviceWireless (self ._device_path , bus = self ._bus )
199+ interface_name = await device .interface
197200 networks : List [ScannedWifiNetwork ] = []
198201
199202 ap_paths = await device .get_all_access_points ()
203+ logger .info (f"Scanning on { interface_name } : found { len (ap_paths )} access points" )
200204 for ap_path in ap_paths :
201205 ap = AccessPoint (ap_path , self ._bus )
202206 freq = await ap .frequency .get_async ()
@@ -312,11 +316,17 @@ async def wait_for_connection(timeout: int = 30) -> bool:
312316 await self .enable_hotspot ()
313317
314318 async def _find_existing_connection (self , credentials : WifiCredentials ) -> Optional [str ]:
315- """Find existing connection for given SSID, checking password if provided """
319+ """Find existing connection for given SSID, checking password and interface compatibility """
316320 try :
317321 if not self ._nm_settings :
318322 return None
319323
324+ # Get current interface name to check compatibility
325+ current_interface = None
326+ if self ._device_path :
327+ current_device = NetworkDeviceWireless (self ._device_path , self ._bus )
328+ current_interface = await current_device .interface
329+
320330 for conn_path in await self ._nm_settings .connections :
321331 try :
322332 settings = NetworkConnectionSettings (conn_path , self ._bus )
@@ -328,6 +338,15 @@ async def _find_existing_connection(self, credentials: WifiCredentials) -> Optio
328338 if profile .wireless .ssid .decode ("utf-8" ) != credentials .ssid :
329339 continue
330340
341+ # Check if connection has interface-name constraint that doesn't match current interface
342+ if profile .connection .interface_name and current_interface :
343+ if profile .connection .interface_name != current_interface :
344+ logger .info (
345+ f"Skipping connection for { credentials .ssid } : "
346+ f"bound to { profile .connection .interface_name } , current is { current_interface } "
347+ )
348+ continue
349+
331350 # If no password provided, we can use any existing connection
332351 if not credentials .password :
333352 logger .info (f"Found existing connection for { credentials .ssid } (no password check)" )
0 commit comments