Skip to main content

TrustedDevice

Struct TrustedDevice 

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

An end device a relay trusts: its keys, the WOR frame counter it expects next, and how much of it the relay forwards.

Implementations§

Source§

impl TrustedDevice

Source

pub fn new( dev_addr: u32, root_wor_s_key: &[u8; 16], next_wfcnt: u32, bucket: TokenBucket, ) -> TrustedDevice

Trusts an end device, as UpdateUplinkListReq asks.

§Arguments
  • dev_addr - its address.
  • root_wor_s_key - the root relay session key the network sent for it, which its integrity and encryption keys derive from.
  • next_wfcnt - the WOR frame counter the network expects from it next.
  • bucket - how many of its uplinks the relay forwards.
§Returns

The trusted device.

Source

pub const fn with_keys( dev_addr: u32, keys: WorKeys, next_wfcnt: u32, bucket: TokenBucket, ) -> TrustedDevice

Trusts an end device whose keys are already derived.

§Arguments
  • dev_addr - its address.
  • keys - its integrity and encryption keys.
  • next_wfcnt - the WOR frame counter expected from it next.
  • bucket - how many of its uplinks the relay forwards.
§Returns

The trusted device.

Source

pub const fn dev_addr(&self) -> u32

Returns the device’s address.

§Returns

The address.

Source

pub const fn keys(&self) -> &WorKeys

Returns the device’s keys.

§Returns

The integrity and encryption keys.

Source

pub const fn next_wfcnt(&self) -> Option<u32>

Returns the WOR frame counter the relay accepts next, at the least.

§Returns

The counter, or None once a frame with the last counter there is has been accepted.

Source

pub const fn last_wfcnt(&self) -> u32

Returns the last WOR frame counter the relay accepted, which CtrlUplinkListAns reports.

§Returns

The counter. Before any frame arrives, it is one less than the counter the network said to expect, wrapping, so the network reads back what it set.

Source

pub const fn bucket(&self) -> &TokenBucket

Returns how many of the device’s uplinks the relay forwards.

§Returns

The bucket.

Source

pub fn bucket_mut(&mut self) -> &mut TokenBucket

Returns the device’s bucket to spend from or reconfigure.

§Returns

The bucket.

Source

pub fn open( &mut self, wor: &SealedWor, carrier: Carrier, ) -> Result<(u32, Carrier), LorawanError>

Checks and opens a wake-on-radio frame from the device, then moves the counter past it.

The frame carries the counter’s low sixteen bits. The relay takes the first full counter at or after the one it expects with those bits, so a frame it has seen, or an older one, does not verify.

§Arguments
  • wor - the frame.
  • carrier - the carrier it arrived on.
§Returns

The full counter the frame carried and where its uplink follows.

§Errors

Returns LorawanError::FcntMismatch for a frame addressed elsewhere or past the last counter, and LorawanError::MicMismatch when it does not verify, leaving the counter where it was.

Trait Implementations§

Source§

impl Clone for TrustedDevice

Source§

fn clone(&self) -> TrustedDevice

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 TrustedDevice

Source§

impl Debug for TrustedDevice

Source§

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

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

impl Eq for TrustedDevice

Source§

impl PartialEq for TrustedDevice

Source§

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

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.