RadioLib
Universal wireless communication library for Arduino
Loading...
Searching...
No Matches
LR2021 Class Reference
Inheritance diagram for LR2021:
LRxxxx PhysicalLayer

Public Types

enum  OpMode_t {
  MODE_END_OF_TABLE = Module::MODE_END_OF_TABLE , MODE_STBY = Module::MODE_IDLE , MODE_RX = Module::MODE_RX , MODE_TX = Module::MODE_TX ,
  MODE_RX_HF , MODE_TX_HF
}
 Custom operation modes for LR2021. Needed because LR2021 has several modems (sub-GHz, 2.4 GHz etc.) in one package. More...
 

Public Member Functions

 LR2021 (Module *mod)
 Default constructor.
 
int16_t begin (float freq=434.0, float bw=125.0, uint8_t sf=9, uint8_t cr=7, uint8_t syncWord=RADIOLIB_LR2021_LORA_SYNC_WORD_PRIVATE, int8_t power=10, uint16_t preambleLength=8, float tcxoVoltage=1.6)
 Initialization method for LoRa modem.
 
int16_t beginGFSK (float freq=434.0, float br=4.8, float freqDev=5.0, float rxBw=153.8, int8_t power=10, uint16_t preambleLength=16, float tcxoVoltage=1.6)
 Initialization method for FSK modem.
 
int16_t beginOOK (float freq=434.0, float br=4.8, float rxBw=153.8, int8_t power=10, uint16_t preambleLength=16, float tcxoVoltage=1.6)
 Initialization method for OOK modem.
 
int16_t beginLRFHSS (float freq=434.0, uint8_t bw=RADIOLIB_LRXXXX_LR_FHSS_BW_722_66, uint8_t cr=RADIOLIB_LRXXXX_LR_FHSS_CR_2_3, bool narrowGrid=true, int8_t power=10, float tcxoVoltage=1.6)
 Initialization method for LR-FHSS modem.
 
int16_t beginFLRC (float freq=434.0, uint16_t br=650, uint8_t cr=RADIOLIB_LR2021_FLRC_CR_2_3, int8_t pwr=10, uint16_t preambleLength=16, uint8_t dataShaping=RADIOLIB_SHAPING_0_5, float tcxoVoltage=1.6)
 Initialization method for FLRC modem.
 
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.
 
int16_t receive (uint8_t *data, size_t len, RadioLibTime_t timeout=0) override
 Blocking binary receive method. Overloads for string-based transmissions are implemented in PhysicalLayer.
 
int16_t transmitDirect (uint32_t frf=0) override
 Starts direct mode transmission.
 
int16_t receiveDirect () override
 Starts direct mode reception. Only implemented for PhysicalLayer compatibility, as LR2021 does not support direct mode reception. Will always return RADIOLIB_ERR_UNKNOWN.
 
int16_t scanChannel () override
 Performs scan for LoRa transmission in the current channel. Detects both preamble and payload.
 
int16_t scanChannel (const ChannelScanConfig_t &config) override
 Performs scan for LoRa transmission in the current channel. Detects both preamble and payload.
 
int16_t standby () override
 Sets the module to standby mode (overload for PhysicalLayer compatibility, uses 13 MHz RC oscillator).
 
int16_t standby (uint8_t mode) override
 Sets the module to standby mode.
 
int16_t standby (uint8_t mode, bool wakeup)
 Sets the module to standby mode.
 
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.
 
int16_t sleep (bool retainConfig, uint32_t sleepTime)
 Sets the module to sleep mode. To wake the device up, call standby().
 
size_t getPacketLength (bool update=true) override
 Query modem for the packet length of received payload.
 
int16_t finishTransmit () override
 Clean up after transmission is done.
 
int16_t startReceive () override
 Interrupt-driven receive method with default parameters. Implemented for compatibility with PhysicalLayer.
 
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!
 
int16_t finishReceive () override
 Clean up after reception is done.
 
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.
 
int16_t startChannelScan (const ChannelScanConfig_t &config) override
 Interrupt-driven channel activity detection method. IRQ pin will be activated when LoRa preamble is detected, or upon timeout.
 
int16_t getChannelScanResult () override
 Read the channel scan result.
 
uint32_t getIrqFlags () override
 Read currently active IRQ flags.
 
int16_t setIrqFlags (uint32_t irq) override
 Set interrupt on DIO1 to be sent on a specific IRQ bit (e.g. RxTimeout, CadDone).
 
int16_t clearIrqFlags (uint32_t irq) override
 Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone).
 
int16_t setModem (ModemType_t modem) override
 Set modem for the radio to use. Will perform full reset and reconfigure the radio using its default parameters.
 
int16_t setFrequency (float freq) override
 Sets carrier frequency. Allowed values are in range from 150.0 to 960.0 MHz, 1900 - 2200 MHz and 2400 - 2500 MHz. Will automatically perform image calibration if the frequency changes by more than RADIOLIB_LR2021_CAL_IMG_FREQ_TRIG MHz. NOTE: When switching between sub-GHz and high-frequency bands, after changing the frequency, setOutputPower() must be called in order to set the correct power amplifier!
 
int16_t setFrequency (float freq, bool skipCalibration)
 Sets carrier frequency. Allowed values are in range from 150.0 to 960.0 MHz, 1900 - 2200 MHz and 2400 - 2500 MHz. Will automatically perform image calibration if the frequency changes by more than RADIOLIB_LR2021_CAL_IMG_FREQ_TRIG MHz. NOTE: When switching between sub-GHz and high-frequency bands, after changing the frequency, setOutputPower() must be called in order to set the correct power amplifier!
 
int16_t setOutputPower (int8_t power) override
 Sets output power. Allowed values are in range from -9 to 22 dBm (sub-GHz PA) or -19 to 12 dBm (high-frequency PA).
 
int16_t setOutputPower (int8_t power, uint32_t rampTimeUs)
 Sets output power. Allowed values are in range from -9 to 22 dBm (sub-GHz PA) or -19 to 12 dBm (high-frequency PA).
 
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.
 
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.
 
int16_t setBandwidth (float bw)
 Sets LoRa bandwidth. Allowed values are 31.25, 41.67, 62.5, 83.34, 125.0, 101.56, 203.13, 250.0, 406.25, 500.0 kHz, 812.5 kHz and 1000.0 kHz.
 
int16_t setSpreadingFactor (uint8_t sf, bool legacy=false)
 Sets LoRa spreading factor. Allowed values range from 5 to 12.
 
int16_t setCodingRate (uint8_t cr, bool longInterleave=false)
 Sets LoRa coding rate denominator. Allowed values range from 4 to 8. Note that a value of 4 means no coding, is undocumented and not recommended without your own FEC.
 
int16_t setSyncWord (uint8_t syncWord)
 Sets LoRa sync word.
 
int16_t setPreambleLength (size_t preambleLength) override
 Sets preamble length for LoRa or GFSK modem. Allowed values range from 1 to 65535.
 
int16_t setTCXO (float voltage, uint32_t delay=1000000)
 Sets TCXO (Temperature Compensated Crystal Oscillator) configuration.
 
int16_t setCRC (uint8_t len, uint32_t initial=0x00001D0FUL, uint32_t polynomial=0x00001021UL, bool inverted=true)
 Sets CRC configuration.
 
int16_t invertIQ (bool enable) override
 Enable/disable inversion of the I and Q signals.
 
int16_t setBitRate (float br) override
 Sets GFSK bit rate. Allowed values range from 0.5 to 2000.0 kbps.
 
int16_t setFrequencyDeviation (float freqDev) override
 Sets GFSK frequency deviation. Allowed values range from 0.6 to 500.0 kHz.
 
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.
 
int16_t setSyncWord (uint8_t *syncWord, size_t len) override
 Sets GFSK sync word in the form of array of up to 8 bytes.
 
int16_t setNodeAddress (uint8_t nodeAddr)
 Sets node address. Calling this method will also enable address filtering for node address only.
 
int16_t setBroadcastAddress (uint8_t broadAddr)
 Sets broadcast address. Calling this method will also enable address filtering for node and broadcast address.
 
int16_t disableAddressFiltering ()
 Disables address filtering. Calling this method will also erase previously set addresses.
 
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.
 
int16_t setEncoding (uint8_t encoding) override
 Sets transmission encoding. Available in GFSK mode only. Serves only as alias for PhysicalLayer compatibility.
 
int16_t fixedPacketLengthMode (uint8_t len=RADIOLIB_LR2021_MAX_PACKET_LENGTH)
 Set modem in fixed packet length mode. Available in GFSK mode only.
 
int16_t variablePacketLengthMode (uint8_t maxLen=RADIOLIB_LR2021_MAX_PACKET_LENGTH)
 Set modem in variable packet length mode. Available in GFSK mode only.
 
int16_t setWhitening (bool enabled, uint16_t initial=0x01FF)
 Sets GFSK whitening parameters.
 
int16_t setDataRate (DataRate_t dr, ModemType_t modem=RADIOLIB_MODEM_NONE) override
 Set data rate.
 
