Allow wifi-connect to refresh networks while connected #492
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ofwifi-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 toactivate
.wifiscanner
usesiw
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 aNetwork
but unfortunatelywifiscanner
doesn't currently parse security info from the output ofiw
😬 Fortunately, this scan still seems to allow NetworkManager to discover new APs, so we can just refresh our list of access points andget_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.