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// LR-FHSS packet lengths
24#define RADIOLIB_SX126X_LR_FHSS_MAX_ENC_SIZE (608)
25#define RADIOLIB_SX126X_LR_FHSS_HEADER_BITS (114)
26#define RADIOLIB_SX126X_LR_FHSS_HDR_BYTES (10)
27#define RADIOLIB_SX126X_LR_FHSS_SYNC_WORD_BYTES (4)
28#define RADIOLIB_SX126X_LR_FHSS_FRAG_BITS (48)
29#define RADIOLIB_SX126X_LR_FHSS_BLOCK_PREAMBLE_BITS (2)
30#define RADIOLIB_SX126X_LR_FHSS_BLOCK_BITS (RADIOLIB_SX126X_LR_FHSS_FRAG_BITS + RADIOLIB_SX126X_LR_FHSS_BLOCK_PREAMBLE_BITS)
31
37class SX126x: public PhysicalLayer {
38 public:
39 // introduce PhysicalLayer overloads
46
52 struct __attribute__((packed)) paTableEntry_t {
53 uint8_t paDutyCycle: 4;
54 uint8_t hpMax: 4;
55 int8_t paVal;
56 };
57
62 explicit SX126x(Module* mod);
63
67 bool XTAL;
68
73
74 // basic methods
75
86 int16_t begin(uint8_t cr, uint8_t syncWord, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO = false);
87
99 int16_t beginFSK(float br, float freqDev, float rxBw, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO = false);
100
108 int16_t beginBPSK(float br, float tcxoVoltage, bool useRegulatorLDO = false);
109
119 int16_t beginLRFHSS(uint8_t bw, uint8_t cr, bool narrowGrid, float tcxoVoltage, bool useRegulatorLDO = false);
120
129 int16_t setLrFhssConfig(uint8_t bw, uint8_t cr, uint8_t hdrCount = 3, uint16_t hopSeqId = 0x100);
130
137 int16_t reset(bool verify = true);
138
147 int16_t transmit(const uint8_t* data, size_t len, uint8_t addr = 0) override;
148
158 int16_t receive(uint8_t* data, size_t len, RadioLibTime_t timeout = 0) override;
159
165 int16_t transmitDirect(uint32_t frf = 0) override;
166
172 int16_t receiveDirect() override;
173
179 int16_t scanChannel() override;
180
186 int16_t scanChannel(const ChannelScanConfig_t &config) override;
187
194 int16_t resetAGC();
195
202 int16_t calibrate(uint8_t params);
203
209 int16_t sleep() override;
210
217 int16_t sleep(bool retainConfig);
218
223 int16_t standby() override;
224
231 int16_t standby(uint8_t mode) override;
232
240 int16_t standby(uint8_t mode, bool wakeup);
241
247 int16_t hopLRFHSS();
248
249 // interrupt methods
250
255 virtual void setDio1Action(void (*func)(void));
256
260 virtual void clearDio1Action();
261
266 void setPacketReceivedAction(void (*func)(void)) override;
267
271 void clearPacketReceivedAction() override;
272
277 void setPacketSentAction(void (*func)(void)) override;
278
282 void clearPacketSentAction() override;
283
288 void setChannelScanAction(void (*func)(void)) override;
289
293 void clearChannelScanAction() override;
294
299 int16_t finishTransmit() override;
300
305 int16_t finishReceive() override;
306
313 int16_t startReceive() override;
314
327 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);
328
347 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);
348
357 int16_t readData(uint8_t* data, size_t len) override;
358
364 int16_t startChannelScan() override;
365
372 int16_t startChannelScan(const ChannelScanConfig_t &config) override;
373
378 int16_t getChannelScanResult() override;
379
380 // configuration methods
381
387 virtual int16_t setBandwidth(float bw);
388
394 virtual int16_t setSpreadingFactor(uint8_t sf);
395
405 int16_t setCodingRate(uint8_t cr, bool longInterleave = false);
406
413 int16_t setSyncWord(uint8_t syncWord, uint8_t controlBits = 0x44);
414
420 int16_t setCurrentLimit(float currentLimit);
421
426 float getCurrentLimit();
427
437 int16_t setPreambleLength(size_t preambleLength) override;
438
444 int16_t setFrequencyDeviation(float freqDev) override;
445
451 int16_t setBitRate(float br) override;
452
460 int16_t setDataRate(DataRate_t dr, ModemType_t modem = RADIOLIB_MODEM_NONE) override;
461
469 int16_t checkDataRate(DataRate_t dr, ModemType_t modem = RADIOLIB_MODEM_NONE) override;
470
477 int16_t setRxBandwidth(float rxBw);
478
487 int16_t setRxBoostedGainMode(bool rxbgm, bool persist = true);
488
496 int16_t setDataShaping(uint8_t sh) override;
497
509 int16_t setSyncWord(uint8_t* syncWord, size_t len) override;
510
519 int16_t setCRC(uint8_t len, uint16_t initial = 0x1D0F, uint16_t polynomial = 0x1021, bool inverted = true);
520
528 int16_t setWhitening(bool enabled, uint16_t initial = 0x01FF);
529
539 int16_t setTCXO(float voltage, uint32_t delay = 5000);
540
545 int16_t setDio2AsRfSwitch(bool enable = true);
546
552 float getRSSI() override;
553
559 float getRSSI(bool packet);
560
565 float getSNR() override;
566
574 float getFrequencyError();
575
583 size_t getPacketLength(bool update = true) override;
584
593 size_t getPacketLength(bool update, uint8_t* offset);
594
601 int16_t getLoRaRxHeaderInfo(uint8_t* cr, bool* hasCRC);
602
608 int16_t fixedPacketLengthMode(uint8_t len = RADIOLIB_SX126X_MAX_PACKET_LENGTH);
609
615 int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_SX126X_MAX_PACKET_LENGTH);
616
625 RadioLibTime_t calculateTimeOnAir(ModemType_t modem, DataRate_t dr, PacketConfig_t pc, size_t len) override;
626
632 RadioLibTime_t getTimeOnAir(size_t len) override;
633
640
645 uint32_t getIrqFlags() override;
646
652 int16_t setIrqFlags(uint32_t irq) override;
653
659 int16_t clearIrqFlags(uint32_t irq) override;
660
666 int16_t implicitHeader(size_t len);
667
672 int16_t explicitHeader();
673
678 int16_t setRegulatorLDO();
679
684 int16_t setRegulatorDCDC();
685
691 int16_t setEncoding(uint8_t encoding) override;
692
694 void setRfSwitchPins(uint32_t rxEn, uint32_t txEn);
695
697 void setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
698
707 int16_t forceLDRO(bool enable);
708
715 int16_t autoLDRO();
716
721 uint8_t randomByte() override;
722
728 int16_t invertIQ(bool enable) override;
729
735 int16_t getModem(ModemType_t* modem) override;
736
738 int16_t stageMode(RadioModeType_t mode, RadioModeConfig_t* cfg) override;
739
741 int16_t launchMode() override;
742
743 #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
748 void setDirectAction(void (*func)(void)) override;
749
754 void readBit(uint32_t pin) override;
755 #endif
756
766 int16_t uploadPatch(const uint32_t* patch, size_t len, bool nonvolatile = true);
767
775 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);
776
780 void spectralScanAbort();
781
786 int16_t spectralScanGetStatus();
787
793 int16_t spectralScanGetResult(uint16_t* results);
794
806 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);
807
815 int16_t calibrateImage(float freq);
816
824 int16_t calibrateImageRejection(float freqMin, float freqMax);
825
830 int16_t setPaRampTime(uint8_t rampTime);
831
845 int16_t setOutputPower(int8_t power, uint8_t paDutyCycle, uint8_t hpMax, uint8_t deviceSel);
846
847#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
848 protected:
849#endif
850 Module* getMod() override;
851
852 // SX126x SPI command implementations
853 int16_t setFs();
854 int16_t setTx(uint32_t timeout = 0);
855 int16_t setRx(uint32_t timeout);
856 int16_t setCad(uint8_t symbolNum, uint8_t detPeak, uint8_t detMin, uint8_t exitMode, RadioLibTime_t timeout);
857 int16_t writeRegister(uint16_t addr, const uint8_t* data, uint8_t numBytes);
858 int16_t readRegister(uint16_t addr, uint8_t* data, uint8_t numBytes);
859 int16_t writeBuffer(const uint8_t* data, uint8_t numBytes, uint8_t offset = 0x00);
860 int16_t readBuffer(uint8_t* data, uint8_t numBytes, uint8_t offset = 0x00);
861 int16_t setDioIrqParams(uint16_t irqMask, uint16_t dio1Mask, uint16_t dio2Mask = RADIOLIB_SX126X_IRQ_NONE, uint16_t dio3Mask = RADIOLIB_SX126X_IRQ_NONE);
862 virtual int16_t clearIrqStatus(uint16_t clearIrqParams = RADIOLIB_SX126X_IRQ_ALL);
863 int16_t setRfFrequency(uint32_t frf);
864 int16_t calibrateImage(const uint8_t* data);
865 uint8_t getPacketType();
866 int16_t setTxParams(uint8_t power, uint8_t rampTime);
867 int16_t setModulationParams(uint8_t sf, uint8_t bw, uint8_t cr, uint8_t ldro);
868 int16_t setModulationParamsFSK(uint32_t br, uint8_t sh, uint8_t rxBw, uint32_t freqDev);
869 int16_t setModulationParamsBPSK(uint32_t br, uint8_t sh = RADIOLIB_SX126X_BPSK_PULSE_SHAPE);
870 int16_t setPacketParams(uint16_t preambleLen, uint8_t crcType, uint8_t payloadLen, uint8_t hdrType, uint8_t invertIQ);
871 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);
872 int16_t setPacketParamsBPSK(uint8_t payloadLen, uint16_t rampUpDelay, uint16_t rampDownDelay, uint16_t payloadLenBits);
873 int16_t setBufferBaseAddress(uint8_t txBaseAddress = 0x00, uint8_t rxBaseAddress = 0x00);
874 int16_t setRegulatorMode(uint8_t mode);
875 uint8_t getStatus();
876 uint32_t getPacketStatus();
877 uint16_t getDeviceErrors();
878 int16_t clearDeviceErrors();
879
880#if !RADIOLIB_GODMODE
881 protected:
882#endif
883 const char* chipType = NULL;
884 uint8_t bandwidth = 0;
885 float freqMHz = 0;
886
887 // Allow subclasses to define different TX modes
888 uint8_t txMode = Module::MODE_TX;
889
890 int16_t setFrequencyRaw(float freq);
891 int16_t fixPaClamping(bool enable = true);
892
893 // common low-level SPI interface
894 static int16_t SPIparseStatus(uint8_t in);
895
896#if !RADIOLIB_GODMODE
897 private:
898#endif
899 Module* mod;
900
901 uint8_t spreadingFactor = 0, codingRate = 0, ldrOptimize = 0, crcTypeLoRa = 0, headerType = 0;
902 uint16_t preambleLengthLoRa = 0;
903 float bandwidthKhz = 0;
904 bool ldroAuto = true;
905
906 uint32_t bitRate = 0, frequencyDev = 0;
907 uint8_t preambleDetLength = 0, rxBandwidth = 0, pulseShape = 0, crcTypeFSK = 0, syncWordLength = 0, whitening = 0, packetType = 0;
908 uint16_t preambleLengthFSK = 0;
909 float rxBandwidthKhz = 0;
910
911 uint32_t tcxoDelay = 0;
912 uint8_t pwr = 0;
913 bool dio2RfSwitch = false;
914 bool rxBoostedGainMode = false;
915
916 size_t implicitLen = 0;
917 uint8_t invertIQEnabled = RADIOLIB_SX126X_LORA_IQ_STANDARD;
918 uint32_t rxTimeout = 0;
919
920 // LR-FHSS stuff - there's a lot of it because all the encoding happens in software
921 uint8_t lrFhssCr = RADIOLIB_SX126X_LR_FHSS_CR_2_3;
922 uint8_t lrFhssBw = RADIOLIB_SX126X_LR_FHSS_BW_722_66;
923 uint8_t lrFhssHdrCount = 3;
924 uint8_t lrFhssSyncWord[RADIOLIB_SX126X_LR_FHSS_SYNC_WORD_BYTES] = { 0x12, 0xAD, 0x10, 0x1B };
925 bool lrFhssGridNonFcc = false;
926 uint16_t lrFhssNgrid = 0;
927 uint16_t lrFhssLfsrState = 0;
928 uint16_t lrFhssPoly = 0;
929 uint16_t lrFhssSeed = 0;
930 uint16_t lrFhssHopSeqId = 0;
931 size_t lrFhssFrameBitsRem = 0;
932 size_t lrFhssFrameHopsRem = 0;
933 size_t lrFhssHopNum = 0;
934
935 int16_t modSetup(float tcxoVoltage, bool useRegulatorLDO, uint8_t modem);
936 int16_t config(uint8_t modem);
937 bool findChip(const char* verStr);
938 int16_t setPacketMode(uint8_t mode, uint8_t len);
939 int16_t setHeaderType(uint8_t hdrType, size_t len = 0xFF);
940 int16_t directMode();
941 int16_t packetMode();
942
943 // fixes to errata
944 int16_t fixSensitivity();
945 int16_t fixImplicitTimeout();
946 int16_t fixInvertedIQ(uint8_t iqConfig);
947 int16_t fixGFSK();
948
949 // LR-FHSS utilities
950 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);
951 int16_t resetLRFHSS();
952 uint16_t stepLRFHSS();
953 int16_t setLRFHSSHop(uint8_t index);
954
955 void regdump();
956 void effectEvalPre(uint8_t* buff, uint32_t start);
957 void effectEvalPost(uint8_t* buff, uint32_t start);
958 void effectEval();
959};
960
961#endif
962
963#endif
Implements all common low-level methods to control the wireless module. Every module class contains o...
Definition Module.h:73
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:82
@ MODE_TX
Transmission mode.
Definition Module.h:119
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition PhysicalLayer.h:257
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:225
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:156
virtual int16_t setOutputPower(int8_t power)
Set output power. Must be implemented in module class if the module supports it.
Definition PhysicalLayer.cpp:270
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
Base class for SX126x series. All derived classes for SX126x (e.g. SX1262 or SX1268) inherit from thi...
Definition SX126x.h:37
int16_t startChannelScan() override
Interrupt-driven channel activity detection method. DIO1 will be activated when LoRa preamble is dete...
Definition SX126x.cpp:576
float getFrequencyError()
Gets frequency error of the latest received packet. WARNING: This functionality is based on SX128x im...
Definition SX126x.cpp:670
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:620
virtual void setDio1Action(void(*func)(void))
Sets interrupt service routine to call when DIO1 activates.
Definition SX126x_config.cpp:12
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:143
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:724
RadioLibTime_t getTimeOnAir(size_t len) override
Get expected time-on-air for a given size of payload.
Definition SX126x.cpp:811
uint8_t randomByte() override
Get one truly random byte from RSSI noise.
Definition SX126x.cpp:899
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:878
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:415
int16_t setRegulatorLDO()
Set regulator mode to LDO.
Definition SX126x_config.cpp:608
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 siz...
Definition SX126x.cpp:738
int16_t invertIQ(bool enable) override
Enable/disable inversion of the I and Q signals.
Definition SX126x_config.cpp:649
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:1143
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:616
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:624
int16_t beginFSK(float br, float freqDev, float rxBw, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO=false)
Initialization method for FSK modem.
Definition SX126x.cpp:70
virtual int16_t setBandwidth(float bw)
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:44
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:536
int16_t calibrateImage(float freq)
Perform image rejection calibration for the specified frequency. Will try to use Semtech-defined pres...
Definition SX126x.cpp:1231
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:308
int16_t explicitHeader()
Set explicit header mode for future reception/transmission.
Definition SX126x_config.cpp:604
void clearChannelScanAction() override
Clears interrupt service routine to call when a channel scan is finished.
Definition SX126x_config.cpp:40
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:726
int16_t forceLDRO(bool enable)
Forces LoRa low data rate optimization. Only available in LoRa mode. After calling this method,...
Definition SX126x_config.cpp:628
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:1134
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:891
int16_t spectralScanGetStatus()
Read the status of spectral scan.
Definition SX126x.cpp:1211
void clearPacketReceivedAction() override
Clears interrupt service routine to call when a packet is received.
Definition SX126x_config.cpp:24
int16_t setTCXO(float voltage, uint32_t delay=5000)
Sets TCXO (Temperature Compensated Crystal Oscillator) configuration.
Definition SX126x_config.cpp:663
float getSNR() override
Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem.
Definition SX126x.cpp:654
int16_t setRxBandwidth(float 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:334
int16_t finishReceive() override
Clean up after reception is done.
Definition SX126x.cpp:460
int16_t setRegulatorDCDC()
Set regulator mode to DC-DC.
Definition SX126x_config.cpp:612
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 startReceive() override
Interrupt-driven receive method with default parameters. Implemented for compatibility with PhysicalL...
Definition SX126x.cpp:474
virtual void clearDio1Action()
Clears interrupt service routine to call when DIO1 activates.
Definition SX126x_config.cpp:16
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 ...
Definition SX126x_config.cpp:108
void setPacketReceivedAction(void(*func)(void)) override
Sets interrupt service routine to call when a packet is received.
Definition SX126x_config.cpp:20
float getRSSI() override
Gets received signal strength indicator. Overload with packet mode enabled for PhysicalLayer compatib...
Definition SX126x.cpp:636
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 setFrequencyDeviation(float freqDev) override
Sets FSK frequency deviation. Allowed values range from 0.0 to 200.0 kHz.
Definition SX126x_config.cpp:194
void spectralScanAbort()
Abort an ongoing spectral scan.
Definition SX126x.cpp:1207
int16_t getModem(ModemType_t *modem) override
Get modem currently in use by the radio.
Definition SX126x.cpp:928
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:338
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:1191
int16_t finishTransmit() override
Clean up after transmission is done.
Definition SX126x.cpp:451
int16_t beginBPSK(float br, float tcxoVoltage, bool useRegulatorLDO=false)
Initialization method for BPSK modem.
Definition SX126x.cpp:123
int16_t setCurrentLimit(float currentLimit)
Sets current protection limit. Can be set in 2.5 mA steps.
Definition SX126x_config.cpp:150
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:397
int16_t transmitDirect(uint32_t frf=0) override
Starts direct mode transmission.
Definition SX126x.cpp:323
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:597
int16_t begin(uint8_t cr, uint8_t syncWord, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO=false)
Initialization method for LoRa modem.
Definition SX126x.cpp:24
int16_t setCRC(uint8_t len, uint16_t initial=0x1D0F, uint16_t polynomial=0x1021, bool inverted=true)
Sets CRC configuration.
Definition SX126x_config.cpp:494
int16_t reset(bool verify=true)
Reset method. Will reset the chip to the default state using RST pin.
Definition SX126x.cpp:180
int16_t setSyncWord(uint8_t syncWord, uint8_t controlBits=0x44)
Sets LoRa sync word.
Definition SX126x_config.cpp:139
int16_t setLrFhssConfig(uint8_t bw, uint8_t cr, uint8_t hdrCount=3, uint16_t hopSeqId=0x100)
Sets LR-FHSS configuration.
Definition SX126x.cpp:167
int16_t calibrateImageRejection(float freqMin, float freqMax)
Perform image rejection calibration for the specified frequency band. WARNING: Use at your own risk!...
Definition SX126x.cpp:1268
float getCurrentLimit()
Reads current protection limit.
Definition SX126x_config.cpp:163
int16_t launchMode() override
Launch previously staged mode.
Definition SX126x.cpp:1106
int16_t stageMode(RadioModeType_t mode, RadioModeConfig_t *cfg) override
Stage mode of the radio to be launched later using launchMode.
Definition SX126x.cpp:947
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:895
uint32_t getIrqFlags() override
Read currently active IRQ flags.
Definition SX126x.cpp:885
int16_t autoLDRO()
Re-enables automatic LDRO configuration. Only available in LoRa mode. After calling this method,...
Definition SX126x_config.cpp:640
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:593
int16_t setBitRate(float br) override
Sets FSK bit rate. Allowed values range from 0.6 to 300.0 kbps.
Definition SX126x_config.cpp:218
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:703
void setPacketSentAction(void(*func)(void)) override
Sets interrupt service routine to call when a packet is sent.
Definition SX126x_config.cpp:28
int16_t setDataRate(DataRate_t dr, ModemType_t modem=RADIOLIB_MODEM_NONE) override
Set data rate.
Definition SX126x_config.cpp:255
void readBit(uint32_t pin) override
Function to read and process data bit in direct reception mode.
Definition SX126x.cpp:1138
int16_t scanChannel() override
Performs scan for LoRa transmission in the current channel. Detects both preamble and payload....
Definition SX126x.cpp:412
int16_t setPreambleLength(size_t preambleLength) override
Sets preamble length for LoRa or FSK modem. Allowed values range from 1 to 65535.
Definition SX126x_config.cpp:172
int16_t setPaRampTime(uint8_t rampTime)
Set PA ramp-up time. Set to 200us by default.
Definition SX126x_config.cpp:722
bool XTAL
Whether the module has an XTAL (true) or TCXO (false). Defaults to false.
Definition SX126x.h:67
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:600
int16_t setDio2AsRfSwitch(bool enable=true)
Set DIO2 to function as RF switch (default in Semtech example designs).
Definition SX126x_config.cpp:716
int16_t spectralScanGetResult(uint16_t *results)
Read the result of spectral scan.
Definition SX126x.cpp:1219
int16_t setWhitening(bool enabled, uint16_t initial=0x01FF)
Sets FSK whitening parameters.
Definition SX126x_config.cpp:554
virtual int16_t setSpreadingFactor(uint8_t sf)
Sets LoRa spreading factor. Allowed values range from 5 to 12.
Definition SX126x_config.cpp:95
bool standbyXOSC
Whether to use XOSC (true) or RC (false) oscillator in standby mode. Defaults to false.
Definition SX126x.h:72
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:514
void setChannelScanAction(void(*func)(void)) override
Sets interrupt service routine to call when a channel scan is finished.
Definition SX126x_config.cpp:36
void clearPacketSentAction() override
Clears interrupt service routine to call when a packet is sent.
Definition SX126x_config.cpp:32
int16_t beginLRFHSS(uint8_t bw, uint8_t cr, bool narrowGrid, float tcxoVoltage, bool useRegulatorLDO=false)
Initialization method for LR-FHSS modem. This modem only supports transmission!
Definition SX126x.cpp:139
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:478
int16_t getChannelScanResult() override
Read the channel scan result.
Definition SX126x.cpp:617
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition TypeDef.h:679
uint32_t RadioLibIrqFlags_t
Type used for radio-agnostic IRQ flags. IRQ to enable corresponds to the bit index (RadioLibIrq_t)....
Definition TypeDef.h:685
Description of RF switch pin states for a single mode. See setRfSwitchTable for details.
Definition Module.h:89
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:165
Common data rate structure.
Definition PhysicalLayer.h:74
Common packet configuration structure.
Definition PhysicalLayer.h:119
Definition PhysicalLayer.h:208