Crates.io | wpa-ctrl |
lib.rs | wpa-ctrl |
version | 0.2.1 |
source | src |
created_at | 2022-08-25 14:05:57.594782 |
updated_at | 2024-01-13 12:08:29.111053 |
description | WPA controller interface |
homepage | |
repository | https://github.com/DoumanAsh/wpa-ctrl |
max_upload_size | |
id | 652193 |
size | 30,853 |
use wpa_ctrl::{WpaControlReq, WpaControllerBuilder};
const WPA_CTRL_BUILD: WpaControllerBuilder<'static> = WpaControllerBuilder::new();
let mut ctrl = match WPA_CTRL_BUILD.open("wlan0") {
Ok(ctrl) => ctrl,
Err(error) => panic!("Cannot open wlan0"),
};
ctrl.request(WpaControlReq::status()).expect("Successful command");
while let Some(resp) = ctrl.recv().expect("To read message") {
//Skip messages that are not intended as responses
if resp.is_unsolicited() {
continue;
}
if let Some(status) = resp.as_status() {
println!("Network status={:?}", status);
break;
}
}
scan
and check list of networks using scan_results
add_network
which returns returns id
of networkset_network <id> ssid "network name"
which specifies network's name to associate withset_network <id> psk "WAP password"
which specifies WPA password, only usable when network
requires WPA securityset_network <id> key_mgmt NONE
which specifies no security, required to connect to networks
without passwordselect_network <id>
- Select network for use.save_config
- Optionally to save configuration.disconnect
;reassociate
to start process of connecting to currently selected network