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
impl TrustedDevice
Sourcepub fn new(
dev_addr: u32,
root_wor_s_key: &[u8; 16],
next_wfcnt: u32,
bucket: TokenBucket,
) -> TrustedDevice
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.
Sourcepub const fn with_keys(
dev_addr: u32,
keys: WorKeys,
next_wfcnt: u32,
bucket: TokenBucket,
) -> TrustedDevice
pub const fn with_keys( dev_addr: u32, keys: WorKeys, next_wfcnt: u32, bucket: TokenBucket, ) -> TrustedDevice
Sourcepub const fn next_wfcnt(&self) -> Option<u32>
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.
Sourcepub const fn last_wfcnt(&self) -> u32
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.
Sourcepub const fn bucket(&self) -> &TokenBucket
pub const fn bucket(&self) -> &TokenBucket
Sourcepub fn bucket_mut(&mut self) -> &mut TokenBucket
pub fn bucket_mut(&mut self) -> &mut TokenBucket
Sourcepub fn open(
&mut self,
wor: &SealedWor,
carrier: Carrier,
) -> Result<(u32, Carrier), LorawanError>
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
impl Clone for TrustedDevice
Source§fn clone(&self) -> TrustedDevice
fn clone(&self) -> TrustedDevice
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more