Table of Contents

Class Sx127x

Namespace
Pamoja.Radios
Assembly
Pamoja.Radios.dll

The Semtech SX1276, SX1277, SX1278, and SX1279, and modules such as the RFM95W.

public static class Sx127x
Inheritance
Sx127x
Inherited Members

Remarks

These radios are driven through registers. Each SPI transaction starts with an address byte whose top bit is set for a write, followed by the data, and the address advances with each byte except at the FIFO. These methods give the addresses, the values a LoRa link and an output power put in them, and the readings decoded, from the SX1276/77/78/79 datasheet (Rev 7). Nothing here touches a bus.

Fields

Dio0CadDone

RegDioMapping1 with DIO0 signaling CadDone.

public const byte Dio0CadDone = 128

Field Value

byte

Dio0RxDone

RegDioMapping1 with DIO0 signaling RxDone.

public const byte Dio0RxDone = 0

Field Value

byte

Dio0TxDone

RegDioMapping1 with DIO0 signaling TxDone.

public const byte Dio0TxDone = 64

Field Value

byte

ImageCalRunningBit

The RegImageCal bit set while a calibration runs.

public const byte ImageCalRunningBit = 32

Field Value

byte

ImageCalStartBit

The RegImageCal bit that starts a calibration.

public const byte ImageCalStartBit = 64

Field Value

byte

LnaBoosted

RegLna with maximum gain and the high frequency LNA boost.

public const byte LnaBoosted = 35

Field Value

byte

PaDacDefault

RegPaDac at its reset value.

public const byte PaDacDefault = 132

Field Value

byte

PaDacHighPower

RegPaDac with the +20 dBm setting on PA_BOOST.

public const byte PaDacHighPower = 135

Field Value

byte

SyncWordPrivate

The private sync word, and the chip's reset value.

public const byte SyncWordPrivate = 18

Field Value

byte

SyncWordPublic

The sync word the datasheet reserves for LoRaWAN networks.

public const byte SyncWordPublic = 52

Field Value

byte

TcxoInputOn

RegTcxo for a module clocked by a TCXO.

public const byte TcxoInputOn = 25

Field Value

byte

Version

The RegVersion value of an SX1276, SX1277, SX1278, or SX1279.

public const byte Version = 18

Field Value

byte

Write

The bit of an address byte that makes an access a write.

public const byte Write = 128

Field Value

byte

Methods

AutomaticIf(byte, bool)

Returns RegDetectOptimize with AutomaticIFOn set or clear.

public static byte AutomaticIf(byte current, bool on)

Parameters

current byte

The register's current value.

on bool

Whether the automatic IF stays on.

Returns

byte

The register value.

FrequencyFromWord(uint)

Returns the frequency a RegFrf word selects.

public static uint FrequencyFromWord(uint word)

Parameters

word uint

The 24-bit frequency word.

Returns

uint

The carrier frequency in hertz.

FrequencyWord(uint)

Returns the 24-bit RegFrf word for a frequency.

public static uint FrequencyWord(uint frequencyHz)

Parameters

frequencyHz uint

The carrier frequency in hertz.

Returns

uint

The frequency in steps of 32 MHz over 2^19, rounded to the nearest step.

FskOpMode(Sx127xMode)

Returns the RegOpMode value for an FSK operating mode, which image calibration needs.

public static byte FskOpMode(Sx127xMode mode)

Parameters

mode Sx127xMode

The operating mode.

Returns

byte

The register value.

Returns the writes of the 500 kHz sensitivity erratum.

public static Sx127xHighBwOptimize HighBwOptimize(LoraLink link, uint frequencyHz)

Parameters

link LoraLink

The link settings, whose bandwidth decides.

frequencyHz uint

The carrier frequency in hertz.

Returns

Sx127xHighBwOptimize

RegHighBwOptimize1 and, where it is written, RegHighBwOptimize2.

Exceptions

PamojaException

The SX127x has no such bandwidth.

ImageCalStart(byte)

Returns RegImageCal to start a calibration.

public static byte ImageCalStart(byte current)

Parameters

current byte

The register's current value.

Returns

byte

The value with ImageCalStart set and AutoImageCalOn clear.

InvertIq(bool, bool)

Returns RegInvertIQ for the IQ polarity of each path.

public static byte InvertIq(bool receive, bool transmit)

Parameters

receive bool

Whether to invert the receive path, as a LoRaWAN device does for downlinks.

transmit bool

Whether to invert the transmit path, as a gateway does.

Returns

byte

The register value, with the transmit bit set for normal IQ as the reference drivers have it.

InvertIq2(bool)

Returns RegInvertIQ2 for the path in use.

