diff --git a/core/frontend/src/components/wifi/WifiManager.vue b/core/frontend/src/components/wifi/WifiManager.vue index 5698353222..e94d49b0e0 100644 --- a/core/frontend/src/components/wifi/WifiManager.vue +++ b/core/frontend/src/components/wifi/WifiManager.vue @@ -80,8 +80,13 @@ flat class="text-body-1 text-center" > - No wifi networks available :(
- Rescanning... + +
diff --git a/core/frontend/src/components/wifi/WifiUpdater.vue b/core/frontend/src/components/wifi/WifiUpdater.vue index 8187640f5c..4adfc8ced8 100644 --- a/core/frontend/src/components/wifi/WifiUpdater.vue +++ b/core/frontend/src/components/wifi/WifiUpdater.vue @@ -40,6 +40,15 @@ export default Vue.extend({ timeout: 10000, }) .then((response) => { + if (response.data.state === 'unavailable') { + wifi.setNetworkStatus(response.data) + wifi.setCurrentNetwork(null) + wifi.setAvailableNetworks([]) + this.fetch_network_status_task.setDelay(30000) + return + } + + this.fetch_network_status_task.setDelay(5000) wifi.setNetworkStatus(response.data) if (response.data.wpa_state !== 'COMPLETED') { diff --git a/core/frontend/src/types/wifi.ts b/core/frontend/src/types/wifi.ts index c5ddf67615..a88784d371 100644 --- a/core/frontend/src/types/wifi.ts +++ b/core/frontend/src/types/wifi.ts @@ -27,6 +27,7 @@ export interface WifiStatus { p2p_device_address: string address: string uuid: string + state?: string } export interface WPANetwork { diff --git a/core/services/wifi/wifi_handlers/wpa_supplicant/WifiManager.py b/core/services/wifi/wifi_handlers/wpa_supplicant/WifiManager.py index c5600b5a50..a0412a32f9 100644 --- a/core/services/wifi/wifi_handlers/wpa_supplicant/WifiManager.py +++ b/core/services/wifi/wifi_handlers/wpa_supplicant/WifiManager.py @@ -192,6 +192,8 @@ def hotspot(self) -> HotspotManager: async def get_wifi_available(self) -> List[ScannedWifiNetwork]: """Get a dict from the wifi signals available""" + if self.wpa_path is None: + return [] async def perform_new_scan() -> None: try: @@ -231,6 +233,8 @@ async def perform_new_scan() -> None: async def get_saved_wifi_network(self) -> List[SavedWifiNetwork]: """Get a list of saved wifi networks""" + if self.wpa_path is None: + return [] try: data = await self.wpa.send_command_list_networks() networks_list = WifiManager.__dict_from_table(data) @@ -331,6 +335,8 @@ async def connect_to_network(self, network_id: int, timeout: float = 20.0) -> No async def status(self) -> WifiStatus: """Check wpa_supplicant status""" + if self.wpa_path is None: + return WifiStatus(state="unavailable") try: data = await self.wpa.send_command_status() return WifiStatus(**WifiManager.__dict_from_list(data)) @@ -473,6 +479,9 @@ async def set_hotspot_credentials(self, credentials: WifiCredentials) -> None: self._settings_manager.settings.hotspot_password = credentials.password self._settings_manager.save() + if self.wpa_path is None: + return + self.hotspot.set_credentials(credentials) if self.hotspot.is_running(): @@ -481,6 +490,9 @@ async def set_hotspot_credentials(self, credentials: WifiCredentials) -> None: await self.enable_hotspot(save_settings=False) def hotspot_credentials(self) -> WifiCredentials: + if self.wpa_path is None: + settings = self._settings_manager.settings + return WifiCredentials(ssid=settings.hotspot_ssid or "", password=settings.hotspot_password or "") credentials: WifiCredentials = self.hotspot.credentials return credentials @@ -566,14 +578,19 @@ def is_socket(file_path: str) -> bool: try: await self.connect(("127.0.0.1", 6664)) except Exception as udp_connection_error: - logger.error(f"Could not connect with internet socket: {udp_connection_error}. Exiting.") - raise udp_connection_error + logger.error(f"Could not connect with internet socket: {udp_connection_error}.") + self.wpa_path = None + return loop = asyncio.get_event_loop() loop.create_task(self.auto_reconnect(60)) loop.create_task(self.start_hotspot_watchdog()) async def supports_hotspot(self) -> bool: + if self.wpa_path is None: + return False return self.hotspot.supports_hotspot async def hotspot_is_running(self) -> bool: + if self.wpa_path is None: + return False return self.hotspot.is_running()