Skip to content

core: services: wifi: WifiManager: Start without a wlan interface - #4215

Draft
patrickelectric wants to merge 3 commits into
bluerobotics:masterfrom
patrickelectric:quiet-missing-wlan
Draft

core: services: wifi: WifiManager: Start without a wlan interface#4215
patrickelectric wants to merge 3 commits into
bluerobotics:masterfrom
patrickelectric:quiet-missing-wlan

Conversation

@patrickelectric

Copy link
Copy Markdown
Member

wpa_supplicant fails when there is no wlan adapter.

Fix #4210

@github-actions

Copy link
Copy Markdown

Automated PR Review

0. Summary

  • Verdict: DOES NOT SAIL 🪨
  • Critical items to address: 1.1, 1.2

Guards the wpa_supplicant WifiManager (status, get_wifi_available, get_saved_wifi_network) with a _iface_exists() check on /sys/class/net/<iface>, returning an empty result / WifiStatus(state="unavailable") when the interface is missing. The frontend WifiUpdater detects the new state === 'unavailable' and stops the five polling OneMoreTime tasks.

1. Correctness & Implementation Bugs

  • 1.1 [major] core/services/wifi/wifi_handlers/wpa_supplicant/WifiManager.py:194_iface_exists() falls back to "wlan0" whenever self.args.socket_name is not passed on the CLI, but in start() (lines 529–560) the socket is auto-detected from /var/run/wpa_supplicant/ and may resolve to wlp*, wifi*, etc. That resolved name is stored in a local variable and never written back to self.args.socket_name, so on any host where the interface is not wlan0 and --socket was omitted, _iface_exists() will always return False and every WiFi endpoint will silently report "unavailable" even though wpa_supplicant is up and working. Store the resolved name on self (e.g. self._iface_name) during start() and read it back from _iface_exists().
  • 1.2 [major] core/frontend/src/components/wifi/WifiUpdater.vue:43-49 — On state === 'unavailable' the code stops all five OneMoreTime tasks, including fetch_network_status_task, which is the only mechanism that would have re-detected the interface becoming available. OneMoreTime.stop() only sets isPaused = true; nothing in this component ever calls .resume(), so hot-plugging a USB Wi-Fi adapter (or the interface coming back after a driver reload) requires a full page reload. Prefer leaving fetch_network_status_task running (so state can flip back), or wire up a resume path when a subsequent status poll reports the interface again.
  • 1.3 [minor] core/frontend/src/components/wifi/WifiUpdater.vue:43-49 — The unavailable branch calls wifi.setCurrentNetwork(null) but skips the corresponding wifi.setNetworkStatus(...), setSavedNetworks(null), setAvailableNetworks(null), and setHotspotStatus(null) calls. Any component that was reading wifi.network_status.wpa_state === 'COMPLETED' (or the saved/available/hotspot lists) will keep showing pre-removal data indefinitely because the polling tasks that would have cleared it on the next tick are now stopped.

6. Code Quality & Style

  • 6.1 [minor] core/services/wifi/wifi_handlers/wpa_supplicant/WifiManager.py:193 — the "wlan0" fallback and the "/sys/class/net/…" path are magic strings. "wlan0" also appears at line 187 (HotspotManager("wlan0", …)) and 394 (dhcpcd -n wlan0); consider a module-level DEFAULT_WLAN_IFACE = "wlan0" so a future rename hits one place.
  • 6.2 [nit] core/frontend/src/components/wifi/WifiUpdater.vue:43'unavailable' is a shared protocol string between backend and frontend; extracting it into a constant (or into @/types/wifi) would prevent a silent divergence if the backend value ever changes.

7. Tests

  • 7.1 [minor] No unit tests were added for the new _iface_exists() branch, and there are no existing tests exercising WifiManager.status() returning state="unavailable". Given ./.hooks/pre-push enforces coverage via pytest, at minimum a small test asserting status() short-circuits when the sysfs path is absent (monkeypatching os.path.exists) would prevent regressions such as the 1.1 fallback bug.

8. Documentation

  • 8.1 [nit] core/services/wifi/wifi_handlers/wpa_supplicant/WifiManager.py:193_iface_exists is a nicely-named helper, but adding a one-line comment explaining that state="unavailable" is a contract the frontend depends on would help future editors avoid breaking the cross-service handshake.

Generated by PR Review Bot. This is advisory, a human reviewer must still approve.

@patrickelectric patrickelectric changed the title core: services: wifi: WifiManager: Return empty status if wlan is gone core: services: wifi: WifiManager: Start without a wlan interface Aug 21, 2026
@patrickelectric
patrickelectric requested a review from a team August 21, 2026 02:36
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
…s gone

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
…dapter

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
@patrickelectric
patrickelectric force-pushed the quiet-missing-wlan branch 2 times, most recently from 1ad8405 to 01815e3 Compare August 21, 2026 14:57
@patrickelectric

Copy link
Copy Markdown
Member Author

sorry, it should be ready now @bluerobotics/blueos-team

@patrickelectric

Copy link
Copy Markdown
Member Author

ping @bluerobotics/blueos-team

1 similar comment
@patrickelectric

Copy link
Copy Markdown
Member Author

ping @bluerobotics/blueos-team

@patrickelectric patrickelectric added the move-to-stable Needs to be cherry-picked and move to stable label Sep 3, 2026
@joaoantoniocardoso

joaoantoniocardoso commented Sep 3, 2026

Copy link
Copy Markdown
Member

I'm unable to use/test wifi on this branch (from the UI).

@patrickelectric

Copy link
Copy Markdown
Member Author

@joaoantoniocardoso check now

@patrickelectric

Copy link
Copy Markdown
Member Author

I found a problem, let me investigate further

@patrickelectric
patrickelectric marked this pull request as draft September 3, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

move-to-stable Needs to be cherry-picked and move to stable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: WIFI_STATUS_FETCH_FAIL spam with no wlan

2 participants