RadioLib
Universal wireless communication library for Arduino
SX1281 Class Reference

Derived class for SX1281 modules. More...

#include <SX1281.h>

Inheritance diagram for SX1281:
SX128x PhysicalLayer SX1280 SX1282

Public Member Functions

 SX1281 (Module *mod)
 Default constructor. More...
 
- Public Member Functions inherited from SX128x
 SX128x (Module *mod)
 Default constructor. More...
 
int16_t begin (float freq=2400.0, float bw=812.5, uint8_t sf=9, uint8_t cr=7, uint8_t syncWord=RADIOLIB_SX128X_SYNC_WORD_PRIVATE, int8_t pwr=10, uint16_t preambleLength=12)
 Initialization method for LoRa modem. More...
 
int16_t beginGFSK (float freq=2400.0, uint16_t br=800, float freqDev=400.0, int8_t pwr=10, uint16_t preambleLength=16)
 Initialization method for GFSK modem. More...
 
int16_t beginBLE (float freq=2400.0, uint16_t br=800, float freqDev=400.0, int8_t pwr=10, uint8_t dataShaping=RADIOLIB_SHAPING_0_5)
 Initialization method for BLE modem. More...
 
int16_t beginFLRC (float freq=2400.0, uint16_t br=650, uint8_t cr=3, int8_t pwr=10, uint16_t preambleLength=16, uint8_t dataShaping=RADIOLIB_SHAPING_0_5)
 Initialization method for FLRC modem. More...
 
int16_t reset (bool verify=true)
 Reset method. Will reset the chip to the default state using RST pin. More...
 
int16_t transmit (uint8_t *data, size_t len, uint8_t addr=0) 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 SX128x 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 sleep ()
 Sets the module to sleep mode. To wake the device up, call standby(). Overload for PhysicalLayer compatibility. More...
 
int16_t sleep (bool retainConfig)
 Sets the module to sleep mode. To wake the device up, call standby(). More...
 
int16_t standby () override
 Sets the module to standby mode (overload for PhysicalLayer compatibility, uses 13 MHz RC oscillator). More...
 
int16_t standby (uint8_t mode, bool wakeup=false)
 Sets the module to standby mode. More...
 
void setDio1Action (void(*func)(void))
 Sets interrupt service routine to call when DIO1 activates. More...
 
void clearDio1Action ()
 Clears interrupt service routine to call when DIO1 activates.
 
void setPacketReceivedAction (void(*func)(void)) override
 Sets interrupt service routine to call when a packet is received. More...
 
void clearPacketReceivedAction () override
 Clears interrupt service routine to call when a packet is received.
 
void setPacketSentAction (void(*func)(void)) override
 Sets interrupt service routine to call when a packet is sent. More...
 
void clearPacketSentAction () override
 Clears interrupt service routine to call when a packet is sent.
 
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 (uint16_t timeout, uint32_t irqFlags=RADIOLIB_SX128X_IRQ_RX_DEFAULT, uint32_t irqMask=RADIOLIB_SX128X_IRQ_RX_DONE, size_t len=0)
 Interrupt-driven receive method. DIO1 will be activated when full packet is received. More...
 
uint16_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. DIO1 will be activated when LoRa preamble is detected, or upon timeout. Defaults to CAD parameter values recommended by AN1200.48. More...
 
int16_t getChannelScanResult () override
 Read the channel scan result. More...
 
int16_t setFrequency (float freq) override
 Sets carrier frequency. Allowed values are in range from 2400.0 to 2500.0 MHz. More...
 
int16_t setBandwidth (float bw)
 Sets LoRa bandwidth. Allowed values are 203.125, 406.25, 812.5 and 1625.0 kHz. More...
 
int16_t setSpreadingFactor (uint8_t sf)
 Sets LoRa spreading factor. Allowed values range from 5 to 12. More...
 
int16_t setCodingRate (uint8_t cr, bool longInterleaving=false)
 Sets LoRa coding rate denominator. Allowed values range from 5 to 8. More...
 
int16_t setOutputPower (int8_t pwr) override
 Sets output power. Allowed values are in range from -18 to 13 dBm. More...
 
int16_t checkOutputPower (int8_t power, int8_t *clipped) override
 Check if output power is configurable. More...
 
int16_t setPreambleLength (uint32_t preambleLength)
 Sets preamble length for currently active modem. Allowed values range from 1 to 65535. More...
 
int16_t setBitRate (float br) override
 Sets FSK or FLRC bit rate. Allowed values are 125, 250, 400, 500, 800, 1000, 1600 and 2000 kbps (for FSK modem) or 260, 325, 520, 650, 1000 and 1300 (for FLRC modem). More...
 
int16_t setFrequencyDeviation (float freqDev) override
 Sets FSK frequency deviation. Allowed values range from 0.0 to 3200.0 kHz. More...
 
int16_t setDataShaping (uint8_t sh) override
 Sets time-bandwidth product of Gaussian filter applied for shaping. Allowed values are RADIOLIB_SHAPING_0_5 or RADIOLIB_SHAPING_1_0. Set to RADIOLIB_SHAPING_NONE to disable data shaping. More...
 
