Table of Contents

Class LoraRadio

Namespace
Pamoja.Radios
Assembly
Pamoja.Radios.dll

A LoRa radio opened on a Linux board or wired to a simulated chip.

public sealed class LoraRadio : IDisposable
Inheritance
LoraRadio
Implements
Inherited Members

Remarks

A module is reached through the kernel's spidev and GPIO character devices, so it opens only on Linux; every other platform throws PlatformNotSupportedException. Radio() gives the same class on any platform.

Every call waits on the chip, a transmission for its airtime and a reception for its timeout, so a program with a user interface makes these calls on a worker thread. One thread at a time uses a radio.

Properties

Family

The family of the radio's chip.

public LoraRadioFamily Family { get; }

Property Value

LoraRadioFamily

Methods

Configure(LoraRadioConfig)

Tunes the radio to a configuration.

public void Configure(LoraRadioConfig config)

Parameters

config LoraRadioConfig

The carrier, link, power, sync word, and IQ polarity.

Exceptions

PamojaException

The chip cannot use the settings, or did not answer.

Detect(byte)

Listens a few symbols for a LoRa preamble and reports whether one is there, as a relay's scan does, leaving the chip in standby.

public bool Detect(byte symbols)

Parameters

symbols byte

How many symbols an SX126x listens over: 1, 2, 4, 8, or 16, rounded down to one of them. An SX127x listens over one.

Returns

bool

Whether a preamble was there.

Exceptions

PamojaException

The radio is unconfigured, or the chip did not answer.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Listen()

Starts listening, frame after frame, until another call changes the mode.

public void Listen()

Exceptions

PamojaException

The radio is unconfigured, or the chip did not answer.

OpenSx126x(LoraRadioWiring, Sx126xBoard)

Opens an SX1261, SX1262, SX1268, or LLCC68 module and resets it.

public static LoraRadio OpenSx126x(LoraRadioWiring wiring, Sx126xBoard board)

Parameters

wiring LoraRadioWiring

The SPI device and the lines, which must name the BUSY line.

board Sx126xBoard

How the module wires the chip.

Returns

LoraRadio

The radio, reset and in standby, ready for Configure(LoraRadioConfig).

Exceptions

PlatformNotSupportedException

The platform is not Linux.

ArgumentOutOfRangeException

DIO3 cannot supply the TCXO voltage.

PamojaException

A device could not be opened, or no chip answered.

OpenSx127x(LoraRadioWiring, Sx127xBoard)

Opens an SX1276, SX1277, SX1278, or SX1279 module, such as an RFM95W, and resets it into LoRa mode.

public static LoraRadio OpenSx127x(LoraRadioWiring wiring, Sx127xBoard board)

Parameters

wiring LoraRadioWiring

The SPI device and the reset line.

board Sx127xBoard

How the module wires the chip.

Returns

LoraRadio

The radio, reset and in standby, ready for Configure(LoraRadioConfig).

Exceptions

PlatformNotSupportedException

The platform is not Linux.

PamojaException

A device could not be opened, or no chip answered.

Random()

Draws a random number from the noise the receiver hears, leaving the chip in standby.

public uint Random()

Returns

uint

Thirty-two bits of noise.

Remarks

Semtech's own drivers draw it the same way, and LoRaWAN 1.0.3 suggests this source for a join nonce on a device that has no other.

Exceptions

PamojaException

The chip did not answer.

ReadRegister(ushort)

Reads one register of the radio's chip.

public byte ReadRegister(ushort address)

Parameters

address ushort

A 16-bit address on the SX126x, 0x00 to 0x7F on the SX127x.

Returns

byte

The register's value.

Exceptions

PamojaException

The address is past the chip's map, or it did not answer.

Receive(TimeSpan)

Listens for one frame.

public LoraReception Receive(TimeSpan timeout)

Parameters

timeout TimeSpan

How long to listen for a frame to start.

Returns

LoraReception

The frame and its levels, or that the timeout passed or the frame was corrupt.

Exceptions

PamojaException

The radio is unconfigured, or the chip did not answer.

Sleep()

Puts the radio to sleep until the next call wakes it. An SX126x is configured again before its next frame; an SX127x keeps its registers.

public void Sleep()

Exceptions

PamojaException

The chip did not answer.

Standby()

Puts the radio in standby, which stops a transmission or a reception.

public void Standby()

Exceptions

PamojaException

The chip did not answer.

TakeFrame()

Takes the frame a listening radio has received, if one has arrived.

public LoraReception TakeFrame()

Returns

LoraReception

The frame, a corrupt frame, or Nothing when nothing has arrived.

Exceptions

PamojaException

The chip did not answer.

Transmit(ReadOnlySpan<byte>)

Sends one frame and waits for it to leave.

public ulong Transmit(ReadOnlySpan<byte> payload)

Parameters

payload ReadOnlySpan<byte>

The payload, 1 to 255 bytes.

Returns

ulong

The frame's time on air, in microseconds.

Exceptions

PamojaException

The radio is unconfigured, or the chip did not answer.

WriteRegister(ushort, byte)

Writes one register of the radio's chip.

public void WriteRegister(ushort address, byte value)

Parameters

address ushort

A 16-bit address on the SX126x, 0x00 to 0x7F on the SX127x.

value byte

The value to write.

Exceptions

PamojaException

The address is past the chip's map, or it did not answer.