Class LorawanPackages
The four LoRaWAN application layer packages: clock synchronization TS003-2.0.0, fragmented data block transport TS004-2.0.0, remote multicast setup TS005-2.0.0 and firmware management TS006-1.0.0.
public static class LorawanPackages
- Inheritance
-
LorawanPackages
- Inherited Members
Remarks
The key derivations and the parity matrix are functions of their arguments and live here. What has to remember something is a class: LorawanClockSync, LorawanFirmware, LorawanDefragmenter and LorawanBlockMic. One command of any of the four is LorawanPackageCommand.
Fields
ClockPort
The port clock synchronization is spoken on.
public const byte ClockPort = 202
Field Value
FirmwarePort
The port firmware management is spoken on.
public const byte FirmwarePort = 203
Field Value
FragmentPort
The port fragmented data block transport is spoken on.
public const byte FragmentPort = 201
Field Value
MaxFragments
The most fragments one session carries.
public const ushort MaxFragments = 16383
Field Value
MulticastPort
The port remote multicast setup is spoken on.
public const byte MulticastPort = 200
Field Value
Methods
DataBlockIntKey(ReadOnlySpan<byte>)
Derives the key that signs a data block, TS004-2.0.0 section 3.3.
public static byte[] DataBlockIntKey(ReadOnlySpan<byte> rootKey)
Parameters
rootKeyReadOnlySpan<byte>The device's root key.
Returns
- byte[]
The sixteen-byte
DataBlockIntKey.
Exceptions
- ArgumentException
The key was not sixteen bytes.
FragFragment(ReadOnlySpan<byte>, byte, ushort)
Builds one fragment of a session out of a block held whole.
public static byte[] FragFragment(ReadOnlySpan<byte> block, byte fragSize, ushort n)
Parameters
blockReadOnlySpan<byte>The block, padding and all.
fragSizebyteHow many bytes each fragment carries.
nushortWhich fragment, counting from one.
Returns
- byte[]
Its bytes.
Remarks
Up to the session's fragment count the fragment is a piece of the block; past that it is a coded fragment, the exclusive-or of a pseudo-random half of the pieces.
Exceptions
- PamojaException
The fragment is not one of this session.
FragParityLine(ushort, ushort)
Lists the uncoded fragments one coded fragment is made of.
public static ushort[] FragParityLine(ushort coded, ushort nbFrag)
Parameters
codedushortWhich coded fragment, counting from one past the uncoded ones.
nbFragushortHow many uncoded fragments the session carries.
Returns
- ushort[]
The fragments it is the exclusive-or of, counting from zero.
Exceptions
- PamojaException
The session is not one this build runs.
FragPrbs23(uint)
Steps the pseudo-random sequence the parity matrix is drawn from.
public static uint FragPrbs23(uint x)
Parameters
xuintThe current state.
Returns
- uint
The next one.
FragSession(int, byte)
Says how many fragments a block takes, and how much padding the last one needs.
public static LorawanFragSession FragSession(int blockLen, byte fragSize)
Parameters
Returns
- LorawanFragSession
The shape of the session.
Exceptions
- PamojaException
The block does not fit a session this build runs.
McAppSKey(ReadOnlySpan<byte>, uint)
Derives the key that reads a multicast group's payloads.
public static byte[] McAppSKey(ReadOnlySpan<byte> mcKey, uint mcAddr)
Parameters
mcKeyReadOnlySpan<byte>The group key.
mcAddruintThe address the group answers to.
Returns
- byte[]
The group's
McAppSKey.
Exceptions
- ArgumentException
The key was not sixteen bytes.
McKeKey(ReadOnlySpan<byte>)
Derives the key a multicast group's key travels under.
public static byte[] McKeKey(ReadOnlySpan<byte> mcRootKey)
Parameters
mcRootKeyReadOnlySpan<byte>What McRootKey(ReadOnlySpan<byte>, bool) derived.
Returns
- byte[]
The sixteen-byte
McKEKey.
Exceptions
- ArgumentException
The key was not sixteen bytes.
McKey(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
Unwraps the group key a setup command carried.
public static byte[] McKey(ReadOnlySpan<byte> mcKeKey, ReadOnlySpan<byte> wrapped)
Parameters
mcKeKeyReadOnlySpan<byte>What McKeKey(ReadOnlySpan<byte>) derived.
wrappedReadOnlySpan<byte>The wrapped key the command carried.
Returns
- byte[]
The group key.
Exceptions
- ArgumentException
Either value was not sixteen bytes.
McNwkSKey(ReadOnlySpan<byte>, uint)
Derives the key that verifies a multicast group's frames.
public static byte[] McNwkSKey(ReadOnlySpan<byte> mcKey, uint mcAddr)
Parameters
mcKeyReadOnlySpan<byte>The group key.
mcAddruintThe address the group answers to.
Returns
- byte[]
The group's
McNwkSKey.
Exceptions
- ArgumentException
The key was not sixteen bytes.
McRootKey(ReadOnlySpan<byte>, bool)
Derives a device's multicast root key, TS005-2.0.0 section 4.3.
public static byte[] McRootKey(ReadOnlySpan<byte> rootKey, bool lorawan11 = false)
Parameters
rootKeyReadOnlySpan<byte>The device's
GenAppKeyon 1.0.x, or itsAppKeyon 1.1.lorawan11boolWhether to use the 1.1 scheme, which starts from another constant.
Returns
- byte[]
The sixteen-byte
McRootKey.
Exceptions
- ArgumentException
The key was not sixteen bytes.
WrapMcKey(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
Wraps a group key for a device, which is what a server does before sending it.
public static byte[] WrapMcKey(ReadOnlySpan<byte> mcKeKey, ReadOnlySpan<byte> mcKey)
Parameters
mcKeKeyReadOnlySpan<byte>The device's key encryption key.
mcKeyReadOnlySpan<byte>The group key to wrap.
Returns
- byte[]
The wrapped key a setup command carries.
Exceptions
- ArgumentException
Either key was not sixteen bytes.