RadioLib
Universal wireless communication library for Arduino
LR11x0 Class Reference

Base class for LR11x0 series. All derived classes for LR11x0 (e.g. LR1110 or LR1120) inherit from this base class. This class should not be instantiated directly from user code, only from its derived classes. More...

#include <LR11x0.h>

Inheritance diagram for LR11x0:
PhysicalLayer LR1110 LR1120 LR1121

Public Member Functions

 LR11x0 (Module *mod)
 Default constructor. More...
 
int16_t begin (float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, float tcxoVoltage)
 Initialization method for LoRa modem. More...
 
int16_t beginGFSK (float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength, float tcxoVoltage)
 Initialization method for FSK modem. More...
 
int16_t beginLRFHSS (uint8_t bw, uint8_t cr, int8_t power, float tcxoVoltage)
 Initialization method for LR-FHSS modem. More...
 
int16_t reset ()
 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) 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. More...
 
int16_t scanChannel (uint8_t symbolNum, uint8_t detPeak, uint8_t detMin)
 Performs scan for LoRa transmission in the current channel. Detects both preamble and payload. 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...
 
int16_t sleep (bool retainConfig=true, uint32_t sleepTime=0)
 Sets the module to sleep mode. To wake the device up, call standby(). More...
 
void setIrqAction (void(*func)(void))
 Sets interrupt service routine to call when IRQ1 activates. More...
 
void clearIrqAction ()
 Clears interrupt service routine to call when IRQ1 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.
 
int16_t startTransmit (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, uint32_t irqFlags=RADIOLIB_LR11X0_IRQ_RX_DONE, uint32_t irqMask=0, size_t len=0)
 Interrupt-driven receive method. IRQ1 will be activated when full packet is received. More...
 
uint32_t getIrqStatus ()
 Reads the current IRQ status. 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. IRQ1 will be activated when LoRa preamble is detected, or upon timeout. Defaults to CAD parameter values recommended by AN1200.48. More...
 
int16_t startChannelScan (uint8_t symbolNum, uint8_t detPeak, uint8_t detMin)
 Interrupt-driven channel activity detection method. IRQ1 will be activated when LoRa preamble is detected, or upon timeout. More...
 
int16_t getChannelScanResult () override
 Read the channel scan result. More...
 
int16_t setOutputPower (int8_t power) override
 Sets output power. Allowed values are in range from -9 to 22 dBm (high-power PA) or -17 to 14 dBm (low-power PA). More...
 
int16_t setOutputPower (int8_t power, bool forceHighPower)
 Sets output power. Allowed values are in range from -9 to 22 dBm (high-power PA) or -17 to 14 dBm (low-power PA). More...
 
int16_t checkOutputPower (int8_t power, int8_t *clipped) override
 Check if output power is configurable. This method is needed for compatibility with PhysicalLayer::checkOutputPower. More...
 
int16_t checkOutputPower (int8_t power, int8_t *clipped, bool forceHighPower)
 Check if output power is configurable. More...
 
int16_t setBandwidth (float bw)
 Sets LoRa bandwidth. Allowed values are 62.5, 125.0, 250.0 and 500.0 kHz. More...
 
int16_t setSpreadingFactor (uint8_t sf, bool legacy=false)
 Sets LoRa spreading factor. Allowed values range from 5 to 12. More...
 
int16_t setCodingRate (uint8_t cr, bool longInterleave=false)
 Sets LoRa coding rate denominator. Allowed values range from 5 to 8. More...
 
int16_t setSyncWord (uint32_t syncWord)
 Sets LoRa or LR-FHSS sync word. More...
 
int16_t setBitRate (float br) override
 Sets GFSK bit rate. Allowed values range from 0.6 to 300.0 kbps. More...
 
int16_t setFrequencyDeviation (float freqDev) override
 Sets GFSK frequency deviation. Allowed values range from 0.0 to 200.0 kHz. More...
 
int16_t setRxBandwidth (float rxBw)
 Sets GFSK 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 setSyncWord (uint8_t *syncWord, size_t len) override
 Sets GFSK sync word in the form of array of up to 8 bytes. More...
 
int16_t setSyncBits (uint8_t *syncWord, uint8_t bitsLen)
 Sets GFSK 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 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 setEncoding (uint8_t encoding) override
 Sets transmission encoding. Available in GFSK mode only. Serves only as alias for PhysicalLayer compatibility. More...
 
int16_t fixedPacketLengthMode (uint8_t len=RADIOLIB_LR11X0_MAX_PACKET_LENGTH)
 Set modem in fixed packet length mode. Available in GFSK mode only. More...
 
int16_t variablePacketLengthMode (uint8_t maxLen=RADIOLIB_LR11X0_MAX_PACKET_LENGTH)
 Set modem in variable packet length mode. Available in GFSK mode only. More...
 
int16_t setWhitening (bool enabled, uint16_t initial=0x01FF)
 Sets GFSK whitening parameters. 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 setPreambleLength (size_t preambleLength) override
 Sets preamble length for LoRa or GFSK modem. Allowed values range from 1 to 65535. More...
 
int16_t setTCXO (float voltage, uint32_t delay=5000)
 Sets TCXO (Temperature Compensated Crystal Oscillator) configuration. More...
 
int16_t setCRC (uint8_t len, uint32_t initial=0x00001D0FUL, uint32_t polynomial=0x00001021UL, bool inverted=true)
 Sets CRC configuration. More...
 
int16_t invertIQ (bool enable) override
 Enable/disable inversion of the I and Q signals. More...
 
float getRSSI () override
 Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. Only available for LoRa or GFSK modem. 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. 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. 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...
 
int16_t irqRxDoneRxTimeout (uint32_t &irqFlags, uint32_t &irqMask) override
 Create the flags that make up RxDone and RxTimeout used for receiving downlinks. More...
 
bool isRxTimeout () override
 Check whether the IRQ bit for RxTimeout is set. More...
 
uint8_t randomByte () override
 Get one truly random byte from RSSI noise. 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...
 
float getDataRate () const
 Gets effective data rate for the last transmitted packet. The value is calculated only for payload bytes. More...
 
int16_t setLrFhssConfig (uint8_t bw, uint8_t cr, uint8_t hdrCount=3, uint16_t hopSeed=0x13A)
 Sets LR-FHSS configuration. More...
 
int16_t startWifiScan (char wifiType, uint8_t mode=RADIOLIB_LR11X0_WIFI_ACQ_MODE_FULL_BEACON, uint16_t chanMask=RADIOLIB_LR11X0_WIFI_ALL_CHANNELS, uint8_t numScans=16, uint16_t timeout=100)
 Start passive WiFi scan. BUSY pin will be de-activated when the scan is finished. More...
 
void setWiFiScanAction (void(*func)(void))
 Sets interrupt service routine to call when a WiFi scan is completed. More...
 
void clearWiFiScanAction ()
 Clears interrupt service routine to call when a WiFi scan is completed.
 
int16_t getWifiScanResultsCount (uint8_t *count)
 Get number of WiFi scan results after the scan is finished. More...
 
int16_t getWifiScanResult (LR11x0WifiResult_t *result, uint8_t index, bool brief=false)
 Retrieve passive WiFi scan result. More...
 
int16_t wifiScan (uint8_t wifiType, uint8_t *count, uint8_t mode=RADIOLIB_LR11X0_WIFI_ACQ_MODE_FULL_BEACON, uint16_t chanMask=RADIOLIB_LR11X0_WIFI_ALL_CHANNELS, uint8_t numScans=16, uint16_t timeout=100)
 Blocking WiFi scan method. Performs a full passive WiFi scan. This method may block for several seconds! 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)
 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 (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 sleep ()
 Sets module to sleep. 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...
 
float getFreqStep () const
 Gets the module frequency step size that was set in constructor. 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...
 
virtual void setDirectAction (void(*func)(void))
 Set interrupt service routine function to call when data bit is received in direct mode. Must be implemented in module class. More...
 
virtual void readBit (uint32_t pin)
 Function to read and process data bit in direct reception mode. Must be implemented in module class. 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 void setChannelScanAction (void(*func)(void))
 Sets interrupt service routine to call when a channel scan is finished. More...
 
virtual void clearChannelScanAction ()
 Clears interrupt service routine to call when a channel scan is finished.
 

Public Attributes

bool XTAL
 Whether the module has an XTAL (true) or TCXO (false). Defaults to false.
 

Detailed Description

Base class for LR11x0 series. All derived classes for LR11x0 (e.g. LR1110 or LR1120) inherit from this base class. This class should not be instantiated directly from user code, only from its derived classes.

Constructor & Destructor Documentation

◆ LR11x0()

LR11x0::LR11x0 ( Module mod)
explicit

Default constructor.

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

Member Function Documentation

◆ begin()

int16_t LR11x0::begin ( float  bw,
uint8_t  sf,
uint8_t  cr,
uint8_t  syncWord,
int8_t  power,
uint16_t  preambleLength,
float  tcxoVoltage 
)

Initialization method for LoRa modem.

Parameters
bwLoRa bandwidth in kHz.
sfLoRa spreading factor.
crLoRa coding rate denominator.
syncWord1-byte LoRa sync word.
powerOutput power in dBm.
preambleLengthLoRa preamble length in symbols
tcxoVoltageTCXO reference voltage to be set.
Returns
Status Codes

◆ beginGFSK()

int16_t LR11x0::beginGFSK ( float  br,
float  freqDev,
float  rxBw,
int8_t  power,
uint16_t  preambleLength,
float  tcxoVoltage 
)

Initialization method for FSK modem.

Parameters
brFSK bit rate in kbps.
freqDevFrequency deviation from carrier frequency in kHz.
rxBwReceiver bandwidth in kHz.
powerOutput power in dBm.
preambleLengthFSK preamble length in bits.
tcxoVoltageTCXO reference voltage to be set.
Returns
Status Codes

◆ beginLRFHSS()

int16_t LR11x0::beginLRFHSS ( uint8_t  bw,
uint8_t  cr,
int8_t  power,
float  tcxoVoltage 
)

Initialization method for LR-FHSS modem.

Parameters
bwLR-FHSS bandwidth, one of RADIOLIB_LR11X0_LR_FHSS_BW_* values.
crLR-FHSS coding rate, one of RADIOLIB_LR11X0_LR_FHSS_CR_* values.
powerOutput power in dBm.
tcxoVoltageTCXO reference voltage to be set.
Returns
Status Codes

◆ calculateRxTimeout()

RadioLibTime_t LR11x0::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.

◆ checkDataRate()

int16_t LR11x0::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 (GFSK or LoRa).
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ checkOutputPower() [1/2]

int16_t LR11x0::checkOutputPower ( int8_t  power,
int8_t *  clipped 
)
overridevirtual

Check if output power is configurable. This method is needed for compatibility with PhysicalLayer::checkOutputPower.

Parameters
powerOutput power in dBm, PA will be determined automatically.
clippedClipped output power value to what is possible within the module's range.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ checkOutputPower() [2/2]

int16_t LR11x0::checkOutputPower ( int8_t  power,
int8_t *  clipped,
bool  forceHighPower 
)

Check if output power is configurable.

Parameters
powerOutput power in dBm.
clippedClipped output power value to what is possible within the module's range.
forceHighPowerForce using the high-power PA. If set to false, PA will be determined automatically based on configured output power, preferring the low-power PA. If set to true, only high-power PA will be used.
Returns
Status Codes

◆ disableAddressFiltering()

int16_t LR11x0::disableAddressFiltering ( )

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

Returns
Status Codes

◆ explicitHeader()

int16_t LR11x0::explicitHeader ( )

Set explicit header mode for future reception/transmission.

Returns
Status Codes

◆ finishTransmit()

int16_t LR11x0::finishTransmit ( )
overridevirtual

Clean up after transmission is done.

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ fixedPacketLengthMode()

int16_t LR11x0::fixedPacketLengthMode ( uint8_t  len = RADIOLIB_LR11X0_MAX_PACKET_LENGTH)

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

Parameters
lenPacket length.
Returns
Status Codes

◆ getChannelScanResult()

int16_t LR11x0::getChannelScanResult ( )
overridevirtual

Read the channel scan result.

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ getDataRate()

float LR11x0::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 LR11x0::getFrequencyError ( )

Gets frequency error of the latest received packet.

Returns
Frequency error in Hz.

◆ getIrqStatus()

uint32_t LR11x0::getIrqStatus ( )

Reads the current IRQ status.

Returns
IRQ status bits

◆ getPacketLength() [1/2]

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

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.

◆ getPacketLength() [2/2]

size_t LR11x0::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()

float LR11x0::getRSSI ( )
overridevirtual

Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. Only available for LoRa or GFSK modem.

Returns
RSSI of the last received packet in dBm.

Reimplemented from PhysicalLayer.

◆ getSNR()

float LR11x0::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 LR11x0::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.
Todo:
implement this mess - SX1280 datasheet v3.0 section 7.4.4.2

Reimplemented from PhysicalLayer.

◆ getWifiScanResult()

int16_t LR11x0::getWifiScanResult ( LR11x0WifiResult_t result,
uint8_t  index,
bool  brief = false 
)

Retrieve passive WiFi scan result.

Parameters
resultPointer to structure to hold the result data.
indexResult index, starting from 0. The number of scan results can be retrieved by calling getWifiScanResultsCount.
briefWhether to only retrieve the results in brief format. If set to false, only information in LR11x0WifiResult_t will be retrieved. If set to true, information in LR11x0WifiResultFull_t will be retrieved. In addition, if WiFi scan mode was set to RADIOLIB_LR11X0_WIFI_ACQ_MODE_FULL_BEACON, all information in LR11x0WifiResultExtended_t will be retrieved.
Returns
Status Codes

◆ getWifiScanResultsCount()

int16_t LR11x0::getWifiScanResultsCount ( uint8_t *  count)

Get number of WiFi scan results after the scan is finished.

Parameters
countPointer to a variable that will hold the number of scan results.
Returns
Status Codes

◆ implicitHeader()

int16_t LR11x0::implicitHeader ( size_t  len)

Set implicit header mode for future reception/transmission.

Parameters
lenPayload length in bytes.
Returns
Status Codes

◆ invertIQ()

int16_t LR11x0::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.

◆ irqRxDoneRxTimeout()

int16_t LR11x0::irqRxDoneRxTimeout ( uint32_t &  irqFlags,
uint32_t &  irqMask 
)
overridevirtual

Create the flags that make up RxDone and RxTimeout used for receiving downlinks.

Parameters
irqFlagsThe flags for which IRQs must be triggered
irqMaskMask indicating which IRQ triggers a DIO
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ isRxTimeout()

bool LR11x0::isRxTimeout ( )
overridevirtual

Check whether the IRQ bit for RxTimeout is set.

Returns
Whether RxTimeout IRQ is set

Reimplemented from PhysicalLayer.

◆ randomByte()

uint8_t LR11x0::randomByte ( )
overridevirtual

Get one truly random byte from RSSI noise.

Returns
TRNG byte.

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 LR11x0::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.
lenNumber of bytes that will be received. Must be known in advance for binary transmissions.
Returns
Status Codes

◆ receive() [2/2]

int16_t LR11x0::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 LR11x0::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 LR11x0::reset ( )

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

Returns
Status Codes

◆ scanChannel() [1/2]

int16_t LR11x0::scanChannel ( )
overridevirtual

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

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ scanChannel() [2/2]

int16_t LR11x0::scanChannel ( uint8_t  symbolNum,
uint8_t  detPeak,
uint8_t  detMin 
)

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

Parameters
symbolNumNumber of symbols for CAD detection.
detPeakPeak value for CAD detection.
detMinMinimum value for CAD detection.
Returns
Status Codes

◆ setBandwidth()

int16_t LR11x0::setBandwidth ( float  bw)

Sets LoRa bandwidth. Allowed values are 62.5, 125.0, 250.0 and 500.0 kHz.

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

◆ setBitRate()

int16_t LR11x0::setBitRate ( float  br)
overridevirtual

Sets GFSK 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 LR11x0::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 LR11x0::setCodingRate ( uint8_t  cr,
bool  longInterleave = false 
)

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

Parameters
crLoRa coding rate denominator to be set.
longInterleaveEnable long interleaver when set to true. Note that CR 4/7 is not possible with long interleaver enabled!
Returns
Status Codes

◆ setCRC()

int16_t LR11x0::setCRC ( uint8_t  len,
uint32_t  initial = 0x00001D0FUL,
uint32_t  polynomial = 0x00001021UL,
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. GFSK only. Defaults to 0x1D0F (CCIT CRC).
polynomialPolynomial for CRC calculation. GFSK only. Defaults to 0x1021 (CCIT CRC).
invertedInvert CRC bytes. GFSK only. Defaults to true (CCIT CRC).
Returns
Status Codes

◆ setDataRate()

int16_t LR11x0::setDataRate ( DataRate_t  dr)
overridevirtual

Set data.

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

Reimplemented from PhysicalLayer.

◆ setDataShaping()

int16_t LR11x0::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.

◆ setEncoding()

int16_t LR11x0::setEncoding ( uint8_t  encoding)
overridevirtual

Sets transmission encoding. Available in GFSK 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 LR11x0::setFrequencyDeviation ( float  freqDev)
overridevirtual

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

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

Reimplemented from PhysicalLayer.

◆ setIrqAction()

void LR11x0::setIrqAction ( void(*)(void)  func)

Sets interrupt service routine to call when IRQ1 activates.

Parameters
funcISR to call.

◆ setLrFhssConfig()

int16_t LR11x0::setLrFhssConfig ( uint8_t  bw,
uint8_t  cr,
uint8_t  hdrCount = 3,
uint16_t  hopSeed = 0x13A 
)

Sets LR-FHSS configuration.

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

◆ setNodeAddress()

int16_t LR11x0::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

◆ setOutputPower() [1/2]

int16_t LR11x0::setOutputPower ( int8_t  power)
overridevirtual

Sets output power. Allowed values are in range from -9 to 22 dBm (high-power PA) or -17 to 14 dBm (low-power PA).

Parameters
powerOutput power to be set in dBm, output PA is determined automatically preferring the low-power PA.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ setOutputPower() [2/2]

int16_t LR11x0::setOutputPower ( int8_t  power,
bool  forceHighPower 
)

Sets output power. Allowed values are in range from -9 to 22 dBm (high-power PA) or -17 to 14 dBm (low-power PA).

Parameters
powerOutput power to be set in dBm.
forceHighPowerForce using the high-power PA. If set to false, PA will be determined automatically based on configured output power, preferring the low-power PA. If set to true, only high-power PA will be used.
Returns
Status Codes

◆ setPacketReceivedAction()

void LR11x0::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 LR11x0::setPacketSentAction ( void(*)(void)  func)
overridevirtual

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

Parameters
funcISR to call.

Reimplemented from PhysicalLayer.

◆ setPreambleLength()

int16_t LR11x0::setPreambleLength ( size_t  preambleLength)
overridevirtual

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

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

Reimplemented from PhysicalLayer.

◆ setRxBandwidth()

int16_t LR11x0::setRxBandwidth ( float  rxBw)

Sets GFSK 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
rxBwGFSK receiver bandwidth to be set in kHz.
Returns
Status Codes

◆ setSpreadingFactor()

int16_t LR11x0::setSpreadingFactor ( uint8_t  sf,
bool  legacy = false 
)

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

Parameters
sfLoRa spreading factor to be set.
legacyEnable legacy mode for SF6 - this allows to communicate with SX127x at SF6.
Returns
Status Codes

◆ setSyncBits()

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

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

Parameters
syncWordGFSK sync word to be set.
bitsLenGFSK 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 LR11x0::setSyncWord ( uint32_t  syncWord)

Sets LoRa or LR-FHSS sync word.

Parameters
syncWordLoRa or LR-FHSS sync word to be set. For LoRa, only 8 least significant bits will be used
Returns
Status Codes

◆ setSyncWord() [2/2]

int16_t LR11x0::setSyncWord ( uint8_t *  syncWord,
size_t  len 
)
overridevirtual

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

Parameters
syncWordGFSK sync word to be set.
lenGFSK sync word length in bytes.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ setTCXO()

int16_t LR11x0::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 LR11x0::setWhitening ( bool  enabled,
uint16_t  initial = 0x01FF 
)

Sets GFSK whitening parameters.

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

◆ setWiFiScanAction()

void LR11x0::setWiFiScanAction ( void(*)(void)  func)

Sets interrupt service routine to call when a WiFi scan is completed.

Parameters
funcISR to call.

◆ sleep()

int16_t LR11x0::sleep ( bool  retainConfig = true,
uint32_t  sleepTime = 0 
)

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.
sleepTimeSleep duration (enables automatic wakeup), in multiples of 30.52 us. Ignored if set to 0.
Returns
Status Codes

◆ standby() [1/2]

int16_t LR11x0::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 LR11x0::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_LR11X0_STANDBY_RC (13 MHz RC oscillator) or RADIOLIB_LR11X0_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 LR11x0::startChannelScan ( )
overridevirtual

Interrupt-driven channel activity detection method. IRQ1 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 LR11x0::startChannelScan ( uint8_t  symbolNum,
uint8_t  detPeak,
uint8_t  detMin 
)

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

Parameters
symbolNumNumber of symbols for CAD detection.
detPeakPeak value for CAD detection.
detMinMinimum value for CAD detection.
Returns
Status Codes

◆ startReceive() [1/2]

int16_t LR11x0::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 LR11x0::startReceive ( uint32_t  timeout,
uint32_t  irqFlags = RADIOLIB_LR11X0_IRQ_RX_DONE,
uint32_t  irqMask = 0,
size_t  len = 0 
)
virtual

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

Parameters
timeoutRaw timeout value, expressed as multiples of 1/32.768 kHz (approximately 30.52 us). Defaults to RADIOLIB_LR11X0_RX_TIMEOUT_INF for infinite timeout (Rx continuous mode), set to RADIOLIB_LR11X0_RX_TIMEOUT_NONE for no timeout (Rx single mode). If timeout other than infinite is set, signal will be generated on IRQ1.
irqFlagsSets the IRQ flags that will trigger IRQ1, defaults to RADIOLIB_LR11X0_IRQ_RX_DONE.
irqMaskOnly for PhysicalLayer compatibility, not used.
lenOnly for PhysicalLayer compatibility, not used.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ 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 LR11x0::startTransmit ( 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.

◆ startWifiScan()

int16_t LR11x0::startWifiScan ( char  wifiType,
uint8_t  mode = RADIOLIB_LR11X0_WIFI_ACQ_MODE_FULL_BEACON,
uint16_t  chanMask = RADIOLIB_LR11X0_WIFI_ALL_CHANNELS,
uint8_t  numScans = 16,
uint16_t  timeout = 100 
)

Start passive WiFi scan. BUSY pin will be de-activated when the scan is finished.

Parameters
wifiTypeType of WiFi (802.11) signals to scan, 'b', 'n', 'g' or '*' for all signals.
modeScan acquisition mode, one of RADIOLIB_LR11X0_WIFI_ACQ_MODE_*. The type of results available after the scan depends on this mode. Defaults to RADIOLIB_LR11X0_WIFI_ACQ_MODE_FULL_BEACON, which provides the most information.
chanMaskBit mask of WiFi channels to scan, defaults to all channels. More channels leads to longer overall scan duration.
numScansNumber of scans to perform per each enabled channel. Defaults to 16 scans. More scans leads to longer overall scan duration.
timeoutTimeout of each scan in milliseconds. Defaults to 100 ms Longer timeout leads to longer overall scan duration.
Returns
Status Codes

◆ 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 LR11x0::transmit ( 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 LR11x0::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.

◆ variablePacketLengthMode()

int16_t LR11x0::variablePacketLengthMode ( uint8_t  maxLen = RADIOLIB_LR11X0_MAX_PACKET_LENGTH)

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

Parameters
maxLenMaximum packet length.
Returns
Status Codes

◆ wifiScan()

int16_t LR11x0::wifiScan ( uint8_t  wifiType,
uint8_t *  count,
uint8_t  mode = RADIOLIB_LR11X0_WIFI_ACQ_MODE_FULL_BEACON,
uint16_t  chanMask = RADIOLIB_LR11X0_WIFI_ALL_CHANNELS,
uint8_t  numScans = 16,
uint16_t  timeout = 100 
)

Blocking WiFi scan method. Performs a full passive WiFi scan. This method may block for several seconds!

Parameters
wifiTypeType of WiFi (802.11) signals to scan, 'b', 'n', 'g' or '*' for all signals.
countPointer to a variable that will hold the number of scan results.
modeScan acquisition mode, one of RADIOLIB_LR11X0_WIFI_ACQ_MODE_*. The type of results available after the scan depends on this mode. Defaults to RADIOLIB_LR11X0_WIFI_ACQ_MODE_FULL_BEACON, which provides the most information.
chanMaskBit mask of WiFi channels to scan, defaults to all channels. More channels leads to longer overall scan duration.
numScansNumber of scans to perform per each enabled channel. Defaults to 16 scans. More scans leads to longer overall scan duration.
timeoutTimeout of each scan in milliseconds. Defaults to 100 ms Longer timeout leads to longer overall scan duration.
Returns
Status Codes

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