Skip to main content

JoinRequest

Struct JoinRequest 

Source
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

Source

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.

Source

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.

Source

pub fn app_eui(&self) -> [u8; 8]

Returns the application identifier, most-significant byte first.

§Returns

The AppEUI, as it is written rather than as it was transmitted.

Source

pub fn dev_nonce(&self) -> u16

Returns the nonce this request carried.

A network must remember the nonces a device has already used and refuse a repeat, since replaying one would re-derive the same session keys.

§Returns

The DevNonce.

Trait Implementations§

Source§

impl Clone for JoinRequest

Source§

fn clone(&self) -> JoinRequest

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 JoinRequest

Source§

impl Debug for JoinRequest

Source§

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

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

impl Eq for JoinRequest

Source§

impl PartialEq for JoinRequest

Source§

fn eq(&self, other: &JoinRequest) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for JoinRequest

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, 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.