Table of Contents

Class LorawanMacCommand

Namespace
Pamoja.Lorawan
Assembly
Pamoja.Lorawan.dll

One of the commands a network and a device configure each other with.

public sealed class LorawanMacCommand
Inheritance
LorawanMacCommand
Inherited Members

Remarks

A frame carries these either in its options field, at most fifteen bytes of them, or as a whole payload on port 0.

Cid names the command and Direction says which way it travels; together they decide which of the other properties carry anything. The same identifier means a different command in each direction, so the direction is always given and never guessed.

Fields

MaxLength

The longest command, in bytes: a relay's UpdateUplinkListReq.

public const int MaxLength = 27

Field Value

int

Properties

Action

What a join filter rule does, or whether a trusted end device is read or removed.

public byte Action { get; init; }

Property Value

byte

ActionAck

Whether its action was valid.

public bool ActionAck { get; init; }

Property Value

bool

BackOff

How many WOR frames without an acknowledgment before an uplink goes anyway.

public byte BackOff { get; init; }

Property Value

byte

Battery

A device battery level: 0 on external power, 255 when it cannot tell.

public byte Battery { get; init; }

Property Value

byte

BucketSize

Its bucket size multiplier, as TS011-1.0.1 table 55 codes it.

public byte BucketSize { get; init; }

Property Value

byte

CadPeriodicity

How often a relay scans, as TS011-1.0.1 table 18 codes it.

public byte CadPeriodicity { get; init; }

Property Value

byte

CadPeriodicityAck

Whether the scan period was valid.

public bool CadPeriodicityAck { get; init; }

Property Value

bool

ChannelAck

Whether the frequency was usable.

public bool ChannelAck { get; init; }

Property Value

bool

ChannelMask

Which channels may carry an uplink.

public ushort ChannelMask { get; init; }

Property Value

ushort

ChannelMaskAck

Whether the channel mask was usable.

public bool ChannelMaskAck { get; init; }

Property Value

bool

Cid

The identifier this command travels under.

public required byte Cid { get; init; }

Property Value

byte

CombinedRulesAck

Whether a join filter rule was one to create, change or remove.

public bool CombinedRulesAck { get; init; }

Property Value

bool

DataRate

The data rate a network asks a device to use.

public byte DataRate { get; init; }

Property Value

byte

DataRateAck

Whether the data rate was set.

public bool DataRateAck { get; init; }

Property Value

bool

DataRateRangeOk

Whether the device can run that range of rates.

public bool DataRateRangeOk { get; init; }

Property Value

bool

DefaultChannelIndex

Which of the region's relay channels is a relay's default one.

public byte DefaultChannelIndex { get; init; }

Property Value

byte

DefaultChannelIndexAck

Whether the default channel was valid.

public bool DefaultChannelIndexAck { get; init; }

Property Value

bool

Delay

How long a device waits before its first receive window, as coded.

public byte Delay { get; init; }

Property Value

byte

DevAddr

An end device address a relay command names.

public uint DevAddr { get; init; }

Property Value

uint

Direction

Which way it travels.

public required LorawanDirection Direction { get; init; }

Property Value

LorawanDirection

DownlinkDwell

Whether a downlink is.

public bool DownlinkDwell { get; init; }

Property Value

bool

Enabled

Whether a relay runs.

public bool Enabled { get; init; }

Property Value

bool

Eui

Those bytes, most significant first, with the rest zero.

public byte[] Eui { get; init; }

Property Value

byte[]

EuiLen

How many leading bytes of JoinEUI and DevEUI a join filter rule matches.

public byte EuiLen { get; init; }

Property Value

byte

EuiLenAck

Whether its length was valid.

public bool EuiLenAck { get; init; }

Property Value

bool

Fraction

The fraction of that second, in steps of one part in 256.

public byte Fraction { get; init; }

Property Value

byte

FrequencyHz

A frequency in hertz, for the windows and the channel commands.

public uint FrequencyHz { get; init; }

Property Value

uint

FrequencyOk

Whether its radio can reach that frequency.

public bool FrequencyOk { get; init; }

Property Value

bool

Gateways

How many gateways heard it.

public byte Gateways { get; init; }

Property Value

byte

GlobalUplinkBucketSize

The global uplink bucket size multiplier.

public byte GlobalUplinkBucketSize { get; init; }

Property Value

byte

GlobalUplinkReloadRate

Uplinks a relay forwards an hour across every trusted end device.

public byte GlobalUplinkReloadRate { get; init; }

Property Value

byte

Index

Which channel a channel command names.

public byte Index { get; init; }

Property Value

byte

IndexAck

Whether a trusted list entry was in use.

public bool IndexAck { get; init; }

Property Value

bool

JoinRequestBucketSize

The join request bucket size multiplier.

public byte JoinRequestBucketSize { get; init; }

Property Value

byte

JoinRequestReloadRate

Join requests a relay forwards an hour, 127 for no limit.

public byte JoinRequestReloadRate { get; init; }

Property Value

byte

Margin

How far above the floor a link check arrived, in dB.

public byte Margin { get; init; }

Property Value

byte

MaskControl

Which block of sixteen channels that mask applies to.

public byte MaskControl { get; init; }

Property Value

byte

MaxDataRate

The fastest rate allowed on it.

public byte MaxDataRate { get; init; }

Property Value

byte

MaxDutyCycle

The share of the air a device is held to, as one over two to this.

public byte MaxDutyCycle { get; init; }

Property Value

byte

MaxEirp

