From c187960cc170a7b441cc8bcb8f9c0a37a809d8f4 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 29 Jan 2025 17:51:20 +0000 Subject: [PATCH 1/8] [SX126x] Add public method to handle LR-FHSS hopping --- keywords.txt | 1 + src/modules/SX126x/SX126x.cpp | 13 +++++++++++-- src/modules/SX126x/SX126x.h | 7 +++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/keywords.txt b/keywords.txt index 9457fcb0..f6bc613b 100644 --- a/keywords.txt +++ b/keywords.txt @@ -246,6 +246,7 @@ spectralScanAbort KEYWORD2 spectralScanGetStatus KEYWORD2 spectralScanGetResult KEYWORD2 setPaRampTime KEYWORD2 +hopLRFHSS KEYWORD2 # nRF24 setIrqAction KEYWORD2 diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 224858eb..777dce09 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -235,8 +235,7 @@ int16_t SX126x::transmit(const uint8_t* data, size_t len, uint8_t addr) { break; } else { // handle frequency hop - this->setLRFHSSHop(this->lrFhssHopNum % 16); - clearIrqStatus(); + this->hopLRFHSS(); } } } @@ -477,6 +476,16 @@ int16_t SX126x::standby(uint8_t mode, bool wakeup) { return(this->mod->SPIwriteStream(RADIOLIB_SX126X_CMD_SET_STANDBY, data, 1)); } +int16_t SX126x::hopLRFHSS() { + if(!(this->getIrqFlags() & RADIOLIB_SX126X_IRQ_LR_FHSS_HOP)) { + return(RADIOLIB_ERR_TX_TIMEOUT); + } + + int16_t state = this->setLRFHSSHop(this->lrFhssHopNum % 16); + RADIOLIB_ASSERT(state); + return(clearIrqStatus()); +} + void SX126x::setDio1Action(void (*func)(void)) { this->mod->hal->attachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq()), func, this->mod->hal->GpioInterruptRising); } diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index e37265b0..371926ca 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -628,6 +628,13 @@ class SX126x: public PhysicalLayer { */ int16_t standby(uint8_t mode, bool wakeup = true); + /*! + \brief Handle LR-FHSS hop. + When using LR-FHSS in interrupt-driven mode, this method MUST be called each time an interrupt is triggered! + \returns \ref status_codes + */ + int16_t hopLRFHSS(); + // interrupt methods /*! From 779e0aa4dd624c23f21351cb783000c255adc2a2 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 29 Jan 2025 20:45:41 +0100 Subject: [PATCH 2/8] [SX126x] Rename LR-FHSS modem example to transmit --- .../SX126x_LR_FHSS_Modem.ino | 96 --------------- .../SX126x_LR_FHSS_Transmit_Blocking.ino | 113 ++++++++++++++++++ 2 files changed, 113 insertions(+), 96 deletions(-) delete mode 100644 examples/SX126x/SX126x_LR_FHSS_Modem/SX126x_LR_FHSS_Modem.ino create mode 100644 examples/SX126x/SX126x_LR_FHSS_Transmit_Blocking/SX126x_LR_FHSS_Transmit_Blocking.ino diff --git a/examples/SX126x/SX126x_LR_FHSS_Modem/SX126x_LR_FHSS_Modem.ino b/examples/SX126x/SX126x_LR_FHSS_Modem/SX126x_LR_FHSS_Modem.ino deleted file mode 100644 index 44519d51..00000000 --- a/examples/SX126x/SX126x_LR_FHSS_Modem/SX126x_LR_FHSS_Modem.ino +++ /dev/null @@ -1,96 +0,0 @@ -/* - RadioLib SX126x LR-FHSS Modem Example - - This example shows how to use LR-FHSS modem in SX126x chips. - This modem can only transmit data, and is not able to receive. - - NOTE: The sketch below is just a guide on how to use - LR-FHSS modem, so this code should not be run directly! - Instead, modify the other examples to use LR-FHSS - modem and use the appropriate configuration - methods. - - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lr-fhss-modem - - For full API reference, see the GitHub Pages - https://jgromes.github.io/RadioLib/ -*/ - -// include the library -#include - -// SX1262 has the following connections: -// NSS pin: 10 -// IRQ pin: 2 -// NRST pin: 3 -// BUSY pin: 9 -SX1262 radio = new Module(10, 2, 3, 9); - -// or detect the pinout automatically using RadioBoards -// https://github.com/radiolib-org/RadioBoards -/* -#define RADIO_BOARD_AUTO -#include -Radio radio = new RadioModule(); -*/ - -void setup() { - Serial.begin(9600); - - // initialize SX1262 with default settings - Serial.print(F("[SX1262] Initializing ... ")); - int state = radio.beginLRFHSS(); - if (state == RADIOLIB_ERR_NONE) { - Serial.println(F("success!")); - } else { - Serial.print(F("failed, code ")); - Serial.println(state); - while (true) { delay(10); } - } - - // if needed, you can switch between any of the modems - // - // radio.begin() start LoRa modem (and disable LR-FHSS) - // radio.beginLRFHSS() start LR-FHSS modem (and disable LoRa) - - // the following settings can also - // be modified at run-time - state = radio.setFrequency(433.5); - state = radio.setLrFhssConfig(RADIOLIB_SX126X_LR_FHSS_BW_1523_4, // bandwidth - RADIOLIB_SX126X_LR_FHSS_CR_1_2, // coding rate - 3, // header count - 0x13A); // hopping sequence seed - state = radio.setOutputPower(10.0); - uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67}; - state = radio.setSyncWord(syncWord, 4); - if (state != RADIOLIB_ERR_NONE) { - Serial.print(F("Unable to set configuration, code ")); - Serial.println(state); - while (true) { delay(10); } - } - - #warning "This sketch is just an API guide! Read the note at line 6." -} - -void loop() { - // LR-FHSS modem can only transmit! - // transmit LR-FHSS packet - int state = radio.transmit("Hello World!"); - /* - byte byteArr[] = {0x01, 0x23, 0x45, 0x67, - 0x89, 0xAB, 0xCD, 0xEF}; - int state = radio.transmit(byteArr, 8); - */ - if (state == RADIOLIB_ERR_NONE) { - Serial.println(F("[SX1262] Packet transmitted successfully!")); - } else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) { - Serial.println(F("[SX1262] Packet too long!")); - } else if (state == RADIOLIB_ERR_TX_TIMEOUT) { - Serial.println(F("[SX1262] Timed out while transmitting!")); - } else { - Serial.println(F("[SX1262] Failed to transmit packet, code ")); - Serial.println(state); - } - -} diff --git a/examples/SX126x/SX126x_LR_FHSS_Transmit_Blocking/SX126x_LR_FHSS_Transmit_Blocking.ino b/examples/SX126x/SX126x_LR_FHSS_Transmit_Blocking/SX126x_LR_FHSS_Transmit_Blocking.ino new file mode 100644 index 00000000..4dea005b --- /dev/null +++ b/examples/SX126x/SX126x_LR_FHSS_Transmit_Blocking/SX126x_LR_FHSS_Transmit_Blocking.ino @@ -0,0 +1,113 @@ +/* + RadioLib SX126x LR-FHSS Modem Example + + This example shows how to use LR-FHSS modem in SX126x chips. + This modem can only transmit data, and is not able to receive. + + This example transmits packets using SX1262 LoRa radio module. + Each packet contains up to 256 bytes of data, in the form of: + - Arduino String + - null-terminated char array (C-string) + - arbitrary binary data (byte array) + + Other modules from SX126x family can also be used. + + Using blocking transmit is not recommended, as it will lead + to inefficient use of processor time! + Instead, interrupt transmit is recommended. + + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lr-fhss-modem + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ +*/ + +// include the library +#include + +// SX1262 has the following connections: +// NSS pin: 10 +// IRQ pin: 2 +// NRST pin: 3 +// BUSY pin: 9 +SX1262 radio = new Module(10, 2, 3, 9); + +// or detect the pinout automatically using RadioBoards +// https://github.com/radiolib-org/RadioBoards +/* +#define RADIO_BOARD_AUTO +#include +Radio radio = new RadioModule(); +*/ + +void setup() { + Serial.begin(9600); + + // initialize SX1262 with default settings + Serial.print(F("[SX1262] Initializing ... ")); + int state = radio.beginLRFHSS(); + if (state == RADIOLIB_ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while (true) { delay(10); } + } + + // some modules have an external RF switch + // controlled via two pins (RX enable, TX enable) + // to enable automatic control of the switch, + // call the following method + // RX enable: 4 + // TX enable: 5 + /* + radio.setRfSwitchPins(4, 5); + */ +} + +// counter to keep track of transmitted packets +int count = 0; + +void loop() { + // LR-FHSS modem can only transmit! + Serial.print(F("[SX1262] Transmitting packet ... ")); + + // you can transmit C-string or Arduino string up to + // 256 characters long + String str = "Hello World! #" + String(count++); + int state = radio.transmit(str); + + // you can also transmit byte array up to 256 bytes long + /* + byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF}; + int state = radio.transmit(byteArr, 8); + */ + + if (state == RADIOLIB_ERR_NONE) { + // the packet was successfully transmitted + Serial.println(F("success!")); + + // print measured data rate + Serial.print(F("[SX1262] Datarate:\t")); + Serial.print(radio.getDataRate()); + Serial.println(F(" bps")); + + } else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) { + // the supplied packet was longer than 256 bytes + Serial.println(F("too long!")); + + } else if (state == RADIOLIB_ERR_TX_TIMEOUT) { + // timeout occurred while transmitting packet + Serial.println(F("timeout!")); + + } else { + // some other error occurred + Serial.print(F("failed, code ")); + Serial.println(state); + + } + + // wait for a second before transmitting again + delay(1000); +} From 5eb90ea17a8f83b541c4fcbdc081b573dd0b6f54 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 29 Jan 2025 21:14:36 +0100 Subject: [PATCH 3/8] [SX126x] Add LR-FHSS interrupt transmit example --- .../SX126x_LR_FHSS_Transmit_Interrupt.ino | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 examples/SX126x/SX126x_LR_FHSS_Transmit_Interrupt/SX126x_LR_FHSS_Transmit_Interrupt.ino diff --git a/examples/SX126x/SX126x_LR_FHSS_Transmit_Interrupt/SX126x_LR_FHSS_Transmit_Interrupt.ino b/examples/SX126x/SX126x_LR_FHSS_Transmit_Interrupt/SX126x_LR_FHSS_Transmit_Interrupt.ino new file mode 100644 index 00000000..1a220798 --- /dev/null +++ b/examples/SX126x/SX126x_LR_FHSS_Transmit_Interrupt/SX126x_LR_FHSS_Transmit_Interrupt.ino @@ -0,0 +1,151 @@ +/* + RadioLib SX126x LR-FHSS Transmit with Interrupts Example + + This example shows how to use LR-FHSS modem in SX126x chips. + This modem can only transmit data, and is not able to receive. + + This example transmits packets using SX1262 LoRa radio module. + Each packet contains up to 256 bytes of data, in the form of: + - Arduino String + - null-terminated char array (C-string) + - arbitrary binary data (byte array) + + Other modules from SX126x family can also be used. + + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lr-fhss-modem + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ +*/ + +// include the library +#include + +// SX1262 has the following connections: +// NSS pin: 10 +// IRQ pin: 2 +// NRST pin: 3 +// BUSY pin: 9 +SX1262 radio = new Module(10, 2, 3, 9); + +// or detect the pinout automatically using RadioBoards +// https://github.com/radiolib-org/RadioBoards +/* +#define RADIO_BOARD_AUTO +#include +Radio radio = new RadioModule(); +*/ + +// save transmission state between loops +int transmissionState = RADIOLIB_ERR_NONE; + +// flag to indicate that a packet was sent +// or a frequency hop is needed +volatile bool flag = false; + +// this function is called when a complete packet +// is transmitted by the module +// IMPORTANT: this function MUST be 'void' type +// and MUST NOT have any arguments! +#if defined(ESP8266) || defined(ESP32) + ICACHE_RAM_ATTR +#endif +void setFlag(void) { + // we sent a packet or need to hop, set the flag + flag = true; +} + +void setup() { + Serial.begin(9600); + + // initialize SX1262 with default settings + Serial.print(F("[SX1262] Initializing ... ")); + int state = radio.beginLRFHSS(); + if (state == RADIOLIB_ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while (true) { delay(10); } + } + + // set the function that will be called + // when packet transmission is finished + radio.setPacketSentAction(setFlag); + + // start transmitting the first packet + Serial.print(F("[SX1262] Sending first packet ... ")); + + // you can transmit C-string or Arduino string up to + // 256 characters long + transmissionState = radio.startTransmit("Hello World!"); + + // you can also transmit byte array up to 256 bytes long + /* + byte byteArr[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xAB, 0xCD, 0xEF}; + state = radio.startTransmit(byteArr, 8); + */ +} + +// counter to keep track of transmitted packets +int count = 0; + +void loop() { + // LR-FHSS modem can only transmit! + + // check if the previous transmission finished + if(flag) { + // reset flag + flag = false; + + // check if this was caused by hopping or transmission finished + if(radio.getIrqFlags() & RADIOLIB_SX126X_IRQ_LR_FHSS_HOP) { + radio.hopLRFHSS(); + + } else { + if (transmissionState == RADIOLIB_ERR_NONE) { + // packet was successfully sent + Serial.println(F("transmission finished!")); + + // NOTE: when using interrupt-driven transmit method, + // it is not possible to automatically measure + // transmission data rate using getDataRate() + + } else { + Serial.print(F("failed, code ")); + Serial.println(transmissionState); + + } + + // clean up after transmission is finished + // this will ensure transmitter is disabled, + // RF switch is powered down etc. + radio.finishTransmit(); + + // wait a second before transmitting again + delay(1000); + + // send another one + Serial.print(F("[SX1262] Sending another packet ... ")); + + // you can transmit C-string or Arduino string up to + // 256 characters long + String str = "Hello World! #" + String(count++); + transmissionState = radio.startTransmit(str); + + // you can also transmit byte array up to 256 bytes long + /* + byte byteArr[] = {0x01, 0x23, 0x45, 0x67, + 0x89, 0xAB, 0xCD, 0xEF}; + transmissionState = radio.startTransmit(byteArr, 8); + */ + + } + + + + } + +} From 27653e1cf7292d643e996028c1a40931e7867143 Mon Sep 17 00:00:00 2001 From: StevenCellist Date: Thu, 30 Jan 2025 20:58:53 +0100 Subject: [PATCH 4/8] [LoRaWAN] Allow support for misc MAC commands --- src/protocols/LoRaWAN/LoRaWAN.cpp | 23 ++++++++++++++--------- src/protocols/LoRaWAN/LoRaWAN.h | 3 ++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/protocols/LoRaWAN/LoRaWAN.cpp b/src/protocols/LoRaWAN/LoRaWAN.cpp index cc6ed3df..91cdf65d 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.cpp +++ b/src/protocols/LoRaWAN/LoRaWAN.cpp @@ -1718,14 +1718,14 @@ int16_t LoRaWANNode::parseDownlink(uint8_t* data, size_t* len, LoRaWANEvent_t* e cid = *mPtr; // MAC id is the first byte // fetch length of MAC downlink payload - state = this->getMacLen(cid, &fLen, RADIOLIB_LORAWAN_DOWNLINK, true); + state = this->getMacLen(cid, &fLen, RADIOLIB_LORAWAN_DOWNLINK, true, mPtr + 1); if(state != RADIOLIB_ERR_NONE) { RADIOLIB_DEBUG_PROTOCOL_PRINTLN("WARNING: Unknown MAC CID %02x", cid); RADIOLIB_DEBUG_PROTOCOL_PRINTLN("WARNING: Skipping remaining MAC commands"); break; } - // already fetch length of MAC answer payload (if any) + // already fetch length of MAC answer payload (if any), include CID uint8_t fLenRe = 0; (void)this->getMacLen(cid, &fLenRe, RADIOLIB_LORAWAN_UPLINK, true); // don't care about return value: the previous getMacLen() would have failed anyway @@ -2484,17 +2484,21 @@ int16_t LoRaWANNode::getMacDeviceTimeAns(uint32_t* gpsEpoch, uint8_t* fraction, return(RADIOLIB_ERR_NONE); } -int16_t LoRaWANNode::getMacLen(uint8_t cid, uint8_t* len, uint8_t dir, bool inclusive) { +int16_t LoRaWANNode::getMacLen(uint8_t cid, uint8_t* len, uint8_t dir, bool inclusive, uint8_t* payload) { + (void)payload; + + *len = 0; + if(inclusive) { + *len += 1; // add one byte for CID + } + LoRaWANMacCommand_t cmd = RADIOLIB_LORAWAN_MAC_COMMAND_NONE; int16_t state = this->getMacCommand(cid, &cmd); RADIOLIB_ASSERT(state); if(dir == RADIOLIB_LORAWAN_UPLINK) { - *len = cmd.lenUp; + *len += cmd.lenUp; } else { - *len = cmd.lenDn; - } - if(inclusive) { - *len += 1; // add one byte for CID + *len += cmd.lenDn; } return(RADIOLIB_ERR_NONE); } @@ -2596,7 +2600,8 @@ void LoRaWANNode::clearMacCommands(uint8_t* inOut, uint8_t* lenInOut, uint8_t di uint8_t numDeleted = 0; while(i < *lenInOut) { uint8_t id = inOut[i]; - uint8_t fLen = 1; // if there is an incorrect MAC command, we should at least move forward by one byte + uint8_t fLen = 0; + // include CID byte, so if command fails, we still move one byte forward (void)this->getMacLen(id, &fLen, dir, true); // only clear MAC command if it should not persist until a downlink is received diff --git a/src/protocols/LoRaWAN/LoRaWAN.h b/src/protocols/LoRaWAN/LoRaWAN.h index 977db468..1bfa782c 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.h +++ b/src/protocols/LoRaWAN/LoRaWAN.h @@ -1030,7 +1030,8 @@ class LoRaWANNode { // get the length of a certain MAC command in a specific direction (up/down) // if inclusive is true, add one for the CID byte - int16_t getMacLen(uint8_t cid, uint8_t* len, uint8_t dir, bool inclusive = false); + // include payload in case the MAC command has a dynamic length + virtual int16_t getMacLen(uint8_t cid, uint8_t* len, uint8_t dir, bool inclusive = false, uint8_t* payload = NULL); // find out of a MAC command should persist destruction // in uplink direction, some commands must persist if no downlink is received From 8c304a89c10d86f04fd3b1a1f2fe86635a731e56 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 31 Jan 2025 17:59:47 +0100 Subject: [PATCH 5/8] [LLCC68] Add override begin FSK and LR-FHSS methods (#1405) --- src/modules/LLCC68/LLCC68.cpp | 50 +++++++++++++++++++++++++++++++++++ src/modules/LLCC68/LLCC68.h | 33 ++++++++++++++++++++++- 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/src/modules/LLCC68/LLCC68.cpp b/src/modules/LLCC68/LLCC68.cpp index fe1468a2..17f19794 100644 --- a/src/modules/LLCC68/LLCC68.cpp +++ b/src/modules/LLCC68/LLCC68.cpp @@ -37,6 +37,56 @@ int16_t LLCC68::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync return(state); } +int16_t LLCC68::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { + // execute common part + int16_t state = SX126x::beginFSK(br, freqDev, rxBw, preambleLength, tcxoVoltage, useRegulatorLDO); + if(state == RADIOLIB_ERR_CHIP_NOT_FOUND) { + // bit of a hack, but some LLCC68 chips report as "SX1261", try that + // for full discussion, see https://github.com/jgromes/RadioLib/issues/1329 + chipType = RADIOLIB_SX1261_CHIP_TYPE; + state = SX126x::beginFSK(br, freqDev, rxBw, preambleLength, tcxoVoltage, useRegulatorLDO); + RADIOLIB_DEBUG_PRINTLN("LLCC68 version string not found, using SX1261 instead"); + } + RADIOLIB_ASSERT(state); + + // configure publicly accessible settings + state = setFrequency(freq); + RADIOLIB_ASSERT(state); + + state = SX126x::fixPaClamping(); + RADIOLIB_ASSERT(state); + + state = setOutputPower(power); + RADIOLIB_ASSERT(state); + + return(state); +} + +int16_t LLCC68::beginLRFHSS(float freq, uint8_t bw, uint8_t cr, bool narrowGrid, int8_t power, float tcxoVoltage, bool useRegulatorLDO) { + // execute common part + int16_t state = SX126x::beginLRFHSS(bw, cr, narrowGrid, tcxoVoltage, useRegulatorLDO); + if(state == RADIOLIB_ERR_CHIP_NOT_FOUND) { + // bit of a hack, but some LLCC68 chips report as "SX1261", try that + // for full discussion, see https://github.com/jgromes/RadioLib/issues/1329 + chipType = RADIOLIB_SX1261_CHIP_TYPE; + state = SX126x::beginLRFHSS(bw, cr, narrowGrid, tcxoVoltage, useRegulatorLDO); + RADIOLIB_DEBUG_PRINTLN("LLCC68 version string not found, using SX1261 instead"); + } + RADIOLIB_ASSERT(state); + + // configure publicly accessible settings + state = setFrequency(freq); + RADIOLIB_ASSERT(state); + + state = SX126x::fixPaClamping(); + RADIOLIB_ASSERT(state); + + state = setOutputPower(power); + RADIOLIB_ASSERT(state); + + return(state); +} + int16_t LLCC68::setBandwidth(float bw) { RADIOLIB_CHECK_RANGE(bw, 100.0f, 510.0f, RADIOLIB_ERR_INVALID_BANDWIDTH); return(SX1262::setBandwidth(bw)); diff --git a/src/modules/LLCC68/LLCC68.h b/src/modules/LLCC68/LLCC68.h index 949e666b..5dadf380 100644 --- a/src/modules/LLCC68/LLCC68.h +++ b/src/modules/LLCC68/LLCC68.h @@ -40,7 +40,38 @@ class LLCC68: public SX1262 { \returns \ref status_codes */ int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX126X_SYNC_WORD_PRIVATE, int8_t pwr = 10, uint16_t preambleLength = 8, float tcxoVoltage = 0, bool useRegulatorLDO = false); - + + /*! + \brief Initialization method for FSK modem. + \param freq Carrier frequency in MHz. Defaults to 434.0 MHz. + \param br FSK bit rate in kbps. Defaults to 4.8 kbps. + \param freqDev Frequency deviation from carrier frequency in kHz. Defaults to 5.0 kHz. + \param rxBw Receiver bandwidth in kHz. Defaults to 156.2 kHz. + \param power Output power in dBm. Defaults to 10 dBm. + \param preambleLength FSK preamble length in bits. Defaults to 16 bits. + \param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V. + If you are seeing -706/-707 error codes, it likely means you are using non-0 value for module with XTAL. + To use XTAL, either set this value to 0, or set SX126x::XTAL to true. + \param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false. + \returns \ref status_codes + */ + int16_t beginFSK(float freq = 434.0, float br = 4.8, float freqDev = 5.0, float rxBw = 156.2, int8_t power = 10, uint16_t preambleLength = 16, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); + + /*! + \brief Initialization method for LR-FHSS modem. This modem only supports transmission! + \param freq Carrier frequency in MHz. Defaults to 434.0 MHz. + \param bw LR-FHSS bandwidth, one of RADIOLIB_SX126X_LR_FHSS_BW_* values. Defaults to 722.66 kHz. + \param cr LR-FHSS coding rate, one of RADIOLIB_SX126X_LR_FHSS_CR_* values. Defaults to 2/3 coding rate. + \param narrowGrid Whether to use narrow (3.9 kHz) or wide (25.39 kHz) grid spacing. Defaults to true (narrow/non-FCC) grid. + \param power Output power in dBm. Defaults to 10 dBm. + \param tcxoVoltage TCXO reference voltage to be set. Defaults to 1.6 V. + If you are seeing -706/-707 error codes, it likely means you are using non-0 value for module with XTAL. + To use XTAL, either set this value to 0, or set SX126x::XTAL to true. + \param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false. + \returns \ref status_codes + */ + int16_t beginLRFHSS(float freq = 434.0, uint8_t bw = RADIOLIB_SX126X_LR_FHSS_BW_722_66, uint8_t cr = RADIOLIB_SX126X_LR_FHSS_CR_2_3, bool narrowGrid = true, int8_t power = 10, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); + // configuration methods /*! From b634c9c71190a725e62d38063969fae659c6a6ab Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 31 Jan 2025 18:09:52 +0100 Subject: [PATCH 6/8] [SX126x] Add missing virtual specifier (#1405) --- src/modules/SX126x/SX1262.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX126x/SX1262.h b/src/modules/SX126x/SX1262.h index d0e73a6e..08ac1b6b 100644 --- a/src/modules/SX126x/SX1262.h +++ b/src/modules/SX126x/SX1262.h @@ -75,7 +75,7 @@ class SX1262: public SX126x { \param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false. \returns \ref status_codes */ - int16_t beginLRFHSS(float freq = 434.0, uint8_t bw = RADIOLIB_SX126X_LR_FHSS_BW_722_66, uint8_t cr = RADIOLIB_SX126X_LR_FHSS_CR_2_3, bool narrowGrid = true, int8_t power = 10, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); + virtual int16_t beginLRFHSS(float freq = 434.0, uint8_t bw = RADIOLIB_SX126X_LR_FHSS_BW_722_66, uint8_t cr = RADIOLIB_SX126X_LR_FHSS_CR_2_3, bool narrowGrid = true, int8_t power = 10, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); // configuration methods From 8ab989ab53d4d015776c8d72cc2d807ac2455810 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 31 Jan 2025 18:25:38 +0100 Subject: [PATCH 7/8] [CI] Add helper script to cppcheck single path --- extras/cppcheck/check_file.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 extras/cppcheck/check_file.sh diff --git a/extras/cppcheck/check_file.sh b/extras/cppcheck/check_file.sh new file mode 100755 index 00000000..a560cd33 --- /dev/null +++ b/extras/cppcheck/check_file.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +if [[ $@ -lt 1 ]]; then + echo "Usage: $0 " + exit 1 +fi + +path=$1 + +cppcheck --version +cppcheck $path --enable=all \ + --force \ + --inline-suppr \ + --suppress=ConfigurationNotChecked \ + --suppress=unusedFunction \ + --suppress=missingIncludeSystem \ + --suppress=missingInclude \ + --quiet From 4deec953e8d5edbbf5aca0f0c5460d19c990db45 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 31 Jan 2025 18:25:57 +0100 Subject: [PATCH 8/8] [LLCC68] Add missing override specifiers --- src/modules/LLCC68/LLCC68.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/LLCC68/LLCC68.h b/src/modules/LLCC68/LLCC68.h index 5dadf380..e548fa57 100644 --- a/src/modules/LLCC68/LLCC68.h +++ b/src/modules/LLCC68/LLCC68.h @@ -39,7 +39,7 @@ class LLCC68: public SX1262 { \param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false. \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX126X_SYNC_WORD_PRIVATE, int8_t pwr = 10, uint16_t preambleLength = 8, float tcxoVoltage = 0, bool useRegulatorLDO = false); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX126X_SYNC_WORD_PRIVATE, int8_t power = 10, uint16_t preambleLength = 8, float tcxoVoltage = 0, bool useRegulatorLDO = false) override; /*! \brief Initialization method for FSK modem. @@ -49,13 +49,13 @@ class LLCC68: public SX1262 { \param rxBw Receiver bandwidth in kHz. Defaults to 156.2 kHz. \param power Output power in dBm. Defaults to 10 dBm. \param preambleLength FSK preamble length in bits. Defaults to 16 bits. - \param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V. + \param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 0 V (XTAL). If you are seeing -706/-707 error codes, it likely means you are using non-0 value for module with XTAL. To use XTAL, either set this value to 0, or set SX126x::XTAL to true. \param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false. \returns \ref status_codes */ - int16_t beginFSK(float freq = 434.0, float br = 4.8, float freqDev = 5.0, float rxBw = 156.2, int8_t power = 10, uint16_t preambleLength = 16, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); + int16_t beginFSK(float freq = 434.0, float br = 4.8, float freqDev = 5.0, float rxBw = 156.2, int8_t power = 10, uint16_t preambleLength = 16, float tcxoVoltage = 0, bool useRegulatorLDO = false) override; /*! \brief Initialization method for LR-FHSS modem. This modem only supports transmission! @@ -64,13 +64,13 @@ class LLCC68: public SX1262 { \param cr LR-FHSS coding rate, one of RADIOLIB_SX126X_LR_FHSS_CR_* values. Defaults to 2/3 coding rate. \param narrowGrid Whether to use narrow (3.9 kHz) or wide (25.39 kHz) grid spacing. Defaults to true (narrow/non-FCC) grid. \param power Output power in dBm. Defaults to 10 dBm. - \param tcxoVoltage TCXO reference voltage to be set. Defaults to 1.6 V. + \param tcxoVoltage TCXO reference voltage to be set. Defaults to 0 V (XTAL). If you are seeing -706/-707 error codes, it likely means you are using non-0 value for module with XTAL. To use XTAL, either set this value to 0, or set SX126x::XTAL to true. \param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false. \returns \ref status_codes */ - int16_t beginLRFHSS(float freq = 434.0, uint8_t bw = RADIOLIB_SX126X_LR_FHSS_BW_722_66, uint8_t cr = RADIOLIB_SX126X_LR_FHSS_CR_2_3, bool narrowGrid = true, int8_t power = 10, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); + int16_t beginLRFHSS(float freq = 434.0, uint8_t bw = RADIOLIB_SX126X_LR_FHSS_BW_722_66, uint8_t cr = RADIOLIB_SX126X_LR_FHSS_CR_2_3, bool narrowGrid = true, int8_t power = 10, float tcxoVoltage = 0, bool useRegulatorLDO = false) override; // configuration methods