Skip to content

Commit 9a34d0e

Browse files
authored
Allow set_power_saving even for coex (#3081)
* Allow `set_power_saving` even for coex * CHANGELOG.md * Remove useless migration guide entry
1 parent 4739a67 commit 9a34d0e

File tree

7 files changed

+11
-10
lines changed

7 files changed

+11
-10
lines changed

esp-wifi/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
- `esp_wifi::init` now takes an `impl Peripheral` for RNG source (#2992)
1515

16+
- `set_power_saving` is now also available when the `coex` feature is activated (#3081)
17+
1618
### Fixed
1719

1820
- Fixed a problem using BLE on ESP32-C6 when connected via Serial-JTAG (#2981)

esp-wifi/MIGRATING-0.11.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ As part of limiting public API changes due to config options, the `csi_enabled`
2626
# In `Cargo.toml`:
2727
-esp-wifi = { version = "0.12.0", features = ["wifi"] }
2828
+esp-wifi = { version = "0.12.0", features = ["wifi", "csi"] }
29-
```
29+
```

esp-wifi/src/config.rs

-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ pub(crate) struct EspWifiConfig {
2525
pub(crate) scan_method: u32,
2626
}
2727

28-
#[cfg(not(coex))]
2928
#[non_exhaustive]
3029
#[derive(Default)]
3130
pub enum PowerSaveMode {
@@ -35,7 +34,6 @@ pub enum PowerSaveMode {
3534
Maximum,
3635
}
3736

38-
#[cfg(not(coex))]
3937
impl From<PowerSaveMode> for esp_wifi_sys::include::wifi_ps_type_t {
4038
fn from(s: PowerSaveMode) -> Self {
4139
match s {

esp-wifi/src/esp_now/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ use critical_section::Mutex;
1616
use enumset::EnumSet;
1717
use portable_atomic::{AtomicBool, AtomicU8, Ordering};
1818

19-
#[cfg(not(coex))]
20-
use crate::config::PowerSaveMode;
2119
#[cfg(feature = "csi")]
2220
use crate::wifi::CsiConfig;
2321
use crate::{
2422
binary::include::*,
23+
config::PowerSaveMode,
2524
hal::peripheral::{Peripheral, PeripheralRef},
2625
wifi::{Protocol, RxControlInfo, WifiError},
2726
EspWifiController,
@@ -340,7 +339,6 @@ impl EspNowManager<'_> {
340339
Ok(())
341340
}
342341

343-
#[cfg(not(coex))]
344342
/// Configures modem power saving
345343
pub fn set_power_saving(&self, ps: PowerSaveMode) -> Result<(), WifiError> {
346344
crate::wifi::apply_power_saving(ps)

esp-wifi/src/wifi/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ use serde::{Deserialize, Serialize};
6161
use smoltcp::phy::{Device, DeviceCapabilities, RxToken, TxToken};
6262
pub use state::*;
6363

64-
#[cfg(not(coex))]
65-
use crate::config::PowerSaveMode;
6664
use crate::{
6765
common_adapter::*,
66+
config::PowerSaveMode,
6867
esp_wifi_result,
6968
hal::{
7069
peripheral::{Peripheral, PeripheralRef},
@@ -2516,7 +2515,6 @@ impl<'d> WifiController<'d> {
25162515
Ok(())
25172516
}
25182517

2519-
#[cfg(not(coex))]
25202518
/// Configures modem power saving
25212519
pub fn set_power_saving(&mut self, ps: PowerSaveMode) -> Result<(), WifiError> {
25222520
apply_power_saving(ps)
@@ -3190,7 +3188,6 @@ pub(crate) mod embassy {
31903188
}
31913189
}
31923190

3193-
#[cfg(not(coex))]
31943191
pub(crate) fn apply_power_saving(ps: PowerSaveMode) -> Result<(), WifiError> {
31953192
esp_wifi_result!(unsafe { esp_wifi_sys::include::esp_wifi_set_ps(ps.into()) })?;
31963193
Ok(())

examples/src/bin/wifi_coex.rs

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ fn main() -> ! {
9090

9191
let (iface, device, mut controller) =
9292
create_network_interface(&init, &mut wifi, WifiStaDevice).unwrap();
93+
controller
94+
.set_power_saving(esp_wifi::config::PowerSaveMode::None)
95+
.unwrap();
9396

9497
let mut socket_set_entries: [SocketStorage; 3] = Default::default();
9598
let mut socket_set = SocketSet::new(&mut socket_set_entries[..]);

examples/src/bin/wifi_dhcp.rs

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ fn main() -> ! {
6363
let mut wifi = peripherals.WIFI;
6464
let (iface, device, mut controller) =
6565
create_network_interface(&init, &mut wifi, WifiStaDevice).unwrap();
66+
controller
67+
.set_power_saving(esp_wifi::config::PowerSaveMode::None)
68+
.unwrap();
6669

6770
let mut socket_set_entries: [SocketStorage; 3] = Default::default();
6871
let mut socket_set = SocketSet::new(&mut socket_set_entries[..]);

0 commit comments

Comments
 (0)