ClusterDuck Protocol
Public Member Functions | Protected Member Functions | List of all members
SX126x Class Reference

Base class for SX126x series. All derived classes for SX126x (e.g. SX1262 or SX1268) inherit from this base class. This class should not be instantiated directly from Arduino sketch, only from its derived classes. More...

#include <SX126x.h>

Inheritance diagram for SX126x:
PhysicalLayer SX1262 SX1268 SX1261

Public Member Functions

 SX126x (Module *mod)
 Default constructor. More...
 
int16_t begin (float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, float currentLimit, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO=false)
 Initialization method for LoRa modem. More...
 
int16_t beginFSK (float br, float freqDev, float rxBw, float currentLimit, uint16_t preambleLength, float dataShaping, float tcxoVoltage, bool useRegulatorLDO=false)
 Initialization method for FSK modem. More...
 
int16_t reset (bool verify=true)
 Reset method. Will reset the chip to the default state using RST pin. More...
 
int16_t transmit (uint8_t *data, size_t len, uint8_t addr=0)
 Blocking binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. More...
 
int16_t receive (uint8_t *data, size_t len)
 Blocking binary receive method. Overloads for string-based transmissions are implemented in PhysicalLayer. More...
 
int16_t transmitDirect (uint32_t frf=0)
 Starts direct mode transmission. More...
 
int16_t receiveDirect ()
 Starts direct mode reception. Only implemented for PhysicalLayer compatibility, as SX126x series does not support direct mode reception. Will always return ERR_UNKNOWN. More...
 
int16_t scanChannel ()
 Performs scan for LoRa transmission in the current channel. Detects both preamble and payload. More...
 
int16_t sleep (bool retainConfig=true)
 Sets the module to sleep mode. More...
 
int16_t standby ()
 Sets the module to standby mode (overload for PhysicalLayer compatibility, uses 13 MHz RC oscillator). More...
 
int16_t standby (uint8_t mode)
 Sets the module to standby mode. More...
 
void setDio1Action (void(*func)(void))
 Sets interrupt service routine to call when DIO1 activates. More...
 
void clearDio1Action ()
 Clears interrupt service routine to call when DIO1 activates.
 
int16_t startTransmit (uint8_t *data, size_t len, uint8_t addr=0)
 Interrupt-driven binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. More...
 
int16_t startReceive (uint32_t timeout=SX126X_RX_TIMEOUT_INF)
 Interrupt-driven receive method. DIO1 will be activated when full packet is received. More...
 
int16_t startReceiveDutyCycle (uint32_t rxPeriod, uint32_t sleepPeriod)
 Interrupt-driven receive method where the device mostly sleeps and periodically wakes to listen. Note that this function assumes the unit will take 500us + TCXO_delay to change state. See datasheet section 13.1.7, version 1.2. More...
 
int16_t startReceiveDutyCycleAuto (uint16_t senderPreambleLength=0, uint16_t minSymbols=8)
 Calls startReceiveDutyCycle with rxPeriod and sleepPeriod set so the unit shouldn't miss any messages. More...
 
int16_t readData (uint8_t *data, size_t len)
 Reads data received after calling startReceive method. More...
 
int16_t setBandwidth (float bw)
 Sets LoRa bandwidth. Allowed values are 7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125.0, 250.0 and 500.0 kHz. More...
 
int16_t setSpreadingFactor (uint8_t sf)
 Sets LoRa spreading factor. Allowed values range from 5 to 12. More...
 
int16_t setCodingRate (uint8_t cr)
 Sets LoRa coding rate denominator. Allowed values range from 5 to 8. More...
 
int16_t setSyncWord (uint8_t syncWord, uint8_t controlBits=0x44)
 Sets LoRa sync word. More...
 
int16_t setCurrentLimit (float currentLimit)
 Sets current protection limit. Can be set in 0.25 mA steps. More...
 
float getCurrentLimit ()
 Reads current protection limit. More...
 
int16_t setPreambleLength (uint16_t preambleLength)
 Sets preamble length for LoRa or FSK modem. Allowed values range from 1 to 65535. More...
 
int16_t setFrequencyDeviation (float freqDev)
 Sets FSK frequency deviation. Allowed values range from 0.0 to 200.0 kHz. More...
 
int16_t setBitRate (float br)
 Sets FSK bit rate. Allowed values range from 0.6 to 300.0 kbps. More...
 
int16_t setRxBandwidth (float rxBw)
 Sets FSK receiver bandwidth. Allowed values are 4.8, 5.8, 7.3, 9.7, 11.7, 14.6, 19.5, 23.4, 29.3, 39.0, 46.9, 58.6, 78.2, 93.8, 117.3, 156.2, 187.2, 234.3, 312.0, 373.6 and 467.0 kHz. More...
 
int16_t setDataShaping (float sh)
 Sets time-bandwidth product of Gaussian filter applied for shaping. Allowed values are 0.3, 0.5, 0.7 and 1.0. Set to 0 to disable shaping. More...
 
int16_t setSyncWord (uint8_t *syncWord, uint8_t len)
 Sets FSK sync word in the form of array of up to 8 bytes. More...
 
int16_t setSyncBits (uint8_t *syncWord, uint8_t bitsLen)
 Sets FSK sync word in the form of array of up to 8 bytes. More...
 
int16_t setNodeAddress (uint8_t nodeAddr)
 Sets node address. Calling this method will also enable address filtering for node address only. More...
 
int16_t setBroadcastAddress (uint8_t broadAddr)
 Sets broadcast address. Calling this method will also enable address filtering for node and broadcast address. More...
 
int16_t disableAddressFiltering ()
 Disables address filtering. Calling this method will also erase previously set addresses. More...
 
int16_t setCRC (uint8_t len, uint16_t initial=0x1D0F, uint16_t polynomial=0x1021, bool inverted=true)
 Sets CRC configuration. More...
 
int16_t setWhitening (bool enabled, uint16_t initial=0x0100)
 Sets FSK whitening parameters. More...
 
int16_t setTCXO (float voltage, uint32_t delay=5000)
 Sets TCXO (Temperature Compensated Crystal Oscillator) configuration. More...
 
int16_t setDio2AsRfSwitch (bool enable=true)
 Set DIO2 to function as RF switch (default in Semtech example designs). More...
 
float getDataRate ()
 Gets effective data rate for the last transmitted packet. The value is calculated only for payload bytes. More...
 
float getRSSI ()
 Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. More...
 
float getSNR ()
 Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem. More...
 
size_t getPacketLength (bool update=true)
 Query modem for the packet length of received payload. More...
 
int16_t fixedPacketLengthMode (uint8_t len=SX126X_MAX_PACKET_LENGTH)
 Set modem in fixed packet length mode. Available in FSK mode only. More...
 
int16_t variablePacketLengthMode (uint8_t maxLen=SX126X_MAX_PACKET_LENGTH)
 Set modem in variable packet length mode. Available in FSK mode only. More...
 
uint32_t getTimeOnAir (size_t len)
 Get expected time-on-air for a given size of payload. More...
 
int16_t implicitHeader (size_t len)
 Set implicit header mode for future reception/transmission. More...
 
int16_t explicitHeader ()
 Set explicit header mode for future reception/transmission. More...
 
int16_t setRegulatorLDO ()
 Set regulator mode to LDO. More...
 
int16_t setRegulatorDCDC ()
 Set regulator mode to DC-DC. More...
 
int16_t setEncoding (uint8_t encoding)
 Sets transmission encoding. Available in FSK mode only. Serves only as alias for PhysicalLayer compatibility. More...
 
int16_t transmit (__FlashStringHelper *fstr, uint8_t addr=0)
 Arduino Flash String transmit method. More...
 
int16_t transmit (String &str, uint8_t addr=0)
 Arduino String transmit method. More...
 
int16_t transmit (const char *str, uint8_t addr=0)
 C-string transmit method. More...
 
virtual int16_t transmit (uint8_t *data, size_t len, uint8_t addr=0)=0
 Binary transmit method. Must be implemented in module class. More...
 
int16_t receive (String &str, size_t len=0)
 Arduino String receive method. More...
 
virtual int16_t receive (uint8_t *data, size_t len)=0
 Binary receive method. Must be implemented in module class. More...
 
int16_t startTransmit (String &str, uint8_t addr=0)
 Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes. More...
 
int16_t startTransmit (const char *str, uint8_t addr=0)
 Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes. More...
 
virtual int16_t startTransmit (uint8_t *data, size_t len, uint8_t addr=0)=0
 Interrupt-driven binary transmit method. More...
 
int16_t readData (String &str, size_t len=0)
 Reads data that was received after calling startReceive method. More...
 
virtual int16_t readData (uint8_t *data, size_t len)=0
 Reads data that was received after calling startReceive method. More...
 
- Public Member Functions inherited from PhysicalLayer
 PhysicalLayer (float freqStep, size_t maxPacketLength)
 Default constructor. More...
 
int16_t transmit (__FlashStringHelper *fstr, uint8_t addr=0)
 Arduino Flash String transmit method. More...
 
int16_t transmit (String &str, uint8_t addr=0)
 Arduino String transmit method. More...
 
int16_t transmit (const char *str, uint8_t addr=0)
 C-string transmit method. More...
 
int16_t receive (String &str, size_t len=0)
 Arduino String receive method. More...
 
int16_t startTransmit (String &str, uint8_t addr=0)
 Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes. More...
 
int16_t startTransmit (const char *str, uint8_t addr=0)
 Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes. More...
 
int16_t readData (String &str, size_t len=0)
 Reads data that was received after calling startReceive method. More...
 
float getFreqStep ()
 Gets the module frequency step size that was set in constructor. More...
 

Protected Member Functions

int16_t setTx (uint32_t timeout=0)
 
int16_t setRx (uint32_t timeout)
 
int16_t setCad ()
 
int16_t setPaConfig (uint8_t paDutyCycle, uint8_t deviceSel, uint8_t hpMax=SX126X_PA_CONFIG_HP_MAX, uint8_t paLut=SX126X_PA_CONFIG_PA_LUT)
 
int16_t writeRegister (uint16_t addr, uint8_t *data, uint8_t numBytes)
 
int16_t readRegister (uint16_t addr, uint8_t *data, uint8_t numBytes)
 
int16_t writeBuffer (uint8_t *data, uint8_t numBytes, uint8_t offset=0x00)
 
int16_t readBuffer (uint8_t *data, uint8_t numBytes)
 
int16_t setDioIrqParams (uint16_t irqMask, uint16_t dio1Mask, uint16_t dio2Mask=SX126X_IRQ_NONE, uint16_t dio3Mask=SX126X_IRQ_NONE)
 
uint16_t getIrqStatus ()
 
int16_t clearIrqStatus (uint16_t clearIrqParams=SX126X_IRQ_ALL)
 
int16_t setRfFrequency (uint32_t frf)
 
int16_t calibrateImage (uint8_t *data)
 
uint8_t getPacketType ()
 
int16_t setTxParams (uint8_t power, uint8_t rampTime=SX126X_PA_RAMP_200U)
 
int16_t setModulationParams (uint8_t sf, uint8_t bw, uint8_t cr, uint8_t ldro=0xFF)
 
int16_t setModulationParamsFSK (uint32_t br, uint8_t pulseShape, uint8_t rxBw, uint32_t freqDev)
 
int16_t setPacketParams (uint16_t preambleLength, uint8_t crcType, uint8_t payloadLength, uint8_t headerType, uint8_t invertIQ=SX126X_LORA_IQ_STANDARD)
 
int16_t setPacketParamsFSK (uint16_t preambleLength, uint8_t crcType, uint8_t syncWordLength, uint8_t addrComp, uint8_t whitening, uint8_t packetType=SX126X_GFSK_PACKET_VARIABLE, uint8_t payloadLength=0xFF, uint8_t preambleDetectorLength=SX126X_GFSK_PREAMBLE_DETECT_16)
 
int16_t setBufferBaseAddress (uint8_t txBaseAddress=0x00, uint8_t rxBaseAddress=0x00)
 
int16_t setRegulatorMode (uint8_t mode)
 
uint8_t getStatus ()
 
uint32_t getPacketStatus ()
 
uint16_t getDeviceErrors ()
 
int16_t clearDeviceErrors ()
 
int16_t startReceiveCommon ()
 
int16_t setFrequencyRaw (float freq)
 
int16_t setPacketMode (uint8_t mode, uint8_t len)
 
int16_t setHeaderType (uint8_t headerType, size_t len=0xFF)
 
int16_t fixSensitivity ()
 
int16_t fixPaClamping ()
 
int16_t fixImplicitTimeout ()
 
int16_t fixInvertedIQ (uint8_t iqConfig)
 

Detailed Description

Base class for SX126x series. All derived classes for SX126x (e.g. SX1262 or SX1268) inherit from this base class. This class should not be instantiated directly from Arduino sketch, only from its derived classes.

Constructor & Destructor Documentation

◆ SX126x()

SX126x::SX126x ( Module mod)

Default constructor.

Parameters
modInstance of Module that will be used to communicate with the radio.

Member Function Documentation

◆ begin()

int16_t SX126x::begin ( float  bw,
uint8_t  sf,
uint8_t  cr,
uint8_t  syncWord,
float  currentLimit,
uint16_t  preambleLength,
float  tcxoVoltage,
bool  useRegulatorLDO = false 
)

Initialization method for LoRa modem.

Parameters
bwLoRa bandwidth in kHz. Allowed values are 7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125.0, 250.0 and 500.0 kHz.
sfLoRa spreading factor. Allowed values are in range 5 to 12.
crLoRa coding rate denominator. Allowed values range from 5 to 8.
syncWord1-byte LoRa sync word.
currentLimitCurrent protection limit in mA.
preambleLengthLoRa preamble length in symbols. Allowed values range from 1 to 65535.
tcxoVoltageTCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip.
useRegulatorLDOuse the LDO instead of DC-DC converter (default false). This is necessary for some modules such as the LAMBDA from RF solutions.
Returns
Status Codes

◆ beginFSK()

int16_t SX126x::beginFSK ( float  br,
float  freqDev,
float  rxBw,
float  currentLimit,
uint16_t  preambleLength,
float  dataShaping,
float  tcxoVoltage,
bool  useRegulatorLDO = false 
)

Initialization method for FSK modem.

Parameters
brFSK bit rate in kbps. Allowed values range from 0.6 to 300.0 kbps.
freqDevFrequency deviation from carrier frequency in kHz. Allowed values range from 0.0 to 200.0 kHz.
rxBwReceiver bandwidth in kHz. Allowed values are 4.8, 5.8, 7.3, 9.7, 11.7, 14.6, 19.5, 23.4, 29.3, 39.0, 46.9, 58.6, 78.2, 93.8, 117.3, 156.2, 187.2, 234.3, 312.0, 373.6 and 467.0 kHz.
currentLimitCurrent protection limit in mA.
preambleLengthFSK preamble length in bits. Allowed values range from 0 to 65535.
dataShapingTime-bandwidth product of the Gaussian filter to be used for shaping. Allowed values are 0.3, 0.5, 0.7 and 1.0. Set to 0 to disable shaping.
tcxoVoltageTCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip.
useRegulatorLDOuse the LDO instead of DC-DC converter (default false). This is necessary for some modules such as the LAMBDA from RF solutions.
Returns
Status Codes

◆ disableAddressFiltering()

int16_t SX126x::disableAddressFiltering ( )

Disables address filtering. Calling this method will also erase previously set addresses.

Returns
Status Codes

◆ explicitHeader()

int16_t SX126x::explicitHeader ( )

Set explicit header mode for future reception/transmission.

Parameters
lenPayload length in bytes.
Returns
Status Codes

◆ fixedPacketLengthMode()

int16_t SX126x::fixedPacketLengthMode ( uint8_t  len = SX126X_MAX_PACKET_LENGTH)