int16_t checkDataRate (DataRate_t dr, ModemType_t modem=RADIOLIB_MODEM_NONE) override
 Check the data rate can be configured by this module.
 
int16_t setLrFhssConfig (uint8_t bw, uint8_t cr, uint8_t hdrCount=3, uint16_t hopSeed=0x13A)
 Sets LR-FHSS configuration.
 
int16_t setRxBoostedGainMode (uint8_t level)
 Enables or disables Rx Boosted Gain mode (additional Rx gain for increased power consumption).
 
RadioLibTime_t getTimeOnAir (size_t len) override
 Get expected time-on-air for a given size of payload.
 
int16_t getModem (ModemType_t *modem) override
 Get modem currently in use by the radio.
 
int16_t stageMode (RadioModeType_t mode, RadioModeConfig_t *cfg) override
 Stage mode of the radio to be launched later using launchMode.
 
int16_t launchMode () override
 Launch previously staged mode.
 
float getVoltage (uint8_t bits=13)
 Read the supply voltage on the Vbat pin.
 
float getTemperature (uint8_t source, uint8_t bits=13)
 Read the temperature.
 
float getRSSI () override
 Gets recorded signal strength indicator. Overload with packet mode enabled for PhysicalLayer compatibility.
 
float getRSSI (bool packet)
 Gets RSSI (Recorded Signal Strength Indicator).
 
float getSNR () override
 Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem.
 
uint8_t randomByte () override
 Get one truly random byte from RSSI noise.
 
int16_t implicitHeader (size_t len)
 Set implicit header mode for future reception/transmission.
 
int16_t explicitHeader ()
 Set explicit header mode for future reception/transmission.
 
int16_t ookDetector (uint16_t pattern=0x0285, uint8_t len=16, uint8_t repeats=0, bool syncRaw=false, bool rising=false, uint8_t sofLen=0)
 Set OOK detector properties. The default values are set to allow ADS-B reception.
 
int16_t setSideDetector (const LR2021LoRaSideDetector_t *cfg, size_t numDetectors)
 Configure LoRa side detector, which enables to detect mutiple spreading factors and receive one of them. The following limitations apply: In Rx mode, all side-detector spreading factors must be higher than the primary one (configured via begin or setSpreadingFactor) For CAD mode, the above condition is inverted - all side-detector spreading factors must be smaller All packets to be detected must have the same header type (implicit or explicit) If bandwidth is higher than 500 kHz, at most 2 side detectors are allowed. If the primary spreading factor is 10, 11 or 12, at most 2 side detectors are allowed. All spreading factors must be different. The difference between maximum and minimum spreading factor used must be less than or equal to 4.
 
int16_t transmit (const char *str, uint8_t addr=0)
 C-string transmit method.
 
virtual int16_t transmit (const uint8_t *data, size_t len, uint8_t addr=0)
 Binary transmit method. Must be implemented in module class.
 
virtual int16_t receive (uint8_t *data, size_t len, RadioLibTime_t timeout=0)
 Binary receive method. Must be implemented in module class.
 
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.
 
virtual int16_t startTransmit (const uint8_t *data, size_t len, uint8_t addr=0)
 Interrupt-driven binary transmit method.
 
virtual int16_t startReceive ()
 Sets module to received mode using its default configuration.
 
virtual 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. A DIO pin will be activated when full packet is received. Must be implemented in module class.
 
virtual int16_t readData (uint8_t *data, size_t len)
 Reads data that was received after calling startReceive method.
 
- Public Member Functions inherited from LRxxxx
 LRxxxx (Module *mod)
 
int16_t reset ()
 Reset method. Will reset the chip to the default state using RST pin.
 
void setIrqAction (void(*func)(void))
 Sets interrupt service routine to call when IRQ1 activates.
 
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.
 
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.
 
void clearPacketSentAction () override
 Clears interrupt service routine to call when a packet is sent.
 
uint32_t getIrqStatus ()
 Reads the current IRQ status.
 
RadioLibTime_t calculateTimeOnAir (ModemType_t modem, DataRate_t dr, PacketConfig_t pc, size_t len) override
 Calculate the expected time-on-air for a given modem, data rate, packet configuration and payload size.
 
RadioLibTime_t calculateRxTimeout (RadioLibTime_t timeoutUs) override
 Calculate the timeout value for this specific module / series (in number of symbols or units of time)
 
- Public Member Functions inherited from PhysicalLayer
 PhysicalLayer ()
 Default constructor.
 
virtual ~PhysicalLayer ()=default
 Default destructor.
 
int16_t transmit (const char *str, uint8_t addr=0)
 C-string transmit method.
 
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.
 
