Get current Ethernet interface status.
(self)
| 160 | self.ethernet_last_refresh = timestamp |
| 161 | |
| 162 | def get_ethernet_status(self) -> Dict: |
| 163 | """Get current Ethernet interface status.""" |
| 164 | with self._lock: |
| 165 | active_interface = None |
| 166 | for iface in self.ethernet_interfaces.values(): |
| 167 | # Only consider interfaces with valid (non-link-local) IPs |
| 168 | if (iface.get('connected') and |
| 169 | iface.get('has_carrier') and |
| 170 | iface.get('ip_address') and |
| 171 | not iface.get('is_link_local')): |
| 172 | active_interface = iface |
| 173 | break |
| 174 | |
| 175 | ethernet_scan_enabled = self.shared_data.config.get('ethernet_scan_enabled', True) |
| 176 | has_active_connection = active_interface is not None |
| 177 | |
| 178 | return { |
| 179 | 'available': bool(self.ethernet_interfaces), |
| 180 | 'active': has_active_connection, |
| 181 | 'active_interface': active_interface, |
| 182 | 'interfaces': list(self.ethernet_interfaces.values()), |
| 183 | 'scan_enabled': ethernet_scan_enabled, |
| 184 | 'can_toggle_scan': has_active_connection, |
| 185 | 'last_refresh': self.ethernet_last_refresh, |
| 186 | } |
| 187 | |
| 188 | def set_ethernet_scan_enabled(self, enabled: bool) -> Dict: |
| 189 | """Enable or disable scanning over Ethernet.""" |
no test coverage detected