Skip to content

Commit

Permalink
Add wifiscanner from balena-os#492
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickinthebox committed Nov 14, 2023
1 parent f9f3ebe commit 2ee40d3
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 4 deletions.
70 changes: 67 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ params = "0.8"
log = "0.3"
env_logger = "0.4"
nix = "0.25"
wifiscanner = "0.5.1"

[dependencies.error-chain]
version = "0.12"
Expand Down
13 changes: 12 additions & 1 deletion src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,18 @@ impl NetworkCommandHandler {
fn activate(&mut self) -> ExitResult {
self.activated = true;

let networks = get_networks(&self.access_points);
// wifiscanner will use iw to scan which allows us to refresh access points _without_
// needing to stop the captive portal. We'll discard its results rather than converting to
// Network since it has not implemented parsing security.
let _ = wifiscanner::scan();
self.access_points = get_access_points(&self.device)?;

let networks = {
let mut networks = get_networks(&self.access_points);
// Drop our portal SSID from the list of returned networks
networks.retain(|network| network.ssid != self.config.ssid);
networks
};

self.server_tx
.send(NetworkCommandResponse::Networks(networks))
Expand Down

0 comments on commit 2ee40d3

Please sign in to comment.