https://github.com/doumanash/wpa-ctrl
Library to interact with wpa_supplicant
https://github.com/doumanash/wpa-ctrl
Last synced: 2 months ago
JSON representation
Library to interact with wpa_supplicant
- Host: GitHub
- URL: https://github.com/doumanash/wpa-ctrl
- Owner: DoumanAsh
- License: bsl-1.0
- Created: 2022-08-25T07:52:01.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-10-04T14:14:18.000Z (8 months ago)
- Last Synced: 2025-02-28T18:26:17.958Z (3 months ago)
- Language: Rust
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wpa-ctrl

[](https://crates.io/crates/wpa-ctrl)
[](https://docs.rs/crate/wpa-ctrl/)## Usage
```rust,no_run
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;
}
}
```## Usage scenarios
### Add new network
- Optionally `scan` and check list of networks using `scan_results`
- `add_network` which returns returns `id` of network
- `set_network ssid "network name"` which specifies network's name to associate with
- `set_network psk "WAP password"` which specifies WPA password, only usable when network
requires WPA security
- `set_network key_mgmt NONE` which specifies no security, required to connect to networks
without password
- `select_network ` - Select network for use.
- `save_config` - Optionally to save configuration.### Reconnect
- Optionally `disconnect`;
- Run `reassociate` to start process of connecting to currently selected network