Class Sx127x
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
Dio0RxDone
RegDioMapping1 with DIO0 signaling RxDone.
public const byte Dio0RxDone = 0
Field Value
Dio0TxDone
RegDioMapping1 with DIO0 signaling TxDone.
public const byte Dio0TxDone = 64
Field Value
ImageCalRunningBit
The RegImageCal bit set while a calibration runs.
public const byte ImageCalRunningBit = 32
Field Value
ImageCalStartBit
The RegImageCal bit that starts a calibration.
public const byte ImageCalStartBit = 64
Field Value
LnaBoosted
RegLna with maximum gain and the high frequency LNA boost.
public const byte LnaBoosted = 35
Field Value
PaDacDefault
RegPaDac at its reset value.
public const byte PaDacDefault = 132
Field Value
PaDacHighPower
RegPaDac with the +20 dBm setting on PA_BOOST.
public const byte PaDacHighPower = 135
Field Value
SyncWordPrivate
The private sync word, and the chip's reset value.
public const byte SyncWordPrivate = 18
Field Value
SyncWordPublic
The sync word the datasheet reserves for LoRaWAN networks.
public const byte SyncWordPublic = 52
Field Value
TcxoInputOn
RegTcxo for a module clocked by a TCXO.
public const byte TcxoInputOn = 25
Field Value
Version
The RegVersion value of an SX1276, SX1277, SX1278, or SX1279.
public const byte Version = 18
Field Value
Write
The bit of an address byte that makes an access a write.
public const byte Write = 128
Field Value
Methods
AutomaticIf(byte, bool)
Returns RegDetectOptimize with AutomaticIFOn set or clear.
public static byte AutomaticIf(byte current, bool on)
Parameters
Returns
- byte
The register value.
FrequencyFromWord(uint)
Returns the frequency a RegFrf word selects.
public static uint FrequencyFromWord(uint word)
Parameters
worduintThe 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
frequencyHzuintThe 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
modeSx127xModeThe operating mode.
Returns
- byte
The register value.
HighBwOptimize(LoraLink, uint)
Returns the writes of the 500 kHz sensitivity erratum.
public static Sx127xHighBwOptimize HighBwOptimize(LoraLink link, uint frequencyHz)
Parameters
linkLoraLinkThe link settings, whose bandwidth decides.
frequencyHzuintThe 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
currentbyteThe 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
receiveboolWhether to invert the receive path, as a LoRaWAN device does for downlinks.
transmitboolWhether 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
invertedboolWhether 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
modeSx127xModeThe 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
opModebyteThe register value.
Returns
- Sx127xMode
The mode.
Modem(LoraLink, uint, ushort)
Returns the LoRa modem registers for a link at a carrier.
public static Sx127xModem Modem(LoraLink link, uint frequencyHz, ushort symbolTimeout = 0)
Parameters
linkLoraLinkThe link settings.
frequencyHzuintThe carrier frequency, which rules out 250 and 500 kHz below 175 MHz.
symbolTimeoutushortA 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
valuebyteThe register value.
Returns
- Sx127xModemStatus
The modem's live state.
OcpRegister(ushort)
Returns RegOcp for a current limit.
public static byte OcpRegister(ushort milliamps)
Parameters
milliampsushortThe 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
answerReadOnlySpan<byte>The two register values, SNR first.
frequencyHzuintThe 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
addressbyteThe 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
Returns
- double
The signal power the receiver hears right now, in dBm.
SpuriousReception(LoraLink)
Returns the receive settings of the spurious reception erratum.
public static Sx127xSpuriousReception SpuriousReception(LoraLink link)
Parameters
linkLoraLinkThe 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.
SymbolTimeout(LoraLink, ulong)
Returns a single reception timeout in the link's symbols.
public static ushort SymbolTimeout(LoraLink link, ulong timeoutMicros)
Parameters
linkLoraLinkThe link settings, whose symbol time counts the timeout.
timeoutMicrosulongHow 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
outputSx127xPaOutputThe amplifier output the module uses.
outputDbmsbyteThe 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
outputSx127xPaOutputThe amplifier output the module uses.
budgetLoraLinkBudgetThe link budget, whose transmitting antenna and cable apply.
eirpCeilingDbmdoubleThe 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
addressbyteThe register address.
Returns
- byte
The address with the write bit set.