Fix the example

This commit is contained in:
umgefahren 2023-12-13 18:12:42 +01:00
parent 2dc421a589
commit 5fa1b8bc26
2 changed files with 3 additions and 6 deletions

View File

@ -516,7 +516,7 @@ pub struct BssInfo {
pub bssid: [u8; 6], pub bssid: [u8; 6],
pub beacon_period: u16, pub beacon_period: u16,
pub capability: u16, pub capability: u16,
pub ssid: heapless::String<32>, pub ssid: heapless::Vec<u8, 32>,
pub rssi: i16, pub rssi: i16,
pub security: BssSecurity, pub security: BssSecurity,
} }
@ -573,10 +573,7 @@ impl BssInfo {
0 => BssSecurity::Open, 0 => BssSecurity::Open,
_ => BssSecurity::None, _ => BssSecurity::None,
}; };
let ssid = heapless::String::from_utf8( let ssid = heapless::Vec::from_slice(&bss_info.ssid[..bss_info.ssid_len as usize]).unwrap();
heapless::Vec::from_slice(&bss_info.ssid[..bss_info.ssid_len as usize]).unwrap(),
)
.ok()?;
let BssInfoInternal { let BssInfoInternal {
version, version,
length, length,

View File

@ -65,7 +65,7 @@ async fn main(spawner: Spawner) {
.set_power_management(cyw43::PowerManagementMode::PowerSave) .set_power_management(cyw43::PowerManagementMode::PowerSave)
.await; .await;
let mut scanner = control.scan().await; let mut scanner = control.scan(Default::default()).await;
while let Some(bss) = scanner.next().await { while let Some(bss) = scanner.next().await {
if let Ok(ssid_str) = str::from_utf8(&bss.ssid) { if let Ok(ssid_str) = str::from_utf8(&bss.ssid) {
info!("scanned {} == {:x}", ssid_str, bss.bssid); info!("scanned {} == {:x}", ssid_str, bss.bssid);