uint32_t getIrqMapped (RadioLibIrqFlags_t irq)
 Convert from radio-agnostic IRQ flags to radio-specific flags.
 
int16_t checkIrq (RadioLibIrqType_t irq)
 Check whether a specific IRQ bit is set (e.g. RxTimeout, CadDone).
 
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!
 
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!
 
int32_t random (int32_t max)
 Get truly random number in range 0 - max.
 
int32_t random (int32_t min, int32_t max)
 Get truly random number in range min - max.
 
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.
 
int16_t setDirectSyncWord (uint32_t syncWord, uint8_t len)
 Set sync word to be used to determine start of packet in direct reception mode.
 
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.
 
virtual void readBit (uint32_t pin)
 Function to read and process data bit in direct reception mode. Must be implemented in module class.
 
int16_t available ()
 Get the number of direct mode bytes currently available in buffer.
 
void dropSync ()
 Forcefully drop synchronization.
 
uint8_t read (bool drop=true)
 Get data from direct mode buffer.
 
virtual void setChannelScanAction (void(*func)(void))
 Sets interrupt service routine to call when a channel scan is finished.
 
virtual void clearChannelScanAction ()
 Clears interrupt service routine to call when a channel scan is finished.
 

Public Attributes

uint32_t irqDioNum = 5
 Which DIO pin is to be used as the interrupt pin.
 
- Public Attributes inherited from LRxxxx
bool XTAL
 Whether the module has an XTAL (true) or TCXO (false). Defaults to false.
 
- Public Attributes inherited from PhysicalLayer
float freqStep
 Frequency step of the synthesizer in Hz.
 
size_t maxPacketLength
 Maximum length of packet that can be received by the module.
 

Member Enumeration Documentation

◆ OpMode_t

Custom operation modes for LR2021. Needed because LR2021 has several modems (sub-GHz, 2.4 GHz etc.) in one package.

Enumerator
MODE_END_OF_TABLE 

End of table marker, use END_OF_MODE_TABLE constant instead

MODE_STBY 

Standby/idle mode

MODE_RX 

Receive mode

MODE_TX 

Transmission mode

MODE_RX_HF 

High frequency receive mode

MODE_TX_HF 

High frequency transmission mode

Constructor & Destructor Documentation

◆ LR2021()

LR2021::LR2021 ( Module mod)

Default constructor.

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

Member Function Documentation

◆ begin()

int16_t LR2021::begin ( float  freq = 434.0,
float  bw = 125.0,
uint8_t  sf = 9,
uint8_t  cr = 7,
uint8_t  syncWord = RADIOLIB_LR2021_LORA_SYNC_WORD_PRIVATE,
int8_t  power = 10,
uint16_t  preambleLength = 8,
float  tcxoVoltage = 1.6 
)

Initialization method for LoRa modem.

Parameters
freqCarrier frequency in MHz. Defaults to 434.0 MHz.
bwLoRa bandwidth in kHz. Defaults to 125.0 kHz.
sfLoRa spreading factor. Defaults to 9.
crLoRa coding rate denominator. Defaults to 7 (coding rate 4/7). Allowed values range from 4 to 8. Note that a value of 4 means no coding, is undocumented and not recommended without your own FEC.
syncWord1-byte LoRa sync word. Defaults to RADIOLIB_LR2021_LORA_SYNC_WORD_PRIVATE (0x12).
powerOutput power in dBm. Defaults to 10 dBm.
preambleLengthLoRa preamble length in symbols. Defaults to 8 symbols.
tcxoVoltageTCXO reference voltage to be set. Defaults to 1.6 V. If you are seeing -706/-707 error codes, it likely means you are using non-0 value for module with XTAL. To use XTAL, either set this value to 0, or set LR2021::XTAL to true.
Returns
Status Codes

◆ beginFLRC()

int16_t LR2021::beginFLRC ( float  freq = 434.0,
uint16_t  br = 650,
uint8_t  cr = RADIOLIB_LR2021_FLRC_CR_2_3,
int8_t  pwr = 10,
uint16_t  preambleLength = 16,
uint8_t  dataShaping = RADIOLIB_SHAPING_0_5,
float  tcxoVoltage = 1.6 
)

Initialization method for FLRC modem.

Parameters
freqCarrier frequency in MHz. Defaults to 434.0 MHz.
brFLRC bit rate in kbps. Defaults to 650 kbps.
crFLRC coding rate. Defaults to RADIOLIB_LR2021_FLRC_CR_2_3 (coding rate 2/3).
pwrOutput power in dBm. Defaults to 10 dBm.
preambleLengthFLRC preamble length in bits. Defaults to 16 bits.
dataShapingTime-bandwidth product of the Gaussian filter to be used for shaping. Defaults to 0.5.
Returns
Status Codes

