5 releases

0.2.1 Jan 13, 2024
0.2.0 Oct 27, 2022
0.1.3 Oct 6, 2022
0.1.2 Aug 26, 2022

#455 in Network programming

Download history 1/week @ 2024-07-22 25/week @ 2024-09-16 180/week @ 2024-09-23 138/week @ 2024-09-30 144/week @ 2024-10-07 92/week @ 2024-10-14 58/week @ 2024-10-21 73/week @ 2024-10-28

223 downloads per month

BSL-1.0 license

30KB
535 lines

wpa-ctrl

Rust Crates.io Documentation

Usage

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 <id> ssid "network name" which specifies network's name to associate with
  • set_network <id> psk "WAP password" which specifies WPA password, only usable when network requires WPA security
  • set_network <id> key_mgmt NONE which specifies no security, required to connect to networks without password
  • select_network <id> - Select network for use.
  • save_config - Optionally to save configuration.

Reconnect

  • Optionally disconnect;
  • Run reassociate to start process of connecting to currently selected network

Dependencies

~185KB