diff --git a/esp-radio/CHANGELOG.md b/esp-radio/CHANGELOG.md index 637ac20f67..4d91f62a32 100644 --- a/esp-radio/CHANGELOG.md +++ b/esp-radio/CHANGELOG.md @@ -47,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `connect_async` now returns `Ok(ConnectedStationInfo)` on success, providing detailed information about the connection. (#4898) - `disconnect_async` now returns `Ok(DisconnectedStationInfo)`. (#4898) - `WifiError::Disconnected` is now a tuple-like enum variant `WifiError::Disconnected(DisconnectedStationInfo)` containing details about the disconnection. (#4898) +- `WifiController::scan_with_config_async` has been changed to `WifiController::scan_async` (#4946) - Various structs now use the `Ssid` type to represent SSIDs instead of `String` (#4953) ### Fixed diff --git a/esp-radio/src/wifi/mod.rs b/esp-radio/src/wifi/mod.rs index eae3d829ef..8c8be8d6fe 100644 --- a/esp-radio/src/wifi/mod.rs +++ b/esp-radio/src/wifi/mod.rs @@ -2658,7 +2658,7 @@ impl WifiController<'_> { /// // Create a scan configuration (e.g., scan up to 10 APs) /// let scan_config = ScanConfig::default().with_max(10); /// let result = controller - /// .scan_with_config_async(scan_config) + /// .scan_async(&scan_config) /// .await /// .unwrap(); /// for ap in result { @@ -2666,17 +2666,17 @@ impl WifiController<'_> { /// } /// # {after_snippet} /// ``` - pub async fn scan_with_config_async( + pub async fn scan_async( &mut self, - config: ScanConfig, + config: &ScanConfig, ) -> Result, WifiError> { let mut subscriber = EVENT_CHANNEL .subscriber() .expect("Unable to subscribe to events - consider increasing the internal event channel subscriber count"); - esp_wifi_result!(wifi_start_scan(false, config))?; + esp_wifi_result!(wifi_start_scan(false, *config))?; - // Prevents memory leak if `scan_with_config_async`'s future is dropped. + // Prevents memory leak if `scan_async`'s future is dropped. let guard = FreeApListOnDrop; loop { @@ -2843,7 +2843,7 @@ impl WifiController<'_> { /// /// Use [Self::disconnect_async] to disconnect. /// - /// Calling [Self::scan_with_config_async] will not be effective until + /// Calling [Self::scan_async] will not be effective until /// connection between device and the AP is established. /// /// If device is scanning and connecting at the same time, it will abort scanning and return a diff --git a/esp-radio/src/wifi/scan.rs b/esp-radio/src/wifi/scan.rs index e5e43965e6..a267e28e8a 100644 --- a/esp-radio/src/wifi/scan.rs +++ b/esp-radio/src/wifi/scan.rs @@ -63,7 +63,7 @@ pub enum ScanTypeConfig { /// 3. Repeat from 1. /// /// # Note - /// It is recommended to avoid duration longer thean 1500ms, as it may cause + /// It is recommended to avoid duration longer than 1500ms, as it may cause /// a station to disconnect from the Access Point. Passive(Duration), } diff --git a/examples/wifi/embassy_coex/src/main.rs b/examples/wifi/embassy_coex/src/main.rs index e9faf5ecba..5a9ea28e1c 100644 --- a/examples/wifi/embassy_coex/src/main.rs +++ b/examples/wifi/embassy_coex/src/main.rs @@ -309,10 +309,7 @@ async fn connection(mut controller: WifiController<'static>) { println!("Scan"); let scan_config = ScanConfig::default().with_max(10); - let result = controller - .scan_with_config_async(scan_config) - .await - .unwrap(); + let result = controller.scan_async(&scan_config).await.unwrap(); for ap in result { println!("{:?}", ap); } diff --git a/examples/wifi/embassy_dhcp/src/main.rs b/examples/wifi/embassy_dhcp/src/main.rs index 67c72dfb92..4d93a5b65f 100644 --- a/examples/wifi/embassy_dhcp/src/main.rs +++ b/examples/wifi/embassy_dhcp/src/main.rs @@ -160,10 +160,7 @@ async fn connection(mut controller: WifiController<'static>) { println!("Scan"); let scan_config = ScanConfig::default().with_max(10); - let result = controller - .scan_with_config_async(scan_config) - .await - .unwrap(); + let result = controller.scan_async(&scan_config).await.unwrap(); for ap in result { println!("{:?}", ap); } diff --git a/examples/wifi/embassy_sntp/src/main.rs b/examples/wifi/embassy_sntp/src/main.rs index 99c16b7f4e..8ee84825c5 100644 --- a/examples/wifi/embassy_sntp/src/main.rs +++ b/examples/wifi/embassy_sntp/src/main.rs @@ -220,10 +220,7 @@ async fn connection(mut controller: WifiController<'static>) { println!("Scan"); let scan_config = ScanConfig::default().with_max(10); - let result = controller - .scan_with_config_async(scan_config) - .await - .unwrap(); + let result = controller.scan_async(&scan_config).await.unwrap(); for ap in result { println!("{:?}", ap); } diff --git a/hil-test/src/bin/esp_radio/wifi_controller.rs b/hil-test/src/bin/esp_radio/wifi_controller.rs index 9c980be5aa..f2555112b9 100644 --- a/hil-test/src/bin/esp_radio/wifi_controller.rs +++ b/hil-test/src/bin/esp_radio/wifi_controller.rs @@ -51,25 +51,16 @@ mod tests { controller.start_async().await.unwrap(); let scan_config = ScanConfig::default().with_max(1); - let _ = controller - .scan_with_config_async(scan_config) - .await - .unwrap(); + let _ = controller.scan_async(&scan_config).await.unwrap(); let mut min_free = usize::MAX; for _ in 0..30 { - let _ = controller - .scan_with_config_async(scan_config) - .await - .unwrap(); + let _ = controller.scan_async(&scan_config).await.unwrap(); min_free = usize::min(min_free, esp_alloc::HEAP.free()); } for _ in 0..10 { - let _ = controller - .scan_with_config_async(scan_config) - .await - .unwrap(); + let _ = controller.scan_async(&scan_config).await.unwrap(); assert!( esp_alloc::HEAP.free() >= min_free, "current free: {}, min free: {}", diff --git a/qa-test/src/bin/embassy_scan_after_sleep.rs b/qa-test/src/bin/embassy_scan_after_sleep.rs index 73a14a9aa9..417332e0a5 100644 --- a/qa-test/src/bin/embassy_scan_after_sleep.rs +++ b/qa-test/src/bin/embassy_scan_after_sleep.rs @@ -61,7 +61,7 @@ async fn main(_spawner: Spawner) { controller.start_async().await.unwrap(); let res = controller - .scan_with_config_async(esp_radio::wifi::scan::ScanConfig::default()) + .scan_async(&esp_radio::wifi::scan::ScanConfig::default()) .await .unwrap(); diff --git a/qa-test/src/bin/embassy_wifi_csi.rs b/qa-test/src/bin/embassy_wifi_csi.rs index bbb57def3f..fc58d23afa 100644 --- a/qa-test/src/bin/embassy_wifi_csi.rs +++ b/qa-test/src/bin/embassy_wifi_csi.rs @@ -159,10 +159,7 @@ async fn connection(mut controller: WifiController<'static>) { println!("Scan"); let scan_config = ScanConfig::default().with_max(10); - let result = controller - .scan_with_config_async(scan_config) - .await - .unwrap(); + let result = controller.scan_async(&scan_config).await.unwrap(); for ap in result { println!("{:?}", ap); } diff --git a/qa-test/src/bin/embassy_wifi_stress.rs b/qa-test/src/bin/embassy_wifi_stress.rs index 67ffdb331c..c53f1cd2fe 100644 --- a/qa-test/src/bin/embassy_wifi_stress.rs +++ b/qa-test/src/bin/embassy_wifi_stress.rs @@ -82,7 +82,7 @@ async fn main(_spawner: Spawner) { }); println!("Scanning for WiFi networks"); let aps = controller - .scan_with_config_async(scan_config) + .scan_async(&scan_config) .with_timeout(Duration::from_secs(5)) .await .unwrap(); diff --git a/qa-test/src/bin/wifi_survives_ble_drop.rs b/qa-test/src/bin/wifi_survives_ble_drop.rs index 11982486c5..2f4b39b37c 100644 --- a/qa-test/src/bin/wifi_survives_ble_drop.rs +++ b/qa-test/src/bin/wifi_survives_ble_drop.rs @@ -178,10 +178,7 @@ async fn connection(mut controller: WifiController<'static>) { println!("Scan"); let scan_config = ScanConfig::default().with_max(10); - let result = controller - .scan_with_config_async(scan_config) - .await - .unwrap(); + let result = controller.scan_async(&scan_config).await.unwrap(); for ap in result { println!("{:?}", ap); }