aboutsummaryrefslogtreecommitdiff
path: root/cyw43/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-01-20 00:10:35 +0100
committerDario Nieuwenhuis <[email protected]>2024-01-20 00:10:41 +0100
commit24968629ec810b844b819e8f84baab2a9349ed2f (patch)
tree169574c8fde2500d594f4e1478d270975bf79dd2 /cyw43/src
parent6ca43030db125bd440c8e7383a4fc9c93bea7a4e (diff)
cyw43: Unify dwell time.
Diffstat (limited to 'cyw43/src')
-rw-r--r--cyw43/src/control.rs48
1 files changed, 22 insertions, 26 deletions
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))]
40pub enum ScanType { 40pub 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
65impl Default for ScanOptions { 62impl 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 };