RadioLib
Universal wireless communication library for Arduino
|
Derived class for LR1121 modules. More...
#include <LR1121.h>
Public Member Functions | |
LR1121 (Module *mod) | |
Default constructor. | |
![]() | |
LR1120 (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_LR11X0_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=156.2, int8_t power=10, uint16_t preambleLength=16, float tcxoVoltage=1.6) |
Initialization method for FSK modem. | |
int16_t | beginLRFHSS (float freq=434.0, uint8_t bw=RADIOLIB_LR11X0_LR_FHSS_BW_722_66, uint8_t cr=RADIOLIB_LR11X0_LR_FHSS_CR_2_3, bool narrowGrid=true, int8_t power=10, float tcxoVoltage=1.6) |
Initialization method for LR-FHSS modem. | |
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_LR11X0_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, float band=4) |
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_LR11X0_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 (high-power PA) or -17 to 14 dBm (low-power PA). | |
int16_t | setOutputPower (int8_t power, bool forceHighPower) |
Sets output power. Allowed values are in range from -9 to 22 dBm (high-power PA), -17 to 14 dBm (low-power PA) or -18 to 13 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. | |
int16_t | checkOutputPower (int8_t power, int8_t *clipped, bool forceHighPower) |
Check if output power is configurable. | |
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. | |
![]() | |
LR11x0 (Module *mod) | |
Default constructor. | |
int16_t | begin (float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, uint16_t preambleLength, float tcxoVoltage, bool high=false) |
Initialization method for LoRa modem. | |
int16_t | beginGFSK (float br, float freqDev, float rxBw, uint16_t preambleLength, float tcxoVoltage) |
Initialization method for FSK modem. | |
int16_t | beginLRFHSS (uint8_t bw, uint8_t cr, bool narrowGrid, float tcxoVoltage) |
Initialization method for LR-FHSS modem. | |
int16_t | beginGNSS (uint8_t constellations=RADIOLIB_LR11X0_GNSS_CONSTELLATION_GPS|RADIOLIB_LR11X0_GNSS_CONSTELLATION_BEIDOU, float tcxoVoltage=1.6) |
Initialization method for GNSS scanning. | |
int16_t | reset () |
Reset method. Will reset the chip to the default state using RST pin. | |
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) 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 SX126x series 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, bool wakeup=true) |
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(). | |
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. | |
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. | |
uint32_t | getIrqStatus () |
Reads the current IRQ status. | |
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 | 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. | |
int16_t | setBandwidth (float bw, bool high=false) |
Sets LoRa bandwidth. Allowed values are 62.5, 125.0, 250.0 and 500.0 kHz. (default, high = false) | |
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 5 to 8. | |
int16_t | setSyncWord (uint8_t syncWord) |
Sets LoRa sync word. | |
int16_t | setBitRate (float br) override |
Sets GFSK bit rate. Allowed values range from 0.6 to 300.0 kbps. | |
int16_t | setFrequencyDeviation (float freqDev) override |
Sets GFSK frequency deviation. Allowed values range from 0.0 to 200.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 | setSyncBits (uint8_t *syncWord, uint8_t bitsLen) |
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_LR11X0_MAX_PACKET_LENGTH) |
Set modem in fixed packet length mode. Available in GFSK mode only. | |
int16_t | variablePacketLengthMode (uint8_t maxLen=RADIOLIB_LR11X0_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) override |
Set data. | |
int16_t | checkDataRate (DataRate_t dr) override |
Check the data rate can be configured by this module. | |
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=5000) |
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. | |
float | getRSSI () override |
Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. Only available for LoRa or GFSK modem. | |
float | getSNR () override |
Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem. | |
float | getFrequencyError () |
Gets frequency error of the latest received packet. | |
size_t | getPacketLength (bool update=true) override |
Query modem for the packet length of received payload. | |
size_t | getPacketLength (bool update, uint8_t *offset) |
Query modem for the packet length of received payload. | |
RadioLibTime_t | getTimeOnAir (size_t len) override |
Get expected time-on-air for a given size of payload. | |
RadioLibTime_t | calculateRxTimeout (RadioLibTime_t timeoutUs) override |
Calculate the timeout value for this specific module / series (in number of symbols or units of time) | |
uint32_t | getIrqFlags () override |
Read currently active IRQ flags. | |
int16_t | setIrqFlags (uint32_t irq) override |
Set interrupt on IRQ pin 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). | |
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. | |
float | getDataRate () const |
Gets effective data rate for the last transmitted packet. The value is calculated only for payload bytes. | |
int16_t | setRegulatorLDO () |
Set regulator mode to LDO. | |
int16_t | setRegulatorDCDC () |
Set regulator mode to DC-DC. | |
int16_t | setRxBoostedGainMode (bool en) |
Enables or disables Rx Boosted Gain mode (additional Rx gain for increased power consumption). | |
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 | forceLDRO (bool enable) |
Forces LoRa low data rate optimization. Only available in LoRa mode. After calling this method, LDRO will always be set to the provided value, regardless of symbol length. To re-enable automatic LDRO configuration, call LR11x0::autoLDRO() | |
int16_t | autoLDRO () |
Re-enables automatic LDRO configuration. Only available in LoRa mode. After calling this method, LDRO will be enabled automatically when symbol length exceeds 16 ms. | |
int16_t | setLrFhssConfig (uint8_t bw, uint8_t cr, uint8_t hdrCount=3, uint16_t hopSeed=0x13A) |
Sets LR-FHSS configuration. | |
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. | |
void | setWiFiScanAction (void(*func)(void)) |
Sets interrupt service routine to call when a WiFi scan is completed. | |
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. | |
int16_t | getWifiScanResult (LR11x0WifiResult_t *result, uint8_t index, bool brief=false) |
Retrieve passive WiFi scan result. | |
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! | |
int16_t | getVersionInfo (LR11x0VersionInfo_t *info) |
Retrieve LR11x0 hardware, device and firmware version information. | |
int16_t | updateFirmware (const uint32_t *image, size_t size, bool nonvolatile=true) |
Method to upload new firmware image to the device. The device will be automatically erased, a new firmware will be uploaded, written to flash and executed. | |
int16_t | isGnssScanCapable () |
Method to check whether the device is capable of performing a GNSS scan. | |
int16_t | gnssScan (LR11x0GnssResult_t *res=NULL) |
Performs GNSS scan. | |
int16_t | getGnssAlmanacStatus (LR11x0GnssAlmanacStatus_t *stat) |
Read information about the almanac. | |
int16_t | gnssDelayUntilSubframe (LR11x0GnssAlmanacStatus_t *stat, uint8_t constellation) |
Blocking wait until the next subframe with almanac data is available. Used to control timing during almanac update from satellite. | |
int16_t | updateGnssAlmanac (uint8_t constellation) |
Perform almanac update. Must be called immediately after gnssDelayUntilSubframe. | |
int16_t | getGnssPosition (LR11x0GnssPosition_t *pos, bool filtered=true) |
Get GNSS position. Called after gnssScan to retrieve the position calculated by the internal solver. | |
int16_t | getGnssSatellites (LR11x0GnssSatellite_t *sats, uint8_t numSats) |
Get GNSS satellites found during the last scan. | |
int16_t | getModem (ModemType_t *modem) override |
Get modem currently in use by the radio. | |
int16_t | calibrateImageRejection (float freqMin, float freqMax) |
Perform image rejection calibration for the specified frequency band. WARNING: Use at your own risk! Setting incorrect values may lead to decreased performance. | |
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. | |
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) |
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. | |
![]() | |
PhysicalLayer () | |
Default constructor. | |
int16_t | transmit (const char *str, uint8_t addr=0) |
C-string transmit method. | |
virtual int16_t | standby (uint8_t mode) |
Sets module to a specific standby mode. | |
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 int16_t | setDIOMapping (uint32_t pin, uint32_t value) |
Configure DIO pin mapping to get a given signal on a DIO pin (if available). | |
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. | |
Additional Inherited Members | |
![]() | |
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_TX_HP , MODE_TX_HF , MODE_GNSS , MODE_WIFI } |
Custom operation modes for LR11x0. Needed because LR11x0 has several modems (sub-GHz, 2.4 GHz etc.) in one package. More... | |
![]() | |
bool | XTAL |
Whether the module has an XTAL (true) or TCXO (false). Defaults to false. | |
![]() | |
float | freqStep |
Frequency step of the synthesizer in Hz. | |
size_t | maxPacketLength |
Maximum length of packet that can be received by the module. | |
Derived class for LR1121 modules.
LR1121::LR1121 | ( | Module * | mod | ) |
Default constructor.
mod | Instance of Module that will be used to communicate with the radio. |