Skip to main content

RadioConfig

Struct RadioConfig 

Source
pub struct RadioConfig {
    pub frequency_hz: u32,
    pub band_hz: (u32, u32),
    pub link: LinkSettings,
    pub output_dbm: i8,
    pub sync_word: SyncWord,
    pub invert_iq_transmit: bool,
    pub invert_iq_receive: bool,
}
Expand description

What a radio of either family sends and listens with.

The output power is what the amplifier is asked for, in whole dBm. Each driver clamps it to the range of the amplifier its board names, so a regional ceiling is kept by choosing the power first, with LinkBudget::max_transmit_power_dbm rounded down.

§Examples

use pamoja_lora::LinkSettings;
use pamoja_radios::radio::{RadioConfig, SyncWord};

// A LoRaWAN device on 868.1 MHz at SF9 with 14 dBm, calibrated for the whole band.
let config = RadioConfig::new(868_100_000, LinkSettings::new(9, 125_000), 14)
    .with_band(863_000_000, 870_000_000)
    .lorawan_device();
assert_eq!(config.sync_word, SyncWord::Public);
assert!(config.invert_iq_receive && !config.invert_iq_transmit);

Fields§

§frequency_hz: u32

The carrier frequency in hertz.

§band_hz: (u32, u32)

The band an SX126x calibrates its receiver image for, as its lower and upper edges in hertz. The SX127x calibrates at the carrier instead, once per RF port.

§link: LinkSettings

The spreading factor, bandwidth, coding rate, preamble, header, and CRC.

§output_dbm: i8

The output power asked of the amplifier, in dBm.

§sync_word: SyncWord

The sync word.

§invert_iq_transmit: bool

Whether frames go out with inverted IQ, as a LoRaWAN gateway sends downlinks.

§invert_iq_receive: bool

Whether the receiver expects inverted IQ, as a LoRaWAN device hears downlinks.

Implementations§

Source§

impl RadioConfig

Source

pub const fn new( frequency_hz: u32, link: LinkSettings, output_dbm: i8, ) -> RadioConfig

Builds a configuration with a private sync word and standard IQ both ways.

§Arguments
  • frequency_hz - the carrier frequency in hertz.
  • link - the LoRa link settings.
  • output_dbm - the output power asked of the amplifier, in dBm.
§Returns

The configuration, with the SX126x calibration band covering just the carrier.

Source

pub const fn with_band(self, low_hz: u32, high_hz: u32) -> RadioConfig

Returns the configuration with an SX126x calibrating for a whole band, so moving between channels inside it needs no new calibration.

§Arguments
  • low_hz - the lower edge of the band in hertz.
  • high_hz - the upper edge of the band in hertz.
§Returns

The configuration.

Source

pub const fn with_sync_word(self, sync_word: SyncWord) -> RadioConfig

Returns the configuration with another sync word.

§Arguments
  • sync_word - the sync word.
§Returns

The configuration.

Source

pub const fn with_inverted_iq( self, transmit: bool, receive: bool, ) -> RadioConfig

Returns the configuration with the IQ polarity set for each direction.

§Arguments
  • transmit - true to send with inverted IQ.
  • receive - true to listen for inverted IQ.
§Returns

The configuration.

Source

pub const fn lorawan_device(self) -> RadioConfig

Returns the configuration a LoRaWAN end device uses: the public sync word, uplinks with standard IQ, and downlinks heard with inverted IQ.

§Returns

The configuration.

Trait Implementations§

Source§

impl Clone for RadioConfig

Source§

fn clone(&self) -> RadioConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for RadioConfig

Source§

impl Debug for RadioConfig

Source§

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

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

impl Eq for RadioConfig

Source§

impl PartialEq for RadioConfig

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for RadioConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.