pub struct Device { /* private fields */ }Expand description
An end device’s root credentials for over-the-air activation.
Where a Session is the state of an already-activated device, a Device holds what
it takes to activate: the device and application identifiers and the application root
key. It builds the join_request a device broadcasts and turns
the network’s reply into a ready Session with accept_join,
deriving the session keys the spec prescribes.
The 8-byte identifiers are given most-significant byte first, as they are written; the join-request transmits them little-endian, as the spec requires.
Implementations§
Source§impl Device
impl Device
Sourcepub fn join_request(&self, dev_nonce: u16) -> PhyPayload
pub fn join_request(&self, dev_nonce: u16) -> PhyPayload
Builds a join-request to broadcast.
§Arguments
dev_nonce- a nonce the device must not reuse; keep it for the matchingaccept_join, which needs it to derive the keys.
§Returns
The join-request frame.
Sourcepub fn accept_join(
&self,
bytes: &[u8],
dev_nonce: u16,
) -> Result<JoinAccept, LorawanError>
pub fn accept_join( &self, bytes: &[u8], dev_nonce: u16, ) -> Result<JoinAccept, LorawanError>
Accepts a join-accept, deriving the activated session.
Decrypts the reply, verifies its MIC against the application root key, and derives the network and application session keys from the nonces it carries.
§Arguments
bytes- the raw join-accept as it came off the radio.dev_nonce- the same nonce passed to thejoin_requestthis reply answers.
§Returns
The activation, including the ready-to-use Session.
§Errors
Returns LorawanError::FrameTooShort or LorawanError::MalformedFrame if the
reply is not a valid join-accept shape, LorawanError::UnsupportedMType if it is
not a join-accept, or LorawanError::MicMismatch if its MIC does not verify.