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

LoRa modulation parameters.

Implementations§

source§

impl LoRaModParams

source

pub const fn new() -> LoRaModParams

Create a new LoRaModParams struct.

This is the same as default, but in a const function.

Example
use stm32wlxx_hal::subghz::LoRaModParams;

const MOD_PARAMS: LoRaModParams = LoRaModParams::new();
assert_eq!(MOD_PARAMS, LoRaModParams::default());
source

pub const fn set_sf(self, sf: SpreadingFactor) -> Self

Set the spreading factor.

Example
use stm32wlxx_hal::subghz::{LoRaModParams, SpreadingFactor};

const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_sf(SpreadingFactor::Sf7);
source

pub const fn set_bw(self, bw: LoRaBandwidth) -> Self

Set the bandwidth.

Example
use stm32wlxx_hal::subghz::{LoRaBandwidth, LoRaModParams};

const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_bw(LoRaBandwidth::Bw125);
source

pub const fn set_cr(self, cr: CodingRate) -> Self

Set the forward error correction coding rate.

See CodingRate for more information.

Example
use stm32wlxx_hal::subghz::{CodingRate, LoRaModParams};

const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_cr(CodingRate::Cr45);
source

pub const fn set_ldro_en(self, en: bool) -> Self

Set low data rate optimization enable.

For low data rates (typically high SF or low BW) and very long payloads (may last several seconds), the low data rate optimization (LDRO) can be enabled. This reduces the number of bits per symbol to the given SF minus 2, to allow the receiver to have a better tracking of the LoRa receive signal. Depending on the payload length, the low data rate optimization is usually recommended when the LoRa symbol time is equal or above 16.38 ms. When using LoRa modulation, the total frequency drift over the packet time must be kept lower than Freq_drift_max:

Freq_drift_max = BW / (3 × 2SF)

When possible, enabling the low data rate optimization, relaxes the total frequency drift over the packet time by 16:

Freq_drift_optimize_max = 16 × Freq_drift_max

Example
use stm32wlxx_hal::subghz::LoRaModParams;

const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_ldro_en(true);
source

pub const fn as_slice(&self) -> &[u8]

Extracts a slice containing the packet.

Example
use stm32wlxx_hal::subghz::{CodingRate, LoRaBandwidth, LoRaModParams, SpreadingFactor};

const MOD_PARAMS: LoRaModParams = LoRaModParams::new()
    .set_sf(SpreadingFactor::Sf7)
    .set_bw(LoRaBandwidth::Bw125)
    .set_cr(CodingRate::Cr45)
    .set_ldro_en(false);

assert_eq!(MOD_PARAMS.as_slice(), &[0x8B, 0x07, 0x04, 0x01, 0x00]);

Trait Implementations§

source§

impl Clone for LoRaModParams

source§

fn clone(&self) -> LoRaModParams

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 LoRaModParams

source§

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

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

impl Default for LoRaModParams

source§

fn default() -> Self

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

impl PartialEq for LoRaModParams

source§

fn eq(&self, other: &LoRaModParams) -> 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 LoRaModParams

source§

impl Eq for LoRaModParams

source§

impl StructuralEq for LoRaModParams

source§

impl StructuralPartialEq for LoRaModParams

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.