◆ beginGFSK()

int16_t LR2021::beginGFSK ( float  freq = 434.0,
float  br = 4.8,
float  freqDev = 5.0,
float  rxBw = 153.8,
int8_t  power = 10,
uint16_t  preambleLength = 16,
float  tcxoVoltage = 1.6 
)

Initialization method for FSK modem.

Parameters
freqCarrier frequency in MHz. Defaults to 434.0 MHz.
brFSK bit rate in kbps. Defaults to 4.8 kbps.
freqDevFrequency deviation from carrier frequency in kHz. Defaults to 5.0 kHz.
rxBwReceiver bandwidth in kHz. Defaults to 153.8 kHz.
powerOutput power in dBm. Defaults to 10 dBm.
preambleLengthFSK preamble length in bits. Defaults to 16 bits.
tcxoVoltageTCXO reference voltage to be set. Defaults to 1.6 V. If you are seeing -706/-707 error codes, it likely means you are using non-0 value for module with XTAL. To use XTAL, either set this value to 0, or set LR2021::XTAL to true.
Returns
Status Codes

◆ beginLRFHSS()

int16_t LR2021::beginLRFHSS ( float  freq = 434.0,
uint8_t  bw = RADIOLIB_LRXXXX_LR_FHSS_BW_722_66,
uint8_t  cr = RADIOLIB_LRXXXX_LR_FHSS_CR_2_3,
bool  narrowGrid = true,
int8_t  power = 10,
float  tcxoVoltage = 1.6 
)

Initialization method for LR-FHSS modem.

Parameters
freqCarrier frequency in MHz. Defaults to 434.0 MHz.
bwLR-FHSS bandwidth, one of RADIOLIB_LRXXXX_LR_FHSS_BW_* values. Defaults to 722.66 kHz.
crLR-FHSS coding rate, one of RADIOLIB_LRXXXX_LR_FHSS_CR_* values. Defaults to 2/3 coding rate.
narrowGridWhether to use narrow (3.9 kHz) or wide (25.39 kHz) grid spacing. Defaults to true (narrow/non-FCC) grid.
powerOutput power in dBm. Defaults to 10 dBm.
tcxoVoltageTCXO reference voltage to be set. Defaults to 1.6 V. If you are seeing -706/-707 error codes, it likely means you are using non-0 value for module with XTAL. To use XTAL, either set this value to 0, or set LR2021::XTAL to true.
Returns
Status Codes

◆ beginOOK()

int16_t LR2021::beginOOK ( float  freq = 434.0,
float  br = 4.8,
float  rxBw = 153.8,
int8_t  power = 10,
uint16_t  preambleLength = 16,
float  tcxoVoltage = 1.6 
)

Initialization method for OOK modem.

Parameters
freqCarrier frequency in MHz. Defaults to 434.0 MHz.
brOOK bit rate in kbps. Defaults to 4.8 kbps.
rxBwReceiver bandwidth in kHz. Defaults to 153.8 kHz.
powerOutput power in dBm. Defaults to 10 dBm.
preambleLengthOOK preamble length in bits. Defaults to 16 bits.
tcxoVoltageTCXO reference voltage to be set. Defaults to 1.6 V. If you are seeing -706/-707 error codes, it likely means you are using non-0 value for module with XTAL. To use XTAL, either set this value to 0, or set LR2021::XTAL to true.
Returns
Status Codes

◆ checkDataRate()

int16_t LR2021::checkDataRate ( DataRate_t  dr,
ModemType_t  modem = RADIOLIB_MODEM_NONE 
)
overridevirtual

Check the data rate can be configured by this module.

Parameters
drData rate struct.
modemThe modem corresponding to the requested datarate (FSK, LoRa or LR-FHSS). Defaults to currently active modem if not supplied.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ checkOutputPower()

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

◆ clearIrqFlags()

int16_t LR2021::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 LR2021::disableAddressFiltering ( )

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

Returns
Status Codes

◆ explicitHeader()

int16_t LR2021::explicitHeader ( )

Set explicit header mode for future reception/transmission.

Returns
Status Codes

◆ finishReceive()

int16_t LR2021::finishReceive ( )
overridevirtual

Clean up after reception is done.

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ finishTransmit()

int16_t LR2021::finishTransmit ( )
overridevirtual

Clean up after transmission is done.

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ fixedPacketLengthMode()

int16_t LR2021::fixedPacketLengthMode ( uint8_t  len = RADIOLIB_LR2021_MAX_PACKET_LENGTH)

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

