From 9a3811e6e72c200617699e60a06d1607e50e65e4 Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Thu, 7 Nov 2024 11:38:32 +0000 Subject: [PATCH] cfg away ps API --- esp-wifi/CHANGELOG.md | 1 + esp-wifi/src/config.rs | 2 ++ esp-wifi/src/esp_now/mod.rs | 7 +++---- esp-wifi/src/wifi/mod.rs | 13 +++++-------- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/esp-wifi/CHANGELOG.md b/esp-wifi/CHANGELOG.md index 5174947a718..7351d11a835 100644 --- a/esp-wifi/CHANGELOG.md +++ b/esp-wifi/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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 diff --git a/esp-wifi/src/config.rs b/esp-wifi/src/config.rs index 31f4a0125fa..0a5710f5300 100644 --- a/esp-wifi/src/config.rs +++ b/esp-wifi/src/config.rs @@ -27,6 +27,7 @@ pub(crate) struct EspWifiConfig { pub(crate) scan_method: u32, } +#[cfg(not(coex))] #[non_exhaustive] #[derive(Default)] pub enum PowerSaveMode { @@ -36,6 +37,7 @@ pub enum PowerSaveMode { Maximum, } +#[cfg(not(coex))] impl From for include::wifi_ps_type_t { fn from(s: PowerSaveMode) -> Self { match s { diff --git a/esp-wifi/src/esp_now/mod.rs b/esp-wifi/src/esp_now/mod.rs index adc9e1889a1..b92babdf23b 100644 --- a/esp-wifi/src/esp_now/mod.rs +++ b/esp-wifi/src/esp_now/mod.rs @@ -16,9 +16,10 @@ use critical_section::Mutex; use enumset::EnumSet; use portable_atomic::{AtomicBool, AtomicU8, Ordering}; +#[cfg(coex)] +use crate::config::PowerSaveMode; use crate::{ binary::include::*, - config::PowerSaveMode, hal::peripheral::{Peripheral, PeripheralRef}, wifi::{Protocol, RxControlInfo, WifiError}, EspWifiController, @@ -336,10 +337,8 @@ impl EspNowManager<'_> { Ok(()) } + #[cfg(not(coex))] /// Configures modem power saving - /// - /// This is ignored, and set to `PowerSaveMode::Minimum` when `coex` is - /// enabled. pub fn set_power_saving(&self, ps: PowerSaveMode) -> Result<(), WifiError> { crate::wifi::apply_power_saving(ps) } diff --git a/esp-wifi/src/wifi/mod.rs b/esp-wifi/src/wifi/mod.rs index e43fd83682a..cfc22ef2ddb 100644 --- a/esp-wifi/src/wifi/mod.rs +++ b/esp-wifi/src/wifi/mod.rs @@ -61,9 +61,10 @@ 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::*, - config::PowerSaveMode, esp_wifi_result, hal::{ macros::ram, @@ -2591,10 +2592,8 @@ impl<'d> WifiController<'d> { Ok(()) } + #[cfg(not(coex))] /// Configures modem power saving - /// - /// This is ignored, and set to `PowerSaveMode::Minimum` when `coex` is - /// enabled. pub fn set_power_saving(&mut self, ps: PowerSaveMode) -> Result<(), WifiError> { apply_power_saving(ps) } @@ -3266,10 +3265,8 @@ pub(crate) mod embassy { } } -pub(crate) fn apply_power_saving(mut ps: PowerSaveMode) -> Result<(), WifiError> { - if cfg!(coex) { - ps = PowerSaveMode::Minimum; - } +#[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(()) }