RadioLib
Universal wireless communication library for Arduino
Loading...
Searching...
No Matches
SX126x.h
1#if !defined(_RADIOLIB_SX126X_H)
2#define _RADIOLIB_SX126X_H
3
4#include "../../TypeDef.h"
5
6#if !RADIOLIB_EXCLUDE_SX126X
7
8#include "../../Module.h"
9
10#include "../../protocols/PhysicalLayer/PhysicalLayer.h"
11#include "../../utils/ConvCode.h"
12#include "../../utils/CRC.h"
13
14#include "SX126x_commands.h"
15#include "SX126x_registers.h"
16
17// SX126X physical layer properties
18#define RADIOLIB_SX126X_FREQUENCY_STEP_SIZE 0.9536743164
19#define RADIOLIB_SX126X_MAX_PACKET_LENGTH 255
20#define RADIOLIB_SX126X_CRYSTAL_FREQ 32.0f
21#define RADIOLIB_SX126X_DIV_EXPONENT 25
22
23#define RADIOLIB_SX1261_POUT_MIN -17
24#define RADIOLIB_SX1261_POUT_MAX 15
25#define RADIOLIB_SX1262_POUT_MIN -9
26#define RADIOLIB_SX1262_POUT_MAX 22
27#define RADIOLIB_SX1268_POUT_MIN -9
28#define RADIOLIB_SX1268_POUT_MAX 22
29#define RADIOLIB_STM32WLX_LP_POUT_MIN -17
30#define RADIOLIB_STM32WLX_LP_POUT_MAX 14
31#define RADIOLIB_STM32WLX_HP_POUT_MIN -9
32#define RADIOLIB_STM32WLX_HP_POUT_MAX 22
33
34// LR-FHSS packet lengths
35#define RADIOLIB_SX126X_LR_FHSS_MAX_ENC_SIZE (608)
36#define RADIOLIB_SX126X_LR_FHSS_HEADER_BITS (114)
37#define RADIOLIB_SX126X_LR_FHSS_HDR_BYTES (10)
38#define RADIOLIB_SX126X_LR_FHSS_SYNC_WORD_BYTES (4)
39#define RADIOLIB_SX126X_LR_FHSS_FRAG_BITS (48)
40#define RADIOLIB_SX126X_LR_FHSS_BLOCK_PREAMBLE_BITS (2)
41#define RADIOLIB_SX126X_LR_FHSS_BLOCK_BITS (RADIOLIB_SX126X_LR_FHSS_FRAG_BITS + RADIOLIB_SX126X_LR_FHSS_BLOCK_PREAMBLE_BITS)
42
43// convert a GFSK/BPSK bit rate in bps to the raw value used by the radio
44#define RADIOLIB_SX126X_BIT_RATE_RAW(BR) ((uint32_t)((RADIOLIB_UNIT_MEGA(RADIOLIB_SX126X_CRYSTAL_FREQ) * 32UL) / (BR)))
45
51class SX126x: public PhysicalLayer {
52 public:
53 // introduce PhysicalLayer overloads
60
66 struct __attribute__((packed)) paTableEntry_t {
67 uint8_t paDutyCycle: 4;
68 uint8_t hpMax: 4;
69 int8_t paVal;
70 };
71
76 explicit SX126x(Module* mod);
77
84 RadioLibTCXOVoltage_t tcxoVoltage = Voltage1V6;
85
90 bool useRegulatorLDO = false;
91
92 // basic methods
93
102 int16_t begin(uint8_t cr, uint8_t syncWord, uint16_t preambleLength);
103
112 int16_t beginFSK(uint32_t br, uint32_t freqDev, uint32_t rxBw, uint16_t preambleLength);
113
119 int16_t beginBPSK(uint32_t br);
120
128 int16_t beginLRFHSS(uint8_t bw, uint8_t cr, bool narrowGrid);
129
139 int16_t setLrFhssConfig(uint8_t bw, uint8_t cr, bool narrowGrid, uint8_t hdrCount = 3, uint16_t hopSeed = 0x13A) override;
140
147 int16_t reset(bool verify = true);
148
157 int16_t transmit(const uint8_t* data, size_t len, uint8_t addr = 0) override;
158
168 int16_t receive(uint8_t* data, size_t len, RadioLibTime_t timeout = 0) override;
169
175 int16_t transmitDirect(uint32_t frf = 0) override;
176
182 int16_t receiveDirect() override;
183
189 int16_t scanChannel() override;
190
196 int16_t scanChannel(const ChannelScanConfig_t &config) override;
197
204 int16_t resetAGC();
205
212 int16_t calibrate(uint8_t params);
213
219 int16_t sleep() override;
220
227 int16_t sleep(bool retainConfig);
228
234 int16_t standby() override;
235
242 int16_t standby(uint8_t mode) override;
243
251 int16_t standby(uint8_t mode, bool wakeup);
252
258 int16_t hopLRFHSS();
259
260 // interrupt methods
261
266 virtual void setDio1Action(void (*func)(void));
267
271 virtual void clearDio1Action();
272
277 int16_t finishReceive() override;
278
285 int16_t startReceive() override;
286
299 int16_t startReceiveDutyCycle(uint32_t rxPeriod, uint32_t sleepPeriod, RadioLibIrqFlags_t irqFlags = RADIOLIB_IRQ_RX_DEFAULT_FLAGS, RadioLibIrqFlags_t irqMask = RADIOLIB_IRQ_RX_DEFAULT_MASK);
300
319 int16_t startReceiveDutyCycleAuto(uint16_t senderPreambleLength = 0, uint16_t minSymbols = 0, RadioLibIrqFlags_t irqFlags = RADIOLIB_IRQ_RX_DEFAULT_FLAGS, RadioLibIrqFlags_t irqMask = RADIOLIB_IRQ_RX_DEFAULT_MASK);
320
329 int16_t readData(uint8_t* data, size_t len) override;
330
336 int16_t startChannelScan() override;
337
344 int16_t startChannelScan(const ChannelScanConfig_t &cfg) override;
345
350 int16_t getChannelScanResult() override;
351
352 // configuration methods
353
359 int16_t setBandwidth(uint32_t bw) override;
360
366 int16_t setSpreadingFactor(uint8_t sf) override;
367
377 int16_t setCodingRate(uint8_t cr, bool longInterleave = false) override;
378
385 int16_t setSyncWord(uint8_t syncWord, uint8_t controlBits = 0x44);
386
392 int16_t setCurrentLimit(float currentLimit);
393
398 float getCurrentLimit();
399
409 int16_t setPreambleLength(size_t len, size_t detLen = 0xFFFFFFFF) override;
410
416 int16_t setFrequencyDeviation(uint32_t freqDev) override;
417
423 int16_t setBitRate(uint32_t br) override;
424
432 int16_t checkDataRate(DataRate_t dr, ModemType_t modem = RADIOLIB_MODEM_NONE) override;
433
441 int16_t setRxBandwidth(uint32_t rxBw);
442
451 int16_t setRxBoostedGainMode(bool rxbgm, bool persist = true);
452
460 int16_t setDataShaping(uint8_t sh) override;
461
473 int16_t setSyncWord(uint8_t* syncWord, size_t len) override;
474
483 int16_t setCRC(uint8_t len, uint16_t initial = 0x1D0F, uint16_t polynomial = 0x1021, bool inverted = true);
484
492 int16_t setWhitening(bool enabled, uint16_t initial = 0x01FF);
493
503 int16_t setTCXO(RadioLibTCXOVoltage_t voltage, uint32_t delay = 5000);
504
509 int16_t setDio2AsRfSwitch(bool enable = true);
510
516 float getRSSI() override;
517
523 float getRSSI(bool packet);
524
529 float getSNR() override;
530
538 int32_t getFrequencyError();
539
547 size_t getPacketLength(bool update = true) override;
548
557 size_t getPacketLength(bool update, uint8_t* offset);
558
565 int16_t getLoRaRxHeaderInfo(uint8_t* cr, bool* hasCRC);
566
572 int16_t fixedPacketLengthMode(uint8_t len = RADIOLIB_SX126X_MAX_PACKET_LENGTH);
573
579 int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_SX126X_MAX_PACKET_LENGTH);
580
586 RadioLibTime_t getTimeOnAir(size_t len) override;
587
594
599 uint32_t getIrqFlags() override;
600
606 int16_t setIrqFlags(uint32_t irq) override;
607
613 int16_t clearIrqFlags(uint32_t irq) override;
614
620 int16_t implicitHeader(size_t len);
621
626 int16_t explicitHeader();
627
632 int16_t setRegulatorLDO();
633
638 int16_t setRegulatorDCDC();
639
645 int16_t setEncoding(uint8_t encoding) override;
646
648 void setRfSwitchPins(uint32_t rxEn, uint32_t txEn);
649
651 void setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
652
661 int16_t forceLDRO(bool enable);
662
669 int16_t autoLDRO();
670
675 uint8_t randomByte() override;
676
682 int16_t invertIQ(bool enable) override;
683
689 int16_t getModem(ModemType_t* modem) override;
690
692 int16_t getMode(RadioModeType_t* mode) override;
693
695 int16_t stageMode(RadioModeType_t mode, RadioModeConfig_t* cfg) override;
696
698 int16_t launchMode() override;
699
701 int16_t writeTxBuffer(const uint8_t* data, size_t len) override;
702
704 int16_t clearTxBuffer() override;
705
706 #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
711 void setDirectAction(void (*func)(void)) override;
712
717 void readBit(uint32_t pin) override;
718 #endif
719
729 int16_t uploadPatch(const uint32_t* patch, size_t len, bool nonvolatile = true);
730
738 int16_t spectralScanStart(uint16_t numSamples, uint8_t window = RADIOLIB_SX126X_SPECTRAL_SCAN_WINDOW_DEFAULT, uint8_t interval = RADIOLIB_SX126X_SCAN_INTERVAL_8_20_US);
739
743 void spectralScanAbort();
744
749 int16_t spectralScanGetStatus();
750
756 int16_t spectralScanGetResult(uint16_t* results);
757
769 int16_t setPaConfig(uint8_t paDutyCycle, uint8_t deviceSel, uint8_t hpMax = RADIOLIB_SX126X_PA_CONFIG_HP_MAX, uint8_t paLut = RADIOLIB_SX126X_PA_CONFIG_PA_LUT);
770
778 int16_t calibrateImage(uint32_t freq);
779
787 int16_t calibrateImageRejection(uint32_t freqMin, uint32_t freqMax);
788
793 int16_t setPaRampTime(uint8_t rampTime);
794
808 int16_t setOutputPower(int8_t power, uint8_t paDutyCycle, uint8_t hpMax, uint8_t deviceSel);
809
817 void setPaTable(SX126x::paTableEntry_t* table);
818
825 int16_t setStandbyXOSC(bool enable);
826
827#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
828 protected:
829#endif
830 Module* getMod() override;
831
832 // SX126x SPI command implementations
833 int16_t setFs();
834 int16_t setTx(uint32_t timeout = 0);
835 int16_t setRx(uint32_t timeout);
836 int16_t setCad(uint8_t symbolNum, uint8_t detPeak, uint8_t detMin, uint8_t exitMode, RadioLibTime_t timeout);
837 int16_t writeRegister(uint16_t addr, const uint8_t* data, uint8_t numBytes);
838 int16_t readRegister(uint16_t addr, uint8_t* data, uint8_t numBytes);
839 int16_t writeBuffer(const uint8_t* data, uint8_t numBytes, uint8_t offset = 0x00);
840 int16_t readBuffer(uint8_t* data, uint8_t numBytes, uint8_t offset = 0x00);
841 int16_t setDioIrqParams(uint16_t irqMask, uint16_t dio1Mask, uint16_t dio2Mask = RADIOLIB_SX126X_IRQ_NONE, uint16_t dio3Mask = RADIOLIB_SX126X_IRQ_NONE);
842 virtual int16_t clearIrqStatus(uint16_t clearIrqParams = RADIOLIB_SX126X_IRQ_ALL);
843 int16_t setRfFrequency(uint32_t frf);
844 int16_t calibrateImage(const uint8_t* data);
845 uint8_t getPacketType();
846 int16_t setTxParams(uint8_t power, uint8_t rampTime);
847 int16_t setModulationParams(uint8_t sf, uint8_t bw, uint8_t cr, uint8_t ldro);
848 int16_t setModulationParamsFSK(uint32_t br, uint8_t sh, uint8_t rxBw, uint32_t freqDev);
849 int16_t setModulationParamsBPSK(uint32_t br, uint8_t sh = RADIOLIB_SX126X_BPSK_PULSE_SHAPE);
850 int16_t setPacketParams(uint16_t preambleLen, uint8_t crcType, uint8_t payloadLen, uint8_t hdrType, uint8_t invertIQ);
851 int16_t setPacketParamsFSK(uint16_t preambleLen, uint8_t preambleDetectorLen, uint8_t crcType, uint8_t syncWordLen, uint8_t addrCmp, uint8_t whiten, uint8_t packType = RADIOLIB_SX126X_GFSK_PACKET_VARIABLE, uint8_t payloadLen = 0xFF);
852 int16_t setPacketParamsBPSK(uint8_t payloadLen, uint16_t rampUpDelay, uint16_t rampDownDelay, uint16_t payloadLenBits);
853 int16_t setBufferBaseAddress(uint8_t txBaseAddress = 0x00, uint8_t rxBaseAddress = 0x00);
854 int16_t setRegulatorMode(uint8_t mode);
855 int16_t setLoRaSymbNumTimeout(uint8_t symbolNum);
856 uint8_t getStatus();
857 uint32_t getPacketStatus();
858 uint16_t getDeviceErrors();
859 int16_t clearDeviceErrors();
860
861#if !RADIOLIB_GODMODE
862 protected:
863#endif
864 const char* chipType = NULL;
865 uint8_t bandwidth = 0;
866 uint32_t freqHz = 0;
867
868 // Allow subclasses to define different TX modes
869 uint8_t txMode = Module::MODE_TX;
870
871 // pointer to PA lookup table - may be overridden by the user
872 SX126x::paTableEntry_t* paOptTable = nullptr;
873
874 int16_t setFrequencyRaw(uint32_t freq);
875 int16_t fixPaClamping(bool enable = true);
876
877 // common low-level SPI interface
878 static int16_t SPIparseStatus(uint8_t in);
879
880#if !RADIOLIB_GODMODE
881 private:
882#endif
883 Module* mod;
884
885 uint8_t spreadingFactor = 0, codingRate = 0, ldrOptimize = 0, crcTypeLoRa = 0, headerType = 0;
886 uint16_t preambleLengthLoRa = 0;
887 uint32_t bandwidthHz = 0;
888 bool ldroAuto = true;
889 bool standbyXOSC = false;
890
891 uint32_t bitRateRaw = 0, frequencyDev = 0;
892 uint8_t preambleDetLength = 0, rxBandwidth = 0, pulseShape = 0, crcTypeFSK = 0, syncWordLength = 0, whitening = 0, packetType = 0;
893 uint16_t preambleLengthFSK = 0;
894 uint32_t rxBandwidthHz = 0;
895
896 uint32_t tcxoDelay = 0;
897 uint8_t pwr = 0;
898 bool dio2RfSwitch = false;
899 bool rxBoostedGainMode = false;
900
901 size_t implicitLen = 0;
902 uint8_t invertIQEnabled = RADIOLIB_SX126X_LORA_IQ_STANDARD;
903 uint32_t rxTimeout = 0;
904
905 // LR-FHSS stuff - there's a lot of it because all the encoding happens in software
906 uint8_t lrFhssCr = RADIOLIB_SX126X_LR_FHSS_CR_2_3;
907 uint8_t lrFhssBw = RADIOLIB_SX126X_LR_FHSS_BW_722_66;
908 uint8_t lrFhssHdrCount = 3;
909 uint8_t lrFhssSyncWord[RADIOLIB_SX126X_LR_FHSS_SYNC_WORD_BYTES] = { 0x12, 0xAD, 0x10, 0x1B };
910 bool lrFhssGridNonFcc = false;
911 uint16_t lrFhssNgrid = 0;
912 uint16_t lrFhssLfsrState = 0;
913 uint16_t lrFhssPoly = 0;
914 uint16_t lrFhssSeed = 0;
915 uint16_t lrFhssHopSeqId = 0;
916 size_t lrFhssFrameBitsRem = 0;
917 size_t lrFhssFrameHopsRem = 0;
918 size_t lrFhssHopNum = 0;
919
920 int16_t modSetup(uint8_t modem);
921 int16_t config(uint8_t modem);
922 bool findChip(const char* verStr);
923 int16_t setPacketMode(uint8_t mode, uint8_t len);
924 int16_t setHeaderType(uint8_t hdrType, size_t len = 0xFF);
925 int16_t directMode();
926 int16_t packetMode();
927
928 // fixes to errata
929 int16_t fixSensitivity();
930 int16_t fixImplicitTimeout();
931 int16_t fixInvertedIQ(uint8_t iqConfig);
932 int16_t fixGFSK();
933
934 // LR-FHSS utilities
935 int16_t buildLRFHSSPacket(const uint8_t* in, size_t in_len, uint8_t* out, size_t* out_len, size_t* out_bits, size_t* out_hops);
936 int16_t resetLRFHSS();
937 uint16_t stepLRFHSS();
938 int16_t setLRFHSSHop(uint8_t index);
939};
940
941#endif
942
943#endif
Implements all common low-level methods to control the wireless module. Every module class contains o...
Definition Module.h:74
static const size_t RFSWITCH_MAX_PINS
The maximum number of pins supported by the RF switch code. Note: It is not recommended to use this c...
Definition Module.h:83
@ MODE_TX
Transmission mode.
Definition Module.h:120
virtual int16_t startReceive()
Sets module to received mode using its default configuration.
Definition PhysicalLayer.cpp:131
virtual int16_t readData(uint8_t *data, size_t len)
Reads data that was received after calling startReceive method.
Definition PhysicalLayer.cpp:235
int16_t transmit(const char *str, uint8_t addr=0)
C-string transmit method.
Definition PhysicalLayer.cpp:53
int16_t startTransmit(const char *str, uint8_t addr=0)
Interrupt-driven Arduino String transmit method. Unlike the standard transmit method,...
Definition PhysicalLayer.cpp:157
virtual int16_t setOutputPower(int8_t power)
Set output power. Must be implemented in module class if the module supports it.
Definition PhysicalLayer.cpp:305
virtual int16_t receive(uint8_t *data, size_t len, RadioLibTime_t timeout=0)
Binary receive method. Must be implemented in module class.
Definition PhysicalLayer.cpp:111
PhysicalLayer()
Default constructor.
Definition PhysicalLayer.cpp:5
int16_t startChannelScan() override
Interrupt-driven channel activity detection method. DIO1 will be activated when LoRa preamble is dete...
Definition SX126x.cpp:568
int16_t setRxBandwidth(uint32_t rxBw)
Sets FSK receiver bandwidth. Allowed values are 4.8, 5.8, 7.3, 9.7, 11.7, 14.6, 19....
Definition SX126x_config.cpp:254
int16_t calibrateImage(uint32_t freq)
Perform image rejection calibration for the specified frequency. Will try to use Semtech-defined pres...
Definition SX126x.cpp:1222
void setRfSwitchPins(uint32_t rxEn, uint32_t txEn)
Some modules contain external RF switch controlled by pins. This function gives RadioLib control over...
Definition SX126x_config.cpp:520
int16_t beginFSK(uint32_t br, uint32_t freqDev, uint32_t rxBw, uint16_t preambleLength)
Initialization method for FSK modem.
Definition SX126x.cpp:69
virtual void setDio1Action(void(*func)(void))
Sets interrupt service routine to call when DIO1 activates.
Definition SX126x_config.cpp:12
int16_t setSpreadingFactor(uint8_t sf) override
Sets LoRa spreading factor. Allowed values range from 5 to 12.
Definition SX126x_config.cpp:68
int16_t setPaConfig(uint8_t paDutyCycle, uint8_t deviceSel, uint8_t hpMax=RADIOLIB_SX126X_PA_CONFIG_HP_MAX, uint8_t paLut=RADIOLIB_SX126X_PA_CONFIG_PA_LUT)
Set the PA configuration. Allows user to optimize PA for a specific output power and matching network...
Definition SX126x_commands.cpp:168
int16_t getLoRaRxHeaderInfo(uint8_t *cr, bool *hasCRC)
Get LoRa header information from last received packet. Only valid in explicit header mode.
Definition SX126x.cpp:721
RadioLibTime_t getTimeOnAir(size_t len) override
Get expected time-on-air for a given size of payload.
Definition SX126x.cpp:735
uint8_t randomByte() override
Get one truly random byte from RSSI noise.
Definition SX126x.cpp:831
RadioLibTime_t calculateRxTimeout(RadioLibTime_t timeoutUs) override
Calculate the timeout value for this specific module / series (in number of symbols or units of time)...
Definition SX126x.cpp:810
int16_t setDataShaping(uint8_t sh) override
Sets time-bandwidth product of Gaussian filter applied for shaping. Allowed values are RADIOLIB_SHAPI...
Definition SX126x_config.cpp:315
int16_t setRegulatorLDO()
Set regulator mode to LDO.
Definition SX126x_config.cpp:508
int16_t invertIQ(bool enable) override
Enable/disable inversion of the I and Q signals.
Definition SX126x_config.cpp:549
int16_t uploadPatch(const uint32_t *patch, size_t len, bool nonvolatile=true)
Upload binary patch into the SX126x device RAM. Patch is needed to e.g., enable spectral scan and mus...
Definition SX126x.cpp:1134
int16_t setEncoding(uint8_t encoding) override
Sets transmission encoding. Available in FSK mode only. Serves only as alias for PhysicalLayer compat...
Definition SX126x_config.cpp:516
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...
Definition SX126x_config.cpp:524
int16_t setFrequencyDeviation(uint32_t freqDev) override
Sets FSK frequency deviation. Allowed values range from 0 to 200 kHz.
Definition SX126x_config.cpp:172
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...
Definition SX126x.cpp:528
int16_t setStandbyXOSC(bool enable)
Set standby mode to be used. XOSC standby uses more power, but allows faster switching between Rx and...
Definition SX126x_config.cpp:628
int16_t checkDataRate(DataRate_t dr, ModemType_t modem=RADIOLIB_MODEM_NONE) override
Check the data rate can be configured by this module.
Definition SX126x_config.cpp:228
int16_t explicitHeader()
Set explicit header mode for future reception/transmission.
Definition SX126x_config.cpp:504
int16_t setOutputPower(int8_t power, uint8_t paDutyCycle, uint8_t hpMax, uint8_t deviceSel)
Sets output power. Allowed values are in range from -9 to 22 dBm. This method allows user full contro...
Definition SX126x_config.cpp:606
int16_t writeTxBuffer(const uint8_t *data, size_t len) override
Write a payload into the transmit buffer without staging or starting a transmission....
Definition SX126x.cpp:1077
int16_t forceLDRO(bool enable)
Forces LoRa low data rate optimization. Only available in LoRa mode. After calling this method,...
Definition SX126x_config.cpp:528
int16_t begin(uint8_t cr, uint8_t syncWord, uint16_t preambleLength)
Initialization method for LoRa modem.
Definition SX126x.cpp:23
int16_t hopLRFHSS()
Handle LR-FHSS hop. When using LR-FHSS in interrupt-driven mode, this method MUST be called each time...
Definition SX126x.cpp:441
int16_t resetAGC()
Reset the AGC gain state by performing a warm sleep, recalibration, and image rejection calibration c...
Definition SX126x_commands.cpp:11
void setDirectAction(void(*func)(void)) override
Set interrupt service routine function to call when data bit is received in direct mode.
Definition SX126x.cpp:1125
int16_t setIrqFlags(uint32_t irq) override
Set interrupt on DIO1 to be sent on a specific IRQ bit (e.g. RxTimeout, CadDone).
Definition SX126x.cpp:823
int16_t spectralScanGetStatus()
Read the status of spectral scan.
Definition SX126x.cpp:1202
int16_t setLrFhssConfig(uint8_t bw, uint8_t cr, bool narrowGrid, uint8_t hdrCount=3, uint16_t hopSeed=0x13A) override
Sets LR-FHSS configuration.
Definition SX126x.cpp:164
float getSNR() override
Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem.
Definition SX126x.cpp:652
int16_t finishReceive() override
Clean up after reception is done.
Definition SX126x.cpp:451
int16_t setRegulatorDCDC()
Set regulator mode to DC-DC.
Definition SX126x_config.cpp:512
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 Physical...
Definition SX126x.cpp:213
int16_t setBandwidth(uint32_t bw) override
Sets LoRa bandwidth. Allowed values are 7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125....
Definition SX126x_config.cpp:20
int16_t startReceive() override
Interrupt-driven receive method with default parameters. Implemented for compatibility with PhysicalL...
Definition SX126x.cpp:465
virtual void clearDio1Action()
Clears interrupt service routine to call when DIO1 activates.
Definition SX126x_config.cpp:16
int16_t clearTxBuffer() override
Discard a payload previously written by writeTxBuffer. On radios whose transmit buffer is simply over...
Definition SX126x.cpp:1092
int32_t getFrequencyError()
Gets frequency error of the latest received packet. WARNING: This functionality is based on SX128x im...
Definition SX126x.cpp:668
float getRSSI() override
Gets received signal strength indicator. Overload with packet mode enabled for PhysicalLayer compatib...
Definition SX126x.cpp:633
int16_t standby() override
Sets the module to standby mode (overload for PhysicalLayer compatibility). Uses 13 MHz RC oscillator...
Definition SX126x_commands.cpp:67
int16_t setBitRate(uint32_t br) override
Sets FSK bit rate. Allowed values range from 600 bps to 300 kbps.
Definition SX126x_config.cpp:192
int16_t setCodingRate(uint8_t cr, bool longInterleave=false) override
Sets LoRa coding rate denominator. Allowed values range from 4 to 8. Note that a value of 4 means no ...
Definition SX126x_config.cpp:81
int16_t setTCXO(RadioLibTCXOVoltage_t voltage, uint32_t delay=5000)
Sets TCXO (Temperature Compensated Crystal Oscillator) configuration.
Definition SX126x_config.cpp:563
void spectralScanAbort()
Abort an ongoing spectral scan.
Definition SX126x.cpp:1198
int16_t getModem(ModemType_t *modem) override
Get modem currently in use by the radio.
Definition SX126x.cpp:860
int16_t sleep() override
Sets the module to sleep mode. To wake the device up, call standby(). Overload with warm start enable...
Definition SX126x_commands.cpp:47
int16_t receiveDirect() override
Starts direct mode reception. Only implemented for PhysicalLayer compatibility, as SX126x series does...
Definition SX126x.cpp:337
int16_t spectralScanStart(uint16_t numSamples, uint8_t window=RADIOLIB_SX126X_SPECTRAL_SCAN_WINDOW_DEFAULT, uint8_t interval=RADIOLIB_SX126X_SCAN_INTERVAL_8_20_US)
Start spectral scan. Requires binary path to be uploaded.
Definition SX126x.cpp:1182
int16_t setPreambleLength(size_t len, size_t detLen=0xFFFFFFFF) override
Sets preamble length for LoRa or FSK modem. Allowed values range from 1 to 65535.
Definition SX126x_config.cpp:145
int16_t setCurrentLimit(float currentLimit)
Sets current protection limit. Can be set in 2.5 mA steps.
Definition SX126x_config.cpp:123
int16_t setRxBoostedGainMode(bool rxbgm, bool persist=true)
Enables or disables Rx Boosted Gain mode as described in SX126x datasheet section 9....
Definition SX126x_config.cpp:297
int16_t transmitDirect(uint32_t frf=0) override
Starts direct mode transmission.
Definition SX126x.cpp:322
int16_t variablePacketLengthMode(uint8_t maxLen=RADIOLIB_SX126X_MAX_PACKET_LENGTH)
Set modem in variable packet length mode. Available in FSK mode only.
Definition SX126x_config.cpp:497
int16_t setCRC(uint8_t len, uint16_t initial=0x1D0F, uint16_t polynomial=0x1021, bool inverted=true)
Sets CRC configuration.
Definition SX126x_config.cpp:394
int16_t reset(bool verify=true)
Reset method. Will reset the chip to the default state using RST pin.
Definition SX126x.cpp:178
int16_t setSyncWord(uint8_t syncWord, uint8_t controlBits=0x44)
Sets LoRa sync word.
Definition SX126x_config.cpp:112
void setPaTable(SX126x::paTableEntry_t *table)
Sets custom PA configuration table.
Definition SX126x_config.cpp:624
float getCurrentLimit()
Reads current protection limit.
Definition SX126x_config.cpp:136
int16_t beginBPSK(uint32_t br)
Initialization method for BPSK modem.
Definition SX126x.cpp:122
SX126x(Module *mod)
Default constructor.
Definition SX126x.cpp:6
int16_t launchMode() override
Launch previously staged mode.
Definition SX126x.cpp:1097
int16_t stageMode(RadioModeType_t mode, RadioModeConfig_t *cfg) override
Stage mode of the radio to be launched later using launchMode.
Definition SX126x.cpp:908
int16_t calibrate(uint8_t params)
Perform calibration of the specified blocks.
Definition SX126x_commands.cpp:43
int16_t clearIrqFlags(uint32_t irq) override
Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone).
Definition SX126x.cpp:827
uint32_t getIrqFlags() override
Read currently active IRQ flags.
Definition SX126x.cpp:817
int16_t getMode(RadioModeType_t *mode) override
Read the operating mode the radio is in, as the chip reports it. Unlike PhysicalLayer::stagedMode,...
Definition SX126x.cpp:879
int16_t autoLDRO()
Re-enables automatic LDRO configuration. Only available in LoRa mode. After calling this method,...
Definition SX126x_config.cpp:540
int16_t calibrateImageRejection(uint32_t freqMin, uint32_t freqMax)
Perform image rejection calibration for the specified frequency band. WARNING: Use at your own risk!...
Definition SX126x.cpp:1258
int16_t fixedPacketLengthMode(uint8_t len=RADIOLIB_SX126X_MAX_PACKET_LENGTH)
Set modem in fixed packet length mode. Available in FSK mode only.
Definition SX126x_config.cpp:493
size_t getPacketLength(bool update=true) override
Query modem for the packet length of received payload. In LoRa implicit header mode or FSK fixed leng...
Definition SX126x.cpp:700
void readBit(uint32_t pin) override
Function to read and process data bit in direct reception mode.
Definition SX126x.cpp:1129
int16_t scanChannel() override
Performs scan for LoRa transmission in the current channel. Detects both preamble and payload....
Definition SX126x.cpp:411
int16_t setPaRampTime(uint8_t rampTime)
Set PA ramp-up time. Set to 200us by default.
Definition SX126x_config.cpp:602
int16_t beginLRFHSS(uint8_t bw, uint8_t cr, bool narrowGrid)
Initialization method for LR-FHSS modem. This modem only supports transmission!
Definition SX126x.cpp:138
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 PhysicalL...
Definition SX126x.cpp:275
int16_t implicitHeader(size_t len)
Set implicit header mode for future reception/transmission.
Definition SX126x_config.cpp:500
int16_t setDio2AsRfSwitch(bool enable=true)
Set DIO2 to function as RF switch (default in Semtech example designs).
Definition SX126x_config.cpp:596
int16_t spectralScanGetResult(uint16_t *results)
Read the result of spectral scan.
Definition SX126x.cpp:1210
int16_t setWhitening(bool enabled, uint16_t initial=0x01FF)
Sets FSK whitening parameters.
Definition SX126x_config.cpp:454
int16_t startReceiveDutyCycleAuto(uint16_t senderPreambleLength=0, uint16_t minSymbols=0, RadioLibIrqFlags_t irqFlags=RADIOLIB_IRQ_RX_DEFAULT_FLAGS, RadioLibIrqFlags_t irqMask=RADIOLIB_IRQ_RX_DEFAULT_MASK)
Calls startReceiveDutyCycle with rxPeriod and sleepPeriod set so the unit shouldn't miss any messages...
Definition SX126x.cpp:506
int16_t startReceiveDutyCycle(uint32_t rxPeriod, uint32_t sleepPeriod, RadioLibIrqFlags_t irqFlags=RADIOLIB_IRQ_RX_DEFAULT_FLAGS, RadioLibIrqFlags_t irqMask=RADIOLIB_IRQ_RX_DEFAULT_MASK)
Interrupt-driven receive method where the device mostly sleeps and periodically wakes to listen....
Definition SX126x.cpp:469
int16_t getChannelScanResult() override
Read the channel scan result.
Definition SX126x.cpp:614
RadioLibTCXOVoltage_t tcxoVoltage
TCXO reference voltage to be set on DIO3. Defaults to 1.6 V. If you are seeing -706/-707 error codes,...
Definition SX126x.h:84
bool useRegulatorLDO
Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false.
Definition SX126x.h:90
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition TypeDef.h:783
uint32_t RadioLibIrqFlags_t
Type used for radio-agnostic IRQ flags. IRQ to enable corresponds to the bit index (RadioLibIrq_t)....
Definition TypeDef.h:789
Description of RF switch pin states for a single mode. See setRfSwitchTable for details.
Definition Module.h:90
This structure is used as entry in the PA lookup table, to optimize PA configuration for minimum powe...
Common channel scan configuration structure.
Definition PhysicalLayer.h:168
Common data rate structure.
Definition PhysicalLayer.h:74
Definition PhysicalLayer.h:214