Skip to content

Commit

Permalink
esp-wifi: Remove unneeded features (#2446)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
MabezDev authored Nov 8, 2024
1 parent 6d6f6a7 commit 50d8187
Show file tree
Hide file tree
Showing 40 changed files with 187 additions and 232 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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: |
Expand Down
7 changes: 7 additions & 0 deletions esp-wifi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
58 changes: 17 additions & 41 deletions esp-wifi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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"]

Expand All @@ -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"
9 changes: 9 additions & 0 deletions esp-wifi/MIGRATING-0.10.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
```
2 changes: 2 additions & 0 deletions esp-wifi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ fn main() -> Result<(), Box<dyn Error>> {
("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
);
Expand Down
1 change: 0 additions & 1 deletion esp-wifi/src/ble/btdm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion esp-wifi/src/ble/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ impl Write for BleConnector<'_> {
}

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

Expand Down
3 changes: 1 addition & 2 deletions esp-wifi/src/ble/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});
Expand Down
2 changes: 0 additions & 2 deletions esp-wifi/src/ble/npl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions esp-wifi/src/ble/os_adapter_esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion esp-wifi/src/common_adapter/common_adapter_esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/src/common_adapter/common_adapter_esp32c3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/src/common_adapter/common_adapter_esp32c6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/src/common_adapter/common_adapter_esp32h2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/src/common_adapter/common_adapter_esp32s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
47 changes: 47 additions & 0 deletions esp-wifi/src/config.rs
Original file line number Diff line number Diff line change
@@ -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,
}
}
}
Loading

0 comments on commit 50d8187

Please sign in to comment.