Struct stm32wlxx_hal::subghz::CadParams
source · pub struct CadParams { /* private fields */ }
Expand description
Channel activity detection (CAD) parameters.
Argument of set_cad_params
.
Recommended CAD settings
This is taken directly from the datasheet.
“The correct values selected in the table below must be carefully tested to ensure a good detection at sensitivity level and to limit the number of false detections”
SF (Spreading Factor) | set_det_peak | set_det_min |
---|---|---|
5 | 0x18 | 0x10 |
6 | 0x19 | 0x10 |
7 | 0x20 | 0x10 |
8 | 0x21 | 0x10 |
9 | 0x22 | 0x10 |
10 | 0x23 | 0x10 |
11 | 0x24 | 0x10 |
12 | 0x25 | 0x10 |
Implementations§
source§impl CadParams
impl CadParams
sourcepub const fn new() -> CadParams
pub const fn new() -> CadParams
Create a new CadParams
.
This is the same as default
, but in a const
function.
Example
use stm32wlxx_hal::subghz::CadParams;
const CAD_PARAMS: CadParams = CadParams::new();
assert_eq!(CAD_PARAMS, CadParams::default());
sourcepub const fn set_num_symbol(self, nb: NbCadSymbol) -> CadParams
pub const fn set_num_symbol(self, nb: NbCadSymbol) -> CadParams
Number of symbols used for a CAD scan.
Example
Set the number of symbols to 4.
use stm32wlxx_hal::subghz::{CadParams, NbCadSymbol};
const CAD_PARAMS: CadParams = CadParams::new().set_num_symbol(NbCadSymbol::S4);
sourcepub const fn set_det_peak(self, peak: u8) -> CadParams
pub const fn set_det_peak(self, peak: u8) -> CadParams
Used with set_det_min
to correlate the LoRa symbol.
See the table in CadParams
docs for recommended values.
Example
Setting the recommended value for a spreading factor of 7.
use stm32wlxx_hal::subghz::CadParams;
const CAD_PARAMS: CadParams = CadParams::new().set_det_peak(0x20).set_det_min(0x10);
sourcepub const fn set_det_min(self, min: u8) -> CadParams
pub const fn set_det_min(self, min: u8) -> CadParams
Used with set_det_peak
to correlate the LoRa symbol.
See the table in CadParams
docs for recommended values.
Example
Setting the recommended value for a spreading factor of 6.
use stm32wlxx_hal::subghz::CadParams;
const CAD_PARAMS: CadParams = CadParams::new().set_det_peak(0x18).set_det_min(0x10);
sourcepub const fn set_exit_mode(self, mode: ExitMode) -> CadParams
pub const fn set_exit_mode(self, mode: ExitMode) -> CadParams
Mode to enter after a channel activity detection scan is finished.
Example
use stm32wlxx_hal::subghz::{CadParams, ExitMode};
const CAD_PARAMS: CadParams = CadParams::new().set_exit_mode(ExitMode::Standby);
sourcepub const fn set_timeout(self, to: Timeout) -> CadParams
pub const fn set_timeout(self, to: Timeout) -> CadParams
Set the timeout.
This is only used with ExitMode::StandbyLoRa
.
Example
use stm32wlxx_hal::subghz::{CadParams, ExitMode, Timeout};
const TIMEOUT: Timeout = Timeout::from_raw(0x123456);
const CAD_PARAMS: CadParams = CadParams::new()
.set_exit_mode(ExitMode::StandbyLoRa)
.set_timeout(TIMEOUT);
sourcepub const fn as_slice(&self) -> &[u8]
pub const fn as_slice(&self) -> &[u8]
Extracts a slice containing the packet.
Example
use stm32wlxx_hal::subghz::{CadParams, ExitMode, NbCadSymbol, Timeout};
const TIMEOUT: Timeout = Timeout::from_raw(0x123456);
const CAD_PARAMS: CadParams = CadParams::new()
.set_num_symbol(NbCadSymbol::S4)
.set_det_peak(0x18)
.set_det_min(0x10)
.set_exit_mode(ExitMode::StandbyLoRa)
.set_timeout(TIMEOUT);
assert_eq!(
CAD_PARAMS.as_slice(),
&[0x88, 0x02, 0x18, 0x10, 0x01, 0x12, 0x34, 0x56]
);