RadioLib
Universal wireless communication library for Arduino
Loading...
Searching...
No Matches
LR2021.h
1#if !defined(RADIOLIB_LR2021_H)
2#define RADIOLIB_LR2021_H
3
4#include "../../TypeDef.h"
5
6#if !RADIOLIB_EXCLUDE_LR2021
7
8#include "../../Module.h"
9
10#include "../../protocols/PhysicalLayer/PhysicalLayer.h"
11#include "../LR11x0/LR_common.h"
12#include "LR2021_commands.h"
13#include "LR2021_types.h"
14
15// LR2021 physical layer properties
16#define RADIOLIB_LR2021_FREQUENCY_STEP_SIZE 1.0
17#define RADIOLIB_LR2021_MAX_PACKET_LENGTH 255
18#define RADIOLIB_LR2021_CRYSTAL_FREQ 32.0
19#define RADIOLIB_LR2021_DIV_EXPONENT 25
20
25class LR2021: public LRxxxx {
26 public:
27 // introduce PhysicalLayer overloads
33
38 LR2021(Module* mod); // cppcheck-suppress noExplicitConstructor
39
44 uint32_t irqDioNum = 5;
45
52 bool fastCad = false;
53
72
79 float tcxoVoltage = 1.6;
80
81 // basic methods
82
90 int16_t begin(const ConfigLoRa_t& config);
91
108 int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_LR2021_LORA_SYNC_WORD_PRIVATE, int8_t power = 10, uint16_t preambleLength = 8, float tcxoVoltage = 1.6);
109
117 int16_t beginGFSK(const ConfigFSK_t& config);
118
133 int16_t beginGFSK(float freq = 434.0, float br = 4.8, float freqDev = 5.0, float rxBw = 153.8, int8_t power = 10, uint16_t preambleLength = 16, float tcxoVoltage = 1.6);
134
142 int16_t beginOOK(const ConfigOOK_t& config);
143
157 int16_t beginOOK(float freq = 434.0, float br = 4.8, float rxBw = 153.8, int8_t power = 10, uint16_t preambleLength = 16, float tcxoVoltage = 1.6);
158
166 int16_t beginLRFHSS(const ConfigLRFHSS_t& config);
167
181 int16_t beginLRFHSS(float freq = 434.0, uint8_t bw = RADIOLIB_LRXXXX_LR_FHSS_BW_722_66, uint8_t cr = RADIOLIB_LRXXXX_LR_FHSS_CR_2_3, bool narrowGrid = true, int8_t power = 10, float tcxoVoltage = 1.6);
182
190 int16_t beginFLRC(const ConfigFLRC_t& config);
191
206 int16_t beginFLRC(float freq = 434.0, uint16_t br = 650, uint8_t cr = RADIOLIB_LR2021_FLRC_CR_2_3, int8_t pwr = 10, uint16_t preambleLength = 16, uint8_t dataShaping = RADIOLIB_SHAPING_0_5, float tcxoVoltage = 1.6);
207
216 int16_t transmit(const uint8_t* data, size_t len, uint8_t addr = 0) override;
217
227 int16_t receive(uint8_t* data, size_t len, RadioLibTime_t timeout = 0) override;
228
234 int16_t transmitDirect(uint32_t frf = 0) override;
235
241 int16_t receiveDirect() override;
242
247 int16_t scanChannel() override;
248
257 int16_t scanChannel(const ChannelScanConfig_t &config) override;
258
264 int16_t standby() override;
265
272 int16_t standby(uint8_t mode) override;
273
281 int16_t standby(uint8_t mode, bool wakeup);
282
288 int16_t sleep() override;
289
297 int16_t sleep(bool retainConfig, uint32_t sleepTime);
298
304 size_t getPacketLength(bool update = true) override;
305
306 // interrupt methods
307
312 int16_t finishTransmit() override;
313
320 int16_t startReceive() override;
321
334 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);
335
354 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);
355
364 int16_t readData(uint8_t* data, size_t len) override;
365
370 int16_t finishReceive() override;
371
377 int16_t startChannelScan() override;
378
385 int16_t startChannelScan(const ChannelScanConfig_t &cfg) override;
386
391 int16_t getChannelScanResult() override;
392
397 uint32_t getIrqFlags() override;
398
404 int16_t setIrqFlags(uint32_t irq) override;
405
411 int16_t clearIrqFlags(uint32_t irq) override;
412
419 int16_t setModem(ModemType_t modem) override;
420
421 // configuration methods
422
433 int16_t setFrequency(float freq) override;
434
446 int16_t setFrequency(float freq, bool skipCalibration);
447
453 int16_t setOutputPower(int8_t power) override;
454
462 int16_t setOutputPower(int8_t power, uint32_t rampTimeUs);
463
473 void setPaTable(LR2021PaTableEntry_t* table, bool highFreq);
474
481 int16_t setStandbyXOSC(bool enable);
482
490 int16_t checkOutputPower(int8_t power, int8_t* clipped) override;
491
493 void setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
494
501 int16_t forceLDRO(bool enable);
502
508 int16_t autoLDRO();
509
516 int16_t setBandwidth(float bw);
517
524 int16_t setSpreadingFactor(uint8_t sf, bool legacy = false);
525
535 int16_t setCodingRate(uint8_t cr, bool longInterleave = false);
536
542 int16_t setSyncWord(uint8_t syncWord);
543
549 int16_t setPreambleLength(size_t preambleLength) override;
550
560 int16_t setTCXO(float voltage, uint32_t delay = 1000000);
561
570 int16_t setCRC(uint8_t len, uint32_t initial = 0x00001D0FUL, uint32_t polynomial = 0x00001021UL, bool inverted = true);
571
577 int16_t invertIQ(bool enable) override;
578
584 int16_t setBitRate(float br) override;
585
591 int16_t setFrequencyDeviation(float freqDev) override;
592
599 int16_t setRxBandwidth(float rxBw);
600
607 int16_t setSyncWord(uint8_t* syncWord, size_t len) override;
608
614 int16_t setNodeAddress(uint8_t nodeAddr);
615
622 int16_t setBroadcastAddress(uint8_t broadAddr);
623
628 int16_t disableAddressFiltering();
629
637 int16_t setDataShaping(uint8_t sh) override;
638
644 int16_t setEncoding(uint8_t encoding) override;
645
651 int16_t fixedPacketLengthMode(uint8_t len = RADIOLIB_LR2021_MAX_PACKET_LENGTH);
652
658 int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_LR2021_MAX_PACKET_LENGTH);
659
667 int16_t setWhitening(bool enabled, uint16_t initial = 0x01FF);
668
676 int16_t setDataRate(DataRate_t dr, ModemType_t modem = RADIOLIB_MODEM_NONE) override;
677
685 int16_t checkDataRate(DataRate_t dr, ModemType_t modem = RADIOLIB_MODEM_NONE) override;
686
695 int16_t setLrFhssConfig(uint8_t bw, uint8_t cr, uint8_t hdrCount = 3, uint16_t hopSeed = 0x13A);
696
702 int16_t setRxBoostedGainMode(uint8_t level);
703
709 RadioLibTime_t getTimeOnAir(size_t len) override;
710
716 int16_t getModem(ModemType_t* modem) override;
717
719 int16_t getMode(RadioModeType_t* mode) override;
720
722 int16_t stageMode(RadioModeType_t mode, RadioModeConfig_t* cfg) override;
723
725 int16_t launchMode() override;
726
728 int16_t writeTxBuffer(const uint8_t* data, size_t len) override;
729
731 int16_t clearTxBuffer() override;
732
738 float getVoltage(uint8_t bits = 13);
739
746 float getTemperature(uint8_t source, uint8_t bits = 13);
747
753 float getRSSI() override;
754
763 float getRSSI(bool packet, bool skipReceive = false);
764
769 float getSNR() override;
770
775 uint8_t randomByte() override;
776
782 int16_t implicitHeader(size_t len);
783
788 int16_t explicitHeader();
789
800 int16_t ookDetector(uint16_t pattern = 0x0285, uint8_t len = 16, uint8_t repeats = 0, bool syncRaw = false, bool rising = false, uint8_t sofLen = 0);
801
807 int16_t setOokDetectionThreshold(int16_t level);
808
823 int16_t setSideDetector(const LR2021LoRaSideDetector_t* cfg, size_t numDetectors);
824
831 int16_t setGain(uint8_t gain);
832
845 int16_t getLoRaPacketStatus(uint8_t* cr, bool* crc, uint8_t* packetLen = NULL, float* snrPacket = NULL, float* rssiPacket = NULL, float* rssiSignalPacket = NULL, uint8_t* detector = NULL);
846
853 int16_t getLoRaRxHeaderInfo(uint8_t* cr, bool* hasCRC);
854
860 int16_t getErrors(uint16_t* err);
861
870 int16_t getLoRaRxStats(uint16_t* pktRxTotal, uint16_t* pktCrcError, uint16_t* headerCrcError, uint16_t* falseSynch);
871
881 int16_t getRangingStats(uint16_t* exchangeValid, uint16_t* requestValid, uint16_t* responseDone, uint16_t* timeout, uint16_t* requestDiscarded);
882
894 int16_t getGfskRxStats(uint16_t* packetRx, uint16_t* packetCrcError, uint16_t* lenError, uint16_t* preambleDet, uint16_t* syncOk, uint16_t* syncFail, uint16_t* timeout);
895
903 int16_t getOqpskRxStats(uint16_t* packetRx, uint16_t* crcError, uint16_t* lenError);
904
912 int16_t getFlrcRxStats(uint16_t* packetRx, uint16_t* packetCrcError, uint16_t* lenError);
913
921 int16_t getOokRxStats(uint16_t* packetRx, uint16_t* crcError, uint16_t* lenError);
922
927 int16_t setRegulatorLDO();
928
933 int16_t setRegulatorDCDC();
934
935
936#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
937 protected:
938#endif
939 Module* getMod() override;
940
941#if !RADIOLIB_GODMODE
942 protected:
943#endif
944
945#if !RADIOLIB_GODMODE
946 private:
947#endif
948 uint8_t gainModeLf = RADIOLIB_LR2021_RX_BOOST_LF;
949 uint8_t gainModeHf = RADIOLIB_LR2021_RX_BOOST_HF;
950
951 bool standbyXOSC = false;
952
953 // cached FLRC parameters
954 uint16_t bitRateFlrc = 0;
955 uint8_t codingRateFlrc = 0;
956
957 // pointers to PA lookup tables - may be overridden by the user
958 LR2021PaTableEntry_t* paOptTable[2] = { nullptr, nullptr };
959
960 int16_t modSetup(float freq, uint8_t modem);
961 bool findChip(void);
962 int16_t config(uint8_t modem);
963 int16_t setPacketMode(uint8_t mode, uint8_t len);
964 int16_t startCad(uint8_t symbolNum, uint8_t detPeak, bool fast, uint8_t exitMode, RadioLibTime_t timeout);
965
966 // chip control commands
967 int16_t readRadioRxFifo(uint8_t* data, size_t len);
968 int16_t writeRadioTxFifo(const uint8_t* data, size_t len);
969 int16_t writeRegMem32(uint32_t addr, const uint32_t* data, size_t len);
970 int16_t writeRegMemMask32(uint32_t addr, uint32_t mask, uint32_t data);
971 int16_t readRegMem32(uint32_t addr, uint32_t* data, size_t len);
972 int16_t setFs(void);
973 int16_t setAdditionalRegToRetain(uint8_t slot, uint32_t addr);
974 int16_t setRx(uint32_t timeout);
975 int16_t setTx(uint32_t timeout);
976 int16_t setRxTxFallbackMode(uint8_t mode);
977 int16_t setRxDutyCycle(uint32_t rxMaxTime, uint32_t cycleTime, uint8_t mode);
978 int16_t autoTxRx(uint32_t delay, uint8_t mode, uint32_t timeout);
979 int16_t getRxPktLength(uint16_t* len);
980 int16_t resetRxStats(void);
981 int16_t setDefaultRxTxTimeout(uint32_t rxTimeout, uint32_t txTimeout);
982 int16_t setRegMode(uint8_t mode);
983 int16_t calibrate(uint8_t blocks);
984 int16_t calibrateFrontEnd(const uint16_t freq[3]);
985 int16_t getVbat(uint8_t resolution, uint16_t* vbat);
986 int16_t getTemp(uint8_t source, uint8_t resolution, float* temp);
987 int16_t setEolConfig(bool enable, uint8_t trim);
988 int16_t getRandomNumber(uint32_t* rnd);
989 int16_t getVersion(uint8_t* major, uint8_t* minor);
990 int16_t clearErrors(void);
991 int16_t setDioFunction(uint8_t dio, uint8_t func, uint8_t pullDrive);
992 int16_t setDioRfSwitchConfig(uint8_t dio, uint8_t func);
993 int16_t setDioIrqConfig(uint8_t dio, uint32_t irq);
994 int16_t clearIrqState(uint32_t irq);
995 int16_t getAndClearIrqStatus(uint32_t* irq);
996 int16_t configFifoIrq(uint8_t rxFifoIrq, uint8_t txFifoIrq, uint16_t rxHighThreshold, uint16_t txLowThreshold, uint16_t rxLowThreshold, uint16_t txHighThreshold);
997 int16_t getFifoIrqFlags(uint8_t* rxFifoFlags, uint8_t* txFifoFlags);
998 int16_t clearFifoIrqFlags(uint8_t rxFifoFlags, uint8_t txFifoFlags);
999 int16_t getAndClearFifoIrqFlags(uint8_t* rxFifoFlags, uint8_t* txFifoFlags);
1000 int16_t getRxFifoLevel(uint16_t* level);
1001 int16_t getTxFifoLevel(uint16_t* level);
1002 int16_t clearRxFifo(void);
1003 int16_t clearTxFifo(void);
1004 int16_t configLfClock(uint8_t cfg);
1005 int16_t configClkOutputs(uint8_t scaling);
1006 int16_t setTcxoMode(uint8_t tune, uint32_t startTime);
1007 int16_t setXoscCpTrim(uint8_t xta, uint8_t xtb, uint8_t startTime);
1008 int16_t activatePram(void);
1009 int16_t checkPramLoaded(bool* loaded);
1010 int16_t getPramVersion(uint16_t* version);
1011
1012 // radio frequency front end commands
1013 int16_t setRfFrequency(uint32_t rfFreq);
1014 int16_t setRxPath(uint8_t rxPath, uint8_t rxBoost);
1015 int16_t getRssiInst(float* rssi);
1016 int16_t setRssiCalibration(uint8_t rxPath, const uint16_t gain[RADIOLIB_LR2021_GAIN_TABLE_LENGTH], const uint8_t noiseFloor[RADIOLIB_LR2021_GAIN_TABLE_LENGTH]);
1017 int16_t setTimestampSource(uint8_t index, uint8_t source);
1018 int16_t getTimestampValue(uint8_t index, uint32_t* timestamp);
1019 int16_t setCca(uint32_t duration, uint8_t gain);
1020 int16_t getCcaResult(float* rssiMin, float* rssiMax, float* rssiAvg);
1021 int16_t setCadParams(uint32_t cadTimeout, uint8_t threshold, uint8_t exitMode, uint32_t trxTimeout);
1022 int16_t setCad(void);
1023 int16_t selPa(uint8_t pa);
1024 int16_t setPaConfig(uint8_t pa, uint8_t paLfMode, uint8_t paLfDutyCycle, uint8_t paLfSlices, uint8_t paHfDutyCycle);
1025 int16_t setTxParams(int8_t txPower, uint8_t rampTime);
1026
1027 // modem configuration commands
1028 int16_t setPacketType(uint8_t packetType);
1029 int16_t getPacketType(uint8_t* packetType);
1030
1031 // LoRa commands
1032 int16_t setLoRaModulationParams(uint8_t sf, uint8_t bw, uint8_t cr, uint8_t ldro);
1033 int16_t setLoRaPacketParams(uint16_t preambleLen, uint8_t hdrType, uint8_t payloadLen, uint8_t crcType, uint8_t invertIQ);
1034 int16_t setLoRaSynchTimeout(uint8_t numSymbols, bool format);
1035 int16_t setLoRaSyncword(uint8_t syncword);
1036 int16_t setLoRaSideDetConfig(uint8_t* configs, size_t numSideDets);
1037 int16_t setLoRaSideDetSyncword(uint8_t* syncwords, size_t numSideDets);
1038 int16_t setLoRaCadParams(uint8_t numSymbols, bool preambleOnly, uint8_t pnrDelta, uint8_t cadExitMode, uint32_t timeout, uint8_t detPeak);
1039 int16_t setLoRaCad(void);
1040 int16_t setLoRaAddress(uint8_t addrLen, uint8_t addrPos, const uint8_t* addr);
1041 int16_t setLoRaHopping(uint8_t hopCtrl, uint16_t hopPeriod, const uint32_t* freqHops, size_t numFreqHops);
1042 int16_t setLoRaTxSync(uint8_t function, uint8_t dioNum);
1043 int16_t setLoRaSideDetCad(const uint8_t* pnrDelta, const uint8_t* detPeak, size_t numSideDets);
1044 int16_t setLoRaHeaderType(uint8_t hdrType, size_t len = RADIOLIB_LR2021_MAX_PACKET_LENGTH);
1045
1046 // ranging commands
1047 int16_t setRangingAddr(uint32_t addr, uint8_t checkLen);
1048 int16_t setRangingReqAddr(uint32_t addr);
1049 int16_t getRangingResult(uint8_t type, uint32_t* rng1, uint8_t* rssi1, uint32_t* rng2);
1050 int16_t setRangingTxRxDelay(uint32_t delay);
1051 int16_t setRangingParams(bool spyMode, uint8_t nbSymbols);
1052
1053 // GFSK commands
1054 int16_t setGfskModulationParams(uint32_t bitRate, uint8_t pulseShape, uint8_t rxBw, uint32_t freqDev);
1055 int16_t setGfskPacketParams(uint16_t preambleLen, uint8_t preambleDetect, bool longPreamble, bool pldLenBits, uint8_t addrComp, uint8_t packetFormat, uint16_t payloadLen, uint8_t crc, uint8_t dcFree);
1056 int16_t setGfskWhiteningParams(uint8_t whitenType, uint16_t init);
1057 int16_t setGfskCrcParams(uint32_t poly, uint32_t init);
1058 int16_t setGfskSyncword(const uint8_t* syncWord, size_t syncWordLen, bool msbFirst);
1059 int16_t setGfskAddress(uint8_t addrNode, uint8_t addrBroadcast);
1060 int16_t getGfskPacketStatus(uint16_t* packetLen, float* rssiAvg, float* rssiSync, bool* addrMatchNode, bool* addrMatchBroadcast, float* lqi);
1061
1062 // OQPSK commands
1063 int16_t setOqpskParams(uint8_t mode, uint8_t rxBw, uint8_t payloadLen, uint16_t preambleLen, bool addrFilt, bool fcsManual);
1064 int16_t getOqpskPacketStatus(uint8_t* rxHeader, uint16_t* payloadLen, float* rssiAvg, float* rssiSync, float* lqi);
1065 int16_t setOqpskPacketLen(uint8_t len);
1066 int16_t setOqpskAddress(const uint8_t longDestAddr[8], uint16_t shortDestAddr, uint16_t panId, uint8_t transId);
1067
1068 // BPSK commands
1069 int16_t setBpskModulationParams(uint32_t bitRate, uint8_t pulseShape, bool diff, uint8_t diffInit);
1070 int16_t setBpskPacketParams(uint8_t payloadLen, uint8_t mode, bool sigFoxControlMsg, uint8_t sigFoxRank);
1071
1072 // FLRC commands
1073 int16_t setFlrcModulationParams(uint8_t brBw, uint8_t cr, uint8_t pulseShape);
1074 int16_t setFlrcPacketParams(uint8_t agcPreambleLen, uint8_t syncWordLen, uint8_t syncWordTx, uint8_t syncMatch, bool fixedLength, uint8_t crc, uint16_t payloadLen);
1075 int16_t getFlrcPacketStatus(uint16_t* packetLen, float* rssiAvg, float* rssiSync, uint8_t* syncWordNum);
1076 int16_t setFlrcSyncWord(uint8_t syncWordNum, uint32_t syncWord);
1077
1078 // LR-FHSS commands
1079 int16_t lrFhssSetSyncword(uint32_t syncWord);
1081 //int16_t readLrFhssHoppingTable(LR2021LrFhssHopTableEntry_t* hopTable[40], size_t* hopTableLen);
1082 //int16_t writeLrFhssHoppingTable(LR2021LrFhssHopTableEntry_t* hopTable[40], size_t hopTableLen);
1083
1084 // OOK commands
1085 int16_t setOokModulationParams(uint32_t bitRate, uint8_t pulseShape, uint8_t rxBw, uint8_t depth);
1086 int16_t setOokPacketParams(uint16_t preambleLen, uint8_t addrComp, uint8_t packetFormat, uint16_t payloadLen, uint8_t crc, uint8_t manchester);
1087 int16_t setOokCrcParams(uint32_t poly, uint32_t init);
1088 int16_t setOokSyncword(const uint8_t* syncWord, size_t syncWordLen, bool msbFirst);
1089 int16_t setOokAddress(uint8_t addrNode, uint8_t addrBroadcast);
1090 int16_t getOokPacketStatus(uint16_t* packetLen, float* rssiAvg, float* rssiHigh, bool* addrMatchNode, bool* addrMatchBroadcast, float* lqi);
1091 int16_t setOokDetector(uint16_t preamblePattern, uint8_t patternLen, uint8_t patternNumRepeaters, bool syncWordRaw, bool sofDelimiterRising, uint8_t sofDelimiterLen);
1092 int16_t setOokWhiteningParams(uint8_t bitIdx, uint16_t poly, uint16_t init);
1093
1094 // test commands
1095 int16_t setTxTestMode(uint8_t mode);
1096
1097 // port of semtech's workaround
1098 int16_t setDCDCworkaround();
1099 int16_t resetDCDCworkaround();
1100};
1101#endif
1102
1103#endif
int16_t setBitRate(float br) override
Sets GFSK bit rate. Allowed values range from 0.5 to 2000.0 kbps.
Definition LR2021_config.cpp:566
int16_t setSyncWord(uint8_t syncWord)
Sets LoRa sync word.
Definition LR2021_config.cpp:397
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 LR2021.cpp:317
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....
Definition LR2021_config.cpp:639
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 LR2021.cpp:566
int16_t sleep() override
Sets the module to sleep mode. To wake the device up, call standby(). Overload with warm start enable...
Definition LR2021.cpp:458
LR2021(Module *mod)
Default constructor.
Definition LR2021.cpp:8
int16_t getLoRaPacketStatus(uint8_t *cr, bool *crc, uint8_t *packetLen=NULL, float *snrPacket=NULL, float *rssiPacket=NULL, float *rssiSignalPacket=NULL, uint8_t *detector=NULL)
Read status of the last received packet. Each parameter can be set to NULL if the caller is not inten...
Definition LR2021_cmds_lora.cpp:82
void setPaTable(LR2021PaTableEntry_t *table, bool highFreq)
Sets custom PA configuration table.
Definition LR2021_config.cpp:178
int16_t begin(const ConfigLoRa_t &config)
Initialization method for LoRa modem.
Definition LR2021.cpp:24
int16_t receiveDirect() override
Starts direct mode reception. Only implemented for PhysicalLayer compatibility, as LR2021 does not su...
Definition LR2021.cpp:399
int16_t getLoRaRxHeaderInfo(uint8_t *cr, bool *hasCRC)
Get LoRa header information from last received packet. Implementation based on getLoRaPacketStatus.
Definition LR2021.cpp:1248
int16_t setStandbyXOSC(bool enable)
Set standby mode to be used. XOSC standby uses more power, but allows faster switching between Rx and...
Definition LR2021_config.cpp:182
int16_t clearIrqFlags(uint32_t irq) override
Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone).
Definition LR2021.cpp:703
int16_t setDataRate(DataRate_t dr, ModemType_t modem=RADIOLIB_MODEM_NONE) override
Set data rate.
Definition LR2021_config.cpp:869
int16_t checkDataRate(DataRate_t dr, ModemType_t modem=RADIOLIB_MODEM_NONE) override
Check the data rate can be configured by this module.
Definition LR2021_config.cpp:921
int16_t autoLDRO()
Re-enables automatic LDRO configuration. Only available in LoRa mode. After calling this method,...
Definition LR2021_config.cpp:255
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 LR2021.cpp:1123
int16_t beginFLRC(const ConfigFLRC_t &config)
Initialization method for FLRC modem.
Definition LR2021.cpp:203
int16_t setTCXO(float voltage, uint32_t delay=1000000)
Sets TCXO (Temperature Compensated Crystal Oscillator) configuration.
Definition LR2021_config.cpp:444
int16_t disableAddressFiltering()
Disables address filtering. Calling this method will also erase previously set addresses.
Definition LR2021_config.cpp:1090
int16_t setBroadcastAddress(uint8_t broadAddr)
Sets broadcast address. Calling this method will also enable address filtering for node and broadcast...
Definition LR2021_config.cpp:1071
int16_t checkOutputPower(int8_t power, int8_t *clipped) override
Check if output power is configurable. This method is needed for compatibility with PhysicalLayer::ch...
Definition LR2021_config.cpp:195
int16_t scanChannel() override
Performs scan for LoRa transmission in the current channel. Detects both preamble and payload.
Definition LR2021.cpp:407
uint32_t getIrqFlags() override
Read currently active IRQ flags.
Definition LR2021.cpp:695
int16_t beginOOK(const ConfigOOK_t &config)
Initialization method for OOK modem.
Definition LR2021.cpp:123
int16_t getRangingStats(uint16_t *exchangeValid, uint16_t *requestValid, uint16_t *responseDone, uint16_t *timeout, uint16_t *requestDiscarded)
Get ranging Rx statistics.
Definition LR2021_cmds_ranging.cpp:44
float getRSSI() override
Gets received signal strength indicator. Overload with packet mode enabled for PhysicalLayer compatib...
Definition LR2021.cpp:1195
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 LR2021_config.cpp:351
int16_t setOokDetectionThreshold(int16_t level)
Set OOK detection threshold.
Definition LR2021_config.cpp:1117
int16_t setCRC(uint8_t len, uint32_t initial=0x00001D0FUL, uint32_t polynomial=0x00001021UL, bool inverted=true)
Sets CRC configuration.
Definition LR2021_config.cpp:495
int16_t explicitHeader()
Set explicit header mode for future reception/transmission.
Definition LR2021_config.cpp:1047
int16_t getOokRxStats(uint16_t *packetRx, uint16_t *crcError, uint16_t *lenError)
Get OOK Rx statistics.
Definition LR2021_cmds_ook.cpp:62
int16_t forceLDRO(bool enable)
Forces LoRa low data rate optimization. Only available in LoRa mode. After calling this method,...
Definition LR2021_config.cpp:240
int16_t getChannelScanResult() override
Read the channel scan result.
Definition LR2021.cpp:672
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...
Definition LR2021_config.cpp:84
int16_t getErrors(uint16_t *err)
Get internal error bits.
Definition LR2021_cmds_chip_control.cpp:205
int16_t startChannelScan() override
Interrupt-driven channel activity detection method. IRQ1 will be activated when LoRa preamble is dete...
Definition LR2021.cpp:627
int16_t transmitDirect(uint32_t frf=0) override
Starts direct mode transmission.
Definition LR2021.cpp:384
int16_t variablePacketLengthMode(uint8_t maxLen=RADIOLIB_LR2021_MAX_PACKET_LENGTH)
Set modem in variable packet length mode. Available in GFSK mode only.
Definition LR2021_config.cpp:832
int16_t setEncoding(uint8_t encoding) override
Sets transmission encoding. Available in GFSK mode only. Serves only as alias for PhysicalLayer compa...
Definition LR2021_config.cpp:787
int16_t launchMode() override
Launch previously staged mode.
Definition LR2021.cpp:1142
int16_t invertIQ(bool enable) override
Enable/disable inversion of the I and Q signals.
Definition LR2021_config.cpp:552
int16_t getMode(RadioModeType_t *mode) override
Read the operating mode the radio is in, as the chip reports it. Unlike PhysicalLayer::stagedMode,...
Definition LR2021.cpp:954
int16_t setBandwidth(float bw)
Sets LoRa bandwidth. Allowed values are 31.25, 41.67, 62.5, 83.34, 125.0, 101.56, 203....
Definition LR2021_config.cpp:267
OpMode_t
Custom operation modes for LR2021. Needed because LR2021 has several modems (sub-GHz,...
Definition LR2021.h:58
@ MODE_END_OF_TABLE
Definition LR2021.h:60
@ MODE_RX
Definition LR2021.h:64
@ MODE_RX_HF
Definition LR2021.h:68
@ MODE_STBY
Definition LR2021.h:62
@ MODE_TX_HF
Definition LR2021.h:70
@ MODE_TX
Definition LR2021.h:66
int16_t setWhitening(bool enabled, uint16_t initial=0x01FF)
Sets GFSK whitening parameters.
Definition LR2021_config.cpp:836
int16_t finishTransmit() override
Clean up after transmission is done.
Definition LR2021.cpp:495
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 LR2021.cpp:257
RadioLibTime_t getTimeOnAir(size_t len) override
Get expected time-on-air for a given size of payload.
Definition LR2021.cpp:883
int16_t setGain(uint8_t gain)
Sets gain of receiver LNA (low-noise amplifier). Can be set to any integer in range 1 to 13,...
Definition LR2021_config.cpp:1200
int16_t beginGFSK(const ConfigFSK_t &config)
Initialization method for FSK modem.
Definition LR2021.cpp:69
int16_t getModem(ModemType_t *modem) override
Get modem currently in use by the radio.
Definition LR2021.cpp:932
int16_t fixedPacketLengthMode(uint8_t len=RADIOLIB_LR2021_MAX_PACKET_LENGTH)
Set modem in fixed packet length mode. Available in GFSK mode only.
Definition LR2021_config.cpp:828
int16_t getOqpskRxStats(uint16_t *packetRx, uint16_t *crcError, uint16_t *lenError)
Get OQPSK Rx statistics.
Definition LR2021_cmds_oqpsk.cpp:19
int16_t setDataShaping(uint8_t sh) override
Sets time-bandwidth product of Gaussian filter applied for shaping. Allowed values are RADIOLIB_SHAPI...
Definition LR2021_config.cpp:749
int16_t getLoRaRxStats(uint16_t *pktRxTotal, uint16_t *pktCrcError, uint16_t *headerCrcError, uint16_t *falseSynch)
Get LoRa Rx statistics.
Definition LR2021_cmds_lora.cpp:72
float getVoltage(uint8_t bits=13)
Read the supply voltage on the Vbat pin.
Definition LR2021.cpp:1169
int16_t finishReceive() override
Clean up after reception is done.
Definition LR2021.cpp:618
int16_t standby() override
Sets the module to standby mode (overload for PhysicalLayer compatibility). Uses 13 MHz RC oscillator...
Definition LR2021.cpp:436
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 LR2021_config.cpp:213
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 LR2021.cpp:544
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 p...
Definition LR2021.cpp:707
int16_t setNodeAddress(uint8_t nodeAddr)
Sets node address. Calling this method will also enable address filtering for node address only.
Definition LR2021_config.cpp:1051
int16_t setPreambleLength(size_t preambleLength) override
Sets preamble length for LoRa or GFSK modem. Allowed values range from 1 to 65535.
Definition LR2021_config.cpp:409
int16_t setOutputPower(int8_t power) override
Sets output power. Allowed values are in range from -9 to 22 dBm (sub-GHz PA) or -19 to 12 dBm (high-...
Definition LR2021_config.cpp:144
int16_t setSideDetector(const LR2021LoRaSideDetector_t *cfg, size_t numDetectors)
Configure LoRa side detector, which enables to detect mutiple spreading factors and receive one of th...
Definition LR2021_config.cpp:1122
int16_t setSpreadingFactor(uint8_t sf, bool legacy=false)
Sets LoRa spreading factor. Allowed values range from 5 to 12.
Definition LR2021_config.cpp:326
int16_t setRegulatorDCDC()
Set regulator mode to DC-DC.
Definition LR2021_cmds_chip_control.cpp:344
int16_t clearTxBuffer() override
Discard a payload previously written by writeTxBuffer. On radios whose transmit buffer is simply over...
Definition LR2021.cpp:1138
int16_t implicitHeader(size_t len)
Set implicit header mode for future reception/transmission.
Definition LR2021_config.cpp:1043
int16_t startReceive() override
Interrupt-driven receive method with default parameters. Implemented for compatibility with PhysicalL...
Definition LR2021.cpp:503
int16_t beginLRFHSS(const ConfigLRFHSS_t &config)
Initialization method for LR-FHSS modem.
Definition LR2021.cpp:172
int16_t setRxBoostedGainMode(uint8_t level)
Enables or disables Rx Boosted Gain mode (additional Rx gain for increased power consumption).
Definition LR2021_config.cpp:968
int16_t setRegulatorLDO()
Set regulator mode to LDO.
Definition LR2021_cmds_chip_control.cpp:340
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 LR2021.cpp:507
float getSNR() override
Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem.
Definition LR2021.cpp:1231
int16_t getFlrcRxStats(uint16_t *packetRx, uint16_t *packetCrcError, uint16_t *lenError)
Get FLRC Rx statistics.
Definition LR2021_cmds_flrc.cpp:28
int16_t stageMode(RadioModeType_t mode, RadioModeConfig_t *cfg) override
Stage mode of the radio to be launched later using launchMode.
Definition LR2021.cpp:984
int16_t setFrequencyDeviation(float freqDev) override
Sets GFSK frequency deviation. Allowed values range from 0.6 to 500.0 kHz.
Definition LR2021_config.cpp:618
size_t getPacketLength(bool update=true) override
Query modem for the packet length of received payload.
Definition LR2021.cpp:480
uint8_t randomByte() override
Get one truly random byte from RSSI noise.
Definition LR2021.cpp:1242
int16_t setIrqFlags(uint32_t irq) override
Set interrupt on DIO1 to be sent on a specific IRQ bit (e.g. RxTimeout, CadDone).
Definition LR2021.cpp:699
int16_t ookDetector(uint16_t pattern=0x0285, uint8_t len=16, uint8_t repeats=0, bool syncRaw=false, bool rising=false, uint8_t sofLen=0)
Set OOK detector properties. The default values are set to allow ADS-B reception.
Definition LR2021_config.cpp:1105
float getTemperature(uint8_t source, uint8_t bits=13)
Read the temperature.
Definition LR2021.cpp:1182
int16_t setLrFhssConfig(uint8_t bw, uint8_t cr, uint8_t hdrCount=3, uint16_t hopSeed=0x13A)
Sets LR-FHSS configuration.
Definition LR2021_config.cpp:947
int16_t getGfskRxStats(uint16_t *packetRx, uint16_t *packetCrcError, uint16_t *lenError, uint16_t *preambleDet, uint16_t *syncOk, uint16_t *syncFail, uint16_t *timeout)
Get GFSK Rx statistics.
Definition LR2021_cmds_gfsk.cpp:66
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
@ MODE_IDLE
Idle mode.
Definition Module.h:114
@ MODE_RX
Receive mode.
Definition Module.h:117
@ MODE_END_OF_TABLE
End of table marker, use END_OF_MODE_TABLE constant instead. Value is zero to ensure zero-initialized...
Definition Module.h:111
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 receive(uint8_t *data, size_t len, RadioLibTime_t timeout=0)
Binary receive method. Must be implemented in module class.
Definition PhysicalLayer.cpp:111
#define RADIOLIB_SHAPING_0_5
Gaussian shaping filter, BT = 0.5.
Definition TypeDef.h:27
bool fastCad
Determines the type of Lora CAD to perform, either "standard" CAD (same as is implemented LR11x0,...
Definition LR2021.h:52
uint32_t irqDioNum
Which DIO pin is to be used as the interrupt pin.
Definition LR2021.h:44
float tcxoVoltage
TCXO reference voltage to be set on DIO3. Defaults to 1.6 V. If you are seeing -706/-707 error codes,...
Definition LR2021.h:79
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition TypeDef.h:761
uint32_t RadioLibIrqFlags_t
Type used for radio-agnostic IRQ flags. IRQ to enable corresponds to the bit index (RadioLibIrq_t)....
Definition TypeDef.h:767
Definition PhysicalLayer.h:348
Definition PhysicalLayer.h:298
Definition PhysicalLayer.h:335
Definition PhysicalLayer.h:280
Definition PhysicalLayer.h:322
Structure to configure multi-SF detection.
Definition LR2021_types.h:26
Description of RF switch pin states for a single mode. See setRfSwitchTable for details.
Definition Module.h:90
Common channel scan configuration structure.
Definition PhysicalLayer.h:165
Common data rate structure.
Definition PhysicalLayer.h:74
Definition PhysicalLayer.h:208