Get the preferred interface for scanning. If Ethernet is available and preferred, use it. Otherwise use WiFi.
(self)
| 195 | return self.get_ethernet_status() |
| 196 | |
| 197 | def get_preferred_scan_interface(self) -> Optional[Dict]: |
| 198 | """ |
| 199 | Get the preferred interface for scanning. |
| 200 | If Ethernet is available and preferred, use it. Otherwise use WiFi. |
| 201 | """ |
| 202 | prefer_ethernet = self.shared_data.config.get('ethernet_prefer_over_wifi', True) |
| 203 | ethernet_scan_enabled = self.shared_data.config.get('ethernet_scan_enabled', True) |
| 204 | |
| 205 | if prefer_ethernet and ethernet_scan_enabled: |
| 206 | with self._lock: |
| 207 | for iface in self.ethernet_interfaces.values(): |
| 208 | if iface.get('connected') and iface.get('has_carrier') and iface.get('ip_address'): |
| 209 | return {**iface, 'preferred_reason': 'ethernet_preferred'} |
| 210 | |
| 211 | # Fall back to WiFi |
| 212 | with self._lock: |
| 213 | for iface in self.interfaces.values(): |
| 214 | if iface.get('connected') and iface.get('ip_address'): |
| 215 | return {**iface, 'type': 'wifi', 'preferred_reason': 'wifi_fallback'} |
| 216 | |
| 217 | return None |
| 218 | |
| 219 | def sync_from_interfaces(self, interfaces: List[Dict]): |
| 220 | """Sync incoming interface metadata (from nmcli, wifi manager, or API).""" |
no test coverage detected