Skip to content

Commit 50d8187

Browse files
authored
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
1 parent 6d6f6a7 commit 50d8187

40 files changed

+187
-232
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ jobs:
137137
138138
- name: msrv RISCV (esp-wifi)
139139
run: |
140-
cargo xtask build-package --features=esp32c2,wifi,ble,async --target=riscv32imc-unknown-none-elf esp-wifi
141-
cargo xtask build-package --features=esp32c3,wifi,ble,async --target=riscv32imc-unknown-none-elf esp-wifi
142-
cargo xtask build-package --features=esp32c6,wifi,ble,async --target=riscv32imac-unknown-none-elf esp-wifi
143-
cargo xtask build-package --features=esp32h2,ble,async --target=riscv32imac-unknown-none-elf esp-wifi
140+
cargo xtask build-package --features=esp32c2,wifi,ble --target=riscv32imc-unknown-none-elf esp-wifi
141+
cargo xtask build-package --features=esp32c3,wifi,ble --target=riscv32imc-unknown-none-elf esp-wifi
142+
cargo xtask build-package --features=esp32c6,wifi,ble --target=riscv32imac-unknown-none-elf esp-wifi
143+
cargo xtask build-package --features=esp32h2,ble --target=riscv32imac-unknown-none-elf esp-wifi
144144
145145
# Verify the MSRV for all Xtensa chips:
146146
- name: msrv Xtensa (esp-hal)
@@ -151,9 +151,9 @@ jobs:
151151
152152
- name: msrv Xtensa (esp-wifi)
153153
run: |
154-
cargo xtask build-package --toolchain=esp --features=esp32,wifi,ble,async --target=xtensa-esp32-none-elf esp-wifi
155-
cargo xtask build-package --toolchain=esp --features=esp32s2,wifi,async --target=xtensa-esp32s2-none-elf esp-wifi
156-
cargo xtask build-package --toolchain=esp --features=esp32s3,wifi,ble,async --target=xtensa-esp32s3-none-elf esp-wifi
154+
cargo xtask build-package --toolchain=esp --features=esp32,wifi,ble --target=xtensa-esp32-none-elf esp-wifi
155+
cargo xtask build-package --toolchain=esp --features=esp32s2,wifi --target=xtensa-esp32s2-none-elf esp-wifi
156+
cargo xtask build-package --toolchain=esp --features=esp32s3,wifi,ble --target=xtensa-esp32s3-none-elf esp-wifi
157157
158158
- name: msrv (esp-lp-hal)
159159
run: |

esp-wifi/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Added `serde` support through the `serde` feature (#2346)
13+
- Added `PowerSaveMode` and `set_power_saving` methods on `EspNowManager` & `WifiController` (#2446)
1314

1415
### Changed
1516

1617
- `esp_wifi::init` no longer requires `EspWifiInitFor`, and now returns `EspWifiController`, see the migration guide for more details (#2301)
1718
- No need to add `rom_functions.x` manually anymore (#2374)
1819
- esp-now: Data is now private in `ReceivedData` - use `data()`(#2396)
20+
- Changed the async APIs to have a `_async` postfix to avoid name collisions (#2446)
21+
- `phy_enable_usb` is enabled by default (#2446)
1922

2023
### Fixed
2124

@@ -25,6 +28,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2528
### Removed
2629

2730
- Feature `have-strchr` is removed (#2462)
31+
- Features `async`, `embassy-net` have been removed (#2446)
32+
- Features `phy-enable-usb` & `dump-packets` have been turned into configuration options `phy_enable_usb` & `dump_packets` (#2446)
33+
- Features `ps-min-modem` & `ps-max-modem` have been removed in favour of a runtime config (#2446)
34+
2835

2936
## 0.10.1 - 2024-10-10
3037

esp-wifi/Cargo.toml

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ smoltcp = { version = "0.11.0", default-features = false, features = [
2525
critical-section = "1.1.3"
2626
enumset = { version = "1.1.5", default-features = false, optional = true }
2727
embedded-io = { version = "0.6.1", default-features = false }
28-
embedded-io-async = { version = "0.6.1", optional = true }
28+
embedded-io-async = { version = "0.6.1" }
2929
fugit = "0.3.7"
3030
heapless = { version = "0.8.0", default-features = false, features = [
3131
"portable-atomic",
@@ -101,48 +101,35 @@ esp32s3 = [
101101
"xtensa-lx-rt/float-save-restore",
102102
]
103103

104-
## Enable Async support
105-
async = [
106-
"dep:embassy-sync",
107-
"dep:embedded-io-async",
108-
"dep:bt-hci",
109-
]
110-
111-
## Enable `embassy-net` support
112-
embassy-net = ["dep:embassy-net-driver", "async"]
113-
114104
## Enable WiFi-BLE coexistence support
115105
coex = []
116106

117107
## Logs the WiFi logs from the driver at log level info (needs a nightly-compiler)
118108
sys-logs = ["esp-wifi-sys/sys-logs"]
119109

120-
## Dumps packet info at log level info
121-
dump-packets = []
122-
123-
## Provide implementations of smoltcp traits
124-
smoltcp = ["dep:smoltcp"]
110+
## Enable support for `defmt`
111+
defmt = ["dep:defmt", "smoltcp?/defmt", "esp-hal/defmt", "bt-hci?/defmt", "esp-wifi-sys/defmt"]
125112

126-
## Provide utilities for smoltcp initialization. Adds smoltcp dependency
127-
utils = ["smoltcp"]
113+
## Enable support for the `log` crate
114+
log = ["dep:log", "esp-hal/log", "esp-wifi-sys/log"]
128115

129116
## Enable WiFi support
130-
wifi = ["dep:enumset"]
117+
wifi = ["dep:enumset", "dep:embassy-net-driver", "dep:embassy-sync"]
131118

132-
## Enable BLE support
133-
ble = ["esp-hal/bluetooth"]
119+
## Enable esp-now support
120+
esp-now = ["wifi"]
134121

135-
## See USB-SERIAL-JTAG below
136-
phy-enable-usb = []
122+
## Enable sniffer mode support
123+
sniffer = ["wifi"]
137124

138-
## Enable minimum modem sleep. Only affects STA mode
139-
ps-min-modem = []
125+
## Enable BLE support
126+
ble = ["esp-hal/bluetooth", "dep:bt-hci", "dep:embassy-sync"]
140127

141-
## Enable maximum modem sleep. Only affects STA mode
142-
ps-max-modem = []
128+
## Provide implementations of smoltcp traits
129+
smoltcp = ["dep:smoltcp"]
143130

144-
## Enable esp-now support
145-
esp-now = ["wifi"]
131+
## Provide utilities for smoltcp initialization. Adds smoltcp dependency
132+
utils = ["smoltcp"]
146133

147134
## IPv6 support. Includes utils feature
148135
ipv6 = ["wifi", "utils", "smoltcp?/proto-ipv6"]
@@ -171,15 +158,6 @@ dhcpv4 = ["wifi", "utils", "smoltcp?/proto-dhcpv4", "smoltcp?/socket-dhcpv4"]
171158
## Convenience to enable "ipv4", "tcp", "udp", "icmp", "igmp", "dns", "dhcpv4"
172159
wifi-default = ["ipv4", "tcp", "udp", "icmp", "igmp", "dns", "dhcpv4"]
173160

174-
## Enable support for `defmt`
175-
defmt = ["dep:defmt", "smoltcp?/defmt", "esp-hal/defmt", "bt-hci?/defmt", "esp-wifi-sys/defmt"]
176-
177-
## Enable support for the `log` crate
178-
log = ["dep:log", "esp-hal/log", "esp-wifi-sys/log"]
179-
180-
## Enable sniffer mode support
181-
sniffer = ["wifi"]
182-
183161
# Implement serde Serialize / Deserialize
184162
serde = ["dep:serde", "enumset?/serde", "heapless/serde"]
185163

@@ -189,8 +167,6 @@ features = [
189167
"wifi",
190168
"ble",
191169
"coex",
192-
"async",
193-
"embassy-net",
194170
"esp-hal/default",
195171
]
196-
default-target = "riscv32imc-unknown-none-elf"
172+
default-target = "riscv32imc-unknown-none-elf"

esp-wifi/MIGRATING-0.10.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,12 @@ rustflags = [
3333
Previously `data` and `len` were public - use the previously already existing `data()` function.
3434

3535
Accessing `data` or `len` was never encouraged.
36+
37+
## Async features have been removed and async functionality is always available
38+
39+
The cost of this is that we need to rename the various `async` methods on `WifiController`.
40+
41+
```diff
42+
- controller.start().await.unwrap();
43+
+ controller.start_async().await.unwrap();
44+
```

esp-wifi/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ fn main() -> Result<(), Box<dyn Error>> {
127127
("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"),
128128
("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"),
129129
("scan_method", Value::UnsignedInteger(0), "0 = WIFI_FAST_SCAN, 1 = WIFI_ALL_CHANNEL_SCAN, defaults to 0"),
130+
("dump_packets", Value::Bool(false), "Dump packets via an info log statement"),
131+
("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."),
130132
],
131133
true
132134
);

esp-wifi/src/ble/btdm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ extern "C" fn notify_host_recv(data: *mut u8, len: u16) -> i32 {
7979

8080
super::dump_packet_info(data);
8181

82-
#[cfg(feature = "async")]
8382
crate::ble::controller::asynch::hci_read_data_available();
8483

8584
0

esp-wifi/src/ble/controller/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ impl Write for BleConnector<'_> {
8383
}
8484

8585
/// Async Interface
86-
#[cfg(feature = "async")]
8786
pub(crate) mod asynch {
8887
use core::task::Poll;
8988

esp-wifi/src/ble/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ impl defmt::Format for ReceivedPacket {
117117
}
118118
}
119119

120-
#[cfg(feature = "async")]
121120
pub fn have_hci_read_data() -> bool {
122121
critical_section::with(|cs| {
123122
let queue = BT_RECEIVE_QUEUE.borrow_ref_mut(cs);
@@ -160,7 +159,7 @@ pub fn read_hci(data: &mut [u8]) -> usize {
160159
}
161160

162161
fn dump_packet_info(_buffer: &[u8]) {
163-
#[cfg(feature = "dump-packets")]
162+
#[cfg(dump_packets)]
164163
critical_section::with(|_cs| {
165164
info!("@HCIFRAME {:?}", _buffer);
166165
});

esp-wifi/src/ble/npl.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,6 @@ unsafe extern "C" fn ble_hs_hci_rx_evt(cmd: *const u8, arg: *const c_void) -> i3
12981298

12991299
r_ble_hci_trans_buf_free(cmd);
13001300

1301-
#[cfg(feature = "async")]
13021301
crate::ble::controller::asynch::hci_read_data_available();
13031302

13041303
0
@@ -1327,7 +1326,6 @@ unsafe extern "C" fn ble_hs_rx_data(om: *const OsMbuf, arg: *const c_void) -> i3
13271326

13281327
r_os_mbuf_free_chain(om as *mut _);
13291328

1330-
#[cfg(feature = "async")]
13311329
crate::ble::controller::asynch::hci_read_data_available();
13321330

13331331
0

esp-wifi/src/ble/os_adapter_esp32.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,6 @@ const BTDM_ASYNC_WAKEUP_REQ_COEX: i32 = 1;
586586
/// true if request lock is needed, false otherwise
587587
///
588588
/// *************************************************************************
589-
590589
#[cfg(coex)]
591590
fn async_wakeup_request(event: i32) -> bool {
592591
let mut do_wakeup_request = false;
@@ -623,7 +622,6 @@ fn async_wakeup_request(event: i32) -> bool {
623622
/// true if request lock is needed, false otherwise
624623
///
625624
/// *************************************************************************
626-
627625
#[cfg(coex)]
628626
fn async_wakeup_request_end(event: i32) {
629627
let request_lock = match event {

0 commit comments

Comments
 (0)