Table of Contents

Class LorawanGrant

Namespace
Pamoja.Lorawan
Assembly
Pamoja.Lorawan.dll

What a network grants a device that joined.

public sealed class LorawanGrant
Inheritance
LorawanGrant
Inherited Members

Remarks

Build one, then Accept(ReadOnlySpan<byte>, ushort) it into the frame to transmit and take the matching Session(ReadOnlySpan<byte>, ushort) to secure traffic with. Both sides derive the same keys from the same nonces, so neither ever sends one.

Constructors

LorawanGrant(uint, uint, uint, byte, byte, byte[]?)

Creates a grant of an address and the settings to answer on.

public LorawanGrant(uint appNonce, uint netId, uint devAddr, byte dlSettings = 0, byte rxDelay = 0, byte[]? cflist = null)

Parameters

appNonce uint

A nonce this network must not reuse for the device, since the session keys are derived from it; low 24 bits only.

netId uint

The network identifier; low 24 bits only.

devAddr uint

The address to assign the device.

dlSettings byte

The downlink settings byte.

rxDelay byte

The delay before the first receive window, in seconds.

cflist byte[]

The optional 16-byte channel list.

Properties

DevAddr

The address this grant assigns.

public uint DevAddr { get; }

Property Value

uint

NetId

The network identifier this grant carries.

public uint NetId { get; }

Property Value

uint

Methods

Accept(ReadOnlySpan<byte>, ushort)

Builds the signed join-accept to transmit.

public byte[] Accept(ReadOnlySpan<byte> appKey, ushort devNonce)

Parameters

appKey ReadOnlySpan<byte>

The 16-byte application root key the device shares.

devNonce ushort

The nonce the matching join-request carried.

Returns

byte[]

The join-accept, encrypted and with its MIC in place.

Exceptions

PamojaException

The key or the channel list is the wrong length.

Session(ReadOnlySpan<byte>, ushort)

Derives the session this grant activates.

public LorawanSession Session(ReadOnlySpan<byte> appKey, ushort devNonce)

Parameters

appKey ReadOnlySpan<byte>

The 16-byte application root key the device shares.

devNonce ushort

The nonce the matching join-request carried.

Returns

LorawanSession

The session to secure this device's traffic with, which is the same one the device computes without either side sending a key.

Exceptions

PamojaException

The key or the channel list is the wrong length.