Struct stm32wlxx_hal::subghz::LoRaModParams
source · pub struct LoRaModParams { /* private fields */ }
Expand description
LoRa modulation parameters.
Implementations§
source§impl LoRaModParams
impl LoRaModParams
sourcepub const fn new() -> LoRaModParams
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());
sourcepub const fn set_sf(self, sf: SpreadingFactor) -> Self
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);
sourcepub const fn set_bw(self, bw: LoRaBandwidth) -> Self
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);
sourcepub const fn set_cr(self, cr: CodingRate) -> Self
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);
sourcepub const fn set_ldro_en(self, en: bool) -> Self
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);
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::{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
impl Clone for LoRaModParams
source§fn clone(&self) -> LoRaModParams
fn clone(&self) -> LoRaModParams
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for LoRaModParams
impl Debug for LoRaModParams
source§impl Default for LoRaModParams
impl Default for LoRaModParams
source§impl PartialEq for LoRaModParams
impl PartialEq for LoRaModParams
source§fn eq(&self, other: &LoRaModParams) -> bool
fn eq(&self, other: &LoRaModParams) -> bool
self
and other
values to be equal, and is used
by ==
.