diff options
| -rw-r--r-- | cyw43/Cargo.toml | 2 | ||||
| -rw-r--r-- | cyw43/src/control.rs | 48 |
2 files changed, 23 insertions, 27 deletions
diff --git a/cyw43/Cargo.toml b/cyw43/Cargo.toml index 64c38ea7a..f279739e4 100644 --- a/cyw43/Cargo.toml +++ b/cyw43/Cargo.toml | |||
| @@ -10,7 +10,7 @@ repository = "https://github.com/embassy-rs/embassy" | |||
| 10 | documentation = "https://docs.embassy.dev/cyw43" | 10 | documentation = "https://docs.embassy.dev/cyw43" |
| 11 | 11 | ||
| 12 | [features] | 12 | [features] |
| 13 | defmt = ["dep:defmt", "heapless/defmt-03"] | 13 | defmt = ["dep:defmt", "heapless/defmt-03", "embassy-time/defmt"] |
| 14 | log = ["dep:log"] | 14 | log = ["dep:log"] |
| 15 | 15 | ||
| 16 | # Fetch console logs from the WiFi firmware and forward them to `log` or `defmt`. | 16 | # Fetch console logs from the WiFi firmware and forward them to `log` or `defmt`. |
diff --git a/cyw43/src/control.rs b/cyw43/src/control.rs index 26d50d311..135b8c245 100644 --- a/cyw43/src/control.rs +++ b/cyw43/src/control.rs | |||
| @@ -38,14 +38,8 @@ pub struct Control<'a> { | |||
| 38 | #[derive(Copy, Clone)] | 38 | #[derive(Copy, Clone)] |
| 39 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 39 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 40 | pub enum ScanType { | 40 | pub enum ScanType { |
| 41 | Active { | 41 | Active, |
| 42 | /// Period of time to wait on each channel when active scanning. | 42 | Passive, |
| 43 | dwell_time: Option<Duration>, | ||
| 44 | }, | ||
| 45 | Passive { | ||
| 46 | /// Period of time to wait on each channel when passive scanning. | ||
| 47 | dwell_time: Option<Duration>, | ||
| 48 | }, | ||
| 49 | } | 43 | } |
| 50 | 44 | ||
| 51 | #[derive(Clone)] | 45 | #[derive(Clone)] |
| @@ -59,7 +53,10 @@ pub struct ScanOptions { | |||
| 59 | pub nprobes: Option<u16>, | 53 | pub nprobes: Option<u16>, |
| 60 | /// Time to spend waiting on the home channel. | 54 | /// Time to spend waiting on the home channel. |
| 61 | pub home_time: Option<Duration>, | 55 | pub home_time: Option<Duration>, |
| 56 | /// Scan type: active or passive. | ||
| 62 | pub scan_type: ScanType, | 57 | pub scan_type: ScanType, |
| 58 | /// Period of time to wait on each channel when passive scanning. | ||
| 59 | pub dwell_time: Option<Duration>, | ||
| 63 | } | 60 | } |
| 64 | 61 | ||
| 65 | impl Default for ScanOptions { | 62 | impl Default for ScanOptions { |
| @@ -69,7 +66,8 @@ impl Default for ScanOptions { | |||
| 69 | bssid: None, | 66 | bssid: None, |
| 70 | nprobes: None, | 67 | nprobes: None, |
| 71 | home_time: None, | 68 | home_time: None, |
| 72 | scan_type: ScanType::Passive { dwell_time: None }, | 69 | scan_type: ScanType::Passive, |
| 70 | dwell_time: None, | ||
| 73 | } | 71 | } |
| 74 | } | 72 | } |
| 75 | } | 73 | } |
| @@ -514,28 +512,26 @@ impl<'a> Control<'a> { | |||
| 514 | const SCANTYPE_ACTIVE: u8 = 0; | 512 | const SCANTYPE_ACTIVE: u8 = 0; |
| 515 | const SCANTYPE_PASSIVE: u8 = 1; | 513 | const SCANTYPE_PASSIVE: u8 = 1; |
| 516 | 514 | ||
| 515 | let dwell_time = match scan_opts.dwell_time { | ||
| 516 | None => !0, | ||
| 517 | Some(t) => { | ||
| 518 | let mut t = t.as_millis() as u32; | ||
| 519 | if t == !0 { | ||
| 520 | t = !0 - 1; | ||
| 521 | } | ||
| 522 | t | ||
| 523 | } | ||
| 524 | }; | ||
| 525 | |||
| 517 | let mut active_time = !0; | 526 | let mut active_time = !0; |
| 518 | let mut passive_time = !0; | 527 | let mut passive_time = !0; |
| 519 | |||
| 520 | let scan_type = match scan_opts.scan_type { | 528 | let scan_type = match scan_opts.scan_type { |
| 521 | ScanType::Active { dwell_time: None } => SCANTYPE_ACTIVE, | 529 | ScanType::Active => { |
| 522 | ScanType::Active { | 530 | active_time = dwell_time; |
| 523 | dwell_time: Some(dwell_time), | ||
| 524 | } => { | ||
| 525 | active_time = dwell_time.as_millis() as u32; | ||
| 526 | if active_time == !0 { | ||
| 527 | active_time = !0 - 1; | ||
| 528 | } | ||
| 529 | SCANTYPE_ACTIVE | 531 | SCANTYPE_ACTIVE |
| 530 | } | 532 | } |
| 531 | ScanType::Passive { dwell_time: None } => SCANTYPE_PASSIVE, | 533 | ScanType::Passive => { |
| 532 | ScanType::Passive { | 534 | passive_time = dwell_time; |
| 533 | dwell_time: Some(dwell_time), | ||
| 534 | } => { | ||
| 535 | passive_time = dwell_time.as_millis() as u32; | ||
| 536 | if passive_time == !0 { | ||
| 537 | passive_time = !0 - 1; | ||
| 538 | } | ||
| 539 | SCANTYPE_PASSIVE | 535 | SCANTYPE_PASSIVE |
| 540 | } | 536 | } |
| 541 | }; | 537 | }; |
