Skip to main content

Plan

Struct Plan 

Source
pub struct Plan {
    pub carrier_hz: u32,
    pub channels: [Listener; 8],
    pub spreading_factors: u8,
    pub public: bool,
    pub service: Option<Service>,
    pub fsk: Option<Fsk>,
}
Expand description

What a concentrator is to listen for.

Fields§

§carrier_hz: u32

The carrier the first radio is tuned to, in hertz, which every offset is measured from.

§channels: [Listener; 8]

The eight receivers that take any spreading factor.

§spreading_factors: u8

Which spreading factors to look for, one bit each counting from MIN_SPREADING_FACTOR.

§public: bool

Whether the network is a public one, which decides the sync word the receivers look for. LoRaWAN networks are public; the chip powers up expecting a private one.

§service: Option<Service>

The receiver fixed to one spreading factor, or None to leave it where reset left it.

§fsk: Option<Fsk>

The receiver that hears frequency shift keying, or None to leave it where reset left it.

Implementations§

Source§

impl Plan

Source

pub fn new(carrier_hz: u32, offsets_hz: &[i32]) -> Plan

A plan on one carrier, listening on these offsets.

§Arguments
  • carrier_hz - what the radio is tuned to.
  • offsets_hz - how far from it each receiver listens. Anything past the eighth is ignored, and any receiver left over is switched off.
§Returns

The plan, looking for every spreading factor.

§Examples
use pamoja_radios::sx1302::channel::Plan;

// The eight channels a European gateway usually runs, 867.1 MHz through 868.5 MHz.
// The carrier sits in the middle of them, because a radio only hears so far either
// side of what it is tuned to.
let plan = Plan::new(
    867_800_000,
    &[-700_000, -500_000, -300_000, -100_000, 100_000, 300_000, 500_000, 700_000],
);
assert!(plan.channels[0].enabled);
assert_eq!(plan.channels[4].offset_hz, 100_000);
Source

pub const fn network(self, public: bool) -> Plan

The same plan, on a public network or a private one.

§Arguments
  • public - whether the network is public. Every LoRaWAN network is.
§Returns

The plan.

§Examples
use pamoja_radios::sx1302::channel::Plan;

// A plan listens to a public network unless it is told otherwise.
assert!(Plan::new(867_800_000, &[0]).public);
assert!(!Plan::new(867_800_000, &[0]).network(false).public);
Source

pub const fn serving(self, service: Service) -> Plan

The same plan, with the fixed-rate receiver pointed at a channel.

That receiver is switched on whatever a plan says, so one never given a channel listens wherever reset left it. This is what gives it somewhere to listen.

§Arguments
  • service - the channel it runs on.
§Returns

The plan.

§Examples
use pamoja_radios::sx1302::channel::{Plan, Service};

let plan = Plan::new(867_800_000, &[-300_000])
    .serving(Service::at(500_000, 7).bandwidth(250_000));
assert_eq!(plan.service.map(|service| service.spreading_factor), Some(7));
Source

pub const fn hearing(self, fsk: Fsk) -> Plan

The same plan, with the frequency shift keying receiver pointed at a channel.

That receiver is switched on whatever a plan says, so one never given a channel listens wherever reset left it, as the fixed-rate one does.

§Arguments
  • fsk - the channel it runs on.
§Returns

The plan.

§Examples
use pamoja_radios::sx1302::channel::{Fsk, Plan};
use pamoja_radios::sx1302::tx::Chain;

let plan = Plan::new(867_800_000, &[-300_000]).hearing(Fsk::at(600_000).on(Chain::B));
assert_eq!(plan.fsk.map(|fsk| fsk.bitrate), Some(50_000));
Source

pub fn looking_for(self, wanted: &[u8]) -> Plan

The same plan, looking only for these spreading factors.

§Arguments
  • wanted - the spreading factors to look for. Anything outside 5 to 12 is ignored.
§Returns

The plan.

§Examples
use pamoja_radios::sx1302::channel::Plan;

// A network that only runs the faster half of the range.
let plan = Plan::new(867_500_000, &[-400_000]).looking_for(&[7, 8, 9]);
assert_eq!(plan.spreading_factors, 0b0001_1100);
Source

pub const fn radios(&self) -> u8

Which radio each receiver takes its samples from, one bit per receiver.

§Returns

The mask the chip takes, with a bit set for every receiver on the second radio.

§Examples
use pamoja_radios::sx1302::channel::Plan;
use pamoja_radios::sx1302::tx::Chain;

let mut plan = Plan::new(867_500_000, &[0, 0]);
plan.channels[1] = plan.channels[1].on(Chain::B);
assert_eq!(plan.radios(), 0b0000_0010);
Source

pub const fn running(&self) -> u8

Which receivers run, one bit each.

§Returns

The mask the chip takes.

§Examples
use pamoja_radios::sx1302::channel::Plan;

// Three offsets given, so three receivers run and five do not.
let plan = Plan::new(867_500_000, &[-400_000, -200_000, 0]);
assert_eq!(plan.running(), 0b0000_0111);

Trait Implementations§

Source§

impl Clone for Plan

Source§

fn clone(&self) -> Plan

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 Plan

Source§

impl Debug for Plan

Source§

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

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

impl Eq for Plan

Source§

impl PartialEq for Plan

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Plan

Auto Trait Implementations§

§

impl Freeze for Plan

§

impl RefUnwindSafe for Plan

§

impl Send for Plan

§

impl Sync for Plan

§

impl Unpin for Plan

§

impl UnsafeUnpin for Plan

§

impl UnwindSafe for Plan

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.