Parameters
lenPacket length.
Returns
Status Codes

◆ getChannelScanResult()

int16_t LR2021::getChannelScanResult ( )
overridevirtual

Read the channel scan result.

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ getIrqFlags()

uint32_t LR2021::getIrqFlags ( )
overridevirtual

Read currently active IRQ flags.

Returns
IRQ flags.

Reimplemented from PhysicalLayer.

◆ getModem()

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

size_t LR2021::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 LR2021::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 LR2021::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 LR2021::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.

◆ getTemperature()

float LR2021::getTemperature ( uint8_t  source,
uint8_t  bits = 13 
)

Read the temperature.

Parameters
sourceMeasurement source, one of RADIOLIB_LR2021_TEMP_SOURCE_* macros.
bitsMeasurement resolution in bits, 8 to 13.
Returns
Temperature in degrees Celsius.

◆ getTimeOnAir()

RadioLibTime_t LR2021::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:
[LR2021] Add FLRC to the modems supported in ModemType_t

Reimplemented from PhysicalLayer.

◆ getVoltage()

float LR2021::getVoltage ( uint8_t  bits = 13)

Read the supply voltage on the Vbat pin.

Parameters
bitsMeasurement resolution in bits, 8 to 13.
Returns
Supply voltage in volts.

◆ implicitHeader()

int16_t LR2021::implicitHeader ( size_t  len)

Set implicit header mode for future reception/transmission.

Parameters
lenPayload length in bytes.
Returns
Status Codes

◆ invertIQ()

int16_t LR2021::invertIQ ( bool  enable)
overridevirtual

Enable/disable inversion of the I and Q signals.

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

Reimplemented from PhysicalLayer.

◆ launchMode()

int16_t LR2021::launchMode ( )
overridevirtual

Launch previously staged mode.

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ ookDetector()

int16_t LR2021::ookDetector ( uint16_t  pattern = 0x0285,
uint8_t  len = 16,
uint8_t  repeats = 0,
bool  syncRaw = false,
bool  rising = false,
uint8_t  sofLen = 0 
)

Set OOK detector properties. The default values are set to allow ADS-B reception.

Parameters
patternPreamble pattern, should end with 01 or 10 (binary).
lenPreamble pattern length in bits.
repeatsNumber of preamble repeats, maximum of 31.
syncRawWhether the sync word is send raw (unencoded) or encoded. Set to true for encoded sync word.
risingWhether the start of frame delimiter edge is rising (true) or falling (false).
sofLenStart-of-frame length in bits.
Returns
Status Codes

◆ randomByte()

uint8_t LR2021::randomByte ( )
overridevirtual

Get one truly random byte from RSSI noise.

Returns
TRNG byte.

Reimplemented from PhysicalLayer.

◆ readData() [1/2]

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

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

Reimplemented from PhysicalLayer.

◆ readData() [2/2]

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

\TODO: [LR2021] legacy from LR11x0, is it still needed?

Reimplemented from PhysicalLayer.

◆ receive() [1/2]

int16_t PhysicalLayer::receive ( uint8_t *  data,
size_t  len,
RadioLibTime_t  timeout = 0 
)
virtual

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).
timeoutReception timeout in milliseconds. If set to 0, timeout period will be calculated automatically based on the radio configuration.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ receive() [2/2]

int16_t LR2021::receive ( uint8_t *  data,
size_t  len,
RadioLibTime_t  timeout = 0 
)
overridevirtual

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

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.
timeoutReception timeout in milliseconds. If set to 0, timeout period will be calculated automatically based on the radio configuration.
Returns
Status Codes

\TODO: [LR2021] taken from SX126x, does this really work?

Reimplemented from PhysicalLayer.

◆ receiveDirect()

int16_t LR2021::receiveDirect ( )
overridevirtual

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

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ scanChannel() [1/2]

int16_t LR2021::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 LR2021::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 LR2021::setBandwidth ( float  bw)

Sets LoRa bandwidth. Allowed values are 31.25, 41.67, 62.5, 83.34, 125.0, 101.56, 203.13, 250.0, 406.25, 500.0 kHz, 812.5 kHz and 1000.0 kHz.

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

◆ setBitRate()

int16_t LR2021::setBitRate ( float  br)
overridevirtual

Sets GFSK bit rate. Allowed values range from 0.5 to 2000.0 kbps.

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

\TODO: [LR2021] implement fractional bit rate configuration

\TODO: [LR2021] implement fractional bit rate configuration

\TODO: [LR2021] implement OOK magnitude depth configuration

Reimplemented from PhysicalLayer.

◆ setBroadcastAddress()

int16_t LR2021::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 LR2021::setCodingRate ( uint8_t  cr,
bool  longInterleave = false 
)

Sets LoRa coding rate denominator. Allowed values range from 4 to 8. Note that a value of 4 means no coding, is undocumented and not recommended without your own FEC.

Parameters
crLoRa coding rate denominator to be set.
longInterleaveEnable long interleaver when set to true. Note that with long interleaver enabled, CR 4/7 is not possible, there are packet length restrictions, and it is not compatible with SX127x radios!
Returns
Status Codes

◆ setCRC()

int16_t LR2021::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 (CCITT CRC).
polynomialPolynomial for CRC calculation. GFSK only. Defaults to 0x1021 (CCITT CRC).
invertedInvert CRC bytes. GFSK only. Defaults to true (CCITT CRC).
Returns
Status Codes

◆ setDataRate()

int16_t LR2021::setDataRate ( DataRate_t  dr,
ModemType_t  modem = RADIOLIB_MODEM_NONE 
)
overridevirtual

Set data rate.

Parameters
drData rate struct.
modemThe modem corresponding to the requested datarate (FSK, LoRa or LR-FHSS). Defaults to currently active modem if not supplied.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ setDataShaping()

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

◆ setFrequency() [1/2]

int16_t LR2021::setFrequency ( float  freq)
overridevirtual

Sets carrier frequency. Allowed values are in range from 150.0 to 960.0 MHz, 1900 - 2200 MHz and 2400 - 2500 MHz. Will automatically perform image calibration if the frequency changes by more than RADIOLIB_LR2021_CAL_IMG_FREQ_TRIG MHz. NOTE: When switching between sub-GHz and high-frequency bands, after changing the frequency, setOutputPower() must be called in order to set the correct power amplifier!

Parameters
freqCarrier frequency to be set in MHz.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ setFrequency() [2/2]

int16_t LR2021::setFrequency ( float  freq,
bool  skipCalibration 
)

Sets carrier frequency. Allowed values are in range from 150.0 to 960.0 MHz, 1900 - 2200 MHz and 2400 - 2500 MHz. Will automatically perform image calibration if the frequency changes by more than RADIOLIB_LR2021_CAL_IMG_FREQ_TRIG MHz. NOTE: When switching between sub-GHz and high-frequency bands, after changing the frequency, setOutputPower() must be called in order to set the correct power amplifier!

Parameters
freqCarrier frequency to be set in MHz.
skipCalibrationSkip automated image calibration.
Returns
Status Codes

◆ setFrequencyDeviation()

int16_t LR2021::setFrequencyDeviation ( float  freqDev)
overridevirtual

Sets GFSK frequency deviation. Allowed values range from 0.6 to 500.0 kHz.

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

Reimplemented from PhysicalLayer.

◆ setIrqFlags()

int16_t LR2021::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 LR2021::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_LRXXXX_LR_FHSS_BW_* values.
crLR-FHSS coding rate, one of RADIOLIB_LRXXXX_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

◆ setModem()

int16_t LR2021::setModem ( ModemType_t  modem)
overridevirtual

Set modem for the radio to use. Will perform full reset and reconfigure the radio using its default parameters.

Parameters
modemModem type to set - FSK, LoRa or LR-FHSS.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ setNodeAddress()

int16_t LR2021::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 LR2021::setOutputPower ( int8_t  power)
overridevirtual

Sets output power. Allowed values are in range from -9 to 22 dBm (sub-GHz PA) or -19 to 12 dBm (high-frequency PA).

Parameters
powerOutput power to be set in dBm.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ setOutputPower() [2/2]

int16_t LR2021::setOutputPower ( int8_t  power,
uint32_t  rampTimeUs 
)

Sets output power. Allowed values are in range from -9 to 22 dBm (sub-GHz PA) or -19 to 12 dBm (high-frequency PA).

Parameters
powerOutput power to be set in dBm.
rampTimeUsPA power ramping time in microseconds. Provided value is rounded up to the nearest discrete ramp time supported by the PA.
Returns
Status Codes

\TODO: [LR2021] how and when to configure OCP? \TODO: [LR2021] Determine the optimal PA configuration

◆ setPreambleLength()

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

◆ setRfSwitchTable()

void LR2021::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 LR2021::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

◆ setRxBoostedGainMode()

int16_t LR2021::setRxBoostedGainMode ( uint8_t  level)

Enables or disables Rx Boosted Gain mode (additional Rx gain for increased power consumption).

Parameters
levelRx gain boost level. 0 (disabled) to 7 (maximum boost).
Returns
Status Codes

◆ setSideDetector()

