diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79f6b994eb0..e8bef8ccac6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -137,10 +137,10 @@ jobs: - name: msrv RISCV (esp-wifi) run: | - cargo xtask build-package --features=esp32c2,wifi,ble,async --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=esp32c6,wifi,ble,async --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=esp32c2,wifi,ble --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 --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: - name: msrv Xtensa (esp-hal) @@ -151,9 +151,9 @@ jobs: - name: msrv Xtensa (esp-wifi) 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=esp32s2,wifi,async --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=esp32,wifi,ble --target=xtensa-esp32-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 --target=xtensa-esp32s3-none-elf esp-wifi - name: msrv (esp-lp-hal) run: | diff --git a/esp-wifi/CHANGELOG.md b/esp-wifi/CHANGELOG.md index fcf7d07bb3b..7351d11a835 100644 --- a/esp-wifi/CHANGELOG.md +++ b/esp-wifi/CHANGELOG.md @@ -10,12 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added `serde` support through the `serde` feature (#2346) +- Added `PowerSaveMode` and `set_power_saving` methods on `EspNowManager` & `WifiController` (#2446) ### Changed - `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) - 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 @@ -25,6 +28,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed - 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 diff --git a/esp-wifi/Cargo.toml b/esp-wifi/Cargo.toml index 4ac482a6a88..65d1beb2443 100644 --- a/esp-wifi/Cargo.toml +++ b/esp-wifi/Cargo.toml @@ -25,7 +25,7 @@ smoltcp = { version = "0.11.0", default-features = false, features = [ critical-section = "1.1.3" enumset = { version = "1.1.5", default-features = false, optional = true } 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" heapless = { version = "0.8.0", default-features = false, features = [ "portable-atomic", @@ -101,48 +101,35 @@ esp32s3 = [ "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 coex = [] ## Logs the WiFi logs from the driver at log level info (needs a nightly-compiler) sys-logs = ["esp-wifi-sys/sys-logs"] -## Dumps packet info at log level info -dump-packets = [] - -## Provide implementations of smoltcp traits -smoltcp = ["dep:smoltcp"] +## Enable support for `defmt` +defmt = ["dep:defmt", "smoltcp?/defmt", "esp-hal/defmt", "bt-hci?/defmt", "esp-wifi-sys/defmt"] -## Provide utilities for smoltcp initialization. Adds smoltcp dependency -utils = ["smoltcp"] +## Enable support for the `log` crate +log = ["dep:log", "esp-hal/log", "esp-wifi-sys/log"] ## Enable WiFi support -wifi = ["dep:enumset"] +wifi = ["dep:enumset", "dep:embassy-net-driver", "dep:embassy-sync"] -## Enable BLE support -ble = ["esp-hal/bluetooth"] +## Enable esp-now support +esp-now = ["wifi"] -## See USB-SERIAL-JTAG below -phy-enable-usb = [] +## Enable sniffer mode support +sniffer = ["wifi"] -## Enable minimum modem sleep. Only affects STA mode -ps-min-modem = [] +## Enable BLE support +ble = ["esp-hal/bluetooth", "dep:bt-hci", "dep:embassy-sync"] -## Enable maximum modem sleep. Only affects STA mode -ps-max-modem = [] +## Provide implementations of smoltcp traits +smoltcp = ["dep:smoltcp"] -## Enable esp-now support -esp-now = ["wifi"] +## Provide utilities for smoltcp initialization. Adds smoltcp dependency +utils = ["smoltcp"] ## IPv6 support. Includes utils feature 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" 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 serde = ["dep:serde", "enumset?/serde", "heapless/serde"] @@ -189,8 +167,6 @@ features = [ "wifi", "ble", "coex", - "async", - "embassy-net", "esp-hal/default", ] -default-target = "riscv32imc-unknown-none-elf" +default-target = "riscv32imc-unknown-none-elf" \ No newline at end of file diff --git a/esp-wifi/MIGRATING-0.10.md b/esp-wifi/MIGRATING-0.10.md index 0bf1d4c5c73..d2763ba21fb 100644 --- a/esp-wifi/MIGRATING-0.10.md +++ b/esp-wifi/MIGRATING-0.10.md @@ -33,3 +33,12 @@ rustflags = [ Previously `data` and `len` were public - use the previously already existing `data()` function. 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(); +``` diff --git a/esp-wifi/build.rs b/esp-wifi/build.rs index 5197c6ffb41..23be6c6ab3b 100644 --- a/esp-wifi/build.rs +++ b/esp-wifi/build.rs @@ -127,6 +127,8 @@ fn main() -> Result<(), Box> { ("ap_beacon_timeout", Value::UnsignedInteger(300), "For SoftAP, If the SoftAP doesn’t 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"), ("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 ); diff --git a/esp-wifi/src/ble/btdm.rs b/esp-wifi/src/ble/btdm.rs index c6ca321db35..6d444c2d464 100644 --- a/esp-wifi/src/ble/btdm.rs +++ b/esp-wifi/src/ble/btdm.rs @@ -79,7 +79,6 @@ extern "C" fn notify_host_recv(data: *mut u8, len: u16) -> i32 { super::dump_packet_info(data); - #[cfg(feature = "async")] crate::ble::controller::asynch::hci_read_data_available(); 0 diff --git a/esp-wifi/src/ble/controller/mod.rs b/esp-wifi/src/ble/controller/mod.rs index bd2b58c92f9..7667a187982 100644 --- a/esp-wifi/src/ble/controller/mod.rs +++ b/esp-wifi/src/ble/controller/mod.rs @@ -83,7 +83,6 @@ impl Write for BleConnector<'_> { } /// Async Interface -#[cfg(feature = "async")] pub(crate) mod asynch { use core::task::Poll; diff --git a/esp-wifi/src/ble/mod.rs b/esp-wifi/src/ble/mod.rs index 7246ffbcb8b..22994478b53 100644 --- a/esp-wifi/src/ble/mod.rs +++ b/esp-wifi/src/ble/mod.rs @@ -117,7 +117,6 @@ impl defmt::Format for ReceivedPacket { } } -#[cfg(feature = "async")] pub fn have_hci_read_data() -> bool { critical_section::with(|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]) { - #[cfg(feature = "dump-packets")] + #[cfg(dump_packets)] critical_section::with(|_cs| { info!("@HCIFRAME {:?}", _buffer); }); diff --git a/esp-wifi/src/ble/npl.rs b/esp-wifi/src/ble/npl.rs index 3d8696966b5..f08516f95da 100644 --- a/esp-wifi/src/ble/npl.rs +++ b/esp-wifi/src/ble/npl.rs @@ -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); - #[cfg(feature = "async")] crate::ble::controller::asynch::hci_read_data_available(); 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 _); - #[cfg(feature = "async")] crate::ble::controller::asynch::hci_read_data_available(); 0 diff --git a/esp-wifi/src/ble/os_adapter_esp32.rs b/esp-wifi/src/ble/os_adapter_esp32.rs index 39f55cadc2b..f49c2ac05ba 100644 --- a/esp-wifi/src/ble/os_adapter_esp32.rs +++ b/esp-wifi/src/ble/os_adapter_esp32.rs @@ -586,7 +586,6 @@ const BTDM_ASYNC_WAKEUP_REQ_COEX: i32 = 1; /// true if request lock is needed, false otherwise /// /// ************************************************************************* - #[cfg(coex)] fn async_wakeup_request(event: i32) -> bool { 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 /// /// ************************************************************************* - #[cfg(coex)] fn async_wakeup_request_end(event: i32) { let request_lock = match event { diff --git a/esp-wifi/src/common_adapter/common_adapter_esp32.rs b/esp-wifi/src/common_adapter/common_adapter_esp32.rs index 26a05931a95..268311fe81c 100644 --- a/esp-wifi/src/common_adapter/common_adapter_esp32.rs +++ b/esp-wifi/src/common_adapter/common_adapter_esp32.rs @@ -155,7 +155,6 @@ pub(crate) unsafe fn phy_disable_clock() { /// Register value /// /// ************************************************************************* - #[ram] #[no_mangle] unsafe extern "C" fn esp_dport_access_reg_read(reg: u32) -> u32 { diff --git a/esp-wifi/src/common_adapter/common_adapter_esp32c3.rs b/esp-wifi/src/common_adapter/common_adapter_esp32c3.rs index 8a4bf0ab044..eaa7903a1fe 100644 --- a/esp-wifi/src/common_adapter/common_adapter_esp32c3.rs +++ b/esp-wifi/src/common_adapter/common_adapter_esp32c3.rs @@ -76,7 +76,7 @@ pub(crate) unsafe fn phy_enable() { let init_data = &PHY_INIT_DATA_DEFAULT; - #[cfg(feature = "phy-enable-usb")] + #[cfg(phy_enable_usb)] { extern "C" { fn phy_bbpll_en_usb(param: bool); diff --git a/esp-wifi/src/common_adapter/common_adapter_esp32c6.rs b/esp-wifi/src/common_adapter/common_adapter_esp32c6.rs index 74f3d76cecd..bd0e30cfe66 100644 --- a/esp-wifi/src/common_adapter/common_adapter_esp32c6.rs +++ b/esp-wifi/src/common_adapter/common_adapter_esp32c6.rs @@ -41,7 +41,7 @@ pub(crate) unsafe fn phy_enable() { let init_data = &PHY_INIT_DATA_DEFAULT; - #[cfg(feature = "phy-enable-usb")] + #[cfg(phy_enable_usb)] { extern "C" { fn phy_bbpll_en_usb(param: bool); diff --git a/esp-wifi/src/common_adapter/common_adapter_esp32h2.rs b/esp-wifi/src/common_adapter/common_adapter_esp32h2.rs index 1cb0b537589..0186c2759fa 100644 --- a/esp-wifi/src/common_adapter/common_adapter_esp32h2.rs +++ b/esp-wifi/src/common_adapter/common_adapter_esp32h2.rs @@ -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 - // #[cfg(feature = "phy-enable-usb")] + // #[cfg(phy_enable_usb)] // { // extern "C" { // pub fn phy_bbpll_en_usb(param: bool); diff --git a/esp-wifi/src/common_adapter/common_adapter_esp32s3.rs b/esp-wifi/src/common_adapter/common_adapter_esp32s3.rs index 249370caa1f..f4213be87dd 100644 --- a/esp-wifi/src/common_adapter/common_adapter_esp32s3.rs +++ b/esp-wifi/src/common_adapter/common_adapter_esp32s3.rs @@ -72,7 +72,7 @@ pub(crate) unsafe fn phy_enable() { let init_data = &PHY_INIT_DATA_DEFAULT; - #[cfg(feature = "phy-enable-usb")] + #[cfg(phy_enable_usb)] { extern "C" { fn phy_bbpll_en_usb(param: bool); diff --git a/esp-wifi/src/config.rs b/esp-wifi/src/config.rs new file mode 100644 index 00000000000..92f2a97e167 --- /dev/null +++ b/esp-wifi/src/config.rs @@ -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 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, + } + } +} diff --git a/esp-wifi/src/esp_now/mod.rs b/esp-wifi/src/esp_now/mod.rs index febd478bf30..cc65c355577 100644 --- a/esp-wifi/src/esp_now/mod.rs +++ b/esp-wifi/src/esp_now/mod.rs @@ -16,6 +16,8 @@ use critical_section::Mutex; use enumset::EnumSet; use portable_atomic::{AtomicBool, AtomicU8, Ordering}; +#[cfg(not(coex))] +use crate::config::PowerSaveMode; use crate::{ binary::include::*, hal::peripheral::{Peripheral, PeripheralRef}, @@ -335,6 +337,12 @@ impl EspNowManager<'_> { 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. /// Should only be used when using ESP-NOW without AP or STA. pub fn set_channel(&self, channel: u8) -> Result<(), EspNowError> { @@ -682,25 +690,6 @@ impl<'d> EspNow<'d> { check_error!({ 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_register_recv_cb(Some(rcv_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); - #[cfg(feature = "async")] asynch::ESP_NOW_TX_WAKER.wake(); }) } @@ -871,15 +859,12 @@ unsafe extern "C" fn rcv_cb( queue.push_back(ReceivedData { data, info }); - #[cfg(feature = "async")] asynch::ESP_NOW_RX_WAKER.wake(); }); } -#[cfg(feature = "async")] pub use asynch::SendFuture; -#[cfg(feature = "async")] mod asynch { use core::task::{Context, Poll}; diff --git a/esp-wifi/src/lib.rs b/esp-wifi/src/lib.rs index e96f3c41769..3a7d1e195b5 100644 --- a/esp-wifi/src/lib.rs +++ b/esp-wifi/src/lib.rs @@ -48,19 +48,12 @@ //! Within this crate, `CCOMPARE0` CPU timer is used for timing, ensure that in //! 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 //! //! Note that not all features are available on every MCU. For example, `ble` //! (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. //! For more information see //! [extras/esp-wifishark/README.md](../extras/esp-wifishark/README.md) @@ -134,6 +127,8 @@ pub mod ble; #[cfg(feature = "esp-now")] pub mod esp_now; +pub mod config; + pub(crate) mod common_adapter; #[doc(hidden)] @@ -169,34 +164,7 @@ const _: () = { }; }; -#[derive(Debug)] -#[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 { +pub(crate) const CONFIG: config::EspWifiConfig = config::EspWifiConfig { rx_queue_size: esp_config_int!(usize, "ESP_WIFI_RX_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"), @@ -371,11 +339,9 @@ impl private::Sealed for Trng<'_> {} /// ```rust, no_run #[doc = esp_hal::before_snippet!()] /// use esp_hal::{rng::Rng, timg::TimerGroup}; -/// use esp_wifi::EspWifiInitFor; /// /// let timg0 = TimerGroup::new(peripherals.TIMG0); /// let init = esp_wifi::init( -/// EspWifiInitFor::Wifi, /// timg0.timer0, /// Rng::new(peripherals.RNG), /// peripherals.RADIO_CLK, diff --git a/esp-wifi/src/wifi/mod.rs b/esp-wifi/src/wifi/mod.rs index 33df1bcefee..cfc22ef2ddb 100644 --- a/esp-wifi/src/wifi/mod.rs +++ b/esp-wifi/src/wifi/mod.rs @@ -50,7 +50,6 @@ use esp_wifi_sys::include::{ wifi_promiscuous_pkt_type_t, }; use num_derive::FromPrimitive; -use num_traits::FromPrimitive; #[doc(hidden)] pub(crate) use os_adapter::*; #[cfg(feature = "sniffer")] @@ -62,6 +61,8 @@ use serde::{Deserialize, Serialize}; use smoltcp::phy::{Device, DeviceCapabilities, RxToken, TxToken}; pub use state::*; +#[cfg(not(coex))] +use crate::config::PowerSaveMode; use crate::{ common_adapter::*, esp_wifi_result, @@ -105,7 +106,6 @@ use crate::binary::{ esp_wifi_set_country, esp_wifi_set_mode, esp_wifi_set_protocol, - esp_wifi_set_ps, esp_wifi_set_tx_done_cb, esp_wifi_start, esp_wifi_stop, @@ -1623,7 +1623,6 @@ unsafe extern "C" fn recv_cb_sta( false } }) { - #[cfg(feature = "embassy-net")] embassy::STA_RECEIVE_WAKER.wake(); include::ESP_OK as esp_err_t } else { @@ -1653,7 +1652,6 @@ unsafe extern "C" fn recv_cb_ap( false } }) { - #[cfg(feature = "embassy-net")] embassy::AP_RECEIVE_WAKER.wake(); include::ESP_OK as esp_err_t } else { @@ -1683,7 +1681,6 @@ unsafe extern "C" fn esp_wifi_tx_done_cb( decrement_inflight_counter(); - #[cfg(feature = "embassy-net")] 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]; cntry_code[..crate::CONFIG.country_code.len()] .copy_from_slice(crate::CONFIG.country_code.as_bytes()); @@ -2041,18 +2024,14 @@ mod sealed { fn interface(self) -> wifi_interface_t; - #[cfg(feature = "embassy-net")] fn register_transmit_waker(self, cx: &mut core::task::Context) { embassy::TRANSMIT_WAKER.register(cx.waker()) } - #[cfg(feature = "embassy-net")] 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); - #[cfg(feature = "embassy-net")] fn link_state(self) -> embassy_net_driver::LinkState; } @@ -2075,17 +2054,14 @@ mod sealed { wifi_interface_t_WIFI_IF_STA } - #[cfg(feature = "embassy-net")] fn register_receive_waker(self, cx: &mut core::task::Context) { embassy::STA_RECEIVE_WAKER.register(cx.waker()); } - #[cfg(feature = "embassy-net")] fn register_link_state_waker(self, cx: &mut core::task::Context) { embassy::STA_LINK_STATE_WAKER.register(cx.waker()); } - #[cfg(feature = "embassy-net")] fn link_state(self) -> embassy_net_driver::LinkState { if matches!(get_sta_state(), WifiState::StaConnected) { embassy_net_driver::LinkState::Up @@ -2114,17 +2090,14 @@ mod sealed { wifi_interface_t_WIFI_IF_AP } - #[cfg(feature = "embassy-net")] fn register_receive_waker(self, cx: &mut core::task::Context) { embassy::AP_RECEIVE_WAKER.register(cx.waker()); } - #[cfg(feature = "embassy-net")] fn register_link_state_waker(self, cx: &mut core::task::Context) { embassy::AP_LINK_STATE_WAKER.register(cx.waker()); } - #[cfg(feature = "embassy-net")] fn link_state(self) -> embassy_net_driver::LinkState { if matches!(get_ap_state(), WifiState::ApStarted) { embassy_net_driver::LinkState::Up @@ -2619,6 +2592,12 @@ impl<'d> WifiController<'d> { 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. pub fn is_sta_enabled(&self) -> Result { WifiMode::try_from(&self.config).map(|m| m.is_sta()) @@ -2684,6 +2663,33 @@ impl<'d> WifiController<'d> { Ok(scanned) } + + /// A blocking wifi network scan with default scanning options. + pub fn scan_n( + &mut self, + ) -> Result<(heapless::Vec, 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 @@ -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( - &mut self, - ) -> Result<(heapless::Vec, 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]) { - #[cfg(feature = "dump-packets")] + #[cfg(dump_packets)] { info!("@WIFIFRAME {:?}", _buffer); } @@ -3196,8 +3172,9 @@ fn dump_packet_info(_buffer: &[u8]) { #[macro_export] macro_rules! esp_wifi_result { ($value:expr) => {{ + use num_traits::FromPrimitive; 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); Err(WifiError::InternalError(unwrap!(FromPrimitive::from_i32( result @@ -3208,7 +3185,6 @@ macro_rules! esp_wifi_result { }}; } -#[cfg(feature = "embassy-net")] pub(crate) mod embassy { use embassy_net_driver::{Capabilities, Driver, HardwareAddress, RxToken, TxToken}; 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 { use core::task::Poll; @@ -3300,14 +3281,14 @@ mod asynch { // TODO assumes STA mode only impl WifiController<'_> { /// Async version of [`crate::wifi::WifiController`]'s `scan_n` method - pub async fn scan_n( + pub async fn scan_n_async( &mut self, ) -> Result<(heapless::Vec, 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. - pub async fn scan_with_config( + pub async fn scan_with_config_async( &mut self, config: ScanConfig<'_>, ) -> Result<(heapless::Vec, usize), WifiError> { @@ -3327,7 +3308,7 @@ mod asynch { } /// 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 mut events = enumset::enum_set! {}; @@ -3348,7 +3329,7 @@ mod asynch { } /// 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 mut events = enumset::enum_set! {}; @@ -3372,7 +3353,7 @@ mod asynch { } /// 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); let err = crate::wifi::WifiController::connect_impl(self).err(); @@ -3389,7 +3370,7 @@ mod asynch { /// Async version of [`crate::wifi::WifiController`]'s `Disconnect` /// 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. // It will also wait forever for a `StaDisconnected` event that will never come. // Return early instead of hanging. diff --git a/esp-wifi/src/wifi/os_adapter.rs b/esp-wifi/src/wifi/os_adapter.rs index c059c8c1a5f..cd87ab6633d 100644 --- a/esp-wifi/src/wifi/os_adapter.rs +++ b/esp-wifi/src/wifi/os_adapter.rs @@ -870,10 +870,8 @@ pub unsafe extern "C" fn event_post( super::state::update_state(event); - #[cfg(feature = "async")] event.waker().wake(); - #[cfg(feature = "embassy-net")] match event { WifiEvent::StaConnected | WifiEvent::StaDisconnected => { crate::wifi::embassy::STA_LINK_STATE_WAKER.wake(); diff --git a/esp-wifi/src/wifi/state.rs b/esp-wifi/src/wifi/state.rs index 58d8d4441f9..e11f584f576 100644 --- a/esp-wifi/src/wifi/state.rs +++ b/esp-wifi/src/wifi/state.rs @@ -62,12 +62,10 @@ pub(crate) fn update_state(event: WifiEvent) { } } -#[cfg(feature = "async")] pub(crate) fn reset_ap_state() { AP_STATE.store(WifiState::Invalid, Ordering::Relaxed) } -#[cfg(feature = "async")] pub(crate) fn reset_sta_state() { STA_STATE.store(WifiState::Invalid, Ordering::Relaxed) } diff --git a/examples/src/bin/wifi_80211_tx.rs b/examples/src/bin/wifi_80211_tx.rs index c073ce12789..3b33456fd09 100644 --- a/examples/src/bin/wifi_80211_tx.rs +++ b/examples/src/bin/wifi_80211_tx.rs @@ -1,7 +1,7 @@ //! WiFi frame injection example //! //! 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 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 diff --git a/examples/src/bin/wifi_access_point.rs b/examples/src/bin/wifi_access_point.rs index a4e8032851f..94c5b182105 100644 --- a/examples/src/bin/wifi_access_point.rs +++ b/examples/src/bin/wifi_access_point.rs @@ -6,7 +6,7 @@ //! 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` -//! 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 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 diff --git a/examples/src/bin/wifi_access_point_with_sta.rs b/examples/src/bin/wifi_access_point_with_sta.rs index 36e17512864..f9c3e0792e5 100644 --- a/examples/src/bin/wifi_access_point_with_sta.rs +++ b/examples/src/bin/wifi_access_point_with_sta.rs @@ -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 //! //! 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 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 diff --git a/examples/src/bin/wifi_bench.rs b/examples/src/bin/wifi_bench.rs index 06a474b8f70..511773ee705 100644 --- a/examples/src/bin/wifi_bench.rs +++ b/examples/src/bin/wifi_bench.rs @@ -6,7 +6,7 @@ //! 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. -//! 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 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 diff --git a/examples/src/bin/wifi_coex.rs b/examples/src/bin/wifi_coex.rs index a8c779d117f..002ea35e8f3 100644 --- a/examples/src/bin/wifi_coex.rs +++ b/examples/src/bin/wifi_coex.rs @@ -6,7 +6,7 @@ //! - 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 -//! 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 //% CHIPS: esp32 esp32s3 esp32c2 esp32c3 esp32c6 diff --git a/examples/src/bin/wifi_dhcp.rs b/examples/src/bin/wifi_dhcp.rs index 68f642c3d38..fd756e4478c 100644 --- a/examples/src/bin/wifi_dhcp.rs +++ b/examples/src/bin/wifi_dhcp.rs @@ -4,7 +4,7 @@ //! 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 -//! 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 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 diff --git a/examples/src/bin/wifi_embassy_access_point.rs b/examples/src/bin/wifi_embassy_access_point.rs index 748df8ccba5..ca86dc2d078 100644 --- a/examples/src/bin/wifi_embassy_access_point.rs +++ b/examples/src/bin/wifi_embassy_access_point.rs @@ -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` //! //! 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 #![no_std] @@ -220,7 +220,7 @@ async fn connection(mut controller: WifiController<'static>) { }); controller.set_configuration(&client_config).unwrap(); println!("Starting wifi"); - controller.start().await.unwrap(); + controller.start_async().await.unwrap(); println!("Wifi started!"); } } diff --git a/examples/src/bin/wifi_embassy_access_point_with_sta.rs b/examples/src/bin/wifi_embassy_access_point_with_sta.rs index 82f74805509..6ce2d859052 100644 --- a/examples/src/bin/wifi_embassy_access_point_with_sta.rs +++ b/examples/src/bin/wifi_embassy_access_point_with_sta.rs @@ -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` //! //! 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 #![no_std] @@ -315,7 +315,7 @@ async fn connection(mut controller: WifiController<'static>) { println!("Device capabilities: {:?}", controller.get_capabilities()); println!("Starting wifi"); - controller.start().await.unwrap(); + controller.start_async().await.unwrap(); println!("Wifi started!"); loop { @@ -323,7 +323,7 @@ async fn connection(mut controller: WifiController<'static>) { WifiState::ApStarted => { println!("About to connect..."); - match controller.connect().await { + match controller.connect_async().await { Ok(_) => { // wait until we're no longer connected controller.wait_for_event(WifiEvent::StaDisconnected).await; diff --git a/examples/src/bin/wifi_embassy_bench.rs b/examples/src/bin/wifi_embassy_bench.rs index 80334b862db..d33289a4218 100644 --- a/examples/src/bin/wifi_embassy_bench.rs +++ b/examples/src/bin/wifi_embassy_bench.rs @@ -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. //! //! 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 #![allow(static_mut_refs)] @@ -193,12 +193,12 @@ async fn connection(mut controller: WifiController<'static>) { }); controller.set_configuration(&client_config).unwrap(); println!("Starting wifi"); - controller.start().await.unwrap(); + controller.start_async().await.unwrap(); println!("Wifi started!"); } println!("About to connect..."); - match controller.connect().await { + match controller.connect_async().await { Ok(_) => println!("Wifi connected!"), Err(e) => { println!("Failed to connect to wifi: {e:?}"); diff --git a/examples/src/bin/wifi_embassy_ble.rs b/examples/src/bin/wifi_embassy_ble.rs index 3fb6d0dd181..5ba16b69863 100644 --- a/examples/src/bin/wifi_embassy_ble.rs +++ b/examples/src/bin/wifi_embassy_ble.rs @@ -4,7 +4,7 @@ //! - 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 -//% 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 #![no_std] diff --git a/examples/src/bin/wifi_embassy_dhcp.rs b/examples/src/bin/wifi_embassy_dhcp.rs index 5ee5bb322ba..67bea7f3ada 100644 --- a/examples/src/bin/wifi_embassy_dhcp.rs +++ b/examples/src/bin/wifi_embassy_dhcp.rs @@ -6,9 +6,8 @@ //! 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 -//! 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 #![no_std] @@ -186,12 +185,12 @@ async fn connection(mut controller: WifiController<'static>) { }); controller.set_configuration(&client_config).unwrap(); println!("Starting wifi"); - controller.start().await.unwrap(); + controller.start_async().await.unwrap(); println!("Wifi started!"); } println!("About to connect..."); - match controller.connect().await { + match controller.connect_async().await { Ok(_) => println!("Wifi connected!"), Err(e) => { println!("Failed to connect to wifi: {e:?}"); diff --git a/examples/src/bin/wifi_embassy_esp_now.rs b/examples/src/bin/wifi_embassy_esp_now.rs index 3b7aecd43e8..3828ec9a9e8 100644 --- a/examples/src/bin/wifi_embassy_esp_now.rs +++ b/examples/src/bin/wifi_embassy_esp_now.rs @@ -4,7 +4,7 @@ //! //! 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 #![no_std] diff --git a/examples/src/bin/wifi_embassy_esp_now_duplex.rs b/examples/src/bin/wifi_embassy_esp_now_duplex.rs index 1eeec3a88a5..600aca964c9 100644 --- a/examples/src/bin/wifi_embassy_esp_now_duplex.rs +++ b/examples/src/bin/wifi_embassy_esp_now_duplex.rs @@ -4,7 +4,7 @@ //! //! 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 #![no_std] diff --git a/examples/src/bin/wifi_embassy_trouble.rs b/examples/src/bin/wifi_embassy_trouble.rs index 45253463ae6..a5f55a02750 100644 --- a/examples/src/bin/wifi_embassy_trouble.rs +++ b/examples/src/bin/wifi_embassy_trouble.rs @@ -5,7 +5,7 @@ //! - 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 #![no_std] diff --git a/examples/src/bin/wifi_sniffer.rs b/examples/src/bin/wifi_sniffer.rs index 4e56d6338ef..69256e326bc 100644 --- a/examples/src/bin/wifi_sniffer.rs +++ b/examples/src/bin/wifi_sniffer.rs @@ -1,7 +1,7 @@ //! WiFi sniffer example //! //! 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 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 diff --git a/examples/src/bin/wifi_static_ip.rs b/examples/src/bin/wifi_static_ip.rs index e9a91fe1fac..af7f14d2674 100644 --- a/examples/src/bin/wifi_static_ip.rs +++ b/examples/src/bin/wifi_static_ip.rs @@ -5,7 +5,7 @@ //! - might be necessary to configure your WiFi access point accordingly //! - uses the given static IP //! - 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 //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 diff --git a/extras/esp-wifishark/README.md b/extras/esp-wifishark/README.md index 1a10a828f45..887a3e057c2 100644 --- a/extras/esp-wifishark/README.md +++ b/extras/esp-wifishark/README.md @@ -1,6 +1,6 @@ # 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. @@ -8,6 +8,6 @@ Then you should see two new capture interfaces in Wireshark - esp-wifi HCI capture (for Bluetooth HCI) - 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. diff --git a/hil-test/Cargo.toml b/hil-test/Cargo.toml index 980d53dce0e..112d87941bb 100644 --- a/hil-test/Cargo.toml +++ b/hil-test/Cargo.toml @@ -249,21 +249,18 @@ esp32c3 = [ "esp-hal/esp32c3", "esp-hal-embassy?/esp32c3", "esp-wifi?/esp32c3", - "esp-wifi?/phy-enable-usb", ] esp32c6 = [ "esp-backtrace/esp32c6", "esp-hal/esp32c6", "esp-hal-embassy?/esp32c6", "esp-wifi?/esp32c6", - "esp-wifi?/phy-enable-usb", ] esp32h2 = [ "esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-hal-embassy?/esp32h2", "esp-wifi?/esp32h2", - "esp-wifi?/phy-enable-usb", ] esp32s2 = [ "embedded-test/xtensa-semihosting", @@ -278,7 +275,6 @@ esp32s3 = [ "esp-hal/esp32s3", "esp-hal-embassy?/esp32s3", "esp-wifi?/esp32s3", - "esp-wifi?/phy-enable-usb", ] # Async & Embassy: embassy = [ diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 4a43062fab2..9a4488c6dab 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -697,11 +697,10 @@ fn lint_packages(workspace: &Path, args: LintPackagesArgs) -> Result<()> { } Package::EspWifi => { - let mut features = - format!("--features={chip},async,ps-min-modem,defmt,dump-packets,sys-logs"); + let mut features = format!("--features={chip},defmt,sys-logs"); 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") { features.push_str(",ble")