public static byte InvertIq2(bool inverted)

Parameters

inverted bool

Whether that path is inverted.

Returns

byte

0x19 when inverted, else 0x1D.

LoraOpMode(Sx127xMode)

Returns the RegOpMode value for a LoRa operating mode.

public static byte LoraOpMode(Sx127xMode mode)

Parameters

mode Sx127xMode

The operating mode.

Returns

byte

The register value, with the LoRa register page selected.

ModeFromOpMode(byte)

Returns the operating mode a RegOpMode value holds.

public static Sx127xMode ModeFromOpMode(byte opMode)

Parameters

opMode byte

The register value.

Returns

Sx127xMode

The mode.

Returns the LoRa modem registers for a link at a carrier.

public static Sx127xModem Modem(LoraLink link, uint frequencyHz, ushort symbolTimeout = 0)

Parameters

link LoraLink

The link settings.

frequencyHz uint

The carrier frequency, which rules out 250 and 500 kHz below 175 MHz.

symbolTimeout ushort

A single reception timeout in symbols, whose top bits go in RegModemConfig2.

Returns

Sx127xModem

RegModemConfig1 to 3 and the SF6 detection settings.

Exceptions

PamojaException

The SX127x cannot use the link at the carrier.

ModemStatus(byte)

Decodes RegModemStat.

public static Sx127xModemStatus ModemStatus(byte value)

Parameters

value byte

The register value.

Returns

Sx127xModemStatus

The modem's live state.

OcpRegister(ushort)

Returns RegOcp for a current limit.

public static byte OcpRegister(ushort milliamps)

Parameters

milliamps ushort

The most current the amplifier may draw.

Returns

byte

The register value with the protection on.

PacketStatus(ReadOnlySpan<byte>, uint)

Decodes RegPktSnrValue and RegPktRssiValue, read together.

public static Sx127xPacketStatus PacketStatus(ReadOnlySpan<byte> answer, uint frequencyHz)

Parameters

answer ReadOnlySpan<byte>

The two register values, SNR first.

frequencyHz uint

The carrier the packet was heard at, which picks the RF port's offset.

Returns

Sx127xPacketStatus

The three signal levels.

Exceptions

ArgumentException

The answer is not two bytes.

ReadAddress(byte)

Returns the address byte that reads a register.

public static byte ReadAddress(byte address)

Parameters

address byte

The register address.

Returns

byte

The address with the write bit clear.

RssiDbm(byte, uint)

Decodes RegRssiValue.

public static double RssiDbm(byte value, uint frequencyHz)

Parameters

value byte

The register value.

frequencyHz uint

The carrier the receiver is tuned to.

Returns

double

The signal power the receiver hears right now, in dBm.

Returns the receive settings of the spurious reception erratum.

public static Sx127xSpuriousReception SpuriousReception(LoraLink link)

Parameters

link LoraLink

The link settings, whose bandwidth decides.

Returns

Sx127xSpuriousReception

The automatic IF, the hand-set IF, and the carrier offset.

Exceptions

PamojaException

The SX127x has no such bandwidth.

Returns a single reception timeout in the link's symbols.

public static ushort SymbolTimeout(LoraLink link, ulong timeoutMicros)

Parameters

link LoraLink

The link settings, whose symbol time counts the timeout.

timeoutMicros ulong

How long to listen for a preamble, in microseconds.

Returns

ushort

The timeout rounded up to whole symbols, from 4 to 1023.

TxPower(Sx127xPaOutput, sbyte)

Chooses the amplifier settings for an output power.

public static Sx127xTxPower TxPower(Sx127xPaOutput output, sbyte outputDbm)

Parameters

output Sx127xPaOutput

The amplifier output the module uses.

outputDbm sbyte

The output power wanted, in dBm.

Returns

Sx127xTxPower

The settings, clamped to what the output delivers.

TxPowerUnderCeiling(Sx127xPaOutput, LoraLinkBudget, double)

Chooses the amplifier settings that keep a link's EIRP at or under a ceiling.

public static Sx127xTxPower TxPowerUnderCeiling(Sx127xPaOutput output, LoraLinkBudget budget, double eirpCeilingDbm)

Parameters

output Sx127xPaOutput

The amplifier output the module uses.

budget LoraLinkBudget

The link budget, whose transmitting antenna and cable apply.

eirpCeilingDbm double

The EIRP limit in dBm.

Returns

Sx127xTxPower

The settings, rounded down to whole decibels.

WriteAddress(byte)

Returns the address byte that writes a register.

public static byte WriteAddress(byte address)

Parameters

address byte

The register address.

Returns

byte

The address with the write bit set.