Skip to main content

ChannelPlan

Struct ChannelPlan 

Source
pub struct ChannelPlan<'a> {
Show 30 fields pub name: &'a str, pub uplink_data_rates: &'a [Option<DataRate>], pub downlink_data_rates: &'a [Option<DataRate>], pub max_payload_repeater: &'a [Option<MaxPayload>], pub max_payload_direct: &'a [Option<MaxPayload>], pub downlink_max_payload_repeater: &'a [Option<MaxPayload>], pub downlink_max_payload_direct: &'a [Option<MaxPayload>], pub max_payload_dwell_limited: Option<&'a [Option<MaxPayload>]>, pub join_channels: &'a [ChannelBlock], pub default_channels: &'a [ChannelBlock], pub sub_bands: &'a [SubBand], pub default_max_eirp_dbm: i8, pub tx_power_step_db: u8, pub max_tx_power_index: u8, pub rx1_data_rate_offsets: &'a [&'a [u8]], pub rx1_data_rate_offsets_dwell_limited: Option<&'a [&'a [u8]]>, pub max_rx1_data_rate_offset: u8, pub rx2_frequency_hz: u32, pub rx2_data_rate: u8, pub data_rate_backoff: &'a [Option<u8>], pub beacon: Beacon, pub relay_channels: &'a [RelayChannel], pub has_dwell_time_limit: bool, pub kind: PlanKind, pub tx_param_setup: bool, pub mask_controls: [MaskControl; 8], pub downlink_channels: &'a [ChannelBlock], pub join_sequence: JoinSequence, pub power_reference: PowerReference, pub join_plans: &'a [JoinPlan<'a>],
}
Expand description

A complete regional channel plan.

The named Region values are constants of this type. A deployment on licensed spectrum, or one doing something the published regions do not describe, builds its own from tables it owns, and every method here still applies.

Fields§

§name: &'a str

The specification’s name for the band, such as "EU863-870".

§uplink_data_rates: &'a [Option<DataRate>]

The uplink data rates, indexed by data-rate number; None where the number is reserved.

§downlink_data_rates: &'a [Option<DataRate>]

The downlink data rates, indexed by data-rate number.

Most regions use one table in both directions, and carry the same slice here. The 900 MHz plans do not, which is why this is separate.

§max_payload_repeater: &'a [Option<MaxPayload>]

The uplink payload limits when the device may be behind a repeater.

§max_payload_direct: &'a [Option<MaxPayload>]

The uplink payload limits when it will not be.

§downlink_max_payload_repeater: &'a [Option<MaxPayload>]

The downlink payload limits when the device may be behind a repeater.

Most regions number their downlink data rates the same way as their uplink ones and carry the same slice here. The 900 MHz plans do not.

§downlink_max_payload_direct: &'a [Option<MaxPayload>]

The downlink payload limits when it will not be.

§max_payload_dwell_limited: Option<&'a [Option<MaxPayload>]>

The payload limits under a dwell-time limit, where the region has one.

§join_channels: &'a [ChannelBlock]

The channels a device must use to send a join request.

§default_channels: &'a [ChannelBlock]

The channels a device starts with before a network adds any.

§sub_bands: &'a [SubBand]

The sub-bands and their transmit limits.

§default_max_eirp_dbm: i8

The power ceiling assumed when no sub-band says otherwise, in dBm.

It is radiated power unless power_reference says the plan counts conducted power, as US902-928 does.

§tx_power_step_db: u8

The step between transmit-power settings, in dB.

§max_tx_power_index: u8

The highest transmit-power index the region defines.

§rx1_data_rate_offsets: &'a [&'a [u8]]

The downlink data rate for each uplink data rate and RX1 offset, as [uplink data rate][offset].

§rx1_data_rate_offsets_dwell_limited: Option<&'a [&'a [u8]]>

The same mapping under a downlink dwell-time limit, where the region publishes a second table for it.

§max_rx1_data_rate_offset: u8

The highest RX1 data-rate offset the region allows.

§rx2_frequency_hz: u32

The fixed frequency the second receive window listens on, in hertz.

§rx2_data_rate: u8

The data rate the second receive window listens at.

§data_rate_backoff: &'a [Option<u8>]

The next lower uplink data rate during adaptive back-off, indexed by the current data rate; None where there is nothing lower.

§beacon: Beacon

The Class B beacon settings.

§relay_channels: &'a [RelayChannel]

The default channels of a LoRaWAN relay, by channel index, from the region’s relay parameters in RP002-1.0.5 sections 3.4.9 to 3.13.9; empty where a region defines none.

§has_dwell_time_limit: bool

Whether the region limits how long one transmission may occupy a channel.

§kind: PlanKind

Whether a network may create and move channels, or only enable numbered ones.

§tx_param_setup: bool

Whether devices in the region answer TXParamSetupReq, which sets their radiated power ceiling and dwell time.

RP002-1.0.5 has AS923 and AU915-928 implement it and every other region leave it out; a device in a region without it drops the command unanswered.

§mask_controls: [MaskControl; 8]

What each value of a LinkADRReq command’s ChMaskCntl field does, indexed by the value.

§downlink_channels: &'a [ChannelBlock]

The numbered downlink channels the first receive window answers on, for a plan that has them, and empty for one that answers on the uplink’s own frequency.

The fixed plans number their downlink channels apart from their uplink ones, and answer an uplink on channel n on downlink channel n modulo how many there are: “RX1 Channel Number = Transmit Channel Number modulo NbChannel”, RP002-1.0.5 section 3.5.7.

§join_sequence: JoinSequence

The order a device tries the join channels in.

§power_reference: PowerReference

What the transmit power indexes count down from.

§join_plans: &'a [JoinPlan<'a>]

The plans a join selects between, for a region that puts a device on a plan by the channel it joined on, and empty where the plan is the one a device joins on.

Implementations§

Source§

impl<'a> ChannelPlan<'a>

Source

pub fn join_plan(&self, join_channel: u16) -> Option<(JoinPlan<'a>, u16)>

Returns the run of join channels a join channel number falls in.

Join channels are numbered through join_plans in order, which is how RP002-1.0.5 table 49 indexes the CN470-510 common join channels.

§Arguments
  • join_channel - the join channel number.
§Returns

The run and the channel’s position within it, or None for a plan with no join plans or a number past the last run.

§Examples
use pamoja_lora::region::{Cn470Plan, Region};

// RP002-1.0.5 table 49: common join channel 9 goes out on 499.9 MHz, is answered
// there, and puts the device on the 20 MHz antenna's plan B.
let (run, offset) = Region::Cn470.plan().join_plan(9).expect("twenty join channels");
assert_eq!(run.channels.frequency_hz(offset), Some(499_900_000));
assert_eq!(run.accept_hz(offset), Some(499_900_000));
assert!(core::ptr::eq(run.plan, Cn470Plan::Antenna20MhzB.plan()));
Source§

impl ChannelPlan<'_>

Returns the frequency of a numbered downlink channel.

§Arguments
§Returns

Some(hz), or None if the plan numbers no such downlink channel.

Returns how many numbered downlink channels the plan has.

§Returns

The count, zero for a plan that answers on the uplink’s own frequency.

Source

pub fn rx1_frequency_hz( &self, uplink_channel: u16, uplink_hz: u32, ) -> Option<u32>

Returns where the first receive window listens after an uplink.

§Arguments
  • uplink_channel - the channel number the uplink went out on.
  • uplink_hz - the frequency it went out on.
§Returns

The uplink’s own frequency for a plan with no numbered downlink channels, and otherwise the downlink channel the uplink channel maps to, or None if the plan’s downlink channels leave it undefined.

§Examples
use pamoja_lora::region::Region;

// US902-928: an uplink on channel 65, the second 500 kHz channel at 904.6 MHz, is
// answered on downlink channel 1 at 923.9 MHz.
let plan = Region::Us915.plan();
assert_eq!(plan.rx1_frequency_hz(65, 904_600_000), Some(923_900_000));

Returns the uplink data rate a number selects.

§Arguments
  • data_rate - the data-rate number.
§Returns

Some(rate), or None if the number is out of range or reserved in this region.

Returns the downlink data rate a number selects.

§Arguments
  • data_rate - the data-rate number.
§Returns

Some(rate), or None if the number is out of range or reserved.

Returns the link settings an uplink data rate describes.

This is the bridge into the airtime and duty-cycle math the rest of the crate already provides.

§Arguments
  • data_rate - the uplink data-rate number.
§Returns

Some(settings) for a LoRa data rate, or None if the number is not defined here or names an FSK or LR-FHSS rate, which the chirp airtime model does not describe.

Source

pub fn max_payload( &self, data_rate: u8, behind_repeater: bool, ) -> Option<MaxPayload>

Returns the largest payload an uplink data rate carries.

§Arguments
  • data_rate - the uplink data-rate number.
  • behind_repeater - whether the device may operate through a repeater, which costs a few bytes of encapsulation at the higher data rates.
§Returns

Some(limit), or None if the data rate carries no payload here.

Returns the largest payload a downlink data rate carries.

§Arguments
  • data_rate - the downlink data-rate number.
  • behind_repeater - whether the device may operate through a repeater.
§Returns

Some(limit), or None if the data rate carries no payload here.

Source

pub fn max_payload_dwell_limited(&self, data_rate: u8) -> Option<MaxPayload>

Returns the largest payload an uplink data rate carries under a dwell-time limit.

§Arguments
  • data_rate - the uplink data-rate number.
§Returns

Some(limit), or None if the region has no dwell-time limit or the data rate carries nothing under one.

Source

pub fn duty_cycle_permille(&self, frequency_hz: u32) -> Option<u32>

Returns the duty-cycle limit that applies to a frequency.

§Arguments
  • frequency_hz - the frequency to look up.
§Returns

Some(permille) for a frequency inside a sub-band this region limits, or None where the region publishes no duty-cycle limit for it. None is not permission; it means the constraint is elsewhere, typically a dwell-time limit instead.

Source

pub fn max_eirp_dbm(&self, frequency_hz: u32) -> i8

Returns the power ceiling that applies to a frequency, in dBm.

§Arguments
  • frequency_hz - the frequency to look up.
§Returns

The sub-band’s ceiling, or the region default where no sub-band covers the frequency.

Source

pub fn tx_power_dbm(&self, index: u8, max_eirp_dbm: i8) -> Option<i8>

Returns the power a transmit-power index selects, in dBm.

The power is radiated or conducted as the plan’s power_reference says.

§Arguments
  • index - the TXPower index from a LinkADRReq.
  • max_eirp_dbm - the ceiling the index counts down from, usually max_eirp_dbm for the frequency in use.
§Returns

Some(dbm), or None if the index is above what the region defines.

Source

pub fn rx1_data_rate(&self, uplink_data_rate: u8, offset: u8) -> Option<u8>

Returns the downlink data rate the first receive window uses.

§Arguments
  • uplink_data_rate - the data rate the uplink was sent at.
  • offset - the RX1DROffset in force.
§Returns

Some(data_rate), or None if either argument is outside what the region defines.

Source

pub fn rx1_data_rate_dwell_limited( &self, uplink_data_rate: u8, offset: u8, ) -> Option<u8>

Returns the first receive window’s data rate under a dwell-time limit.

§Arguments
  • uplink_data_rate - the data rate the uplink was sent at.
  • offset - the RX1DROffset in force.
§Returns

Some(data_rate), or None if the region publishes no dwell-limited mapping or either argument is outside what it defines.

Source

pub fn relay_channel(&self, index: u8) -> Option<RelayChannel>

Returns a default relay channel.

§Arguments
  • index - the channel index a relay configuration names, 0 or 1.
§Returns

The channel, or None where the region defines none at that index.

§Examples
use pamoja_lora::region::{RelayChannel, Region};

let plan = Region::Eu868.plan();
assert_eq!(
    plan.relay_channel(0),
    Some(RelayChannel::new(865_100_000, 865_300_000, 3))
);
assert_eq!(plan.relay_channel(2), None);
Source

pub fn rx2(&self) -> (u32, u8)

Returns the frequency and data rate of the second receive window.

§Returns

The frequency in hertz and the data-rate number.

Source

pub fn next_backoff_data_rate(&self, data_rate: u8) -> Option<u8>

Returns the next data rate down during adaptive back-off.

§Arguments
  • data_rate - the data rate currently in use.
§Returns

Some(next), or None when the device is already at the lowest rate the region backs off to.

Source

pub fn channel_frequency_hz(&self, channel: u16) -> Option<u32>

Returns the frequency of a channel by its number across the whole plan.

Channel numbers run through the default blocks in order, which is the numbering LinkADRReq channel masks use.

§Arguments
  • channel - the channel number.
§Returns

Some(hz), or None if the plan defines no such channel by default.

Source

pub fn default_channel_count(&self) -> u16

Returns how many channels the plan defines by default.

§Returns

The channel count.

Trait Implementations§

Source§

impl<'a> Clone for ChannelPlan<'a>

Source§

fn clone(&self) -> ChannelPlan<'a>

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<'a> Copy for ChannelPlan<'a>

Source§

impl<'a> Debug for ChannelPlan<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ChannelPlan<'a>

§

impl<'a> RefUnwindSafe for ChannelPlan<'a>

§

impl<'a> Send for ChannelPlan<'a>

§

impl<'a> Sync for ChannelPlan<'a>

§

impl<'a> Unpin for ChannelPlan<'a>

§

impl<'a> UnsafeUnpin for ChannelPlan<'a>

§

impl<'a> UnwindSafe for ChannelPlan<'a>

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.