Merge pull request #10 from ISRAEL-DUFF/smallfix

Some fixes for the examples and the crate
This commit is contained in:
Tochukwu Nkemdilim
2021-02-03 21:41:52 +01:00
committed by GitHub
6 changed files with 54 additions and 6 deletions
+7
View File
@@ -0,0 +1,7 @@
[package]
name = "wifi-cli"
version = "0.1.0"
authors = ["Tochukwu Nkemdilim <nkemdilimtochukwu@gmail.com>"]
[dependencies]
wifi-rs = { path = "../../../wifi-rs" }
+24
View File
@@ -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(())
}
+8 -2
View File
@@ -4,6 +4,7 @@ extern crate wifi_rs;
use clap::{App, Arg};
use std::io;
use wifi_rs::WiFi;
use wifi_rs::prelude::*;
fn main() -> Result<(), io::Error> {
let matches = App::new("Wi-Fi")
@@ -48,8 +49,13 @@ fn main() -> Result<(), io::Error> {
// Get Wireless Interface
let interface = matches.value_of("interface").unwrap();
let wifi = WiFi::new(ssid)?;
println!("Connection Status: {}", wifi.connect(password));
let config = Some(Config {
interface: Some(interface),
});
// let wifi = WiFi::new(ssid)?;
let mut wifi = WiFi::new(config);
println!("Connection Status: {:?}", wifi.connect(ssid, password));
Ok(())
}
+1 -2
View File
@@ -1,4 +1,4 @@
mod providers;
pub mod providers;
use self::providers::prelude::HotspotConfig;
use crate::platforms::{WifiError, WifiInterface};
@@ -44,7 +44,6 @@ pub trait WifiHotspot: fmt::Debug + WifiInterface {
}
/// Stop serving a wireless network.
///
/// **NOTE: All users connected will automatically be disconnected.**
fn stop_hotspot(&mut self) -> Result<bool, WifiHotspotError> {
unimplemented!();
+12 -1
View File
@@ -16,6 +16,17 @@ pub struct HotspotConfig {
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)]
#[derive(Debug)]
/// Band type of wireless hotspot.
@@ -58,9 +69,9 @@ impl WifiHotspot for WiFi {
let mut command = vec![
"device".to_string(),
"wifi".to_string(),
"hotspot".to_string(),
"ifname".to_string(),
self.interface.to_string(),
"hotspot".to_string(),
"con-name".to_string(),
HOTSPOT_GROUP.to_string(),
"ssid".to_string(),
+1
View File
@@ -6,6 +6,7 @@ mod platforms;
pub mod prelude {
pub use crate::connectivity::*;
pub use crate::hotspot::*;
pub use crate::hotspot::providers::prelude::*;
pub use crate::platforms::Config;
}