cyw43: Unify dwell time.
This commit is contained in:
parent
6ca43030db
commit
24968629ec
2 changed files with 23 additions and 27 deletions
|
@ -10,7 +10,7 @@ repository = "https://github.com/embassy-rs/embassy"
|
||||||
documentation = "https://docs.embassy.dev/cyw43"
|
documentation = "https://docs.embassy.dev/cyw43"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
defmt = ["dep:defmt", "heapless/defmt-03"]
|
defmt = ["dep:defmt", "heapless/defmt-03", "embassy-time/defmt"]
|
||||||
log = ["dep:log"]
|
log = ["dep:log"]
|
||||||
|
|
||||||
# Fetch console logs from the WiFi firmware and forward them to `log` or `defmt`.
|
# Fetch console logs from the WiFi firmware and forward them to `log` or `defmt`.
|
||||||
|
|
|
@ -38,14 +38,8 @@ pub struct Control<'a> {
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
pub enum ScanType {
|
pub enum ScanType {
|
||||||
Active {
|
Active,
|
||||||
/// Period of time to wait on each channel when active scanning.
|
Passive,
|
||||||
dwell_time: Option<Duration>,
|
|
||||||
},
|
|
||||||
Passive {
|
|
||||||
/// Period of time to wait on each channel when passive scanning.
|
|
||||||
dwell_time: Option<Duration>,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -59,7 +53,10 @@ pub struct ScanOptions {
|
||||||
pub nprobes: Option<u16>,
|
pub nprobes: Option<u16>,
|
||||||
/// Time to spend waiting on the home channel.
|
/// Time to spend waiting on the home channel.
|
||||||
pub home_time: Option<Duration>,
|
pub home_time: Option<Duration>,
|
||||||
|
/// Scan type: active or passive.
|
||||||
pub scan_type: ScanType,
|
pub scan_type: ScanType,
|
||||||
|
/// Period of time to wait on each channel when passive scanning.
|
||||||
|
pub dwell_time: Option<Duration>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ScanOptions {
|
impl Default for ScanOptions {
|
||||||
|
@ -69,7 +66,8 @@ impl Default for ScanOptions {
|
||||||
bssid: None,
|
bssid: None,
|
||||||
nprobes: None,
|
nprobes: None,
|
||||||
home_time: None,
|
home_time: None,
|
||||||
scan_type: ScanType::Passive { dwell_time: None },
|
scan_type: ScanType::Passive,
|
||||||
|
dwell_time: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -514,28 +512,26 @@ impl<'a> Control<'a> {
|
||||||
const SCANTYPE_ACTIVE: u8 = 0;
|
const SCANTYPE_ACTIVE: u8 = 0;
|
||||||
const SCANTYPE_PASSIVE: u8 = 1;
|
const SCANTYPE_PASSIVE: u8 = 1;
|
||||||
|
|
||||||
|
let dwell_time = match scan_opts.dwell_time {
|
||||||
|
None => !0,
|
||||||
|
Some(t) => {
|
||||||
|
let mut t = t.as_millis() as u32;
|
||||||
|
if t == !0 {
|
||||||
|
t = !0 - 1;
|
||||||
|
}
|
||||||
|
t
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let mut active_time = !0;
|
let mut active_time = !0;
|
||||||
let mut passive_time = !0;
|
let mut passive_time = !0;
|
||||||
|
|
||||||
let scan_type = match scan_opts.scan_type {
|
let scan_type = match scan_opts.scan_type {
|
||||||
ScanType::Active { dwell_time: None } => SCANTYPE_ACTIVE,
|
ScanType::Active => {
|
||||||
ScanType::Active {
|
active_time = dwell_time;
|
||||||
dwell_time: Some(dwell_time),
|
|
||||||
} => {
|
|
||||||
active_time = dwell_time.as_millis() as u32;
|
|
||||||
if active_time == !0 {
|
|
||||||
active_time = !0 - 1;
|
|
||||||
}
|
|
||||||
SCANTYPE_ACTIVE
|
SCANTYPE_ACTIVE
|
||||||
}
|
}
|
||||||
ScanType::Passive { dwell_time: None } => SCANTYPE_PASSIVE,
|
ScanType::Passive => {
|
||||||
ScanType::Passive {
|
passive_time = dwell_time;
|
||||||
dwell_time: Some(dwell_time),
|
|
||||||
} => {
|
|
||||||
passive_time = dwell_time.as_millis() as u32;
|
|
||||||
if passive_time == !0 {
|
|
||||||
passive_time = !0 - 1;
|
|
||||||
}
|
|
||||||
SCANTYPE_PASSIVE
|
SCANTYPE_PASSIVE
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue