Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions esp-radio/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions esp-radio/src/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2658,25 +2658,25 @@ 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 {
/// println!("{:?}", ap);
/// }
/// # {after_snippet}
/// ```
pub async fn scan_with_config_async(
pub async fn scan_async(
&mut self,
config: ScanConfig,
config: &ScanConfig,
) -> Result<Vec<AccessPointInfo>, 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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion esp-radio/src/wifi/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
5 changes: 1 addition & 4 deletions examples/wifi/embassy_coex/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 1 addition & 4 deletions examples/wifi/embassy_dhcp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 1 addition & 4 deletions examples/wifi/embassy_sntp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
15 changes: 3 additions & 12 deletions hil-test/src/bin/esp_radio/wifi_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}",
Expand Down
2 changes: 1 addition & 1 deletion qa-test/src/bin/embassy_scan_after_sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
5 changes: 1 addition & 4 deletions qa-test/src/bin/embassy_wifi_csi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion qa-test/src/bin/embassy_wifi_stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 1 addition & 4 deletions qa-test/src/bin/wifi_survives_ble_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down