The coded transmit power ceiling a region imposes.

public byte MaxEirp { get; init; }

Property Value

byte

MinDataRate

The slowest rate allowed on it.

public byte MinDataRate { get; init; }

Property Value

byte

NotifyBucketSize

The notification bucket size multiplier.

public byte NotifyBucketSize { get; init; }

Property Value

byte

NotifyReloadRate

New end device notifications a relay sends an hour.

public byte NotifyReloadRate { get; init; }

Property Value

byte

OverallBucketSize

The overall bucket size multiplier.

public byte OverallBucketSize { get; init; }

Property Value

byte

OverallReloadRate

Every message a relay sends an hour.

public byte OverallReloadRate { get; init; }

Property Value

byte

PowerAck

Whether the power was set.

public bool PowerAck { get; init; }

Property Value

bool

RelayMode

How an end device uses a relay, as TS011-1.0.1 table 40 codes it.

public byte RelayMode { get; init; }

Property Value

byte

ReloadRate

Tokens a trusted end device earns an hour, 63 for no limit.

public byte ReloadRate { get; init; }

Property Value

byte

ResetLimitCounters

What a forwarding limit command does to a relay's token counters, as table 63 codes it.

public byte ResetLimitCounters { get; init; }

Property Value

byte

RootWorSKey

An end device's root relay session key.

public byte[] RootWorSKey { get; init; }

Property Value

byte[]

RssiDbm

The signal strength of a WOR frame a relay could not verify, in dBm.

public short RssiDbm { get; init; }

Property Value

short

Rx1Offset

How far the first receive window sits below the uplink rate.

public byte Rx1Offset { get; init; }

Property Value

byte

Rx1OffsetAck

Whether the window offset was in range.

public bool Rx1OffsetAck { get; init; }

Property Value

bool

Rx2DataRate

The rate of the second receive window.

public byte Rx2DataRate { get; init; }

Property Value

byte

Rx2DataRateAck

Whether the window rate was known.

public bool Rx2DataRateAck { get; init; }

Property Value

bool

SecondChannelAckOffset

How far above its frequency the second channel is acknowledged, as table 35 codes it.

public byte SecondChannelAckOffset { get; init; }

Property Value

byte

SecondChannelAckOffsetAck

Whether its acknowledgment offset was valid.

public bool SecondChannelAckOffsetAck { get; init; }

Property Value

bool

SecondChannelDataRate

The second channel's data rate; its frequency is the frequency field.

public byte SecondChannelDataRate { get; init; }

Property Value

byte

SecondChannelDataRateAck

Whether the second channel's data rate was valid.

public bool SecondChannelDataRateAck { get; init; }

Property Value

bool

SecondChannelFrequencyAck

Whether its frequency was valid.

public bool SecondChannelFrequencyAck { get; init; }

Property Value

bool

SecondChannelIndex

Whether a relay configuration sets a second channel, 1 for yes.

public byte SecondChannelIndex { get; init; }

Property Value

byte

SecondChannelIndexAck

Whether the second channel index was valid.

public bool SecondChannelIndexAck { get; init; }

Property Value

bool

Seconds

Seconds since the GPS epoch.

public uint Seconds { get; init; }

Property Value

uint

SmartEnableLevel

How many unanswered uplinks turn relaying on, as table 41 codes it.

public byte SmartEnableLevel { get; init; }

Property Value

byte

SnrDb

Its signal-to-noise ratio, in dB.

public sbyte SnrDb { get; init; }

Property Value

sbyte

SnrMargin

The signal-to-noise ratio of the last request, in dB.

public sbyte SnrMargin { get; init; }

Property Value

sbyte

Transmissions

How many times to send an unconfirmed uplink.

public byte Transmissions { get; init; }

Property Value

byte

TxPower

The transmit power it may use, as a ceiling.

public byte TxPower { get; init; }

Property Value

byte

UplinkDwell

Whether an uplink is held to 400 ms of air time.

public bool UplinkDwell { get; init; }

Property Value

bool

UplinkFrequencyExists

Whether the channel already had an uplink frequency to pair with.

public bool UplinkFrequencyExists { get; init; }

Property Value

bool

Wfcnt

A wake-on-radio frame counter.

public uint Wfcnt { get; init; }

Property Value

uint

Methods

Encode()

Writes this command out.

public byte[] Encode()

Returns

byte[]

The bytes it goes out as.

Exceptions

PamojaException

If the identifier and direction name no command, or a field will not fit what carries it.

From(PamojaLorawanMacCommand)

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

public static LorawanMacCommand From(PamojaLorawanMacCommand flat)

Parameters

flat PamojaLorawanMacCommand

The record.

Returns

LorawanMacCommand

The command.

Parse(LorawanDirection, ReadOnlySpan<byte>)

Reads the commands packed into a field.

public static IReadOnlyList<LorawanMacCommand> Parse(LorawanDirection direction, ReadOnlySpan<byte> bytes)

Parameters

direction LorawanDirection

Which way the frame carrying them travels.

bytes ReadOnlySpan<byte>

The options field, or a payload sent on port 0.

Returns

IReadOnlyList<LorawanMacCommand>

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

If the field cannot be read at all.

ArgumentOutOfRangeException

direction is not one of the LorawanDirection values.

ToNative()

Renders this command as the record the C ABI takes.

public PamojaLorawanMacCommand ToNative()

Returns

PamojaLorawanMacCommand

The record.

Exceptions

ArgumentOutOfRangeException

Direction is not one of the LorawanDirection values.