Skip to main content

CfList

Struct CfList 

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

The optional channel list at the end of a join accept.

§Examples

A European network adding the five channels most EU868 networks run between 867.1 and 867.9 MHz:

use pamoja_lorawan::{CfList, CfListKind};

let list = CfList::frequencies([867_100_000, 867_300_000, 867_500_000, 867_700_000, 867_900_000])?;
assert_eq!(list.kind(), CfListKind::Frequencies);
assert_eq!(list.to_bytes().len(), 16, "the last sixteen bytes of the accept");

// A device reads the same frequencies back out.
let heard = CfList::from_bytes(list.to_bytes());
assert_eq!(heard.frequencies_hz(), Some([867_100_000, 867_300_000, 867_500_000, 867_700_000, 867_900_000]));

Implementations§

Source§

impl CfList

Source

pub const fn from_bytes(bytes: [u8; 16]) -> CfList

Keeps a channel list exactly as it arrived.

§Arguments
  • bytes - the sixteen CFList bytes.
§Returns

The channel list, whatever its type byte says.

Source

pub const fn frequencies( frequencies_hz: [u32; 5], ) -> Result<CfList, LorawanError>

Builds a type 0 list from frequencies.

§Arguments
  • frequencies_hz - five frequencies in hertz, with 0 for a slot left unused.
§Returns

The channel list.

§Errors

Returns LorawanError::MalformedFrame if a frequency is not a whole number of hundreds of hertz, or does not fit the three bytes it is carried in, which end just under 1.678 GHz. Between those, RP002-1.0.5 reserves anything below 100 MHz, and that is refused too.

Source

pub const fn channel_masks(masks: [u16; 6]) -> CfList

Builds a type 1 list from channel mask groups.

§Arguments
  • masks - six groups, where bit n of group g enables channel g * 16 + n.
§Returns

The channel list, with its three reserved bytes zero.

Source

pub const fn to_bytes(&self) -> [u8; 16]

Returns the sixteen bytes, as a join accept carries them.

§Returns

The bytes.

Source

pub const fn kind(&self) -> CfListKind

Returns which form the list takes.

§Returns

The kind its last byte names.

Source

pub const fn frequencies_hz(&self) -> Option<[u32; 5]>

Reads the frequencies out of a type 0 list.

§Returns

Five frequencies in hertz, with 0 for an unused slot, or None for a list of any other type.

Source

pub const fn channel_mask_groups(&self) -> Option<[u16; 6]>

Reads the mask groups out of a type 1 list.

§Returns

Six groups, or None for a list of any other type.

Source

pub const fn enables(&self, channel: u8) -> Option<bool>

Reports whether a type 1 list enables a channel.

§Arguments
  • channel - the channel number, group * 16 + bit.
§Returns

Whether its bit is set, or None for a list of any other type or a channel past the 96 the groups cover.

Source

pub fn enabled_channels(&self) -> impl Iterator<Item = u8> + '_

Returns the channels a type 1 list enables, lowest first.

This is the order RP002-1.0.5 section 3.3.1.1 has a dynamic plan create them in, one after its last default channel for each bit set.

§Returns

The channel numbers, which is empty for a list of any other type.

Trait Implementations§

Source§

impl Clone for CfList

Source§

fn clone(&self) -> CfList

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 CfList

Source§

impl Debug for CfList

Source§

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

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

impl Eq for CfList

Source§

impl From<CfList> for [u8; 16]

Source§

fn from(list: CfList) -> [u8; 16]

Converts to this type from the input type.
Source§

impl Hash for CfList

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CfList

Source§

fn eq(&self, other: &CfList) -> 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 CfList

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> Same for T

Source§

type Output = T

Should always be Self
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.