Skip to content

Simple helper library to make it easier to connect to wifi with esp-embassy.

License

Notifications You must be signed in to change notification settings

oyvindnetland/esp-embassy-wifihelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esp-embassy-wifi

Simple helper library to make it easier to connect to wifi with esp-embassy.

How to use

The wifi_example.rs in examples folder show a minimal esp32c3 example code. The part that use this library is this:

let wifi = WifiStack::new(
    spawner,
    peripherals.WIFI,
    peripherals.TIMG0,
    peripherals.RNG,
    SSID.try_into().unwrap(),
    PASSWORD.try_into().unwrap(),
);

How to set up and start delayed through a channel

For cases where wifi is not supposed to connect at startup, or the ssid/password is unknown at startup, a variant for connecting is used. The correct hardware resources are set up and the tasks are spawned, but it waits for a message on a channel with the ssid/password information.

static CHANNEL: Channel<CriticalSectionRawMutex, ClientConfiguration, 1> = Channel::new();

let wifi = WifiStack::new_connect_later(
    spawner,
    peripherals.WIFI,
    peripherals.TIMG0,
    peripherals.RNG,
    CHANNEL.receiver(),
);

The wifi will then try to connect with:

let client_config = ClientConfiguration {
    ssid: SSID.try_into().unwrap(),
    password: PASSWORD.try_into().unwrap(),
    ..Default::default()
};
let _ = CHANNEL.send(client_config).await;

Supported devices

This has been tested on esp32, esp32c3, esp32s3 and esp32c6, and is assumed to work on the remaining esp32 devices as well.

Examples

Examples can be run with the following command:

# replace esp32 with correct device
RUST_LOG=info cargo run --release --features esp32example --features log --target=xtensa-esp32-none-elf --example wifi_example 

or using defmt (also need change in config.toml):

DEFMT_LOG=info cargo run --release --features esp32example --features defmt --target=xtensa-esp32-none-elf --example wifi_example 

About

Simple helper library to make it easier to connect to wifi with esp-embassy.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages