Some fixes for the examples and the crate
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
[package]
|
||||||
|
name = "wifi-cli"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Tochukwu Nkemdilim <[email protected]>"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wifi-rs = { path = "../../../wifi-rs" }
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
extern crate wifi_rs;
|
||||||
|
|
||||||
|
use std::io;
|
||||||
|
use wifi_rs::WiFi;
|
||||||
|
use wifi_rs::prelude::*;
|
||||||
|
|
||||||
|
fn main() -> Result<(), io::Error> {
|
||||||
|
let config = Some(Config {
|
||||||
|
interface: Some("wlo1"),
|
||||||
|
});
|
||||||
|
|
||||||
|
let mut wifi = WiFi::new(config);
|
||||||
|
let config = HotspotConfig::new(Some(HotspotBand::Bg), Some(Channel::One));
|
||||||
|
|
||||||
|
wifi.create_hotspot(
|
||||||
|
"test-hotspot",
|
||||||
|
"password",
|
||||||
|
Some(
|
||||||
|
&config
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ extern crate wifi_rs;
|
|||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
use std::io;
|
use std::io;
|
||||||
use wifi_rs::WiFi;
|
use wifi_rs::WiFi;
|
||||||
|
use wifi_rs::prelude::*;
|
||||||
|
|
||||||
fn main() -> Result<(), io::Error> {
|
fn main() -> Result<(), io::Error> {
|
||||||
let matches = App::new("Wi-Fi")
|
let matches = App::new("Wi-Fi")
|
||||||
@@ -48,8 +49,13 @@ fn main() -> Result<(), io::Error> {
|
|||||||
// Get Wireless Interface
|
// Get Wireless Interface
|
||||||
let interface = matches.value_of("interface").unwrap();
|
let interface = matches.value_of("interface").unwrap();
|
||||||
|
|
||||||
let wifi = WiFi::new(ssid)?;
|
let config = Some(Config {
|
||||||
println!("Connection Status: {}", wifi.connect(password));
|
interface: Some(interface),
|
||||||
|
});
|
||||||
|
|
||||||
|
// let wifi = WiFi::new(ssid)?;
|
||||||
|
let mut wifi = WiFi::new(config);
|
||||||
|
println!("Connection Status: {:?}", wifi.connect(ssid, password));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
+1
-2
@@ -1,4 +1,4 @@
|
|||||||
mod providers;
|
pub mod providers;
|
||||||
|
|
||||||
use self::providers::prelude::HotspotConfig;
|
use self::providers::prelude::HotspotConfig;
|
||||||
use crate::platforms::{WifiError, WifiInterface};
|
use crate::platforms::{WifiError, WifiInterface};
|
||||||
@@ -44,7 +44,6 @@ pub trait WifiHotspot: fmt::Debug + WifiInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Stop serving a wireless network.
|
/// Stop serving a wireless network.
|
||||||
///
|
|
||||||
/// **NOTE: All users connected will automatically be disconnected.**
|
/// **NOTE: All users connected will automatically be disconnected.**
|
||||||
fn stop_hotspot(&mut self) -> Result<bool, WifiHotspotError> {
|
fn stop_hotspot(&mut self) -> Result<bool, WifiHotspotError> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
|
|||||||
@@ -16,6 +16,17 @@ pub struct HotspotConfig {
|
|||||||
channel: Option<Channel>,
|
channel: Option<Channel>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// function to create a new config object
|
||||||
|
#[allow(dead_code)]
|
||||||
|
impl HotspotConfig {
|
||||||
|
pub fn new(band: Option<HotspotBand>, channel: Option<Channel>) -> HotspotConfig {
|
||||||
|
HotspotConfig {
|
||||||
|
band,
|
||||||
|
channel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
/// Band type of wireless hotspot.
|
/// Band type of wireless hotspot.
|
||||||
@@ -58,9 +69,9 @@ impl WifiHotspot for WiFi {
|
|||||||
let mut command = vec![
|
let mut command = vec![
|
||||||
"device".to_string(),
|
"device".to_string(),
|
||||||
"wifi".to_string(),
|
"wifi".to_string(),
|
||||||
|
"hotspot".to_string(),
|
||||||
"ifname".to_string(),
|
"ifname".to_string(),
|
||||||
self.interface.to_string(),
|
self.interface.to_string(),
|
||||||
"hotspot".to_string(),
|
|
||||||
"con-name".to_string(),
|
"con-name".to_string(),
|
||||||
HOTSPOT_GROUP.to_string(),
|
HOTSPOT_GROUP.to_string(),
|
||||||
"ssid".to_string(),
|
"ssid".to_string(),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ mod platforms;
|
|||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::connectivity::*;
|
pub use crate::connectivity::*;
|
||||||
pub use crate::hotspot::*;
|
pub use crate::hotspot::*;
|
||||||
|
pub use crate::hotspot::providers::prelude::*;
|
||||||
pub use crate::platforms::Config;
|
pub use crate::platforms::Config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user