toksdotdev / wifi-rs

📡 Easily interface and manage wireless networks.
https://crates.io/crates/wifi-rs
131 stars 21 forks source link

Use of undeclared type 'HotspotConfig', 'HotspotBand', 'Channel' #13

Open murro-jr opened 2 years ago

murro-jr commented 2 years ago

I tried your example on creating WiFi hotspot and it wasn't able to find 'HotspotConfig', and enums 'HotspotBand' and 'Channel'. I am using the version "0.2.2" release.

use std::io;
use wifi_rs::{prelude::*, WiFi};

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(())
}

error[E0433]: failed to resolve: use of undeclared type HotspotConfig --> src/main.rs:10:18 | 10 | let config = HotspotConfig::new(Some(HotspotBand::Bg), Some(Channel::One)); | ^^^^^^^^^^^^^ use of undeclared type HotspotConfig

error[E0433]: failed to resolve: use of undeclared type HotspotBand --> src/main.rs:10:42 | 10 | let config = HotspotConfig::new(Some(HotspotBand::Bg), Some(Channel::One)); | ^^^^^^^^^^^ use of undeclared type HotspotBand

error[E0433]: failed to resolve: use of undeclared type Channel --> src/main.rs:10:65 | 10 | let config = HotspotConfig::new(Some(HotspotBand::Bg), Some(Channel::One)); | ^^^^^^^ use of undeclared type Channel

error: aborting due to 3 previous errors

murro-jr commented 2 years ago

The workaround for me to build this successfully is to clone the repository and include directly to my dependencies in Cargo.toml.

chriamue commented 2 years ago

Cargo.toml

[dependencies]
wifi-rs = { git = "https://github.com/tnkemdilim/wifi-rs.git" }
opeolluwa commented 2 years ago

Hi @chriamue did the hack work out fine

Cargo.toml

[dependencies]
wifi-rs = { git = "https://github.com/tnkemdilim/wifi-rs.git" }

Hi @chriamue did the hack work out fine

toksdotdev commented 2 years ago

Apologies for not responding to this earlier.

@murro-jr What OS did you try this on? Hotspot functionality for each operating system is selected based on thetarget_os it's built on.

The types Channel, HostpotConfig, and HotspotBand are only available when the target_os=linux.

opeolluwa commented 2 years ago

Apologies for not responding to this earlier.

@murro-jr What OS did you try this on? Hotspot functionality for each operating system is selected based on thetarget_os it's built on.

The types Channel, HostpotConfig, and HotspotBand are only available when the target_os=linux.

It works fine on Linux distro ?

murro-jr commented 2 years ago

Apologies for not responding to this earlier.

@murro-jr What OS did you try this on? Hotspot functionality for each operating system is selected based on thetarget_os it's built on.

The types Channel, HostpotConfig, and HotspotBand are only available when the target_os=linux.

I see, was using win64 but will try it out with linux