int16_t LR2021::setSideDetector ( const LR2021LoRaSideDetector_t cfg,
size_t  numDetectors 
)

Configure LoRa side detector, which enables to detect mutiple spreading factors and receive one of them. The following limitations apply: In Rx mode, all side-detector spreading factors must be higher than the primary one (configured via begin or setSpreadingFactor) For CAD mode, the above condition is inverted - all side-detector spreading factors must be smaller All packets to be detected must have the same header type (implicit or explicit) If bandwidth is higher than 500 kHz, at most 2 side detectors are allowed. If the primary spreading factor is 10, 11 or 12, at most 2 side detectors are allowed. All spreading factors must be different. The difference between maximum and minimum spreading factor used must be less than or equal to 4.

Parameters
cfgPointer to an array of side detector configuration structures. Set to null to disable all side detectors.
numDetectorsNumber of side detectors to configure. Maximum of 3, set to 0 to to disable all side detectors.
Returns
Status Codes
Todo:
[LR2021] implement multi-SF for CAD (main SF must be smallest!)

◆ setSpreadingFactor()

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

\TODO: [LR2021] enable SF6 legacy mode

◆ setSyncWord() [1/2]

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

◆ setSyncWord() [2/2]

int16_t LR2021::setSyncWord ( uint8_t  syncWord)

Sets LoRa sync word.

Parameters
syncWordLoRa sync word to be set.
Returns
Status Codes

◆ setTCXO()

int16_t LR2021::setTCXO ( float  voltage,
uint32_t  delay = 1000000 
)

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 1000000 (1 second), because especially on the first startup, this delay may be measured very inaccurately.
Returns
Status Codes

◆ setWhitening()

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

\TODO: [LR2021] Implement SX128x-compatible whitening

\TODO: [LR2021] Implement configurable index and polynomial

◆ sleep() [1/2]

int16_t LR2021::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 LR2021::sleep ( bool  retainConfig,
uint32_t  sleepTime 
)

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

◆ stageMode()

int16_t LR2021::stageMode ( RadioModeType_t  mode,
RadioModeConfig_t cfg 
)
overridevirtual

Stage mode of the radio to be launched later using launchMode.

Parameters
modeRadio mode to prepare.
cfgConfiguration of this mode (mode-dependent).
Returns
Status Codes
Todo:
[LR2021] implement GFSK address filtering
Todo:
[LR2021] add configurable LR-FHSS device offset

Reimplemented from PhysicalLayer.

◆ standby() [1/3]

int16_t LR2021::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/3]

int16_t LR2021::standby ( uint8_t  mode)
overridevirtual

Sets the module to standby mode.

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

Reimplemented from PhysicalLayer.

◆ standby() [3/3]

int16_t LR2021::standby ( uint8_t  mode,
bool  wakeup 
)

Sets the module to standby mode.

Parameters
modeOscillator to be used in standby mode. Can be set to RADIOLIB_LR2021_STANDBY_RC (13 MHz RC oscillator) or RADIOLIB_LR2021_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 LR2021::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 LR2021::startChannelScan ( const ChannelScanConfig_t config)
overridevirtual

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

Parameters
configCAD configuration structure.
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ startReceive() [1/3]

int16_t PhysicalLayer::startReceive ( )
virtual

Sets module to received mode using its default configuration.

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ startReceive() [2/3]

int16_t LR2021::startReceive ( )
overridevirtual

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

Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ startReceive() [3/3]

int16_t PhysicalLayer::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. A DIO pin will be activated when full packet is received. Must be implemented in module class.

Parameters
timeoutRaw timeout value. Some modules use this argument to specify operation mode (single vs. continuous receive).
irqFlagsSets the IRQ flags.
irqMaskSets the mask of IRQ flags that will trigger the radio interrupt pin.
lenPacket length, needed for some modules under special circumstances (e.g. LoRa implicit header mode).
Returns
Status Codes

Reimplemented from PhysicalLayer.

◆ startTransmit() [1/2]

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

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

◆ startTransmit() [2/2]

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

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

Reimplemented from PhysicalLayer.

◆ transmit() [1/3]

int16_t PhysicalLayer::transmit ( const char *  str,
uint8_t  addr = 0 
)

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 ( const uint8_t *  data,
size_t  len,
uint8_t  addr = 0 
)
virtual

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

Reimplemented from PhysicalLayer.

◆ transmit() [3/3]

int16_t LR2021::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 LR2021::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 LR2021::variablePacketLengthMode ( uint8_t  maxLen = RADIOLIB_LR2021_MAX_PACKET_LENGTH)

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

Parameters
maxLenMaximum packet length.
Returns
Status Codes

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