wifi-rs icon indicating copy to clipboard operation
wifi-rs copied to clipboard

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

Open murro-jr opened this issue 3 years ago • 6 comments

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 avatar Jan 15 '22 23:01 murro-jr

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

murro-jr avatar Jan 15 '22 23:01 murro-jr

Cargo.toml

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

chriamue avatar Jan 28 '22 16:01 chriamue

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

opeolluwa avatar May 14 '22 10:05 opeolluwa

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.

toksdotdev avatar May 15 '22 17:05 toksdotdev

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 ?

opeolluwa avatar May 15 '22 18:05 opeolluwa

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

murro-jr avatar May 24 '22 11:05 murro-jr