pub struct CadParams { /* private fields */ }
Expand description

Channel activity detection (CAD) parameters.

Argument of set_cad_params.

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_peakset_det_min
50x180x10
60x190x10
70x200x10
80x210x10
90x220x10
100x230x10
110x240x10
120x250x10

Implementations§

source§

impl CadParams

source

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());
source

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);
source

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);
source

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);
source

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);
source

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);
source

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]
);

Trait Implementations§

source§

impl Clone for CadParams

source§

fn clone(&self) -> CadParams

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CadParams

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for CadParams

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq for CadParams

source§

fn eq(&self, other: &CadParams) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for CadParams

source§

impl Eq for CadParams

source§

impl StructuralEq for CadParams

source§

impl StructuralPartialEq for CadParams

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.