|
RadioLib
Universal wireless communication library for Arduino
|
Control class for SX1231 module. Overrides some methods from RF69 due to different register values. More...
#include <SX1231.h>
Public Member Functions | |
| SX1231 (Module *mod) | |
| Default constructor. | |
| virtual int16_t | begin (const ConfigFSK_t &config) |
| Initialization method for FSK modem. | |
| Public Member Functions inherited from RF69 | |
| RF69 (Module *module) | |
| Default constructor. | |
| int16_t | begin (const ConfigFSK_t &config) |
| Initialization method for FSK modem. | |
| void | 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, RadioLibTime_t timeout=0) override |
| Blocking binary receive method. Overloads for string-based transmissions are implemented in PhysicalLayer. | |
| int16_t | sleep () override |
| Sets the module to sleep mode. | |
| int16_t | standby () override |
| Sets the module to standby mode. | |
| int16_t | standby (uint8_t mode) override |
| Sets the module to standby. | |
| int16_t | transmitDirect (uint32_t frf=0) override |
| Starts direct mode transmission. | |
| int16_t | receiveDirect () override |
| Starts direct mode reception. | |
| int16_t | packetMode () |
| Stops direct mode. It is required to call this method to switch from direct transmissions to packet-based transmissions. | |
| void | setAESKey (const uint8_t *key) |
| Sets AES key. | |
| int16_t | enableAES () |
| Enables AES encryption. | |
| int16_t | disableAES () |
| Disables AES encryption. | |
| void | setDio0Action (void(*func)(void)) |
| Sets interrupt service routine to call when DIO0 activates. | |
| void | clearDio0Action () |
| Clears interrupt service routine to call when DIO0 activates. | |
| void | setDio1Action (void(*func)(void)) |
| Sets interrupt service routine to call when DIO1 activates. | |
| void | clearDio1Action () |
| Clears interrupt service routine to call when DIO1 activates. | |
| void | setFifoEmptyAction (void(*func)(void)) |
| Set interrupt service routine function to call when FIFO is empty. | |
| void | clearFifoEmptyAction () |
| Clears interrupt service routine to call when FIFO is empty. | |
| void | setFifoThreshold (uint8_t threshold) |
| Set FIFO threshold level. Be aware that threshold is also set in setFifoFullAction method. setFifoThreshold method must be called AFTER calling setFifoFullAction! | |
| void | setFifoFullAction (void(*func)(void)) |
| Set interrupt service routine function to call when FIFO is full. | |
| void | clearFifoFullAction () |
| Clears interrupt service routine to call when FIFO is full. | |
| bool | fifoAdd (uint8_t *data, int totalLen, int *remLen) |
| Set interrupt service routine function to call when FIFO is empty. | |
| bool | fifoGet (volatile uint8_t *data, int totalLen, volatile int *rcvLen) |
| Set interrupt service routine function to call when FIFO is sufficiently full to read. | |
| int16_t | startTransmit (const uint8_t *data, size_t len, uint8_t addr=0) override |
| Interrupt-driven binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. | |
| int16_t | startReceive () override |
| Interrupt-driven receive method. GDO0 will be activated when full packet is received. | |
| int16_t | startReceive (uint32_t timeout, uint32_t irqFlags, uint32_t irqMask, size_t len) override |
| Interrupt-driven receive method, 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 | setFrequency (uint32_t freq) override |
| Sets carrier frequency. Allowed values are in bands 290 to 340 MHz, 431 to 510 MHz and 862 to 1020 MHz. | |
| int16_t | getFrequency (uint32_t *freq) |
| Gets carrier frequency. | |
| int16_t | setBitRate (uint32_t br) override |
| Sets bit rate. Allowed values range from 500 bps to 300 kbps. | |
| int16_t | setRxBandwidth (uint32_t rxBw) |
| Sets FSK receiver bandwidth. Allowed values range from 5200 Hz to 1000 kHz. Only available in FSK mode. NOTE: The values in datasheet (2.6 kHz etc.) are single-sideband (SSB)! For consistency with other radios, RadioLib uses dual-sideband (DSB) values, which are double than what is listed in the datasheet. | |
| int16_t | setFrequencyDeviation (uint32_t freqDev) override |
| Sets frequency deviation. | |
| int16_t | getFrequencyDeviation (uint32_t *freqDev) |
| Gets frequency deviation. | |
| int16_t | setOutputPower (int8_t power) override |
| Sets output power. Allowed values range from -18 to 13 dBm for low power modules (RF69C/CW) or -2 to 20 dBm (RF69H/HC/HCW). Doest not force high power mode; for modules using high power port, use RF69::setOutputPower(pwr, true). | |
| int16_t | setOutputPower (int8_t power, bool highPower) |
| Sets output power. Allowed values range from -18 to 13 dBm for low power modules (RF69C/CW) or -2 to 20 dBm (RF69H/HC/HCW). | |
| int16_t | setSyncWord (uint8_t *syncWord, size_t len) override |
| Sets sync word. Up to 8 bytes can be set as sync word. Override for PhysicalLayer compatibility, with maximum error bits set to 0. | |
| int16_t | setSyncWord (uint8_t *syncWord, size_t len, uint8_t maxErrBits) |
| Sets sync word. Up to 8 bytes can be set as sync word. | |
| int16_t | setPreambleLength (size_t len, size_t detLen=0xFFFFFFFF) override |
| Sets preamble length. | |
| 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. | |
| void | setAmbientTemperature (int16_t tempAmbient) |
| Sets ambient temperature. Required to correct values from on-board temperature sensor. | |
| int16_t | getTemperature () |
| Measures temperature. | |
| size_t | getPacketLength (bool update=true) override |
| Query modem for the packet length of received payload. | |
| int16_t | setOOK (bool enable) |
| Enables/disables OOK modulation instead of FSK. Note: This function calls setRxBandwidth again, since register values differ based on OOK mode being enabled/disabled. | |
| int16_t | setOokThresholdType (uint8_t type) |
| Selects the type of threshold in the OOK data slicer. | |
| int16_t | setOokFixedThreshold (uint8_t value) |
| Fixed threshold for the Data Slicer in OOK mode or floor threshold for the Data Slicer in OOK when Peak mode is used. | |
| int16_t | setOokPeakThresholdDecrement (uint8_t value) |
| Period of decrement of the RSSI threshold in the OOK demodulator. | |
| int16_t | fixedPacketLengthMode (uint8_t len=RADIOLIB_RF69_MAX_PACKET_LENGTH) |
| Set modem in fixed packet length mode. | |
| int16_t | variablePacketLengthMode (uint8_t maxLen=RADIOLIB_RF69_MAX_PACKET_LENGTH) |
| Set modem in variable packet length mode. | |
| int16_t | enableSyncWordFiltering (uint8_t maxErrBits=0) |
| Enable sync word filtering and generation. | |
| int16_t | disableSyncWordFiltering () |
| Disable preamble and sync word filtering and generation. | |
| int16_t | enableContinuousModeBitSync () |
| Enable Bit synchronization in continuous mode. | |
| int16_t | disableContinuousModeBitSync () |
| Disable Bit synchronization in continuous mode. | |
| int16_t | setCrcFiltering (bool enable=true) |
| Enable CRC filtering and generation. | |
| int16_t | setPromiscuousMode (bool enable=true) |
| Set modem in "sniff" mode: no packet filtering (e.g., no preamble, sync word, address, CRC). | |
| int16_t | setDataShaping (uint8_t sh) override |
| Sets Gaussian filter bandwidth-time product that will be used for data shaping. Allowed values are RADIOLIB_SHAPING_0_3, RADIOLIB_SHAPING_0_5 or RADIOLIB_SHAPING_1_0. Set to RADIOLIB_SHAPING_NONE to disable data shaping. | |
| int16_t | setEncoding (uint8_t encoding) override |
| Sets transmission encoding. Allowed values are RADIOLIB_ENCODING_NRZ, RADIOLIB_ENCODING_MANCHESTER and RADIOLIB_ENCODING_WHITENING. | |
| int16_t | setLnaTestBoost (bool value) |
| Enable/disable LNA Boost mode (disabled by default). | |
| float | getRSSI () override |
| Gets RSSI (Received Signal Strength Indicator) of the last received packet. | |
| int16_t | setRSSIThreshold (float dbm) |
| Sets the RSSI value above which the RSSI interrupt is signaled. | |
| 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. | |
| 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. | |
| uint8_t | randomByte () override |
| Get one truly random byte from RSSI noise. | |
| int16_t | getChipVersion () |
| Read version SPI register. Should return RF69_CHIP_VERSION (0x24) if SX127x is connected and working. | |
| void | setDirectAction (void(*func)(void)) override |
| Set interrupt service routine function to call when data bit is received in direct mode. | |
| void | readBit (uint32_t pin) override |
| Function to read and process data bit in direct reception mode. | |
| int16_t | setDIOMapping (uint32_t pin, uint32_t value) |
| Configure DIO pin mapping to get a given signal on a DIO pin (if available). | |
| 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. | |
| 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. | |
| virtual int16_t | finishTransmit () |
| Clean up after transmission is done. | |
| virtual int16_t | setSpreadingFactor (uint8_t sf) |
| Sets LoRa spreading factor. Must be implemented in module class. | |
| virtual int16_t | setBandwidth (uint32_t bw) |
| Sets LoRa bandwidth. Must be implemented in module class. | |
| virtual int16_t | setCodingRate (uint8_t cr, bool longInterleave=false) |
| Sets LoRa coding rate denominator. Must be implemented in module class. | |
| virtual int16_t | setLrFhssConfig (uint8_t bw, uint8_t cr, bool narrowGrid, uint8_t hdrCount=3, uint16_t hopSeed=0x13A) |
| Sets LR-FHSS configuration. Must be implemented in module class. | |
| virtual int16_t | invertIQ (bool enable) |
| Set IQ inversion. Must be implemented in module class if the module supports it. | |
| int16_t | setOutputPowerOffset (int8_t offset) |
| Sets offset of the output power. Useful for devices where the radio has an external power amplifier, or of the RF system has a known loss between the radio and the antenna. NOTE: This method must be called BEFORE any calls to radio.begin() or radio.setOutputPower() for the offset to be applied! | |
| int16_t | setOutputPowerOffset (const int8_t *lut, size_t steps) |
| Sets offset of the output power. Useful for devices where the radio has an external power amplifier, or of the RF system has a known loss between the radio and the antenna. This overload allows to compensate a non-linear PA gain, dependant on the radio power output via a lookup table. NOTE: This method must be called BEFORE any calls to radio.begin() or radio.setOutputPower() for the offset to be applied! | |
| virtual int16_t | setDataRate (DataRate_t dr, ModemType_t modem=RADIOLIB_MODEM_NONE) |
| Set data rate. Must be implemented in module class if the module supports it. | |
| virtual int16_t | checkDataRate (DataRate_t dr, ModemType_t modem=RADIOLIB_MODEM_NONE) |
| Check the data rate can be configured by this module. Must be implemented in module class if the module supports it. | |
| virtual float | getSNR () |
| Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem. | |
| virtual RadioLibTime_t | calculateTimeOnAir (ModemType_t modem, DataRate_t dr, PacketConfig_t pc, size_t len) |
| Calculate the expected time-on-air for a given modem, data rate, packet configuration and payload size. | |
| virtual RadioLibTime_t | getTimeOnAir (size_t len) |
| Get expected time-on-air for a given size of payload. | |
| virtual RadioLibTime_t | calculateRxTimeout (RadioLibTime_t timeoutUs) |
| Calculate the timeout value for this specific module / series (in number of symbols or units of time). | |
| 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! | |
| virtual uint32_t | getIrqFlags () |
| Read currently active IRQ flags. Must be implemented in module class. | |
| virtual int16_t | setIrqFlags (uint32_t irq) |
| Set interrupt on DIO1 to be sent on a specific IRQ bit (e.g. RxTimeout, CadDone). Must be implemented in module class. | |
| virtual int16_t | clearIrqFlags (uint32_t irq) |
| Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone). Must be implemented in module class. | |
| virtual int16_t | startChannelScan () |
| Interrupt-driven channel activity detection method. Interrupt will be activated when packet is detected. Must be implemented in module class. | |
| virtual int16_t | startChannelScan (const ChannelScanConfig_t &config) |
| Interrupt-driven channel activity detection method. interrupt will be activated when packet is detected. Must be implemented in module class. | |
| virtual int16_t | getChannelScanResult () |
| Read the channel scan result. | |
| virtual int16_t | scanChannel () |
| Check whether the current communication channel is free or occupied. Performs CAD for LoRa modules, or RSSI measurement for FSK modules. | |
| virtual int16_t | scanChannel (const ChannelScanConfig_t &config) |
| Check whether the current communication channel is free or occupied. Performs CAD for LoRa modules, or RSSI measurement for FSK modules. | |
| 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. | |
| 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 | setIrqAction (void(*func)(void), bool rising=true) |
| Sets interrupt service routine to call when IRQ is activated. | |
| virtual void | clearIrqAction () |
| Clears interrupt service routine to call when IRQ is activated. | |
| virtual int16_t | setModem (ModemType_t modem) |
| Set modem for the radio to use. Will perform full reset and reconfigure the radio using its default parameters. | |
| virtual int16_t | getModem (ModemType_t *modem) |
| Get modem currently in use by the radio. | |
| virtual int16_t | getMode (RadioModeType_t *mode) |
| Read the operating mode the radio is in, as the chip reports it. Unlike PhysicalLayer::stagedMode, which is what was last asked of the radio, this reads the hardware, so a caller can tell a radio that has left a mode on its own - a receive that did not survive a frame, or a chip that lost its state - from one that is still in it. | |
| virtual int16_t | stageMode (RadioModeType_t mode, RadioModeConfig_t *cfg) |
| Stage mode of the radio to be launched later using launchMode. | |
| virtual int16_t | launchMode () |
| Launch previously staged mode. | |
| virtual int16_t | writeTxBuffer (const uint8_t *data, size_t len) |
| Write a payload into the transmit buffer without staging or starting a transmission. This allows the payload write, which is the slowest part of starting a transmission, to be done while the radio is busy with something else - during a channel scan, for example. The transmission is staged afterwards by calling stageMode with RADIOLIB_RADIO_MODE_TX and RadioModeConfig_t::transmit.data set to NULL, which sets the packet parameters and the IRQ mapping for the payload already in the buffer; transmit.len must still be set to its length. The buffer holds exactly this payload after the call, whether or not one was written before. | |
| virtual int16_t | clearTxBuffer () |
| Discard a payload previously written by writeTxBuffer. On radios whose transmit buffer is simply overwritten by the next write there is nothing to discard, and this reports success without touching the radio. | |
| int16_t | calculateRxDutyCycle (size_t txPreLen, size_t rxPreLen, uint16_t minSymbols, DataRate_t *dr, uint32_t *wakePeriod, uint32_t *sleepPeriod) |
| Calculates sleep and wake cycles for startReceiveDutyCycle methods so that the receiver should not miss any messages. Useful only for LoRa modems. | |
| int8_t | getOutputPowerMin () const |
| Get the minimum output power supported by the radio. This includes any previously configured PA offset. | |
| int8_t | getOutputPowerMax () const |
| Get the maximum output power supported by the radio. This includes any previously configured PA offset. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from PhysicalLayer | |
| static float | getNumSymbols (DataRate_t dr, PacketConfig_t pc, size_t len) |
| Convert from bytes to LoRa symbols. | |
| 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. | |
| bool | resetOnStartup = true |
| Whether to reset the module on startup. Setting to false allows to restore radio operation by calling begin after deep sleep mode on some platforms (like ESP32). | |
Control class for SX1231 module. Overrides some methods from RF69 due to different register values.
| SX1231::SX1231 | ( | Module * | mod | ) |
Default constructor.
| mod | Instance of Module that will be used to communicate with the radio. |
|
virtual |
Initialization method for FSK modem.
| config | Initialization configuration. |
This method initializes the FSK modem with the specified configuration. Supports designated initializers when using C++14 or above.
Reimplemented in SX1233.