Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow wifi-connect to refresh networks while connected #492

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tomasgareau
Copy link

This introduces a quick-and-dirty way that we could allow wifi-connect to refresh its list of nearby APs without restarting the device or interrupting the captive portal. Not sure if this would work for all of wifi-connect's use-cases but it has worked for us so I thought I'd put up a PR to see if there was any interest in this approach (or something like it).

We fire off a wifiscanner::scan on every call to activate. wifiscanner uses iw under the hood on Linux which means we can scan for nearby APs while still providing the captive portal via NetworkManager.

We could convert the resultant wifiscanner::Wifi to a Network but unfortunately wifiscanner doesn't currently parse security info from the output of iw 😬 Fortunately, this scan still seems to allow NetworkManager to discover new APs, so we can just refresh our list of access points and get_networks as usual.

This means that every call to /networks will kick off a new scan. This should allow #354 to "just work" since it would get an updated list of networks every time. Otherwise I've found I can also just refresh the captive portal page.

This uses wifiscanner (which in turn uses iw) to scan for networks. This
means we can refresh our list of networks while still providing an AP
via NetworkManager.

Unfortunately, wifiscanner does not currently parse security for
networks on Linux, so we can't use its results. Fortunately, just doing
the scan seems to be enough for NetworkManager to pick up the results!
Nickinthebox added a commit to mapado/wifi-connect that referenced this pull request Nov 14, 2023
@meelash
Copy link

meelash commented Nov 27, 2023

We could convert the resultant wifiscanner::Wifi to a Network but unfortunately wifiscanner doesn't currently parse security info from the output of iw 😬 Fortunately, this scan still seems to allow NetworkManager to discover new APs, so we can just refresh our list of access points and get_networks as usual.

This didn't work for me on a pi4 for whatever reason. NetworkManager was only returning the broadcasted AP, even after the iw scan. I therefore switched to using a pull request on wifiscanner that has security info and adding the parsing of the results to Networks.

I've created a new pull request of that here: #521

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants