Skip to main content

ChannelPlanBuilder

Struct ChannelPlanBuilder 

Source
pub struct ChannelPlanBuilder { /* private fields */ }
Expand description

Assembles a OwnedChannelPlan a table at a time.

Tables are indexed by position, so entries are pushed in data-rate order and a number the plan does not use is pushed as None. What a region would share between directions is filled in at build rather than being repeated here.

§Examples

use pamoja_lora::region::{
    ChannelBlock, ChannelPlanBuilder, DataRate, MaxPayload, PayloadTable, SubBand,
};

// A private deployment on licensed spectrum: two data rates and no duty cycle.
let plan = ChannelPlanBuilder::new("private-915")
    .uplink_data_rate(Some(DataRate::lora(12, 125_000, 250)))
    .uplink_data_rate(Some(DataRate::lora(7, 125_000, 5_470)))
    .max_payload(PayloadTable::UplinkDirect, Some(MaxPayload::new(59, 51)))
    .max_payload(PayloadTable::UplinkDirect, Some(MaxPayload::new(230, 222)))
    .default_channel(ChannelBlock::new(915_000_000, 500_000, 4, 0, 1))
    .sub_band(SubBand::new(915_000_000, 917_000_000, 1000, 30))
    .rx(915_000_000, 0, 0)
    .rx1_row(&[0])
    .rx1_row(&[1])
    .build()
    .expect("a consistent plan");

// Licensed spectrum is reported as unrestricted, not refused.
assert_eq!(plan.with_plan(|p| p.duty_cycle_permille(915_500_000)), Some(1000));
assert_eq!(plan.with_plan(|p| p.default_channel_count()), 4);

Implementations§

Source§

impl ChannelPlanBuilder

Source

pub fn new(name: impl Into<String>) -> Self

Starts an empty plan.

The plan begins with no data rates, channels, or sub-bands, a two-decibel power ladder, and no dwell-time limit.

§Arguments
  • name - what to call the plan, such as the band it covers.
§Returns

The builder.

Appends the next uplink data rate.

§Arguments
  • rate - the data rate, or None for a number the plan reserves.
§Returns

The builder.

Appends the next downlink data rate.

A plan that never calls this uses its uplink table in both directions, which is what every region but the 900 MHz plans does.

§Arguments
  • rate - the data rate, or None for a number the plan reserves.
§Returns

The builder.

Source

pub fn max_payload( self, table: PayloadTable, payload: Option<MaxPayload>, ) -> Self

Appends the next entry of one payload table.

A downlink table left empty mirrors the matching uplink one.

§Arguments
  • table - which table the entry belongs to.
  • payload - the limits, or None where the data rate carries nothing.
§Returns

The builder.

Source

pub fn join_channel(self, block: ChannelBlock) -> Self

Adds a run of channels a device may send a join request on.

§Arguments
  • block - the channels to add.
§Returns

The builder.

Source

pub fn default_channel(self, block: ChannelBlock) -> Self

Adds a run of channels a device starts with.

§Arguments
  • block - the channels to add.
§Returns

The builder.

Source

pub fn sub_band(self, band: SubBand) -> Self

Adds a sub-band and the transmit limits inside it.

A deployment on licensed spectrum gives its sub-band a duty cycle of 1000, which reports as unrestricted.

§Arguments
  • band - the sub-band to add.
§Returns

The builder.

Source

pub fn rx1_row(self, offsets: &[u8]) -> Self

Appends the RX1 downlink data rates for the next uplink data rate.

§Arguments
  • offsets - the downlink data rate at each RX1 offset, in order.
§Returns

The builder.

Source

pub fn rx1_row_dwell_limited(self, offsets: &[u8]) -> Self

Appends the dwell-limited RX1 downlink data rates for the next uplink data rate.

§Arguments
  • offsets - the downlink data rate at each RX1 offset, in order.
§Returns

The builder.

Source

pub fn backoff(self, lower: Option<u8>) -> Self

Appends the next entry of the adaptive back-off chain.

A chain left empty steps down one data rate at a time.

§Arguments
  • lower - the data rate to fall back to, or None at the slowest.
§Returns

The builder.

Source

pub fn power(self, default_max_eirp_dbm: i8, step_db: u8, max_index: u8) -> Self

Sets the transmit-power ladder.

§Arguments
  • default_max_eirp_dbm - the ceiling where no sub-band says otherwise.
  • step_db - the step between power settings, in decibels.
  • max_index - the highest power index the plan defines.
§Returns

The builder.

Source

pub fn rx( self, rx2_frequency_hz: u32, rx2_data_rate: u8, max_rx1_offset: u8, ) -> Self

Sets the receive windows.

§Arguments
  • rx2_frequency_hz - the fixed frequency the second window listens on.
  • rx2_data_rate - the data rate the second window listens at.
  • max_rx1_offset - the highest RX1 offset the plan allows, which fixes how wide every RX1 row must be.
§Returns

The builder.

Source

pub fn beacon(self, beacon: Beacon) -> Self

Sets the Class B beacon.

§Arguments
  • beacon - the beacon settings.
§Returns

The builder.

Source

pub fn dwell_time_limit(self, limited: bool) -> Self

Sets whether the plan limits how long one transmission may hold a channel.

§Arguments
  • limited - whether a dwell-time limit applies.
§Returns

The builder.

Source

pub fn build(self) -> Result<OwnedChannelPlan, PlanError>

Finishes the plan.

Tables a region would share are filled in first: an empty downlink data-rate table mirrors the uplink one, an empty downlink payload table mirrors its uplink counterpart, and an empty back-off chain steps down one data rate at a time. What cannot be inferred is checked.

§Returns

The finished plan.

§Errors

Returns the PlanError describing the question this plan would answer wrongly.

Trait Implementations§

Source§

impl Clone for ChannelPlanBuilder

Source§

fn clone(&self) -> ChannelPlanBuilder

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 Debug for ChannelPlanBuilder

Source§

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

Formats the value using the given formatter. Read more

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.