esp-wifi: Remove unneeded features (#2446)

* remove async features

* phy-usb config

* modem powersaving

* Fix examples

* make ps a runtime config

* fix linting

* changelog and migration guide

* revert esp-config changes

* remove blanklines after doc comments

* cfg away ps API
This commit is contained in:
Scott Mabin 2024-11-08 13:30:33 +00:00 committed by GitHub
parent 6d6f6a7baa
commit 50d8187e39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
40 changed files with 189 additions and 234 deletions

View File

@ -137,10 +137,10 @@ jobs:
- name: msrv RISCV (esp-wifi) - name: msrv RISCV (esp-wifi)
run: | run: |
cargo xtask build-package --features=esp32c2,wifi,ble,async --target=riscv32imc-unknown-none-elf esp-wifi cargo xtask build-package --features=esp32c2,wifi,ble --target=riscv32imc-unknown-none-elf esp-wifi
cargo xtask build-package --features=esp32c3,wifi,ble,async --target=riscv32imc-unknown-none-elf esp-wifi cargo xtask build-package --features=esp32c3,wifi,ble --target=riscv32imc-unknown-none-elf esp-wifi
cargo xtask build-package --features=esp32c6,wifi,ble,async --target=riscv32imac-unknown-none-elf esp-wifi cargo xtask build-package --features=esp32c6,wifi,ble --target=riscv32imac-unknown-none-elf esp-wifi
cargo xtask build-package --features=esp32h2,ble,async --target=riscv32imac-unknown-none-elf esp-wifi cargo xtask build-package --features=esp32h2,ble --target=riscv32imac-unknown-none-elf esp-wifi
# Verify the MSRV for all Xtensa chips: # Verify the MSRV for all Xtensa chips:
- name: msrv Xtensa (esp-hal) - name: msrv Xtensa (esp-hal)
@ -151,9 +151,9 @@ jobs:
- name: msrv Xtensa (esp-wifi) - name: msrv Xtensa (esp-wifi)
run: | run: |
cargo xtask build-package --toolchain=esp --features=esp32,wifi,ble,async --target=xtensa-esp32-none-elf esp-wifi cargo xtask build-package --toolchain=esp --features=esp32,wifi,ble --target=xtensa-esp32-none-elf esp-wifi
cargo xtask build-package --toolchain=esp --features=esp32s2,wifi,async --target=xtensa-esp32s2-none-elf esp-wifi cargo xtask build-package --toolchain=esp --features=esp32s2,wifi --target=xtensa-esp32s2-none-elf esp-wifi
cargo xtask build-package --toolchain=esp --features=esp32s3,wifi,ble,async --target=xtensa-esp32s3-none-elf esp-wifi cargo xtask build-package --toolchain=esp --features=esp32s3,wifi,ble --target=xtensa-esp32s3-none-elf esp-wifi
- name: msrv (esp-lp-hal) - name: msrv (esp-lp-hal)
run: | run: |

View File

@ -10,12 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Added `serde` support through the `serde` feature (#2346) - Added `serde` support through the `serde` feature (#2346)
- Added `PowerSaveMode` and `set_power_saving` methods on `EspNowManager` & `WifiController` (#2446)
### Changed ### Changed
- `esp_wifi::init` no longer requires `EspWifiInitFor`, and now returns `EspWifiController`, see the migration guide for more details (#2301) - `esp_wifi::init` no longer requires `EspWifiInitFor`, and now returns `EspWifiController`, see the migration guide for more details (#2301)
- No need to add `rom_functions.x` manually anymore (#2374) - No need to add `rom_functions.x` manually anymore (#2374)
- esp-now: Data is now private in `ReceivedData` - use `data()`(#2396) - esp-now: Data is now private in `ReceivedData` - use `data()`(#2396)
- Changed the async APIs to have a `_async` postfix to avoid name collisions (#2446)
- `phy_enable_usb` is enabled by default (#2446)
### Fixed ### Fixed
@ -25,6 +28,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed ### Removed
- Feature `have-strchr` is removed (#2462) - Feature `have-strchr` is removed (#2462)
- Features `async`, `embassy-net` have been removed (#2446)
- Features `phy-enable-usb` & `dump-packets` have been turned into configuration options `phy_enable_usb` & `dump_packets` (#2446)
- Features `ps-min-modem` & `ps-max-modem` have been removed in favour of a runtime config (#2446)
## 0.10.1 - 2024-10-10 ## 0.10.1 - 2024-10-10

View File

@ -25,7 +25,7 @@ smoltcp = { version = "0.11.0", default-features = false, features = [
critical-section = "1.1.3" critical-section = "1.1.3"
enumset = { version = "1.1.5", default-features = false, optional = true } enumset = { version = "1.1.5", default-features = false, optional = true }
embedded-io = { version = "0.6.1", default-features = false } embedded-io = { version = "0.6.1", default-features = false }
embedded-io-async = { version = "0.6.1", optional = true } embedded-io-async = { version = "0.6.1" }
fugit = "0.3.7" fugit = "0.3.7"
heapless = { version = "0.8.0", default-features = false, features = [ heapless = { version = "0.8.0", default-features = false, features = [
"portable-atomic", "portable-atomic",
@ -101,24 +101,29 @@ esp32s3 = [
"xtensa-lx-rt/float-save-restore", "xtensa-lx-rt/float-save-restore",
] ]
## Enable Async support
async = [
"dep:embassy-sync",
"dep:embedded-io-async",
"dep:bt-hci",
]
## Enable `embassy-net` support
embassy-net = ["dep:embassy-net-driver", "async"]
## Enable WiFi-BLE coexistence support ## Enable WiFi-BLE coexistence support
coex = [] coex = []
## Logs the WiFi logs from the driver at log level info (needs a nightly-compiler) ## Logs the WiFi logs from the driver at log level info (needs a nightly-compiler)
sys-logs = ["esp-wifi-sys/sys-logs"] sys-logs = ["esp-wifi-sys/sys-logs"]
## Dumps packet info at log level info ## Enable support for `defmt`
dump-packets = [] defmt = ["dep:defmt", "smoltcp?/defmt", "esp-hal/defmt", "bt-hci?/defmt", "esp-wifi-sys/defmt"]
## Enable support for the `log` crate
log = ["dep:log", "esp-hal/log", "esp-wifi-sys/log"]
## Enable WiFi support
wifi = ["dep:enumset", "dep:embassy-net-driver", "dep:embassy-sync"]
## Enable esp-now support
esp-now = ["wifi"]
## Enable sniffer mode support
sniffer = ["wifi"]
## Enable BLE support
ble = ["esp-hal/bluetooth", "dep:bt-hci", "dep:embassy-sync"]
## Provide implementations of smoltcp traits ## Provide implementations of smoltcp traits
smoltcp = ["dep:smoltcp"] smoltcp = ["dep:smoltcp"]
@ -126,24 +131,6 @@ smoltcp = ["dep:smoltcp"]
## Provide utilities for smoltcp initialization. Adds smoltcp dependency ## Provide utilities for smoltcp initialization. Adds smoltcp dependency
utils = ["smoltcp"] utils = ["smoltcp"]
## Enable WiFi support
wifi = ["dep:enumset"]
## Enable BLE support
ble = ["esp-hal/bluetooth"]
## See USB-SERIAL-JTAG below
phy-enable-usb = []
## Enable minimum modem sleep. Only affects STA mode
ps-min-modem = []
## Enable maximum modem sleep. Only affects STA mode
ps-max-modem = []
## Enable esp-now support
esp-now = ["wifi"]
## IPv6 support. Includes utils feature ## IPv6 support. Includes utils feature
ipv6 = ["wifi", "utils", "smoltcp?/proto-ipv6"] ipv6 = ["wifi", "utils", "smoltcp?/proto-ipv6"]
@ -171,15 +158,6 @@ dhcpv4 = ["wifi", "utils", "smoltcp?/proto-dhcpv4", "smoltcp?/socket-dhcpv4"]
## Convenience to enable "ipv4", "tcp", "udp", "icmp", "igmp", "dns", "dhcpv4" ## Convenience to enable "ipv4", "tcp", "udp", "icmp", "igmp", "dns", "dhcpv4"
wifi-default = ["ipv4", "tcp", "udp", "icmp", "igmp", "dns", "dhcpv4"] wifi-default = ["ipv4", "tcp", "udp", "icmp", "igmp", "dns", "dhcpv4"]
## Enable support for `defmt`
defmt = ["dep:defmt", "smoltcp?/defmt", "esp-hal/defmt", "bt-hci?/defmt", "esp-wifi-sys/defmt"]
## Enable support for the `log` crate
log = ["dep:log", "esp-hal/log", "esp-wifi-sys/log"]
## Enable sniffer mode support
sniffer = ["wifi"]
# Implement serde Serialize / Deserialize # Implement serde Serialize / Deserialize
serde = ["dep:serde", "enumset?/serde", "heapless/serde"] serde = ["dep:serde", "enumset?/serde", "heapless/serde"]
@ -189,8 +167,6 @@ features = [
"wifi", "wifi",
"ble", "ble",
"coex", "coex",
"async",
"embassy-net",
"esp-hal/default", "esp-hal/default",
] ]
default-target = "riscv32imc-unknown-none-elf" default-target = "riscv32imc-unknown-none-elf"

View File

@ -33,3 +33,12 @@ rustflags = [
Previously `data` and `len` were public - use the previously already existing `data()` function. Previously `data` and `len` were public - use the previously already existing `data()` function.
Accessing `data` or `len` was never encouraged. Accessing `data` or `len` was never encouraged.
## Async features have been removed and async functionality is always available
The cost of this is that we need to rename the various `async` methods on `WifiController`.
```diff
- controller.start().await.unwrap();
+ controller.start_async().await.unwrap();
```

View File

@ -127,6 +127,8 @@ fn main() -> Result<(), Box<dyn Error>> {
("ap_beacon_timeout", Value::UnsignedInteger(300), "For SoftAP, If the SoftAP doesnt receive any data from the connected STA during inactive time, the SoftAP will force deauth the STA. Default is 300s"), ("ap_beacon_timeout", Value::UnsignedInteger(300), "For SoftAP, If the SoftAP doesnt receive any data from the connected STA during inactive time, the SoftAP will force deauth the STA. Default is 300s"),
("failure_retry_cnt", Value::UnsignedInteger(1), "Number of connection retries station will do before moving to next AP. scan_method should be set as WIFI_ALL_CHANNEL_SCAN to use this config. Note: Enabling this may cause connection time to increase incase best AP doesn't behave properly. Defaults to 1"), ("failure_retry_cnt", Value::UnsignedInteger(1), "Number of connection retries station will do before moving to next AP. scan_method should be set as WIFI_ALL_CHANNEL_SCAN to use this config. Note: Enabling this may cause connection time to increase incase best AP doesn't behave properly. Defaults to 1"),
("scan_method", Value::UnsignedInteger(0), "0 = WIFI_FAST_SCAN, 1 = WIFI_ALL_CHANNEL_SCAN, defaults to 0"), ("scan_method", Value::UnsignedInteger(0), "0 = WIFI_FAST_SCAN, 1 = WIFI_ALL_CHANNEL_SCAN, defaults to 0"),
("dump_packets", Value::Bool(false), "Dump packets via an info log statement"),
("phy_enable_usb", Value::Bool(true), "Keeps USB running when using WiFi. This allows debugging and log messages via USB Serial JTAG. Turn off for best WiFi performance."),
], ],
true true
); );

View File

@ -79,7 +79,6 @@ extern "C" fn notify_host_recv(data: *mut u8, len: u16) -> i32 {
super::dump_packet_info(data); super::dump_packet_info(data);
#[cfg(feature = "async")]
crate::ble::controller::asynch::hci_read_data_available(); crate::ble::controller::asynch::hci_read_data_available();
0 0

View File

@ -83,7 +83,6 @@ impl Write for BleConnector<'_> {
} }
/// Async Interface /// Async Interface
#[cfg(feature = "async")]
pub(crate) mod asynch { pub(crate) mod asynch {
use core::task::Poll; use core::task::Poll;

View File

@ -117,7 +117,6 @@ impl defmt::Format for ReceivedPacket {
} }
} }
#[cfg(feature = "async")]
pub fn have_hci_read_data() -> bool { pub fn have_hci_read_data() -> bool {
critical_section::with(|cs| { critical_section::with(|cs| {
let queue = BT_RECEIVE_QUEUE.borrow_ref_mut(cs); let queue = BT_RECEIVE_QUEUE.borrow_ref_mut(cs);
@ -160,7 +159,7 @@ pub fn read_hci(data: &mut [u8]) -> usize {
} }
fn dump_packet_info(_buffer: &[u8]) { fn dump_packet_info(_buffer: &[u8]) {
#[cfg(feature = "dump-packets")] #[cfg(dump_packets)]
critical_section::with(|_cs| { critical_section::with(|_cs| {
info!("@HCIFRAME {:?}", _buffer); info!("@HCIFRAME {:?}", _buffer);
}); });

View File

@ -1298,7 +1298,6 @@ unsafe extern "C" fn ble_hs_hci_rx_evt(cmd: *const u8, arg: *const c_void) -> i3
r_ble_hci_trans_buf_free(cmd); r_ble_hci_trans_buf_free(cmd);
#[cfg(feature = "async")]
crate::ble::controller::asynch::hci_read_data_available(); crate::ble::controller::asynch::hci_read_data_available();
0 0
@ -1327,7 +1326,6 @@ unsafe extern "C" fn ble_hs_rx_data(om: *const OsMbuf, arg: *const c_void) -> i3
r_os_mbuf_free_chain(om as *mut _); r_os_mbuf_free_chain(om as *mut _);
#[cfg(feature = "async")]
crate::ble::controller::asynch::hci_read_data_available(); crate::ble::controller::asynch::hci_read_data_available();
0 0

View File

@ -586,7 +586,6 @@ const BTDM_ASYNC_WAKEUP_REQ_COEX: i32 = 1;
/// true if request lock is needed, false otherwise /// true if request lock is needed, false otherwise
/// ///
/// ************************************************************************* /// *************************************************************************
#[cfg(coex)] #[cfg(coex)]
fn async_wakeup_request(event: i32) -> bool { fn async_wakeup_request(event: i32) -> bool {
let mut do_wakeup_request = false; let mut do_wakeup_request = false;
@ -623,7 +622,6 @@ fn async_wakeup_request(event: i32) -> bool {
/// true if request lock is needed, false otherwise /// true if request lock is needed, false otherwise
/// ///
/// ************************************************************************* /// *************************************************************************
#[cfg(coex)] #[cfg(coex)]
fn async_wakeup_request_end(event: i32) { fn async_wakeup_request_end(event: i32) {
let request_lock = match event { let request_lock = match event {

View File

@ -155,7 +155,6 @@ pub(crate) unsafe fn phy_disable_clock() {
/// Register value /// Register value
/// ///
/// ************************************************************************* /// *************************************************************************
#[ram] #[ram]
#[no_mangle] #[no_mangle]
unsafe extern "C" fn esp_dport_access_reg_read(reg: u32) -> u32 { unsafe extern "C" fn esp_dport_access_reg_read(reg: u32) -> u32 {

View File

@ -76,7 +76,7 @@ pub(crate) unsafe fn phy_enable() {
let init_data = &PHY_INIT_DATA_DEFAULT; let init_data = &PHY_INIT_DATA_DEFAULT;
#[cfg(feature = "phy-enable-usb")] #[cfg(phy_enable_usb)]
{ {
extern "C" { extern "C" {
fn phy_bbpll_en_usb(param: bool); fn phy_bbpll_en_usb(param: bool);

View File

@ -41,7 +41,7 @@ pub(crate) unsafe fn phy_enable() {
let init_data = &PHY_INIT_DATA_DEFAULT; let init_data = &PHY_INIT_DATA_DEFAULT;
#[cfg(feature = "phy-enable-usb")] #[cfg(phy_enable_usb)]
{ {
extern "C" { extern "C" {
fn phy_bbpll_en_usb(param: bool); fn phy_bbpll_en_usb(param: bool);

View File

@ -44,7 +44,7 @@ pub(crate) unsafe fn phy_enable() {
// this would cause linker errors when the feature is activated - see https://github.com/esp-rs/esp-wifi/issues/457 // this would cause linker errors when the feature is activated - see https://github.com/esp-rs/esp-wifi/issues/457
// #[cfg(feature = "phy-enable-usb")] // #[cfg(phy_enable_usb)]
// { // {
// extern "C" { // extern "C" {
// pub fn phy_bbpll_en_usb(param: bool); // pub fn phy_bbpll_en_usb(param: bool);

View File

@ -72,7 +72,7 @@ pub(crate) unsafe fn phy_enable() {
let init_data = &PHY_INIT_DATA_DEFAULT; let init_data = &PHY_INIT_DATA_DEFAULT;
#[cfg(feature = "phy-enable-usb")] #[cfg(phy_enable_usb)]
{ {
extern "C" { extern "C" {
fn phy_bbpll_en_usb(param: bool); fn phy_bbpll_en_usb(param: bool);

47
esp-wifi/src/config.rs Normal file
View File

@ -0,0 +1,47 @@
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
/// Tunable parameters for the WiFi driver
#[allow(unused)] // currently there are no ble tunables
pub(crate) struct EspWifiConfig {
pub(crate) rx_queue_size: usize,
pub(crate) tx_queue_size: usize,
pub(crate) static_rx_buf_num: usize,
pub(crate) dynamic_rx_buf_num: usize,
pub(crate) static_tx_buf_num: usize,
pub(crate) dynamic_tx_buf_num: usize,
pub(crate) ampdu_rx_enable: bool,
pub(crate) ampdu_tx_enable: bool,
pub(crate) amsdu_tx_enable: bool,
pub(crate) rx_ba_win: usize,
pub(crate) max_burst_size: usize,
pub(crate) country_code: &'static str,
pub(crate) country_code_operating_class: u8,
pub(crate) mtu: usize,
pub(crate) tick_rate_hz: u32,
pub(crate) listen_interval: u16,
pub(crate) beacon_timeout: u16,
pub(crate) ap_beacon_timeout: u16,
pub(crate) failure_retry_cnt: u8,
pub(crate) scan_method: u32,
}
#[cfg(not(coex))]
#[non_exhaustive]
#[derive(Default)]
pub enum PowerSaveMode {
None,
#[default]
Minimum,
Maximum,
}
#[cfg(not(coex))]
impl From<PowerSaveMode> for esp_wifi_sys::include::wifi_ps_type_t {
fn from(s: PowerSaveMode) -> Self {
match s {
PowerSaveMode::None => esp_wifi_sys::include::wifi_ps_type_t_WIFI_PS_NONE,
PowerSaveMode::Minimum => esp_wifi_sys::include::wifi_ps_type_t_WIFI_PS_MIN_MODEM,
PowerSaveMode::Maximum => esp_wifi_sys::include::wifi_ps_type_t_WIFI_PS_MAX_MODEM,
}
}
}

View File

@ -16,6 +16,8 @@ use critical_section::Mutex;
use enumset::EnumSet; use enumset::EnumSet;
use portable_atomic::{AtomicBool, AtomicU8, Ordering}; use portable_atomic::{AtomicBool, AtomicU8, Ordering};
#[cfg(not(coex))]
use crate::config::PowerSaveMode;
use crate::{ use crate::{
binary::include::*, binary::include::*,
hal::peripheral::{Peripheral, PeripheralRef}, hal::peripheral::{Peripheral, PeripheralRef},
@ -335,6 +337,12 @@ impl EspNowManager<'_> {
Ok(()) Ok(())
} }
#[cfg(not(coex))]
/// Configures modem power saving
pub fn set_power_saving(&self, ps: PowerSaveMode) -> Result<(), WifiError> {
crate::wifi::apply_power_saving(ps)
}
/// Set primary WiFi channel. /// Set primary WiFi channel.
/// Should only be used when using ESP-NOW without AP or STA. /// Should only be used when using ESP-NOW without AP or STA.
pub fn set_channel(&self, channel: u8) -> Result<(), EspNowError> { pub fn set_channel(&self, channel: u8) -> Result<(), EspNowError> {
@ -682,25 +690,6 @@ impl<'d> EspNow<'d> {
check_error!({ check_error!({
esp_wifi_set_inactive_time(wifi_interface_t_WIFI_IF_STA, crate::CONFIG.beacon_timeout) esp_wifi_set_inactive_time(wifi_interface_t_WIFI_IF_STA, crate::CONFIG.beacon_timeout)
})?; })?;
cfg_if::cfg_if! {
if #[cfg(feature = "ps-min-modem")] {
check_error!({esp_wifi_set_ps(
crate::binary::include::wifi_ps_type_t_WIFI_PS_MIN_MODEM
)})?;
} else if #[cfg(feature = "ps-max-modem")] {
check_error!({esp_wifi_set_ps(
crate::binary::include::wifi_ps_type_t_WIFI_PS_MAX_MODEM
)})?;
} else if #[cfg(coex)] {
check_error!({esp_wifi_set_ps(
crate::binary::include::wifi_ps_type_t_WIFI_PS_MIN_MODEM
)})?;
} else {
check_error!({esp_wifi_set_ps(
crate::binary::include::wifi_ps_type_t_WIFI_PS_NONE
)})?;
}
};
check_error!({ esp_now_init() })?; check_error!({ esp_now_init() })?;
check_error!({ esp_now_register_recv_cb(Some(rcv_cb)) })?; check_error!({ esp_now_register_recv_cb(Some(rcv_cb)) })?;
check_error!({ esp_now_register_send_cb(Some(send_cb)) })?; check_error!({ esp_now_register_send_cb(Some(send_cb)) })?;
@ -824,7 +813,6 @@ unsafe extern "C" fn send_cb(_mac_addr: *const u8, status: esp_now_send_status_t
ESP_NOW_SEND_CB_INVOKED.store(true, Ordering::Release); ESP_NOW_SEND_CB_INVOKED.store(true, Ordering::Release);
#[cfg(feature = "async")]
asynch::ESP_NOW_TX_WAKER.wake(); asynch::ESP_NOW_TX_WAKER.wake();
}) })
} }
@ -871,15 +859,12 @@ unsafe extern "C" fn rcv_cb(
queue.push_back(ReceivedData { data, info }); queue.push_back(ReceivedData { data, info });
#[cfg(feature = "async")]
asynch::ESP_NOW_RX_WAKER.wake(); asynch::ESP_NOW_RX_WAKER.wake();
}); });
} }
#[cfg(feature = "async")]
pub use asynch::SendFuture; pub use asynch::SendFuture;
#[cfg(feature = "async")]
mod asynch { mod asynch {
use core::task::{Context, Poll}; use core::task::{Context, Poll};

View File

@ -48,19 +48,12 @@
//! Within this crate, `CCOMPARE0` CPU timer is used for timing, ensure that in //! Within this crate, `CCOMPARE0` CPU timer is used for timing, ensure that in
//! your application you are not using this CPU timer. //! your application you are not using this CPU timer.
//! //!
//! ## USB-SERIAL-JTAG
//!
//! When using USB-SERIAL-JTAG (for example by selecting `jtag-serial` in [`esp-println`](https://crates.io/crates/esp-println)) you have to activate the feature `phy-enable-usb`.
//!
//! Don't use this feature if you are _not_ using USB-SERIAL-JTAG as it might
//! reduce WiFi performance.
//!
//! # Features flags //! # Features flags
//! //!
//! Note that not all features are available on every MCU. For example, `ble` //! Note that not all features are available on every MCU. For example, `ble`
//! (and thus, `coex`) is not available on ESP32-S2. //! (and thus, `coex`) is not available on ESP32-S2.
//! //!
//! When using the `dump-packets` feature you can use the extcap in //! When using the `dump_packets` config you can use the extcap in
//! `extras/esp-wifishark` to analyze the frames in Wireshark. //! `extras/esp-wifishark` to analyze the frames in Wireshark.
//! For more information see //! For more information see
//! [extras/esp-wifishark/README.md](../extras/esp-wifishark/README.md) //! [extras/esp-wifishark/README.md](../extras/esp-wifishark/README.md)
@ -134,6 +127,8 @@ pub mod ble;
#[cfg(feature = "esp-now")] #[cfg(feature = "esp-now")]
pub mod esp_now; pub mod esp_now;
pub mod config;
pub(crate) mod common_adapter; pub(crate) mod common_adapter;
#[doc(hidden)] #[doc(hidden)]
@ -169,34 +164,7 @@ const _: () = {
}; };
}; };
#[derive(Debug)] pub(crate) const CONFIG: config::EspWifiConfig = config::EspWifiConfig {
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
/// Tunable parameters for the WiFi driver
#[allow(unused)] // currently there are no ble tunables
struct Config {
rx_queue_size: usize,
tx_queue_size: usize,
static_rx_buf_num: usize,
dynamic_rx_buf_num: usize,
static_tx_buf_num: usize,
dynamic_tx_buf_num: usize,
ampdu_rx_enable: bool,
ampdu_tx_enable: bool,
amsdu_tx_enable: bool,
rx_ba_win: usize,
max_burst_size: usize,
country_code: &'static str,
country_code_operating_class: u8,
mtu: usize,
tick_rate_hz: u32,
listen_interval: u16,
beacon_timeout: u16,
ap_beacon_timeout: u16,
failure_retry_cnt: u8,
scan_method: u32,
}
pub(crate) const CONFIG: Config = Config {
rx_queue_size: esp_config_int!(usize, "ESP_WIFI_RX_QUEUE_SIZE"), rx_queue_size: esp_config_int!(usize, "ESP_WIFI_RX_QUEUE_SIZE"),
tx_queue_size: esp_config_int!(usize, "ESP_WIFI_TX_QUEUE_SIZE"), tx_queue_size: esp_config_int!(usize, "ESP_WIFI_TX_QUEUE_SIZE"),
static_rx_buf_num: esp_config_int!(usize, "ESP_WIFI_STATIC_RX_BUF_NUM"), static_rx_buf_num: esp_config_int!(usize, "ESP_WIFI_STATIC_RX_BUF_NUM"),
@ -371,11 +339,9 @@ impl private::Sealed for Trng<'_> {}
/// ```rust, no_run /// ```rust, no_run
#[doc = esp_hal::before_snippet!()] #[doc = esp_hal::before_snippet!()]
/// use esp_hal::{rng::Rng, timg::TimerGroup}; /// use esp_hal::{rng::Rng, timg::TimerGroup};
/// use esp_wifi::EspWifiInitFor;
/// ///
/// let timg0 = TimerGroup::new(peripherals.TIMG0); /// let timg0 = TimerGroup::new(peripherals.TIMG0);
/// let init = esp_wifi::init( /// let init = esp_wifi::init(
/// EspWifiInitFor::Wifi,
/// timg0.timer0, /// timg0.timer0,
/// Rng::new(peripherals.RNG), /// Rng::new(peripherals.RNG),
/// peripherals.RADIO_CLK, /// peripherals.RADIO_CLK,

View File

@ -50,7 +50,6 @@ use esp_wifi_sys::include::{
wifi_promiscuous_pkt_type_t, wifi_promiscuous_pkt_type_t,
}; };
use num_derive::FromPrimitive; use num_derive::FromPrimitive;
use num_traits::FromPrimitive;
#[doc(hidden)] #[doc(hidden)]
pub(crate) use os_adapter::*; pub(crate) use os_adapter::*;
#[cfg(feature = "sniffer")] #[cfg(feature = "sniffer")]
@ -62,6 +61,8 @@ use serde::{Deserialize, Serialize};
use smoltcp::phy::{Device, DeviceCapabilities, RxToken, TxToken}; use smoltcp::phy::{Device, DeviceCapabilities, RxToken, TxToken};
pub use state::*; pub use state::*;
#[cfg(not(coex))]
use crate::config::PowerSaveMode;
use crate::{ use crate::{
common_adapter::*, common_adapter::*,
esp_wifi_result, esp_wifi_result,
@ -105,7 +106,6 @@ use crate::binary::{
esp_wifi_set_country, esp_wifi_set_country,
esp_wifi_set_mode, esp_wifi_set_mode,
esp_wifi_set_protocol, esp_wifi_set_protocol,
esp_wifi_set_ps,
esp_wifi_set_tx_done_cb, esp_wifi_set_tx_done_cb,
esp_wifi_start, esp_wifi_start,
esp_wifi_stop, esp_wifi_stop,
@ -1623,7 +1623,6 @@ unsafe extern "C" fn recv_cb_sta(
false false
} }
}) { }) {
#[cfg(feature = "embassy-net")]
embassy::STA_RECEIVE_WAKER.wake(); embassy::STA_RECEIVE_WAKER.wake();
include::ESP_OK as esp_err_t include::ESP_OK as esp_err_t
} else { } else {
@ -1653,7 +1652,6 @@ unsafe extern "C" fn recv_cb_ap(
false false
} }
}) { }) {
#[cfg(feature = "embassy-net")]
embassy::AP_RECEIVE_WAKER.wake(); embassy::AP_RECEIVE_WAKER.wake();
include::ESP_OK as esp_err_t include::ESP_OK as esp_err_t
} else { } else {
@ -1683,7 +1681,6 @@ unsafe extern "C" fn esp_wifi_tx_done_cb(
decrement_inflight_counter(); decrement_inflight_counter();
#[cfg(feature = "embassy-net")]
embassy::TRANSMIT_WAKER.wake(); embassy::TRANSMIT_WAKER.wake();
} }
@ -1707,20 +1704,6 @@ pub(crate) fn wifi_start() -> Result<(), WifiError> {
))?; ))?;
}; };
cfg_if::cfg_if! {
if #[cfg(feature = "ps-min-modem")] {
let ps_mode = include::wifi_ps_type_t_WIFI_PS_MIN_MODEM;
} else if #[cfg(feature = "ps-max-modem")] {
let ps_mode = include::wifi_ps_type_t_WIFI_PS_MAX_MODEM;
} else if #[cfg(coex)] {
let ps_mode = include::wifi_ps_type_t_WIFI_PS_MIN_MODEM;
} else {
let ps_mode = include::wifi_ps_type_t_WIFI_PS_NONE;
}
};
esp_wifi_result!(esp_wifi_set_ps(ps_mode))?;
let mut cntry_code = [0u8; 3]; let mut cntry_code = [0u8; 3];
cntry_code[..crate::CONFIG.country_code.len()] cntry_code[..crate::CONFIG.country_code.len()]
.copy_from_slice(crate::CONFIG.country_code.as_bytes()); .copy_from_slice(crate::CONFIG.country_code.as_bytes());
@ -2041,18 +2024,14 @@ mod sealed {
fn interface(self) -> wifi_interface_t; fn interface(self) -> wifi_interface_t;
#[cfg(feature = "embassy-net")]
fn register_transmit_waker(self, cx: &mut core::task::Context) { fn register_transmit_waker(self, cx: &mut core::task::Context) {
embassy::TRANSMIT_WAKER.register(cx.waker()) embassy::TRANSMIT_WAKER.register(cx.waker())
} }
#[cfg(feature = "embassy-net")]
fn register_receive_waker(self, cx: &mut core::task::Context); fn register_receive_waker(self, cx: &mut core::task::Context);
#[cfg(feature = "embassy-net")]
fn register_link_state_waker(self, cx: &mut core::task::Context); fn register_link_state_waker(self, cx: &mut core::task::Context);
#[cfg(feature = "embassy-net")]
fn link_state(self) -> embassy_net_driver::LinkState; fn link_state(self) -> embassy_net_driver::LinkState;
} }
@ -2075,17 +2054,14 @@ mod sealed {
wifi_interface_t_WIFI_IF_STA wifi_interface_t_WIFI_IF_STA
} }
#[cfg(feature = "embassy-net")]
fn register_receive_waker(self, cx: &mut core::task::Context) { fn register_receive_waker(self, cx: &mut core::task::Context) {
embassy::STA_RECEIVE_WAKER.register(cx.waker()); embassy::STA_RECEIVE_WAKER.register(cx.waker());
} }
#[cfg(feature = "embassy-net")]
fn register_link_state_waker(self, cx: &mut core::task::Context) { fn register_link_state_waker(self, cx: &mut core::task::Context) {
embassy::STA_LINK_STATE_WAKER.register(cx.waker()); embassy::STA_LINK_STATE_WAKER.register(cx.waker());
} }
#[cfg(feature = "embassy-net")]
fn link_state(self) -> embassy_net_driver::LinkState { fn link_state(self) -> embassy_net_driver::LinkState {
if matches!(get_sta_state(), WifiState::StaConnected) { if matches!(get_sta_state(), WifiState::StaConnected) {
embassy_net_driver::LinkState::Up embassy_net_driver::LinkState::Up
@ -2114,17 +2090,14 @@ mod sealed {
wifi_interface_t_WIFI_IF_AP wifi_interface_t_WIFI_IF_AP
} }
#[cfg(feature = "embassy-net")]
fn register_receive_waker(self, cx: &mut core::task::Context) { fn register_receive_waker(self, cx: &mut core::task::Context) {
embassy::AP_RECEIVE_WAKER.register(cx.waker()); embassy::AP_RECEIVE_WAKER.register(cx.waker());
} }
#[cfg(feature = "embassy-net")]
fn register_link_state_waker(self, cx: &mut core::task::Context) { fn register_link_state_waker(self, cx: &mut core::task::Context) {
embassy::AP_LINK_STATE_WAKER.register(cx.waker()); embassy::AP_LINK_STATE_WAKER.register(cx.waker());
} }
#[cfg(feature = "embassy-net")]
fn link_state(self) -> embassy_net_driver::LinkState { fn link_state(self) -> embassy_net_driver::LinkState {
if matches!(get_ap_state(), WifiState::ApStarted) { if matches!(get_ap_state(), WifiState::ApStarted) {
embassy_net_driver::LinkState::Up embassy_net_driver::LinkState::Up
@ -2619,6 +2592,12 @@ impl<'d> WifiController<'d> {
Ok(()) Ok(())
} }
#[cfg(not(coex))]
/// Configures modem power saving
pub fn set_power_saving(&mut self, ps: PowerSaveMode) -> Result<(), WifiError> {
apply_power_saving(ps)
}
/// Checks if Wi-Fi is enabled as a station. /// Checks if Wi-Fi is enabled as a station.
pub fn is_sta_enabled(&self) -> Result<bool, WifiError> { pub fn is_sta_enabled(&self) -> Result<bool, WifiError> {
WifiMode::try_from(&self.config).map(|m| m.is_sta()) WifiMode::try_from(&self.config).map(|m| m.is_sta())
@ -2684,6 +2663,33 @@ impl<'d> WifiController<'d> {
Ok(scanned) Ok(scanned)
} }
/// A blocking wifi network scan with default scanning options.
pub fn scan_n<const N: usize>(
&mut self,
) -> Result<(heapless::Vec<AccessPointInfo, N>, usize), WifiError> {
self.scan_with_config_sync(Default::default())
}
/// Starts the WiFi controller.
pub fn start(&mut self) -> Result<(), WifiError> {
crate::wifi::wifi_start()
}
/// Stops the WiFi controller.
pub fn stop(&mut self) -> Result<(), WifiError> {
self.stop_impl()
}
/// Connects the WiFi controller to a network.
pub fn connect(&mut self) -> Result<(), WifiError> {
self.connect_impl()
}
/// Disconnects the WiFi controller from a network.
pub fn disconnect(&mut self) -> Result<(), WifiError> {
self.disconnect_impl()
}
} }
// see https://docs.rs/smoltcp/0.7.1/smoltcp/phy/index.html // see https://docs.rs/smoltcp/0.7.1/smoltcp/phy/index.html
@ -3155,38 +3161,8 @@ impl WifiController<'_> {
} }
} }
#[cfg(not(feature = "async"))]
impl WifiController<'_> {
/// A blocking wifi network scan with default scanning options.
pub fn scan_n<const N: usize>(
&mut self,
) -> Result<(heapless::Vec<AccessPointInfo, N>, usize), WifiError> {
self.scan_with_config_sync(Default::default())
}
/// Starts the WiFi controller.
pub fn start(&mut self) -> Result<(), WifiError> {
crate::wifi::wifi_start()
}
/// Stops the WiFi controller.
pub fn stop(&mut self) -> Result<(), WifiError> {
self.stop_impl()
}
/// Connects the WiFi controller to a network.
pub fn connect(&mut self) -> Result<(), WifiError> {
self.connect_impl()
}
/// Disconnects the WiFi controller from a network.
pub fn disconnect(&mut self) -> Result<(), WifiError> {
self.disconnect_impl()
}
}
fn dump_packet_info(_buffer: &[u8]) { fn dump_packet_info(_buffer: &[u8]) {
#[cfg(feature = "dump-packets")] #[cfg(dump_packets)]
{ {
info!("@WIFIFRAME {:?}", _buffer); info!("@WIFIFRAME {:?}", _buffer);
} }
@ -3196,8 +3172,9 @@ fn dump_packet_info(_buffer: &[u8]) {
#[macro_export] #[macro_export]
macro_rules! esp_wifi_result { macro_rules! esp_wifi_result {
($value:expr) => {{ ($value:expr) => {{
use num_traits::FromPrimitive;
let result = $value; let result = $value;
if result != include::ESP_OK as i32 { if result != esp_wifi_sys::include::ESP_OK as i32 {
warn!("{} returned an error: {}", stringify!($value), result); warn!("{} returned an error: {}", stringify!($value), result);
Err(WifiError::InternalError(unwrap!(FromPrimitive::from_i32( Err(WifiError::InternalError(unwrap!(FromPrimitive::from_i32(
result result
@ -3208,7 +3185,6 @@ macro_rules! esp_wifi_result {
}}; }};
} }
#[cfg(feature = "embassy-net")]
pub(crate) mod embassy { pub(crate) mod embassy {
use embassy_net_driver::{Capabilities, Driver, HardwareAddress, RxToken, TxToken}; use embassy_net_driver::{Capabilities, Driver, HardwareAddress, RxToken, TxToken};
use embassy_sync::waitqueue::AtomicWaker; use embassy_sync::waitqueue::AtomicWaker;
@ -3289,7 +3265,12 @@ pub(crate) mod embassy {
} }
} }
#[cfg(feature = "async")] #[cfg(not(coex))]
pub(crate) fn apply_power_saving(ps: PowerSaveMode) -> Result<(), WifiError> {
esp_wifi_result!(unsafe { esp_wifi_sys::include::esp_wifi_set_ps(ps.into()) })?;
Ok(())
}
mod asynch { mod asynch {
use core::task::Poll; use core::task::Poll;
@ -3300,14 +3281,14 @@ mod asynch {
// TODO assumes STA mode only // TODO assumes STA mode only
impl WifiController<'_> { impl WifiController<'_> {
/// Async version of [`crate::wifi::WifiController`]'s `scan_n` method /// Async version of [`crate::wifi::WifiController`]'s `scan_n` method
pub async fn scan_n<const N: usize>( pub async fn scan_n_async<const N: usize>(
&mut self, &mut self,
) -> Result<(heapless::Vec<AccessPointInfo, N>, usize), WifiError> { ) -> Result<(heapless::Vec<AccessPointInfo, N>, usize), WifiError> {
self.scan_with_config(Default::default()).await self.scan_with_config_async(Default::default()).await
} }
/// An async wifi network scan with caller-provided scanning options. /// An async wifi network scan with caller-provided scanning options.
pub async fn scan_with_config<const N: usize>( pub async fn scan_with_config_async<const N: usize>(
&mut self, &mut self,
config: ScanConfig<'_>, config: ScanConfig<'_>,
) -> Result<(heapless::Vec<AccessPointInfo, N>, usize), WifiError> { ) -> Result<(heapless::Vec<AccessPointInfo, N>, usize), WifiError> {
@ -3327,7 +3308,7 @@ mod asynch {
} }
/// Async version of [`crate::wifi::WifiController`]'s `start` method /// Async version of [`crate::wifi::WifiController`]'s `start` method
pub async fn start(&mut self) -> Result<(), WifiError> { pub async fn start_async(&mut self) -> Result<(), WifiError> {
let mode = WifiMode::try_from(&self.config)?; let mode = WifiMode::try_from(&self.config)?;
let mut events = enumset::enum_set! {}; let mut events = enumset::enum_set! {};
@ -3348,7 +3329,7 @@ mod asynch {
} }
/// Async version of [`crate::wifi::WifiController`]'s `stop` method /// Async version of [`crate::wifi::WifiController`]'s `stop` method
pub async fn stop(&mut self) -> Result<(), WifiError> { pub async fn stop_async(&mut self) -> Result<(), WifiError> {
let mode = WifiMode::try_from(&self.config)?; let mode = WifiMode::try_from(&self.config)?;
let mut events = enumset::enum_set! {}; let mut events = enumset::enum_set! {};
@ -3372,7 +3353,7 @@ mod asynch {
} }
/// Async version of [`crate::wifi::WifiController`]'s `connect` method /// Async version of [`crate::wifi::WifiController`]'s `connect` method
pub async fn connect(&mut self) -> Result<(), WifiError> { pub async fn connect_async(&mut self) -> Result<(), WifiError> {
Self::clear_events(WifiEvent::StaConnected | WifiEvent::StaDisconnected); Self::clear_events(WifiEvent::StaConnected | WifiEvent::StaDisconnected);
let err = crate::wifi::WifiController::connect_impl(self).err(); let err = crate::wifi::WifiController::connect_impl(self).err();
@ -3389,7 +3370,7 @@ mod asynch {
/// Async version of [`crate::wifi::WifiController`]'s `Disconnect` /// Async version of [`crate::wifi::WifiController`]'s `Disconnect`
/// method /// method
pub async fn disconnect(&mut self) -> Result<(), WifiError> { pub async fn disconnect_async(&mut self) -> Result<(), WifiError> {
// If not connected, this will do nothing. // If not connected, this will do nothing.
// It will also wait forever for a `StaDisconnected` event that will never come. // It will also wait forever for a `StaDisconnected` event that will never come.
// Return early instead of hanging. // Return early instead of hanging.

View File

@ -870,10 +870,8 @@ pub unsafe extern "C" fn event_post(
super::state::update_state(event); super::state::update_state(event);
#[cfg(feature = "async")]
event.waker().wake(); event.waker().wake();
#[cfg(feature = "embassy-net")]
match event { match event {
WifiEvent::StaConnected | WifiEvent::StaDisconnected => { WifiEvent::StaConnected | WifiEvent::StaDisconnected => {
crate::wifi::embassy::STA_LINK_STATE_WAKER.wake(); crate::wifi::embassy::STA_LINK_STATE_WAKER.wake();

View File

@ -62,12 +62,10 @@ pub(crate) fn update_state(event: WifiEvent) {
} }
} }
#[cfg(feature = "async")]
pub(crate) fn reset_ap_state() { pub(crate) fn reset_ap_state() {
AP_STATE.store(WifiState::Invalid, Ordering::Relaxed) AP_STATE.store(WifiState::Invalid, Ordering::Relaxed)
} }
#[cfg(feature = "async")]
pub(crate) fn reset_sta_state() { pub(crate) fn reset_sta_state() {
STA_STATE.store(WifiState::Invalid, Ordering::Relaxed) STA_STATE.store(WifiState::Invalid, Ordering::Relaxed)
} }

View File

@ -1,7 +1,7 @@
//! WiFi frame injection example //! WiFi frame injection example
//! //!
//! Periodically transmits a beacon frame. //! Periodically transmits a beacon frame.
//! When using USB-SERIAL-JTAG you may have to activate the feature `phy-enable-usb` in the esp-wifi crate. //!
//% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils esp-wifi/sniffer //% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils esp-wifi/sniffer
//% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6

View File

@ -6,7 +6,7 @@
//! Open http://192.168.2.1:8080/ in your browser //! Open http://192.168.2.1:8080/ in your browser
//! //!
//! On Android you might need to choose _Keep Accesspoint_ when it tells you the WiFi has no internet connection, Chrome might not want to load the URL - you can use a shell and try `curl` and `ping` //! On Android you might need to choose _Keep Accesspoint_ when it tells you the WiFi has no internet connection, Chrome might not want to load the URL - you can use a shell and try `curl` and `ping`
//! When using USB-SERIAL-JTAG you may have to activate the feature `phy-enable-usb` in the esp-wifi crate. //!
//% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils //% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils
//% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6

View File

@ -7,7 +7,7 @@
//! Open http://192.168.2.1:8080/ in your browser - the example will perform an HTTP get request to some "random" server //! Open http://192.168.2.1:8080/ in your browser - the example will perform an HTTP get request to some "random" server
//! //!
//! On Android you might need to choose _Keep Accesspoint_ when it tells you the WiFi has no internet connection, Chrome might not want to load the URL - you can use a shell and try `curl` and `ping` //! On Android you might need to choose _Keep Accesspoint_ when it tells you the WiFi has no internet connection, Chrome might not want to load the URL - you can use a shell and try `curl` and `ping`
//! When using USB-SERIAL-JTAG you may have to activate the feature `phy-enable-usb` in the esp-wifi crate. //!
//% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils //% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils
//% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6

View File

@ -6,7 +6,7 @@
//! cargo run --release //! cargo run --release
//! ``` //! ```
//! Ensure you have set the IP of your local machine in the `HOST_IP` env variable. E.g `HOST_IP="192.168.0.24"` and also set SSID and PASSWORD env variable before running this example. //! Ensure you have set the IP of your local machine in the `HOST_IP` env variable. E.g `HOST_IP="192.168.0.24"` and also set SSID and PASSWORD env variable before running this example.
//! When using USB-SERIAL-JTAG you may have to activate the feature `phy-enable-usb` in the esp-wifi crate. //!
//% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils //% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils
//% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6

View File

@ -6,7 +6,7 @@
//! - does BLE advertising (you cannot connect to it - it's just not implemented in the example) //! - does BLE advertising (you cannot connect to it - it's just not implemented in the example)
//! //!
//! Note: On ESP32-C2 and ESP32-C3 you need a wifi-heap size of 70000, on ESP32-C6 you need 80000 and a tx_queue_size of 10 //! Note: On ESP32-C2 and ESP32-C3 you need a wifi-heap size of 70000, on ESP32-C6 you need 80000 and a tx_queue_size of 10
//! When using USB-SERIAL-JTAG you may have to activate the feature `phy-enable-usb` in the esp-wifi crate. //!
//% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils esp-wifi/ble esp-wifi/coex //% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils esp-wifi/ble esp-wifi/coex
//% CHIPS: esp32 esp32s3 esp32c2 esp32c3 esp32c6 //% CHIPS: esp32 esp32s3 esp32c2 esp32c3 esp32c6

View File

@ -4,7 +4,7 @@
//! Set SSID and PASSWORD env variable before running this example. //! Set SSID and PASSWORD env variable before running this example.
//! //!
//! This gets an ip address via DHCP then performs an HTTP get request to some "random" server //! This gets an ip address via DHCP then performs an HTTP get request to some "random" server
//! When using USB-SERIAL-JTAG you may have to activate the feature `phy-enable-usb` in the esp-wifi crate. //!
//% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils //% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils
//% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6

View File

@ -7,9 +7,9 @@
//! On Android you might need to choose _Keep Accesspoint_ when it tells you the WiFi has no internet connection, Chrome might not want to load the URL - you can use a shell and try `curl` and `ping` //! On Android you might need to choose _Keep Accesspoint_ when it tells you the WiFi has no internet connection, Chrome might not want to load the URL - you can use a shell and try `curl` and `ping`
//! //!
//! Because of the huge task-arena size configured this won't work on ESP32-S2 //! Because of the huge task-arena size configured this won't work on ESP32-S2
//! When using USB-SERIAL-JTAG you may have to activate the feature `phy-enable-usb` in the esp-wifi crate. //!
//% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/async esp-wifi/embassy-net esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils //% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils
//% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6
#![no_std] #![no_std]
@ -220,7 +220,7 @@ async fn connection(mut controller: WifiController<'static>) {
}); });
controller.set_configuration(&client_config).unwrap(); controller.set_configuration(&client_config).unwrap();
println!("Starting wifi"); println!("Starting wifi");
controller.start().await.unwrap(); controller.start_async().await.unwrap();
println!("Wifi started!"); println!("Wifi started!");
} }
} }

View File

@ -10,9 +10,9 @@
//! On Android you might need to choose _Keep Accesspoint_ when it tells you the WiFi has no internet connection, Chrome might not want to load the URL - you can use a shell and try `curl` and `ping` //! On Android you might need to choose _Keep Accesspoint_ when it tells you the WiFi has no internet connection, Chrome might not want to load the URL - you can use a shell and try `curl` and `ping`
//! //!
//! Because of the huge task-arena size configured this won't work on ESP32-S2 //! Because of the huge task-arena size configured this won't work on ESP32-S2
//! When using USB-SERIAL-JTAG you may have to activate the feature `phy-enable-usb` in the esp-wifi crate. //!
//% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/async esp-wifi/embassy-net esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils //% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils
//% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6
#![no_std] #![no_std]
@ -315,7 +315,7 @@ async fn connection(mut controller: WifiController<'static>) {
println!("Device capabilities: {:?}", controller.get_capabilities()); println!("Device capabilities: {:?}", controller.get_capabilities());
println!("Starting wifi"); println!("Starting wifi");
controller.start().await.unwrap(); controller.start_async().await.unwrap();
println!("Wifi started!"); println!("Wifi started!");
loop { loop {
@ -323,7 +323,7 @@ async fn connection(mut controller: WifiController<'static>) {
WifiState::ApStarted => { WifiState::ApStarted => {
println!("About to connect..."); println!("About to connect...");
match controller.connect().await { match controller.connect_async().await {
Ok(_) => { Ok(_) => {
// wait until we're no longer connected // wait until we're no longer connected
controller.wait_for_event(WifiEvent::StaDisconnected).await; controller.wait_for_event(WifiEvent::StaDisconnected).await;

View File

@ -8,9 +8,9 @@
//! Ensure you have set the IP of your local machine in the `HOST_IP` env variable. E.g `HOST_IP="192.168.0.24"` and also set SSID and PASSWORD env variable before running this example. //! Ensure you have set the IP of your local machine in the `HOST_IP` env variable. E.g `HOST_IP="192.168.0.24"` and also set SSID and PASSWORD env variable before running this example.
//! //!
//! Because of the huge task-arena size configured this won't work on ESP32-S2 and ESP32-C2 //! Because of the huge task-arena size configured this won't work on ESP32-S2 and ESP32-C2
//! When using USB-SERIAL-JTAG you may have to activate the feature `phy-enable-usb` in the esp-wifi crate. //!
//% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/async esp-wifi/embassy-net esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils //% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils
//% CHIPS: esp32 esp32s2 esp32s3 esp32c3 esp32c6 //% CHIPS: esp32 esp32s2 esp32s3 esp32c3 esp32c6
#![allow(static_mut_refs)] #![allow(static_mut_refs)]
@ -193,12 +193,12 @@ async fn connection(mut controller: WifiController<'static>) {
}); });
controller.set_configuration(&client_config).unwrap(); controller.set_configuration(&client_config).unwrap();
println!("Starting wifi"); println!("Starting wifi");
controller.start().await.unwrap(); controller.start_async().await.unwrap();
println!("Wifi started!"); println!("Wifi started!");
} }
println!("About to connect..."); println!("About to connect...");
match controller.connect().await { match controller.connect_async().await {
Ok(_) => println!("Wifi connected!"), Ok(_) => println!("Wifi connected!"),
Err(e) => { Err(e) => {
println!("Failed to connect to wifi: {e:?}"); println!("Failed to connect to wifi: {e:?}");

View File

@ -4,7 +4,7 @@
//! - offers one service with three characteristics (one is read/write, one is write only, one is read/write/notify) //! - offers one service with three characteristics (one is read/write, one is write only, one is read/write/notify)
//! - pressing the boot-button on a dev-board will send a notification if it is subscribed //! - pressing the boot-button on a dev-board will send a notification if it is subscribed
//% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/async esp-wifi/ble //% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/ble
//% CHIPS: esp32 esp32s3 esp32c2 esp32c3 esp32c6 esp32h2 //% CHIPS: esp32 esp32s3 esp32c2 esp32c3 esp32c6 esp32h2
#![no_std] #![no_std]

View File

@ -6,9 +6,8 @@
//! This gets an ip address via DHCP then performs an HTTP get request to some "random" server //! This gets an ip address via DHCP then performs an HTTP get request to some "random" server
//! //!
//! Because of the huge task-arena size configured this won't work on ESP32-S2 //! Because of the huge task-arena size configured this won't work on ESP32-S2
//! When using USB-SERIAL-JTAG you have to activate the feature `phy-enable-usb` in the esp-wifi crate.
//% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/async esp-wifi/embassy-net esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils //% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils
//% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6
#![no_std] #![no_std]
@ -186,12 +185,12 @@ async fn connection(mut controller: WifiController<'static>) {
}); });
controller.set_configuration(&client_config).unwrap(); controller.set_configuration(&client_config).unwrap();
println!("Starting wifi"); println!("Starting wifi");
controller.start().await.unwrap(); controller.start_async().await.unwrap();
println!("Wifi started!"); println!("Wifi started!");
} }
println!("About to connect..."); println!("About to connect...");
match controller.connect().await { match controller.connect_async().await {
Ok(_) => println!("Wifi connected!"), Ok(_) => println!("Wifi connected!"),
Err(e) => { Err(e) => {
println!("Failed to connect to wifi: {e:?}"); println!("Failed to connect to wifi: {e:?}");

View File

@ -4,7 +4,7 @@
//! //!
//! Because of the huge task-arena size configured this won't work on ESP32-S2 //! Because of the huge task-arena size configured this won't work on ESP32-S2
//% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/async esp-wifi/embassy-net esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils esp-wifi/esp-now //% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils esp-wifi/esp-now
//% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6
#![no_std] #![no_std]

View File

@ -4,7 +4,7 @@
//! //!
//! Because of the huge task-arena size configured this won't work on ESP32-S2 //! Because of the huge task-arena size configured this won't work on ESP32-S2
//% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/async esp-wifi/embassy-net esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils esp-wifi/esp-now //% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils esp-wifi/esp-now
//% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6
#![no_std] #![no_std]

View File

@ -5,7 +5,7 @@
//! - automatically notifies subscribers every second //! - automatically notifies subscribers every second
//! //!
//% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/async esp-wifi/ble //% FEATURES: embassy embassy-generic-timers esp-wifi esp-wifi/ble
//% CHIPS: esp32 esp32s3 esp32c2 esp32c3 esp32c6 esp32h2 //% CHIPS: esp32 esp32s3 esp32c2 esp32c3 esp32c6 esp32h2
#![no_std] #![no_std]

View File

@ -1,7 +1,7 @@
//! WiFi sniffer example //! WiFi sniffer example
//! //!
//! Sniffs for beacon frames. //! Sniffs for beacon frames.
//! When using USB-SERIAL-JTAG you may have to activate the feature `phy-enable-usb` in the esp-wifi crate. //!
//% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils esp-wifi/sniffer //% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils esp-wifi/sniffer
//% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6

View File

@ -5,7 +5,7 @@
//! - might be necessary to configure your WiFi access point accordingly //! - might be necessary to configure your WiFi access point accordingly
//! - uses the given static IP //! - uses the given static IP
//! - responds with some HTML content when connecting to port 8080 //! - responds with some HTML content when connecting to port 8080
//! When using USB-SERIAL-JTAG you may have to activate the feature `phy-enable-usb` in the esp-wifi crate. //!
//% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils //% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils
//% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6

View File

@ -1,6 +1,6 @@
# esp-wifishark # esp-wifishark
This is an extcap to be used with esp-wifi and the `dump-packets` feature. This is an extcap to be used with esp-wifi and the `dump_packets` config option.
To use it build via `cargo build --release` and copy the resulting executable to the Wireshark's `extcap` folder. To use it build via `cargo build --release` and copy the resulting executable to the Wireshark's `extcap` folder.
@ -8,6 +8,6 @@ Then you should see two new capture interfaces in Wireshark
- esp-wifi HCI capture (for Bluetooth HCI) - esp-wifi HCI capture (for Bluetooth HCI)
- esp-wifi Ethernet capture (for WiFi traffic) - esp-wifi Ethernet capture (for WiFi traffic)
If you are running an application using esp-wifi's `dump-packets` feature and logging at INFO level active these capture interfaces can connect via serialport to give you insights on what is going on. If you are running an application using esp-wifi's `dump_packets` config and logging at INFO level active these capture interfaces can connect via serialport to give you insights on what is going on.
By default it tries to identify exactly one serialport. If that doesn't work for you, you can configure the serialport via the Wireshark UI. By default it tries to identify exactly one serialport. If that doesn't work for you, you can configure the serialport via the Wireshark UI.

View File

@ -249,21 +249,18 @@ esp32c3 = [
"esp-hal/esp32c3", "esp-hal/esp32c3",
"esp-hal-embassy?/esp32c3", "esp-hal-embassy?/esp32c3",
"esp-wifi?/esp32c3", "esp-wifi?/esp32c3",
"esp-wifi?/phy-enable-usb",
] ]
esp32c6 = [ esp32c6 = [
"esp-backtrace/esp32c6", "esp-backtrace/esp32c6",
"esp-hal/esp32c6", "esp-hal/esp32c6",
"esp-hal-embassy?/esp32c6", "esp-hal-embassy?/esp32c6",
"esp-wifi?/esp32c6", "esp-wifi?/esp32c6",
"esp-wifi?/phy-enable-usb",
] ]
esp32h2 = [ esp32h2 = [
"esp-backtrace/esp32h2", "esp-backtrace/esp32h2",
"esp-hal/esp32h2", "esp-hal/esp32h2",
"esp-hal-embassy?/esp32h2", "esp-hal-embassy?/esp32h2",
"esp-wifi?/esp32h2", "esp-wifi?/esp32h2",
"esp-wifi?/phy-enable-usb",
] ]
esp32s2 = [ esp32s2 = [
"embedded-test/xtensa-semihosting", "embedded-test/xtensa-semihosting",
@ -278,7 +275,6 @@ esp32s3 = [
"esp-hal/esp32s3", "esp-hal/esp32s3",
"esp-hal-embassy?/esp32s3", "esp-hal-embassy?/esp32s3",
"esp-wifi?/esp32s3", "esp-wifi?/esp32s3",
"esp-wifi?/phy-enable-usb",
] ]
# Async & Embassy: # Async & Embassy:
embassy = [ embassy = [

View File

@ -697,11 +697,10 @@ fn lint_packages(workspace: &Path, args: LintPackagesArgs) -> Result<()> {
} }
Package::EspWifi => { Package::EspWifi => {
let mut features = let mut features = format!("--features={chip},defmt,sys-logs");
format!("--features={chip},async,ps-min-modem,defmt,dump-packets,sys-logs");
if device.contains("wifi") { if device.contains("wifi") {
features.push_str(",wifi-default,esp-now,embassy-net,sniffer") features.push_str(",wifi-default,esp-now,sniffer")
} }
if device.contains("bt") { if device.contains("bt") {
features.push_str(",ble") features.push_str(",ble")