RadioLib
Universal wireless communication library for Arduino
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 LLCC68 STM32WLx SX1261

Public Member Functions

 SX126x (Module *mod)
 Default constructor. More...
 
int16_t begin (uint8_t cr, uint8_t syncWord, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO=false)
 Initialization method for LoRa modem. More...
 
int16_t beginFSK (float br, float freqDev, float rxBw, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO=false)
 Initialization method for FSK modem. More...
 
int16_t beginLRFHSS (uint8_t bw, uint8_t cr, bool narrowGrid, float tcxoVoltage, bool useRegulatorLDO=false)
 Initialization method for LR-FHSS modem. This modem only supports transmission! More...
 
int16_t setLrFhssConfig (uint8_t bw, uint8_t cr, uint8_t hdrCount=3, uint16_t hopSeqId=0x100)
 Sets LR-FHSS configuration. More...
 
int16_t reset (bool verify=true)
 Reset method. Will reset the chip to the default state using RST pin. More...
 
int16_t transmit (const uint8_t *data, size_t len, uint8_t addr=0) override
 Blocking binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. More...
 
int16_t receive (uint8_t *data, size_t len) override
 Blocking binary receive method. Overloads for string-based transmissions are implemented in PhysicalLayer. More...
 
int16_t transmitDirect (uint32_t frf=0) override
 Starts direct mode transmission. More...
 
int16_t receiveDirect () override
 Starts direct mode reception. Only implemented for PhysicalLayer compatibility, as SX126x series does not support direct mode reception. Will always return RADIOLIB_ERR_UNKNOWN. More...
 
int16_t scanChannel () override
 Performs scan for LoRa transmission in the current channel. Detects both preamble and payload. Configuration defaults to the values recommended by AN1200.48. More...
 
int16_t scanChannel (const ChannelScanConfig_t &config) override
 Performs scan for LoRa transmission in the current channel. Detects both preamble and payload. More...
 
int16_t sleep () override
 Sets the module to sleep mode. To wake the device up, call standby(). Overload with warm start enabled for PhysicalLayer compatibility. More...
 
int16_t sleep (bool retainConfig)
 Sets the module to sleep mode. To wake the device up, call standby(). More...
 
int16_t standby () override
 Sets the module to standby mode (overload for PhysicalLayer compatibility, uses 13 MHz RC oscillator). More...
 
int16_t standby (uint8_t mode, bool wakeup=true)
 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.
 
void setPacketReceivedAction (void(*func)(void)) override
 Sets interrupt service routine to call when a packet is received. More...
 
void clearPacketReceivedAction () override
 Clears interrupt service routine to call when a packet is received.
 
void setPacketSentAction (void(*func)(void)) override
 Sets interrupt service routine to call when a packet is sent. More...
 
void clearPacketSentAction () override
 Clears interrupt service routine to call when a packet is sent.
 
void setChannelScanAction (void(*func)(void)) override
 Sets interrupt service routine to call when a channel scan is finished. More...
 
void clearChannelScanAction () override
 Clears interrupt service routine to call when a channel scan is finished.
 
int16_t startTransmit (const uint8_t *data, size_t len, uint8_t addr=0) override
 Interrupt-driven binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. More...
 
int16_t finishTransmit () override
 Clean up after transmission is done. More...
 
int16_t startReceive () override
 Interrupt-driven receive method with default parameters. Implemented for compatibility with PhysicalLayer. More...
 
int16_t startReceive (uint32_t timeout, RadioLibIrqFlags_t irqFlags=RADIOLIB_IRQ_RX_DEFAULT_FLAGS, RadioLibIrqFlags_t irqMask=RADIOLIB_IRQ_RX_DEFAULT_MASK, size_t len=0)
 Interrupt-driven receive method. DIO1 will be activated when full packet is received. More...
 
int16_t startReceiveDutyCycle (uint32_t rxPeriod, uint32_t sleepPeriod, RadioLibIrqFlags_t irqFlags=RADIOLIB_IRQ_RX_DEFAULT_FLAGS, RadioLibIrqFlags_t irqMask=RADIOLIB_IRQ_RX_DEFAULT_MASK)
 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, RadioLibIrqFlags_t irqFlags=RADIOLIB_IRQ_RX_DEFAULT_FLAGS, RadioLibIrqFlags_t irqMask=RADIOLIB_IRQ_RX_DEFAULT_MASK)
 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) override
 Reads data received after calling startReceive method. When the packet length is not known in advance, getPacketLength method must be called BEFORE calling readData! More...
 
int16_t startChannelScan () override
 Interrupt-driven channel activity detection method. DIO1 will be activated when LoRa preamble is detected, or upon timeout. Defaults to CAD parameter values recommended by AN1200.48. More...
 
int16_t startChannelScan (const ChannelScanConfig_t &config) override
 Interrupt-driven channel activity detection method. DIO1 will be activated when LoRa preamble is detected, or upon timeout. More...
 
int16_t getChannelScanResult () override
 Read the channel scan result. 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 2.5 mA steps. More...
 
float getCurrentLimit ()
 Reads current protection limit. More...
 
int16_t setPreambleLength (size_t preambleLength) override
 Sets preamble length for LoRa or FSK modem. Allowed values range from 1 to 65535. More...
 
int16_t setFrequencyDeviation (float freqDev) override
 Sets FSK frequency deviation. Allowed values range from 0.0 to 200.0 kHz. More...
 
int16_t setBitRate (float br) override
 Sets FSK bit rate. Allowed values range from 0.6 to 300.0 kbps. More...
 
int16_t setDataRate (DataRate_t dr) override
 Set data. More...
 
int16_t checkDataRate (DataRate_t dr) override
 Check the data rate can be configured by this module. 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 setRxBoostedGainMode (bool rxbgm, bool persist=true)
 Enables or disables Rx Boosted Gain mode as described in SX126x datasheet section 9.6 (SX1261/2 v2.1, SX1268 v1.1) More...
 
int16_t setDataShaping (uint8_t sh) override
 Sets time-bandwidth product of Gaussian filter applied for shaping. Allowed values are RADIOLIB_SHAPING_0_3, RADIOLIB_SHAPING_0_5, RADIOLIB_SHAPING_0_7 or RADIOLIB_SHAPING_1_0. Set to RADIOLIB_SHAPING_NONE to disable data shaping. More...
 
int16_t setSyncWord (uint8_t *syncWord, size_t len) override
 Sets FSK sync word in the form of array of up to 8 bytes. Can also set LR-FHSS sync word, but its length must be 4 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 addr)
 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=0x01FF)
 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 () const
 Gets effective data rate for the last transmitted packet. The value is calculated only for payload bytes. More...
 
float getRSSI () override
 Gets recorded signal strength indicator. Overload with packet mode enabled for PhysicalLayer compatibility. More...
 
float getRSSI (bool packet)
 Gets RSSI (Recorded Signal Strength Indicator). More...
 
float getSNR () override
 Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem. More...
 
float getFrequencyError ()
 Gets frequency error of the latest received packet. WARNING: This functionality is based on SX128x implementation and not documented on SX126x. While it seems to be working, it should be used with caution! More...
 
size_t getPacketLength (bool update=true) override
 Query modem for the packet length of received payload. More...
 
size_t getPacketLength (bool update, uint8_t *offset)
 Query modem for the packet length of received payload and Rx buffer offset. More...
 
int16_t fixedPacketLengthMode (uint8_t len=RADIOLIB_SX126X_MAX_PACKET_LENGTH)
 Set modem in fixed packet length mode. Available in FSK mode only. More...
 
int16_t variablePacketLengthMode (uint8_t maxLen=RADIOLIB_SX126X_MAX_PACKET_LENGTH)
 Set modem in variable packet length mode. Available in FSK mode only. More...
 
RadioLibTime_t getTimeOnAir (size_t len) override
 Get expected time-on-air for a given size of payload. More...
 
RadioLibTime_t calculateRxTimeout (RadioLibTime_t timeoutUs) override
 Calculate the timeout value for this specific module / series (in number of symbols or units of time) More...
 
uint32_t getIrqFlags () override
 Read currently active IRQ flags. More...
 
int16_t setIrqFlags (uint32_t irq) override
 Set interrupt on DIO1 to be sent on a specific IRQ bit (e.g. RxTimeout, CadDone). More...
 
int16_t clearIrqFlags (uint32_t irq) override
 Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone). 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) override
 Sets transmission encoding. Available in FSK mode only. Serves only as alias for PhysicalLayer compatibility. More...
 
void setRfSwitchPins (uint32_t rxEn, uint32_t txEn)
 Some modules contain external RF switch controlled by pins. This function gives RadioLib control over those pins to automatically switch between various modes: When idle both pins will be LOW, during TX the txEn pin will be HIGH, during RX the rxPin will be HIGH. More...
 
void setRfSwitchTable (const uint32_t(&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[])
 Some modules contain external RF switch controlled by pins. This function gives RadioLib control over those pins to automatically switch between various modes. More...
 
int16_t forceLDRO (bool enable)
 Forces LoRa low data rate optimization. Only available in LoRa mode. After calling this method, LDRO will always be set to the provided value, regardless of symbol length. To re-enable automatic LDRO configuration, call SX126x::autoLDRO() More...
 
int16_t autoLDRO ()
 Re-enables automatic LDRO configuration. Only available in LoRa mode. After calling this method, LDRO will be enabled automatically when symbol length exceeds 16 ms. More...
 
uint8_t randomByte () override
 Get one truly random byte from RSSI noise. More...
 
int16_t invertIQ (bool enable) override
 Enable/disable inversion of the I and Q signals. More...
 
int16_t getModem (ModemType_t *modem) override
 Get modem currently in use by the radio. More...
 
void setDirectAction (void(*func)(void)) override
 Set interrupt service routine function to call when data bit is received in direct mode. More...
 
void readBit (uint32_t pin) override
 Function to read and process data bit in direct reception mode. More...
 
int16_t uploadPatch (const uint32_t *patch, size_t len, bool nonvolatile=true)
 Upload binary patch into the SX126x device RAM. Patch is needed to e.g., enable spectral scan and must be uploaded again on every power cycle. More...
 
int16_t spectralScanStart (uint16_t numSamples, uint8_t window=RADIOLIB_SX126X_SPECTRAL_SCAN_WINDOW_DEFAULT, uint8_t interval=RADIOLIB_SX126X_SCAN_INTERVAL_8_20_US)
 Start spectral scan. Requires binary path to be uploaded. More...
 
void spectralScanAbort ()
 Abort an ongoing spectral scan.
 
int16_t spectralScanGetStatus ()
 Read the status of spectral scan. More...
 
int16_t spectralScanGetResult (uint16_t *results)
 Read the result of spectral scan. More...
 
int16_t setPaConfig (uint8_t paDutyCycle, uint8_t deviceSel, uint8_t hpMax=RADIOLIB_SX126X_PA_CONFIG_HP_MAX, uint8_t paLut=RADIOLIB_SX126X_PA_CONFIG_PA_LUT)
 Set the PA configuration. Allows user to optimize PA for a specific output power and matching network. Any calls to this method must be done after calling begin/beginFSK and/or setOutputPower. WARNING: Use at your own risk! Setting invalid values can and will lead to permanent damage! More...
 
int16_t calibrateImage (float freq)
 Perform image rejection calibration for the specified frequency. Will try to use Semtech-defined presets first, and if none of them matches, custom iamge calibration will be attempted using calibrateImageRejection. More...
 
int16_t calibrateImageRejection (float freqMin, float freqMax)
 Perform image rejection calibration for the specified frequency band. WARNING: Use at your own risk! Setting incorrect values may lead to decreased performance. More...
 
int16_t setPaRampTime (uint8_t rampTime)
 Set PA ramp-up time. Set to 200us by default. More...
 
int16_t transmit (const char *str, uint8_t addr=0)
 C-string transmit method. More...
 
virtual int16_t transmit (const uint8_t *data, size_t len, uint8_t addr=0)
 Binary transmit method. Must be implemented in module class. More...
 
virtual int16_t receive (uint8_t *data, size_t len)
 Binary receive method. Must be implemented in module class. 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 (const uint8_t *data, size_t len, uint8_t addr=0)
 Interrupt-driven binary transmit method. More...
 
virtual int16_t readData (uint8_t *data, size_t len)
 Reads data that was received after calling startReceive method. More...
 
- Public Member Functions inherited from PhysicalLayer
 PhysicalLayer (float step, size_t maxLen)
 Default constructor. More...
 
int16_t transmit (const char *str, uint8_t addr=0)
 C-string transmit method. More...
 
virtual int16_t standby (uint8_t mode)
 Sets module to a specific standby mode. 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 setFrequency (float freq)
 Sets carrier frequency. Must be implemented in module class. More...
 
virtual int16_t setOutputPower (int8_t power)
 Set output power. Must be implemented in module class if the module supports it. More...
 
virtual int16_t checkOutputPower (int8_t power, int8_t *clipped)
 Check if output power is configurable. Must be implemented in module class if the module supports it. More...
 
float getFreqStep () const
 Gets the module frequency step size that was set in constructor. More...
 
uint32_t getIrqMapped (RadioLibIrqFlags_t irq)
 Convert from radio-agnostic IRQ flags to radio-specific flags. More...
 
int16_t checkIrq (RadioLibIrqType_t irq)
 Check whether a specific IRQ bit is set (e.g. RxTimeout, CadDone). More...
 
int16_t setIrq (RadioLibIrqFlags_t irq)
 Set interrupt on specific IRQ bit(s) (e.g. RxTimeout, CadDone). Keep in mind that not all radio modules support all RADIOLIB_IRQ_ flags! More...
 
int16_t clearIrq (RadioLibIrqFlags_t irq)
 Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone). Keep in mind that not all radio modules support all RADIOLIB_IRQ_ flags! More...
 
int32_t random (int32_t max)
 Get truly random number in range 0 - max. More...
 
int32_t random (int32_t min, int32_t max)
 Get truly random number in range min - max. More...
 
int16_t startDirect ()
 Configure module parameters for direct modes. Must be called prior to "ham" modes like RTTY or AX.25. Only available in FSK mode. More...
 
int16_t setDirectSyncWord (uint32_t syncWord, uint8_t len)
 Set sync word to be used to determine start of packet in direct reception mode. More...
 
int16_t available ()
 Get the number of direct mode bytes currently available in buffer. More...
 
void dropSync ()
 Forcefully drop synchronization.
 
uint8_t read (bool drop=true)
 Get data from direct mode buffer. More...
 
virtual int16_t setDIOMapping (uint32_t pin, uint32_t value)
 Configure DIO pin mapping to get a given signal on a DIO pin (if available). More...
 
virtual int16_t setModem (ModemType_t modem)
 Set modem for the radio to use. Will perform full reset and reconfigure the radio using its default parameters. More...
 

Public Attributes

bool XTAL
 Whether the module has an XTAL (true) or TCXO (false). Defaults to false.
 
bool standbyXOSC
 Whether to use XOSC (true) or RC (false) oscillator in standby mode. Defaults to false.
 

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)
explicit

Default constructor.

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

Member Function Documentation

◆ autoLDRO()

int16_t SX126x::autoLDRO ( )

Re-enables automatic LDRO configuration. Only available in LoRa mode. After calling this method, LDRO will be enabled automatically when symbol length exceeds 16 ms.

Returns
Status Codes

◆ begin()

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

Initialization method for LoRa modem.

Parameters
crLoRa coding rate denominator. Allowed values range from 5 to 8.
syncWord1-byte LoRa sync word.
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.
useRegulatorLDOWhether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false.
Returns
Status Codes

◆ beginFSK()

int16_t SX126x::beginFSK ( float  br,
float  freqDev,
float  rxBw,
uint16_t  preambleLength,
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.
preambleLengthFSK preamble length in bits. Allowed values range from 0 to 65535.
tcxoVoltageTCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip.
useRegulatorLDOWhether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false.
Returns
Status Codes

◆ beginLRFHSS()

int16_t SX126x::beginLRFHSS ( uint8_t  bw,
uint8_t  cr,
bool  narrowGrid,
float  tcxoVoltage,
bool  useRegulatorLDO = false 
)

Initialization method for LR-FHSS modem. This modem only supports transmission!

Parameters
bwLR-FHSS bandwidth, one of RADIOLIB_SX126X_LR_FHSS_BW_* values.
crLR-FHSS coding rate, one of RADIOLIB_SX126X_LR_FHSS_CR_* values.
narrowGridWhether to use narrow (3.9 kHz) or wide (25.39 kHz) grid spacing.
tcxoVoltageTCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip.
useRegulatorLDOWhether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false.
Returns
Status Codes

◆ calculateRxTimeout()

RadioLibTime_t SX126x::calculateRxTimeout ( RadioLibTime_t  timeoutUs)
overridevirtual

Calculate the timeout value for this specific module / series (in number of symbols or units of time)

Parameters
timeoutUsTimeout in microseconds to listen for
Returns
Timeout value in a unit that is specific for the used module

Reimplemented from PhysicalLayer.

◆ calibrateImage()

int16_t SX126x::calibrateImage ( float  freq)

Perform image rejection calibration for the specified frequency. Will try to use Semtech-defined presets first, and if none of them matches, custom iamge calibration will be attempted using calibrateImageRejection.

Parameters
freqFrequency to perform the calibration for.
Returns
Status Codes

◆ calibrateImageRejection()

int16_t SX126x::calibrateImageRejection ( float  freqMin,
float  freqMax 
)

Perform image rejection calibration for the specified frequency band. WARNING: Use at your own risk! Setting incorrect values may lead to decreased performance.

Parameters
freqMinFrequency band lower bound.
freqMaxFrequency band upper bound.
Returns
Status Codes

◆ checkDataRate()

int16_t SX126x::checkDataRate ( DataRate_t  dr)
overridevirtual

Check the data rate can be configured by this module.

Parameters
drData rate struct. Interpretation depends on currently active modem (FSK or LoRa).
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ clearIrqFlags()

int16_t SX126x::clearIrqFlags ( uint32_t  irq)
overridevirtual

Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone).

Parameters
irqModule-specific IRQ flags.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ 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.

Returns
Status Codes

◆ finishTransmit()

int16_t SX126x::finishTransmit ( )
overridevirtual

Clean up after transmission is done.

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ fixedPacketLengthMode()

int16_t SX126x::fixedPacketLengthMode ( uint8_t  len = RADIOLIB_SX126X_MAX_PACKET_LENGTH)

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

Parameters
lenPacket length.
Returns
Status Codes

◆ forceLDRO()

int16_t SX126x::forceLDRO ( bool  enable)

Forces LoRa low data rate optimization. Only available in LoRa mode. After calling this method, LDRO will always be set to the provided value, regardless of symbol length. To re-enable automatic LDRO configuration, call SX126x::autoLDRO()

Parameters
enableForce LDRO to be always enabled (true) or disabled (false).
Returns
Status Codes

◆ getChannelScanResult()

int16_t SX126x::getChannelScanResult ( )
overridevirtual

Read the channel scan result.

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ getCurrentLimit()

float SX126x::getCurrentLimit ( )

Reads current protection limit.

Returns
Currently configured overcurrent protection limit in mA.

◆ getDataRate()

float SX126x::getDataRate ( ) const

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

Returns
Effective data rate in bps.

◆ getFrequencyError()

float SX126x::getFrequencyError ( )

Gets frequency error of the latest received packet. WARNING: This functionality is based on SX128x implementation and not documented on SX126x. While it seems to be working, it should be used with caution!

Returns
Frequency error in Hz.

◆ getIrqFlags()

uint32_t SX126x::getIrqFlags ( )
overridevirtual

Read currently active IRQ flags.

Returns
IRQ flags.

Reimplemented from PhysicalLayer.

◆ getModem()

int16_t SX126x::getModem ( ModemType_t *  modem)
overridevirtual

Get modem currently in use by the radio.

Parameters
modemPointer to a variable to save the retrieved configuration into.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ getPacketLength() [1/2]

size_t SX126x::getPacketLength ( bool  update,
uint8_t *  offset 
)

Query modem for the packet length of received payload and Rx buffer offset.

Parameters
updateUpdate received packet length. Will return cached value when set to false.
offsetPointer to variable to store the Rx buffer offset.
Returns
Length of last received packet in bytes.

◆ getPacketLength() [2/2]

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

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.

Reimplemented from PhysicalLayer.

◆ getRSSI() [1/2]

float SX126x::getRSSI ( )
overridevirtual

Gets recorded signal strength indicator. Overload with packet mode enabled for PhysicalLayer compatibility.

Returns
RSSI value in dBm.

Reimplemented from PhysicalLayer.

◆ getRSSI() [2/2]

float SX126x::getRSSI ( bool  packet)

Gets RSSI (Recorded Signal Strength Indicator).

Parameters
packetWhether to read last packet RSSI, or the current value.
Returns
RSSI value in dBm.

◆ getSNR()

float SX126x::getSNR ( )
overridevirtual

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.

Reimplemented from PhysicalLayer.

◆ getTimeOnAir()

RadioLibTime_t SX126x::getTimeOnAir ( size_t  len)
overridevirtual

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

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

Reimplemented from PhysicalLayer.

◆ implicitHeader()

int16_t SX126x::implicitHeader ( size_t  len)

Set implicit header mode for future reception/transmission.

Parameters
lenPayload length in bytes.
Returns
Status Codes

◆ invertIQ()

int16_t SX126x::invertIQ ( bool  enable)
overridevirtual

Enable/disable inversion of the I and Q signals.

Parameters
enableQI inversion enabled (true) or disabled (false);
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ randomByte()

uint8_t SX126x::randomByte ( )
overridevirtual

Get one truly random byte from RSSI noise.

Returns
TRNG byte.

Reimplemented from PhysicalLayer.

◆ readBit()

void SX126x::readBit ( uint32_t  pin)
overridevirtual

Function to read and process data bit in direct reception mode.

Parameters
pinPin on which to read.

Reimplemented from PhysicalLayer.

◆ readData() [1/2]

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 read. When set to 0, the packet length will be retrieved automatically. When more bytes than received are requested, only the number of bytes requested will be returned.
Returns
Status Codes

◆ readData() [2/2]

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

Reads data received after calling startReceive method. When the packet length is not known in advance, getPacketLength method must be called BEFORE calling readData!

Parameters
dataPointer to array to save the received binary data.
lenNumber of bytes that will be read. When set to 0, the packet length will be retrieved automatically. When more bytes than received are requested, only the number of bytes requested will be returned.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ receive() [1/2]

int16_t PhysicalLayer::receive

Binary receive method. Must be implemented in module class.

Parameters
dataPointer to array to save the received binary data.
lenPacket length, needed for some modules under special circumstances (e.g. LoRa implicit header mode).
Returns
Status Codes

◆ receive() [2/2]

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

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

Reimplemented from PhysicalLayer.

◆ receiveDirect()

int16_t SX126x::receiveDirect ( )
overridevirtual

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

Returns
Status Codes

Reimplemented from 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() [1/2]

int16_t SX126x::scanChannel ( )
overridevirtual

Performs scan for LoRa transmission in the current channel. Detects both preamble and payload. Configuration defaults to the values recommended by AN1200.48.

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ scanChannel() [2/2]

int16_t SX126x::scanChannel ( const ChannelScanConfig_t config)
overridevirtual

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

Parameters
configCAD configuration structure.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ 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)
overridevirtual

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

Reimplemented from PhysicalLayer.

◆ 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

◆ setChannelScanAction()

void SX126x::setChannelScanAction ( void(*)(void)  func)
overridevirtual

Sets interrupt service routine to call when a channel scan is finished.

Parameters
funcISR to call.

Reimplemented from PhysicalLayer.

◆ 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 2.5 mA steps.

Parameters
currentLimitcurrent protection limit to be set in mA. Allowed values range from 0 to 140.
Returns
Status Codes

◆ setDataRate()

int16_t SX126x::setDataRate ( DataRate_t  dr)
overridevirtual

Set data.

Parameters
drData rate struct. Interpretation depends on currently active modem (FSK or LoRa).
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ setDataShaping()

int16_t SX126x::setDataShaping ( uint8_t  sh)
overridevirtual

Sets time-bandwidth product of Gaussian filter applied for shaping. Allowed values are RADIOLIB_SHAPING_0_3, RADIOLIB_SHAPING_0_5, RADIOLIB_SHAPING_0_7 or RADIOLIB_SHAPING_1_0. Set to RADIOLIB_SHAPING_NONE to disable data shaping.

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

Reimplemented from 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

◆ setDirectAction()

void SX126x::setDirectAction ( void(*)(void)  func)
overridevirtual

Set interrupt service routine function to call when data bit is received in direct mode.

Parameters
funcPointer to interrupt service routine.

Reimplemented from PhysicalLayer.

◆ setEncoding()

int16_t SX126x::setEncoding ( uint8_t  encoding)
overridevirtual

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

Reimplemented from PhysicalLayer.

◆ setFrequencyDeviation()

int16_t SX126x::setFrequencyDeviation ( float  freqDev)
overridevirtual

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

Reimplemented from PhysicalLayer.

◆ setIrqFlags()

int16_t SX126x::setIrqFlags ( uint32_t  irq)
overridevirtual

Set interrupt on DIO1 to be sent on a specific IRQ bit (e.g. RxTimeout, CadDone).

Parameters
irqModule-specific IRQ flags.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ setLrFhssConfig()

int16_t SX126x::setLrFhssConfig ( uint8_t  bw,
uint8_t  cr,
uint8_t  hdrCount = 3,
uint16_t  hopSeqId = 0x100 
)

Sets LR-FHSS configuration.

Parameters
bwLR-FHSS bandwidth, one of RADIOLIB_SX126X_LR_FHSS_BW_* values.
crLR-FHSS coding rate, one of RADIOLIB_SX126X_LR_FHSS_CR_* values.
hdrCountHeader packet count, 1 - 4. Defaults to 3.
hopSeqId9-bit seed number for PRNG generation of the hopping sequence. Defaults to 0x13A.
Returns
Status Codes

◆ setNodeAddress()

int16_t SX126x::setNodeAddress ( uint8_t  addr)

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

Parameters
addrNode address to be set.
Returns
Status Codes

◆ setPacketReceivedAction()

void SX126x::setPacketReceivedAction ( void(*)(void)  func)
overridevirtual

Sets interrupt service routine to call when a packet is received.

Parameters
funcISR to call.

Reimplemented from PhysicalLayer.

◆ setPacketSentAction()

void SX126x::setPacketSentAction ( void(*)(void)  func)
overridevirtual

Sets interrupt service routine to call when a packet is sent.

Parameters
funcISR to call.

Reimplemented from PhysicalLayer.

◆ setPaConfig()

int16_t SX126x::setPaConfig ( uint8_t  paDutyCycle,
uint8_t  deviceSel,
uint8_t  hpMax = RADIOLIB_SX126X_PA_CONFIG_HP_MAX,
uint8_t  paLut = RADIOLIB_SX126X_PA_CONFIG_PA_LUT 
)

Set the PA configuration. Allows user to optimize PA for a specific output power and matching network. Any calls to this method must be done after calling begin/beginFSK and/or setOutputPower. WARNING: Use at your own risk! Setting invalid values can and will lead to permanent damage!

Parameters
paDutyCyclePA duty cycle raw value.
deviceSelDevice select, usually RADIOLIB_SX126X_PA_CONFIG_SX1261, RADIOLIB_SX126X_PA_CONFIG_SX1262 or RADIOLIB_SX126X_PA_CONFIG_SX1268.
hpMaxhpMax raw value.
paLutpaLut PA lookup table raw value.
Returns
Status Codes

◆ setPaRampTime()

int16_t SX126x::setPaRampTime ( uint8_t  rampTime)

Set PA ramp-up time. Set to 200us by default.

Returns
Status Codes

◆ setPreambleLength()

int16_t SX126x::setPreambleLength ( size_t  preambleLength)
overridevirtual

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

Reimplemented from PhysicalLayer.

◆ 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

◆ setRfSwitchPins()

void SX126x::setRfSwitchPins ( uint32_t  rxEn,
uint32_t  txEn 
)

Some modules contain external RF switch controlled by pins. This function gives RadioLib control over those pins to automatically switch between various modes: When idle both pins will be LOW, during TX the txEn pin will be HIGH, during RX the rxPin will be HIGH.

Radiolib will automatically set the pin mode and value of these pins, so do not control them from the sketch.

When more than two pins or more control over the output values are needed, use the setRfSwitchTable() function.

Parameters
rxEnRX enable pin.
txEnTX enable pin.

◆ setRfSwitchTable()

void SX126x::setRfSwitchTable ( const uint32_t(&)  pins[Module::RFSWITCH_MAX_PINS],
const Module::RfSwitchMode_t  table[] 
)

Some modules contain external RF switch controlled by pins. This function gives RadioLib control over those pins to automatically switch between various modes.

Radiolib will automatically set the pin mode and value of these pins, so do not control them from the sketch.

Parameters
pinsA reference to an array of pins to control. This should always be an array of 3 elements. If you need less pins, use RADIOLIB_NC for the unused elements.
tableA reference to an array of pin values to use for each supported mode. Each element is an RfSwitchMode_T struct that lists the mode for which it applies and the values for each of the pins passed in the pins argument respectively.

The pins array will be copied into the Module object, so the original array can be deallocated after this call. However, a reference to the table array will be stored, so that array must remain valid as long RadioLib is being used.

The mode field in each table row should normally use any of the MODE_* constants from the Module::OpMode_t enum. However, some radios support additional modes and will define their own OpMode_t enum.

The length of the table is variable (to support radios that add additional modes), so the table must always be terminated with the special END_OF_MODE_TABLE value.

Normally all modes should be listed in the table, but for some radios, modes can be omitted to indicate they are not supported (e.g. when a radio has a high power and low power TX mode but external circuitry only supports low power). If applicable, this is documented in the radio class itself.

Example

For example, on a board that has an RF switch with an enable pin connected to PA0 and a TX/RX select pin connected to PA1:

// In global scope, define the pin array and mode table
static const uint32_t rfswitch_pins[] =
{PA0, PA1, RADIOLIB_NC};
static const Module::RfSwitchMode_t rfswitch_table[] = {
{Module::MODE_IDLE, {LOW, LOW}},
{Module::MODE_RX, {HIGH, LOW}},
{Module::MODE_TX, {HIGH, HIGH}},
Module::END_OF_MODE_TABLE,
};
void setup() {
...
// Then somewhere in setup, pass them to radiolib
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
...
}
@ MODE_TX
Transmission mode.
Definition: Module.h:119
@ MODE_IDLE
Idle mode.
Definition: Module.h:113
@ MODE_RX
Receive mode.
Definition: Module.h:116
Description of RF switch pin states for a single mode. See setRfSwitchTable for details.
Definition: Module.h:89

◆ 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
rxBwFSK receiver bandwidth to be set in kHz.
Returns
Status Codes

◆ setRxBoostedGainMode()

int16_t SX126x::setRxBoostedGainMode ( bool  rxbgm,
bool  persist = true 
)

Enables or disables Rx Boosted Gain mode as described in SX126x datasheet section 9.6 (SX1261/2 v2.1, SX1268 v1.1)

Parameters
rxbgmTrue for Rx Boosted Gain, false for Rx Power Saving Gain
persistTrue to persist Rx gain setting when waking up from warm-start mode (e.g. when using Rx duty cycle mode).
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,
size_t  len 
)
overridevirtual

Sets FSK sync word in the form of array of up to 8 bytes. Can also set LR-FHSS sync word, but its length must be 4 bytes.

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

Reimplemented from PhysicalLayer.

◆ 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
voltageTCXO reference voltage in volts. Allowed values are 1.6, 1.7, 1.8, 2.2. 2.4, 2.7, 3.0 and 3.3 V. Set to 0 to disable TCXO. NOTE: After setting this parameter to 0, the module will be reset (since there's no other way to disable TCXO).
delayTCXO timeout in us. Defaults to 5000 us.
Returns
Status Codes

◆ setWhitening()

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

Sets FSK whitening parameters.

Parameters
enabledTrue = Whitening enabled
initialInitial value used for the whitening LFSR in FSK mode. By default set to 0x01FF for compatibility with SX127x and LoRaWAN.
Returns
Status Codes

◆ sleep() [1/2]

int16_t SX126x::sleep ( )
overridevirtual

Sets the module to sleep mode. To wake the device up, call standby(). Overload with warm start enabled for PhysicalLayer compatibility.

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ sleep() [2/2]

int16_t SX126x::sleep ( bool  retainConfig)

Sets the module to sleep mode. To wake the device up, call standby().

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

◆ spectralScanGetResult()

int16_t SX126x::spectralScanGetResult ( uint16_t *  results)

Read the result of spectral scan.

Parameters
resultsArray to which the results will be saved, must be RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE long.
Returns
Status Codes

◆ spectralScanGetStatus()

int16_t SX126x::spectralScanGetStatus ( )

Read the status of spectral scan.

Returns
Status Codes

◆ spectralScanStart()

int16_t SX126x::spectralScanStart ( uint16_t  numSamples,
uint8_t  window = RADIOLIB_SX126X_SPECTRAL_SCAN_WINDOW_DEFAULT,
uint8_t  interval = RADIOLIB_SX126X_SCAN_INTERVAL_8_20_US 
)

Start spectral scan. Requires binary path to be uploaded.

Parameters
numSamplesNumber of samples for each scan. Fewer samples = better temporal resolution.
windowRSSI averaging window size.
intervalScan interval length, one of RADIOLIB_SX126X_SCAN_INTERVAL_* macros.
Returns
Status Codes

◆ standby() [1/2]

int16_t SX126x::standby ( )
overridevirtual

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

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ standby() [2/2]

int16_t SX126x::standby ( uint8_t  mode,
bool  wakeup = true 
)

Sets the module to standby mode.

Parameters
modeOscillator to be used in standby mode. Can be set to RADIOLIB_SX126X_STANDBY_RC (13 MHz RC oscillator) or RADIOLIB_SX126X_STANDBY_XOSC (32 MHz external crystal oscillator).
wakeupWhether to force the module to wake up. Setting to true will immediately attempt to wake up the module.
Returns
Status Codes

◆ startChannelScan() [1/2]

int16_t SX126x::startChannelScan ( )
overridevirtual

Interrupt-driven channel activity detection method. DIO1 will be activated when LoRa preamble is detected, or upon timeout. Defaults to CAD parameter values recommended by AN1200.48.

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ startChannelScan() [2/2]

int16_t SX126x::startChannelScan ( const ChannelScanConfig_t config)
overridevirtual

Interrupt-driven channel activity detection method. DIO1 will be activated when LoRa preamble is detected, or upon timeout.

Parameters
configCAD configuration structure.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ startReceive() [1/2]

int16_t SX126x::startReceive ( )
overridevirtual

Interrupt-driven receive method with default parameters. Implemented for compatibility with PhysicalLayer.

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ startReceive() [2/2]

int16_t SX126x::startReceive ( uint32_t  timeout,
RadioLibIrqFlags_t  irqFlags = RADIOLIB_IRQ_RX_DEFAULT_FLAGS,
RadioLibIrqFlags_t  irqMask = RADIOLIB_IRQ_RX_DEFAULT_MASK,
size_t  len = 0 
)
virtual

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

Parameters
timeoutReceive mode type and/or raw timeout value, expressed as multiples of 15.625 us. When set to RADIOLIB_SX126X_RX_TIMEOUT_INF, the timeout will be infinite and the device will remain in Rx mode until explicitly commanded to stop (Rx continuous mode). When set to RADIOLIB_SX126X_RX_TIMEOUT_NONE, there will be no timeout and the device will return to standby when a packet is received (Rx single mode). For any other value, timeout will be applied and signal will be generated on DIO1 for conditions defined by irqFlags and irqMask.
irqFlagsSets the IRQ flags, defaults to RX done, RX timeout, CRC error and header error.
irqMaskSets the mask of IRQ flags that will trigger DIO1, defaults to RX done.
lenOnly for PhysicalLayer compatibility, not used.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ startReceiveDutyCycle()

int16_t SX126x::startReceiveDutyCycle ( uint32_t  rxPeriod,
uint32_t  sleepPeriod,
RadioLibIrqFlags_t  irqFlags = RADIOLIB_IRQ_RX_DEFAULT_FLAGS,
RadioLibIrqFlags_t  irqMask = RADIOLIB_IRQ_RX_DEFAULT_MASK 
)

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.
irqFlagsSets the IRQ flags, defaults to RX done, RX timeout, CRC error and header error.
irqMaskSets the mask of IRQ flags that will trigger DIO1, defaults to RX done.
Returns
Status Codes

◆ startReceiveDutyCycleAuto()

int16_t SX126x::startReceiveDutyCycleAuto ( uint16_t  senderPreambleLength = 0,
uint16_t  minSymbols = 8,
RadioLibIrqFlags_t  irqFlags = RADIOLIB_IRQ_RX_DEFAULT_FLAGS,
RadioLibIrqFlags_t  irqMask = RADIOLIB_IRQ_RX_DEFAULT_MASK 
)

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).
irqFlagsSets the IRQ flags, defaults to RX done, RX timeout, CRC error and header error.
irqMaskSets the mask of IRQ flags that will trigger DIO1, defaults to RX done.
Returns
Status Codes

◆ startTransmit() [1/3]

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/3]

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

◆ startTransmit() [3/3]

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

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

Reimplemented from PhysicalLayer.

◆ transmit() [1/3]

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() [2/3]

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

◆ transmit() [3/3]

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

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

Reimplemented from PhysicalLayer.

◆ transmitDirect()

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

Starts direct mode transmission.

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

Reimplemented from PhysicalLayer.

◆ uploadPatch()

int16_t SX126x::uploadPatch ( const uint32_t *  patch,
size_t  len,
bool  nonvolatile = true 
)

Upload binary patch into the SX126x device RAM. Patch is needed to e.g., enable spectral scan and must be uploaded again on every power cycle.

Parameters
patchBinary patch to upload.
lenLength of the binary patch in 4-byte words.
nonvolatileSet to true when the patch is saved in non-volatile memory of the host processor, or to false when the patch is in its RAM.
Returns
Status Codes

◆ variablePacketLengthMode()

int16_t SX126x::variablePacketLengthMode ( uint8_t  maxLen = RADIOLIB_SX126X_MAX_PACKET_LENGTH)

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

Parameters
maxLenMaximum packet length.
Returns
Status Codes

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