Set modem in fixed packet length mode. Available in FSK mode only.

Parameters
lenPacket length.
Returns
Status Codes

◆ getCurrentLimit()

float SX126x::getCurrentLimit ( )

Reads current protection limit.

Returns
Currently configured overcurrent protection limit in mA.

◆ getDataRate()

float SX126x::getDataRate ( )

Gets effective data rate for the last transmitted packet. The value is calculated only for payload bytes.

Returns
Effective data rate in bps.

◆ getPacketLength()

size_t SX126x::getPacketLength ( bool  update = true)
virtual

Query modem for the packet length of received payload.

Parameters
updateUpdate received packet length. Will return cached value when set to false.
Returns
Length of last received packet in bytes.

Implements PhysicalLayer.

◆ getRSSI()

float SX126x::getRSSI ( )

Gets RSSI (Recorded Signal Strength Indicator) of the last received packet.

Returns
RSSI of the last received packet in dBm.

◆ getSNR()

float SX126x::getSNR ( )

Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem.

Returns
SNR of the last received packet in dB.

◆ getTimeOnAir()

uint32_t SX126x::getTimeOnAir ( size_t  len)

Get expected time-on-air for a given size of payload.

Parameters
lenPayload length in bytes.
Returns
Expected time-on-air in microseconds.

◆ implicitHeader()

int16_t SX126x::implicitHeader ( size_t  len)

Set implicit header mode for future reception/transmission.

Returns
Status Codes

◆ readData() [1/3]

int16_t PhysicalLayer::readData

Reads data that was received after calling startReceive method.

Parameters
strAddress of Arduino String to save the received data.
lenExpected number of characters in the message.
Returns
Status Codes

◆ readData() [2/3]

int16_t SX126x::readData ( uint8_t *  data,
size_t  len 
)
virtual

Reads data received after calling startReceive method.

Parameters
dataPointer to array to save the received binary data.
lenNumber of bytes that will be received. Must be known in advance for binary transmissions.
Returns
Status Codes

Implements PhysicalLayer.

◆ readData() [3/3]

virtual int16_t PhysicalLayer::readData

Reads data that was received after calling startReceive method.

Parameters
dataPointer to array to save the received binary data.
lenNumber of bytes that will be received. Must be known in advance for binary transmissions.
Returns
Status Codes

◆ receive() [1/3]

int16_t PhysicalLayer::receive

Arduino String receive method.

Parameters
strAddress of Arduino String to save the received data.
lenExpected number of characters in the message. Leave as 0 if expecting a unknown size packet
Returns
Status Codes

◆ receive() [2/3]

int16_t SX126x::receive ( uint8_t *  data,
size_t  len 
)
virtual

Blocking binary receive method. Overloads for string-based transmissions are implemented in PhysicalLayer.

Parameters
dataBinary data to be sent.
lenNumber of bytes to send.
Returns
Status Codes

Implements PhysicalLayer.

◆ receive() [3/3]

virtual int16_t PhysicalLayer::receive

Binary receive method. Must be implemented in module class.

Parameters
dataPointer to array to save the received binary data.
lenNumber of bytes that will be received. Must be known in advance for binary transmissions.
Returns
Status Codes

◆ receiveDirect()

int16_t SX126x::receiveDirect ( )
virtual

Starts direct mode reception. Only implemented for PhysicalLayer compatibility, as SX126x series does not support direct mode reception. Will always return ERR_UNKNOWN.

Returns
Status Codes

Implements PhysicalLayer.

◆ reset()

int16_t SX126x::reset ( bool  verify = true)

Reset method. Will reset the chip to the default state using RST pin.

Parameters
verifyWhether correct module startup should be verified. When set to true, RadioLib will attempt to verify the module has started correctly by repeatedly issuing setStandby command. Enabled by default.
Returns
Status Codes

◆ scanChannel()

int16_t SX126x::scanChannel ( )

Performs scan for LoRa transmission in the current channel. Detects both preamble and payload.

Returns
Status Codes

◆ setBandwidth()

int16_t SX126x::setBandwidth ( float  bw)

Sets LoRa bandwidth. Allowed values are 7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125.0, 250.0 and 500.0 kHz.

Parameters
bwLoRa bandwidth to be set in kHz.
Returns
Status Codes

◆ setBitRate()

int16_t SX126x::setBitRate ( float  br)

Sets FSK bit rate. Allowed values range from 0.6 to 300.0 kbps.

Parameters
brFSK bit rate to be set in kbps.
Returns
Status Codes

◆ setBroadcastAddress()

int16_t SX126x::setBroadcastAddress ( uint8_t  broadAddr)

Sets broadcast address. Calling this method will also enable address filtering for node and broadcast address.

Parameters
broadAddrNode address to be set.
Returns
Status Codes

◆ setCodingRate()

int16_t SX126x::setCodingRate ( uint8_t  cr)

Sets LoRa coding rate denominator. Allowed values range from 5 to 8.

Parameters
crLoRa coding rate denominator to be set.
Returns
Status Codes

◆ setCRC()

int16_t SX126x::setCRC ( uint8_t  len,
uint16_t  initial = 0x1D0F,
uint16_t  polynomial = 0x1021,
bool  inverted = true 
)

Sets CRC configuration.

Parameters
lenCRC length in bytes, Allowed values are 1 or 2, set to 0 to disable CRC.
initialInitial CRC value. FSK only. Defaults to 0x1D0F (CCIT CRC).
polynomialPolynomial for CRC calculation. FSK only. Defaults to 0x1021 (CCIT CRC).
invertedInvert CRC bytes. FSK only. Defaults to true (CCIT CRC).
Returns
Status Codes

◆ setCurrentLimit()

int16_t SX126x::setCurrentLimit ( float  currentLimit)

Sets current protection limit. Can be set in 0.25 mA steps.

Parameters
currentLimitcurrent protection limit to be set in mA.
Returns
Status Codes

◆ setDataShaping()

int16_t SX126x::setDataShaping ( float  sh)
virtual

Sets time-bandwidth product of Gaussian filter applied for shaping. Allowed values are 0.3, 0.5, 0.7 and 1.0. Set to 0 to disable shaping.

Parameters
shTime-bandwidth product of Gaussian filter to be set.
Returns
Status Codes

Implements PhysicalLayer.

◆ setDio1Action()

void SX126x::setDio1Action ( void(*)(void)  func)

Sets interrupt service routine to call when DIO1 activates.

Parameters
funcISR to call.

◆ setDio2AsRfSwitch()

int16_t SX126x::setDio2AsRfSwitch ( bool  enable = true)

Set DIO2 to function as RF switch (default in Semtech example designs).

Returns
Status Codes

◆ setEncoding()

int16_t SX126x::setEncoding ( uint8_t  encoding)
virtual

Sets transmission encoding. Available in FSK mode only. Serves only as alias for PhysicalLayer compatibility.

Parameters
encodingEncoding to be used. Set to 0 for NRZ, and 2 for whitening.
Returns
Status Codes

Implements PhysicalLayer.

◆ setFrequencyDeviation()

int16_t SX126x::setFrequencyDeviation ( float  freqDev)
virtual

Sets FSK frequency deviation. Allowed values range from 0.0 to 200.0 kHz.

Parameters
freqDevFSK frequency deviation to be set in kHz.
Returns
Status Codes

Implements PhysicalLayer.

◆ setNodeAddress()

int16_t SX126x::setNodeAddress ( uint8_t  nodeAddr)

Sets node address. Calling this method will also enable address filtering for node address only.

Parameters
nodeAddrNode address to be set.
Returns
Status Codes

◆ setPreambleLength()

int16_t SX126x::setPreambleLength ( uint16_t  preambleLength)

Sets preamble length for LoRa or FSK modem. Allowed values range from 1 to 65535.

Parameters
preambleLengthPreamble length to be set in symbols (LoRa) or bits (FSK).
Returns
Status Codes

◆ setRegulatorDCDC()

int16_t SX126x::setRegulatorDCDC ( )

Set regulator mode to DC-DC.

Returns
Status Codes

◆ setRegulatorLDO()

int16_t SX126x::setRegulatorLDO ( )

Set regulator mode to LDO.

Returns
Status Codes

◆ setRxBandwidth()

int16_t SX126x::setRxBandwidth ( float  rxBw)

Sets FSK receiver bandwidth. Allowed values are 4.8, 5.8, 7.3, 9.7, 11.7, 14.6, 19.5, 23.4, 29.3, 39.0, 46.9, 58.6, 78.2, 93.8, 117.3, 156.2, 187.2, 234.3, 312.0, 373.6 and 467.0 kHz.

Parameters
FSKreceiver bandwidth to be set in kHz.
Returns
Status Codes

◆ setSpreadingFactor()

int16_t SX126x::setSpreadingFactor ( uint8_t  sf)

Sets LoRa spreading factor. Allowed values range from 5 to 12.

Parameters
sfLoRa spreading factor to be set.
Returns
Status Codes

◆ setSyncBits()

int16_t SX126x::setSyncBits ( uint8_t *  syncWord,
uint8_t  bitsLen 
)

Sets FSK sync word in the form of array of up to 8 bytes.

Parameters
syncWordFSK sync word to be set.
bitsLenFSK sync word length in bits. If length is not divisible by 8, least significant bits of syncWord will be ignored.
Returns
Status Codes

◆ setSyncWord() [1/2]

int16_t SX126x::setSyncWord ( uint8_t *  syncWord,
uint8_t  len 
)

Sets FSK sync word in the form of array of up to 8 bytes.

Parameters
syncWordFSK sync word to be set.
lenFSK sync word length in bytes.
Returns
Status Codes

◆ setSyncWord() [2/2]

int16_t SX126x::setSyncWord ( uint8_t  syncWord,
uint8_t  controlBits = 0x44 
)

Sets LoRa sync word.

Parameters
syncWordLoRa sync word to be set.
controlBitsUndocumented control bits, required for compatibility purposes.
Returns
Status Codes

◆ setTCXO()

int16_t SX126x::setTCXO ( float  voltage,
uint32_t  delay = 5000 
)

Sets TCXO (Temperature Compensated Crystal Oscillator) configuration.

Parameters
TCXOreference voltage in volts. Allowed values are 1.6, 1.7, 1.8, 2.2. 2.4, 2.7, 3.0 and 3.3 V
TCXOtimeout in us. Defaults to 5000 us.

◆ setWhitening()

int16_t SX126x::setWhitening ( bool  enabled,
uint16_t  initial = 0x0100 
)

Sets FSK whitening parameters.

Parameters
enabledTrue = Whitening enabled
initialInitial value used for the whitening LFSR in FSK mode.
Returns
Status Codes

◆ sleep()

int16_t SX126x::sleep ( bool  retainConfig = true)

Sets the module to sleep mode.

Parameters
retainConfigSet to true to retain configuration of the currently active modem ("warm start") or to false to discard current configuration ("cold start"). Defaults to true.
Returns
Status Codes

◆ standby() [1/2]

int16_t SX126x::standby ( )
virtual

Sets the module to standby mode (overload for PhysicalLayer compatibility, uses 13 MHz RC oscillator).

Returns
Status Codes

Implements PhysicalLayer.

◆ standby() [2/2]

int16_t SX126x::standby ( uint8_t  mode)

Sets the module to standby mode.

Parameters
modeOscillator to be used in standby mode. Can be set to SX126X_STANDBY_RC (13 MHz RC oscillator) or SX126X_STANDBY_XOSC (32 MHz external crystal oscillator).
Returns
Status Codes

◆ startReceive()

int16_t SX126x::startReceive ( uint32_t  timeout = SX126X_RX_TIMEOUT_INF)

Interrupt-driven receive method. DIO1 will be activated when full packet is received.

Parameters
timeoutRaw timeout value, expressed as multiples of 15.625 us. Defaults to SX126X_RX_TIMEOUT_INF for infinite timeout (Rx continuous mode), set to SX126X_RX_TIMEOUT_NONE for no timeout (Rx single mode).
Returns
Status Codes

◆ startReceiveDutyCycle()

int16_t SX126x::startReceiveDutyCycle ( uint32_t  rxPeriod,
uint32_t  sleepPeriod 
)

Interrupt-driven receive method where the device mostly sleeps and periodically wakes to listen. Note that this function assumes the unit will take 500us + TCXO_delay to change state. See datasheet section 13.1.7, version 1.2.

Parameters
rxPeriodThe duration the receiver will be in Rx mode, in microseconds.
sleepPeriodThe duration the receiver will not be in Rx mode, in microseconds.
Returns
Status Codes

◆ startReceiveDutyCycleAuto()

int16_t SX126x::startReceiveDutyCycleAuto ( uint16_t  senderPreambleLength = 0,
uint16_t  minSymbols = 8 
)

Calls startReceiveDutyCycle with rxPeriod and sleepPeriod set so the unit shouldn't miss any messages.

Parameters
senderPreambleLengthExpected preamble length of the messages to receive. If set to zero, the currently configured preamble length will be used. Defaults to zero.
minSymbolsParameters will be chosen to ensure that the unit will catch at least this many symbols of any preamble of the specified length. Defaults to 8. According to Semtech, receiver requires 8 symbols to reliably latch a preamble. This makes this method redundant when transmitter preamble length is less than 17 (2*minSymbols + 1).
Returns
Status Codes

◆ startTransmit() [1/4]

int16_t PhysicalLayer::startTransmit

Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes.

Parameters
strC-string that will be transmitted.
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ startTransmit() [2/4]

int16_t PhysicalLayer::startTransmit

Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes.

Parameters
strAddress of Arduino String that will be transmitted.
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ startTransmit() [3/4]

int16_t SX126x::startTransmit ( uint8_t *  data,
size_t  len,
uint8_t  addr = 0 
)
virtual

Interrupt-driven binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer.

Parameters
dataBinary data to be sent.
lenNumber of bytes to send.
addrAddress to send the data to. Will only be added if address filtering was enabled.
Returns
Status Codes

Implements PhysicalLayer.

◆ startTransmit() [4/4]

virtual int16_t PhysicalLayer::startTransmit

Interrupt-driven binary transmit method.

Parameters
dataBinary data that will be transmitted.
lenLength of binary data to transmit (in bytes).
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ transmit() [1/5]

int16_t PhysicalLayer::transmit

Arduino Flash String transmit method.

Parameters
strPointer to Arduino Flash String that will be transmitted.
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ transmit() [2/5]

int16_t PhysicalLayer::transmit

C-string transmit method.

Parameters
strC-string that will be transmitted.
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ transmit() [3/5]

int16_t PhysicalLayer::transmit

Arduino String transmit method.

Parameters
strAddress of Arduino string that will be transmitted.
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ transmit() [4/5]

int16_t SX126x::transmit ( uint8_t *  data,
size_t  len,
uint8_t  addr = 0 
)
virtual

Blocking binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer.

Parameters
dataBinary data to be sent.
lenNumber of bytes to send.
addrAddress to send the data to. Will only be added if address filtering was enabled.
Returns
Status Codes

Implements PhysicalLayer.

◆ transmit() [5/5]

virtual int16_t PhysicalLayer::transmit

Binary transmit method. Must be implemented in module class.

Parameters
dataBinary data that will be transmitted.
lenLength of binary data to transmit (in bytes).
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ transmitDirect()

int16_t SX126x::transmitDirect ( uint32_t  frf = 0)
virtual

Starts direct mode transmission.

Parameters
frfRaw RF frequency value. Defaults to 0, required for quick frequency shifts in RTTY.
Returns
Status Codes

Implements PhysicalLayer.

◆ variablePacketLengthMode()

int16_t SX126x::variablePacketLengthMode ( uint8_t  maxLen = SX126X_MAX_PACKET_LENGTH)

Set modem in variable packet length mode. Available in FSK mode only.

Parameters
lenMaximum packet length.
Returns
Status Codes

The documentation for this class was generated from the following files: