Table of Contents

Class LorawanPackageCommand

Namespace
Pamoja.Lorawan
Assembly
Pamoja.Lorawan.dll

One command of an application layer package, whichever package it belongs to.

public sealed class LorawanPackageCommand
Inheritance
LorawanPackageCommand
Inherited Members

Remarks

Port says which package: clock synchronization TS003-2.0.0, fragmented data block transport TS004-2.0.0, remote multicast setup TS005-2.0.0 or firmware management TS006-1.0.0. Cid names the command within it.

The same identifier means a different command in each direction, so Uplink is always given and never guessed. Only the properties that command carries are set; the rest read as zero.

Fields

MaxLength

The longest command any of the four packages writes, in bytes.

public const int MaxLength = 64

Field Value

int

Properties

AckReception

Whether a device reports the block once it has it.

public bool AckReception { get; init; }

Property Value

bool

AllParticipants

Whether every device answers a status request.

public bool AllParticipants { get; init; }

Property Value

bool

AnsRequired

Whether a clock request must be answered.

public bool AnsRequired { get; init; }

Property Value

bool

BlockAckDelay

The coded spread of the delay before a device answers.

public byte BlockAckDelay { get; init; }

Property Value

byte

Cid

Which command within that package.

public required byte Cid { get; init; }

Property Value

byte

Data

The bytes a data fragment carries.

public byte[] Data { get; init; }

Property Value

byte[]

DataRate

The data rate it listens at.

public byte DataRate { get; init; }

Property Value

byte

DeleteVersion

The version a delete command names.

public uint DeleteVersion { get; init; }

Property Value

uint

Descriptor

The four bytes a server describes a block with.

public byte[] Descriptor { get; init; }

Property Value

byte[]

DeviceTime

A device's own clock, in seconds since the GPS epoch.

public uint DeviceTime { get; init; }

Property Value

uint

DlFrequencyHz

Where a group listens, in hertz.

public uint DlFrequencyHz { get; init; }

Property Value

uint

DrError

Whether the data rate named is not one the device has.

public bool DrError { get; init; }

Property Value

bool

Firmware

The firmware a device reports running.

public uint Firmware { get; init; }

Property Value

uint

FragAlgo

Which fragmentation algorithm to run.

public byte FragAlgo { get; init; }

Property Value

byte

FragIndex

Which fragmentation session, 0 to 3.

public byte FragIndex { get; init; }

Property Value

byte

FragSize

How many bytes each fragment carries.

public byte FragSize { get; init; }

Property Value

byte

FragmentN

Which fragment of a session a data fragment carries, counting from one.

public ushort FragmentN { get; init; }

Property Value

ushort

FreqError

Whether the frequency named is not one it can use.

public bool FreqError { get; init; }

Property Value

bool

GroupMask

Which groups a status request or answer covers, a bit for each.

public byte GroupMask { get; init; }

Property Value

byte

Hardware

The hardware it runs on.

public uint Hardware { get; init; }

Property Value

uint

HasNextVersion

Whether a version rides with the image status.

public bool HasNextVersion { get; init; }

Property Value

bool

HasTimeToStart

Whether a delay rides with the answer.

public bool HasTimeToStart { get; init; }

Property Value

bool

IdError

Whether a device holds no group by the identifier named.

public bool IdError { get; init; }

Property Value

bool

ImageStatus

What a device makes of the upgrade image it holds.

public byte ImageStatus { get; init; }

Property Value

byte

InvalidVersion

Whether the version named is not the one held.

public bool InvalidVersion { get; init; }

Property Value

bool

IsStatusItem

Whether this is one group record of a multicast status answer.

public byte IsStatusItem { get; init; }

Property Value

byte

MaxMcFcnt

The last one, which ends the group's life.

public uint MaxMcFcnt { get; init; }

Property Value

uint

McAddr

The address a group answers to.

public uint McAddr { get; init; }

Property Value

uint

McGroupBitMask

Which multicast groups may feed it, a bit for each.

public byte McGroupBitMask { get; init; }

Property Value

byte

McGroupId

Which multicast group, 0 to 3.

public byte McGroupId { get; init; }

Property Value

byte

McKeyEncrypted

A group's key, wrapped under the device's key encryption key.

public byte[] McKeyEncrypted { get; init; }

Property Value

byte[]

MemoryError

Whether a session ran out of memory to defragment with.

public bool MemoryError { get; init; }

Property Value

bool

Mic

The code over the block a device checks once it has it all.

public byte[] Mic { get; init; }

Property Value

byte[]

MicError

Whether the block's code did not check out.

public bool MicError { get; init; }

Property Value

bool

MinMcFcnt

The first frame counter a device accepts from a group.

public uint MinMcFcnt { get; init; }

Property Value

uint

Missing

How many uncoded fragments are still missing.

public byte Missing { get; init; }

Property Value

byte

NbFrag

How many uncoded fragments a block was cut into.

public ushort NbFrag { get; init; }

Property Value

ushort

NbTotalGroups

How many groups a device holds in all.

public byte NbTotalGroups { get; init; }

Property Value

byte

NextVersion

The version it would run once that image is installed.

public uint NextVersion { get; init; }

Property Value

uint

NoSession

Whether the session or group named does not exist on the device.

public bool NoSession { get; init; }

Property Value

bool

NoValidImage

Whether a device holds no valid image.

public bool NoValidImage { get; init; }

Property Value

bool

NotSupported

Whether a device manages its own clock periodicity.

public bool NotSupported { get; init; }

Property Value

bool

Package

The package identifier a version answer carries.

public byte Package { get; init; }

Property Value

byte

Padding

How many bytes of padding the last fragment carries.

public byte Padding { get; init; }

Property Value

byte

Period

The coded period between clock requests.

public byte Period { get; init; }

Property Value

byte

Periodicity

How often a device opens a ping slot inside a Class B window.

public byte Periodicity { get; init; }

Property Value

byte

Port

Which package this command belongs to, as its port.

public required byte Port { get; init; }

Property Value

byte

Reboot

The moment or the delay a reboot is set for.

public uint Reboot { get; init; }

Property Value

uint

Received

How many fragments arrived, coded, uncoded and repeated.

public ushort Received { get; init; }

Property Value

ushort

SessionCnt

The session counter, which must rise for each new block.

public ushort SessionCnt { get; init; }

Property Value

ushort

SessionReplay

Whether the session counter repeats one already used.

public bool SessionReplay { get; init; }

Property Value

bool

SessionTime

When a multicast window opens, in seconds since the GPS epoch.

public uint SessionTime { get; init; }

Property Value

uint

StartMissed

Whether the window was to start at a time already past.

public bool StartMissed { get; init; }

Property Value

bool

TimeCorrection

The seconds to add to a device's clock.

public int TimeCorrection { get; init; }

Property Value

int

TimeOut

How long it lasts at most, coded.

public byte TimeOut { get; init; }

Property Value

byte

TimeToStart

How many seconds until a window opens.

public uint TimeToStart { get; init; }

Property Value

uint

Token

The token that pairs a clock answer with its request.

public byte Token { get; init; }

Property Value

byte

Transmissions

How many requests a resynchronization command asks for.

public byte Transmissions { get; init; }

Property Value

byte

UnsupportedAlgorithm

Whether the setup named an algorithm the device does not run.

public bool UnsupportedAlgorithm { get; init; }

Property Value

bool

UnsupportedIndex

Whether the setup named a session index the device does not keep.

public bool UnsupportedIndex { get; init; }

Property Value

bool

Which way it travels.

public bool Uplink { get; init; }

Property Value

bool

Version

The package version it implements.

public byte Version { get; init; }

Property Value

byte

WrongDescriptor

Whether the descriptor is not one the device accepts.

public bool WrongDescriptor { get; init; }

Property Value

bool

Methods

Encode()

Writes this command out.

public byte[] Encode()

Returns

byte[]

The bytes it goes out as.

Exceptions

PamojaException

The port names no package, the identifier and direction name no command, or a field will not fit what carries it.

From(PamojaLorawanPackageCommand, ReadOnlySpan<byte>)

Reads a command out of the record the C ABI hands back.

public static LorawanPackageCommand From(PamojaLorawanPackageCommand flat, ReadOnlySpan<byte> data = default)

Parameters

flat PamojaLorawanPackageCommand

The record.

data ReadOnlySpan<byte>

The bytes a data fragment carried.

Returns

LorawanPackageCommand

The command.

Parse(byte, bool, ReadOnlySpan<byte>)

Reads one command of an application layer package.

public static LorawanPackageCommand Parse(byte port, bool uplink, ReadOnlySpan<byte> bytes)

Parameters

port byte

Which package: one of ClockPort, FragmentPort, MulticastPort or FirmwarePort.

uplink bool

Whether the frame carrying it traveled up.

bytes ReadOnlySpan<byte>

The message, from this command's identifier on.

Returns

LorawanPackageCommand

The command that was read.

Remarks

A data fragment takes the whole message, as TS004-2.0.0 asks, and its bytes come back on Data.

Exceptions

PamojaException

The port names no package, the message ends inside the command, or the identifier is not one the package defines.

ParseAll(byte, bool, ReadOnlySpan<byte>)

Reads every command in one message.

public static IReadOnlyList<LorawanPackageCommand> ParseAll(byte port, bool uplink, ReadOnlySpan<byte> bytes)

Parameters

port byte

Which package.

uplink bool

Whether the frame carrying them traveled up.

bytes ReadOnlySpan<byte>

The message.

Returns

IReadOnlyList<LorawanPackageCommand>

The commands that were readable, in order.

Remarks

A command does not carry its own length, so one this build does not know cannot be stepped over. Reading stops there and returns what came before it.

Exceptions

PamojaException

The port names no package.

StatusItem(ReadOnlySpan<byte>)

Reads one group record of a multicast status answer.

public static LorawanPackageCommand StatusItem(ReadOnlySpan<byte> bytes)

Parameters

bytes ReadOnlySpan<byte>

The message, from the record on.

Returns

LorawanPackageCommand

The record.

Remarks

The answer says how many groups follow; each is five bytes and carries no identifier of its own, so they are read one at a time rather than by ParseAll(byte, bool, ReadOnlySpan<byte>).

Exceptions

PamojaException

The message ends inside the record.

ToNative()

Renders this command as the record the C ABI takes.

public PamojaLorawanPackageCommand ToNative()

Returns

PamojaLorawanPackageCommand

The record.