From 0bb04d876b0c8767cc58d30ddb934c2acd81f48d Mon Sep 17 00:00:00 2001 From: Mads Date: Fri, 21 Jul 2023 19:37:26 +0200 Subject: [PATCH 1/3] Add optimal PA settings for LLCC68 --- .../SX126x_LoRa_transmitter/SX126x_LoRa_transmitter.ino | 2 +- keywords.txt | 1 + src/SX126x.cpp | 4 ++-- src/SX126x_driver.h | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/SX126x/SX126x_LoRa_transmitter/SX126x_LoRa_transmitter.ino b/examples/SX126x/SX126x_LoRa_transmitter/SX126x_LoRa_transmitter.ino index a56f629..3c48a5b 100644 --- a/examples/SX126x/SX126x_LoRa_transmitter/SX126x_LoRa_transmitter.ino +++ b/examples/SX126x/SX126x_LoRa_transmitter/SX126x_LoRa_transmitter.ino @@ -46,7 +46,7 @@ void setup() { Serial.println("Set frequency to 915 Mhz"); LoRa.setFrequency(915000000); - // Set TX power, default power for SX1262 and SX1268 are +22 dBm and for SX1261 is +14 dBm + // Set TX power, default power for SX1262, SX1268 and LLCC68 are +22 dBm and for SX1261 is +14 dBm // This function will set PA config with optimal setting for requested TX power Serial.println("Set TX power to +17 dBm"); LoRa.setTxPower(17, SX126X_TX_POWER_SX1262); // TX power +17 dBm for SX1262 diff --git a/keywords.txt b/keywords.txt index 786f763..d1bd86d 100644 --- a/keywords.txt +++ b/keywords.txt @@ -135,6 +135,7 @@ SX126X_FSK_MODEM LITERAL1 SX126X_LORA_MODEM LITERAL1 SX126X_TX_POWER_SX1261 LITERAL1 SX126X_TX_POWER_SX1262 LITERAL1 +SX126X_TX_POWER_LLCC68 LITERAL1 SX126X_TX_POWER_SX1268 LITERAL1 SX126X_RX_GAIN_POWER_SAVING LITERAL1 SX126X_RX_GAIN_BOOSTED LITERAL1 diff --git a/src/SX126x.cpp b/src/SX126x.cpp index 36bb165..3628326 100644 --- a/src/SX126x.cpp +++ b/src/SX126x.cpp @@ -238,7 +238,7 @@ void SX126x::setTxPower(uint8_t txPower, uint8_t version) paDutyCycle = 0x04; hpMax = 0x00; power = 0x0E; - } else if (txPower >= 14 && version == SX126X_TX_POWER_SX1262) { + } else if (txPower >= 14 && (version == SX126X_TX_POWER_SX1262 || version == SX126X_TX_POWER_LLCC68)) { paDutyCycle = 0x02; hpMax = 0x02; power = 0x16; @@ -250,7 +250,7 @@ void SX126x::setTxPower(uint8_t txPower, uint8_t version) paDutyCycle = 0x01; hpMax = 0x00; power = 0x0D; - } else if (txPower >= 10 && version == SX126X_TX_POWER_SX1268) { + } else if (txPower >= 10 && (version == SX126X_TX_POWER_SX1268 || version == SX126X_TX_POWER_LLCC68)) { paDutyCycle = 0x00; hpMax = 0x03; power = 0x0F; diff --git a/src/SX126x_driver.h b/src/SX126x_driver.h index 78c300e..f50d695 100644 --- a/src/SX126x_driver.h +++ b/src/SX126x_driver.h @@ -57,6 +57,7 @@ // SetPaConfig #define SX126X_TX_POWER_SX1261 0x01 // device version for TX power: SX1261 #define SX126X_TX_POWER_SX1262 0x02 // : SX1262 +#define SX126X_TX_POWER_LLCC68 0x06 // : LLCC68 #define SX126X_TX_POWER_SX1268 0x08 // : SX1268 // SetRxTxFallbackMode From 3dedc960a3d3b9f0b2eca5e1a9e7f959b4ea3672 Mon Sep 17 00:00:00 2001 From: bry Date: Wed, 12 Mar 2025 21:31:35 -0400 Subject: [PATCH 2/3] Let tx work with lower power --- src/SX126x.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SX126x.cpp b/src/SX126x.cpp index 3628326..52c8d96 100644 --- a/src/SX126x.cpp +++ b/src/SX126x.cpp @@ -254,9 +254,9 @@ void SX126x::setTxPower(uint8_t txPower, uint8_t version) paDutyCycle = 0x00; hpMax = 0x03; power = 0x0F; - } else { - return; } + // There shouldn't have been an `else` here: + // https://github.com/chandrawi/LoRaRF-Arduino/issues/16 // set power amplifier and TX power configuration sx126x_setPaConfig(paDutyCycle, hpMax, deviceSel, 0x01); From ddbb43d6cb8292aaa44fb0a12a46640694cb09c4 Mon Sep 17 00:00:00 2001 From: bry Date: Wed, 12 Mar 2025 21:39:34 -0400 Subject: [PATCH 3/3] Made functions pure-virtual to get rid of linker error on some configurations --- src/BaseLoRa.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/BaseLoRa.h b/src/BaseLoRa.h index 7da9006..cb8f5a6 100644 --- a/src/BaseLoRa.h +++ b/src/BaseLoRa.h @@ -44,18 +44,18 @@ class BaseLoRa public: - virtual void beginPacket(); - virtual bool endPacket(uint32_t timeout); - virtual void write(uint8_t data); - virtual void write(uint8_t* data, uint8_t length); - - virtual bool request(uint32_t timeout); - virtual uint8_t available(); - virtual uint8_t read(); - virtual uint8_t read(uint8_t* data, uint8_t length); - - virtual bool wait(uint32_t timeout); - virtual uint8_t status(); + virtual void beginPacket() = 0; + virtual bool endPacket(uint32_t timeout) = 0; + virtual void write(uint8_t data) = 0; + virtual void write(uint8_t* data, uint8_t length) = 0; + + virtual bool request(uint32_t timeout) = 0; + virtual uint8_t available() = 0; + virtual uint8_t read() = 0; + virtual uint8_t read(uint8_t* data, uint8_t length) = 0; + + virtual bool wait(uint32_t timeout) = 0; + virtual uint8_t status() = 0; };