| Crates.io | esp-embassy-wifihelper |
| lib.rs | esp-embassy-wifihelper |
| version | 0.2.3 |
| created_at | 2025-02-08 21:14:11.991659+00 |
| updated_at | 2025-04-25 17:43:16.42808+00 |
| description | Simple helper library to make it easier to connect to wifi with esp-embassy |
| homepage | https://github.com/oyvindnetland/esp-embassy-wifihelper |
| repository | https://github.com/oyvindnetland/esp-embassy-wifihelper |
| max_upload_size | |
| id | 1548411 |
| size | 58,763 |
Simple helper library to make it easier to connect to wifi with esp-embassy.
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,
peripherals.RADIO_CLK,
SSID.try_into().unwrap(),
PASSWORD.try_into().unwrap(),
);
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,
peripherals.RADIO_CLK,
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;
This has been tested on esp32, esp32c3, esp32s3 and esp32c6, and is assumed to work on the remaining esp32 devices as well.