int16_t setSyncWord (const uint8_t *syncWord, uint8_t len)
 Sets FSK/FLRC sync word in the form of array of up to 5 bytes (FSK). For FLRC modem, the sync word must be exactly 4 bytes long. More...
 
int16_t setSyncWord (uint8_t syncWord, uint8_t controlBits=0x44)
 Sets LoRa sync word. More...
 
int16_t setCRC (uint8_t len, uint32_t initial=0x1D0F, uint16_t polynomial=0x1021)
 Sets CRC configuration. More...
 
int16_t setWhitening (bool enabled)
 Sets whitening parameters, not available for LoRa or FLRC modem. More...
 
int16_t setAccessAddress (uint32_t addr)
 Sets BLE access address. More...
 
int16_t setHighSensitivityMode (bool enable)
 Enables or disables receiver high sensitivity mode. More...
 
int16_t setGainControl (uint8_t gain=0)
 Enables or disables receiver manual gain control. More...
 
float getRSSI () override
 Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. More...
 
float getSNR () override
 Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa or ranging 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...
 
RadioLibTime_t getTimeOnAir (size_t len) override
 Get expected time-on-air for a given size of payload. More...
 
int16_t implicitHeader (size_t len)
 Set implicit header mode for future reception/transmission. More...
 
int16_t explicitHeader ()
 Set explicit header mode for future reception/transmission. More...
 
int16_t setEncoding (uint8_t encoding) override
 Sets transmission encoding. Serves only as alias for PhysicalLayer compatibility. More...
 
void setRfSwitchPins (uint32_t rxEn, uint32_t txEn)
 Some modules contain external RF switch controlled by pins. This function gives RadioLib control over those pins to automatically switch between various modes: When idle both pins will be LOW, during TX the txEn pin will be HIGH, during RX the rxPin will be HIGH. More...
 
void setRfSwitchTable (const uint32_t(&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[])
 Some modules contain external RF switch controlled by pins. This function gives RadioLib control over those pins to automatically switch between various modes. More...
 
uint8_t randomByte () override
 Dummy random method, to ensure PhysicalLayer compatibility. More...
 
int16_t invertIQ (bool enable) override
 Enable/disable inversion of the I and Q signals. More...
 
void setDirectAction (void(*func)(void)) override
 Dummy method, to ensure PhysicalLayer compatibility. More...
 
void readBit (uint32_t pin) override
 Dummy method, to ensure PhysicalLayer compatibility. 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 standby (uint8_t mode)
 Sets module to a specific standby mode. More...
 
virtual int16_t startReceive (uint32_t timeout, uint32_t irqFlags, uint32_t irqMask, size_t len)
 Interrupt-driven receive method. A DIO pin will be activated when full packet is received. 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 setSyncWord (uint8_t *sync, size_t len)
 Set sync word. Must be implemented in module class if the module supports it. More...
 
virtual int16_t setPreambleLength (size_t len)
 Set preamble length. Must be implemented in module class if the module supports it. More...
 
virtual int16_t setDataRate (DataRate_t dr)
 Set data. Must be implemented in module class if the module supports it. More...
 
virtual int16_t checkDataRate (DataRate_t dr)
 Check the data rate can be configured by this module. Must be implemented in module class if the module supports it. More...
 
float getFreqStep () const
 Gets the module frequency step size that was set in constructor. More...
 
virtual RadioLibTime_t calculateRxTimeout (RadioLibTime_t timeoutUs)
 Calculate the timeout value for this specific module / series (in number of symbols or units of time) More...
 
virtual int16_t irqRxDoneRxTimeout (uint32_t &irqFlags, uint32_t &irqMask)
 Create the flags that make up RxDone and RxTimeout used for receiving downlinks. More...
 
virtual bool isRxTimeout ()
 Check whether the IRQ bit for RxTimeout is set. More...
 
int32_t random (int32_t max)
 Get truly random number in range 0 - max. More...
 
int32_t random (int32_t min, int32_t max)
 Get truly random number in range min - max. More...
 
int16_t startDirect ()
 Configure module parameters for direct modes. Must be called prior to "ham" modes like RTTY or AX.25. Only available in FSK mode. More...
 
int16_t setDirectSyncWord (uint32_t syncWord, uint8_t len)
 Set sync word to be used to determine start of packet in direct reception mode. More...
 
int16_t available ()
 Get the number of direct mode bytes currently available in buffer. More...
 
void dropSync ()
 Forcefully drop synchronization.
 
uint8_t read (bool drop=true)
 Get data from direct mode buffer. More...
 
virtual int16_t setDIOMapping (uint32_t pin, uint32_t value)
 Configure DIO pin mapping to get a given signal on a DIO pin (if available). More...
 
virtual 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.
 

Detailed Description

Derived class for SX1281 modules.

Constructor & Destructor Documentation

◆ SX1281()

SX1281::SX1281 ( Module mod)

Default constructor.

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

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