pub struct JoinRequest { /* private fields */ }Expand description
A join-request a device broadcast, with its integrity already verified.
parse checks the request against the application root key
before reporting anything, so the identifiers it hands back are the ones the key holder
actually sent rather than whatever arrived on the air.
§Examples
use pamoja_lorawan::{Device, JoinRequest};
const APP_KEY: [u8; 16] = [0xAB; 16];
let device = Device::new([0x11; 8], [0x22; 8], APP_KEY);
let on_air = device.join_request(0x1234);
// The network recognises the device and the nonce it must not accept twice.
let request = JoinRequest::parse(on_air.as_bytes(), &APP_KEY)?;
assert_eq!(request.dev_eui(), [0x11; 8]);
assert_eq!(request.dev_nonce(), 0x1234);Implementations§
Source§impl JoinRequest
impl JoinRequest
Sourcepub fn parse(
bytes: &[u8],
app_key: &[u8; 16],
) -> Result<JoinRequest, LorawanError>
pub fn parse( bytes: &[u8], app_key: &[u8; 16], ) -> Result<JoinRequest, LorawanError>
Verifies a join-request and reads the identifiers out of it.
§Arguments
bytes- the raw join-request as it came off the radio.app_key- the application root key the device shares with this network.
§Returns
The verified request.
§Errors
Returns LorawanError::FrameTooShort if the frame is empty,
LorawanError::UnsupportedMType if it is not a join-request,
LorawanError::MalformedFrame if it is not the fixed 23 bytes a join-request is,
or LorawanError::MicMismatch if its MIC does not verify, which means it was not
sent by a holder of app_key.
Sourcepub fn dev_eui(&self) -> [u8; 8]
pub fn dev_eui(&self) -> [u8; 8]
Returns the device identifier, most-significant byte first.
§Returns
The DevEUI, as it is written rather than as it was transmitted.
Trait Implementations§
Source§impl Clone for JoinRequest
impl Clone for JoinRequest
Source§fn clone(&self) -> JoinRequest
fn clone(&self) -> JoinRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for JoinRequest
Source§impl Debug for JoinRequest
impl Debug for JoinRequest
impl Eq for JoinRequest
Source§impl PartialEq for JoinRequest
impl PartialEq for JoinRequest
Source§fn eq(&self, other: &JoinRequest) -> bool
fn eq(&self, other: &JoinRequest) -> bool
self and other values to be equal, and is used by ==.