From 6a96d44b2bdee76bd7dbaca09eb24067d02adba1 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 17 Feb 2025 21:19:18 +0100 Subject: [PATCH] [SX127x] Fix automated RFO selection (#1412) --- src/modules/SX127x/SX1272.cpp | 3 ++- src/modules/SX127x/SX1272.h | 5 +++-- src/modules/SX127x/SX1278.cpp | 3 ++- src/modules/SX127x/SX1278.h | 5 +++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index 48f01a65..e6e4406d 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -279,8 +279,9 @@ int16_t SX1272::setOutputPower(int8_t power) { return(this->setOutputPower(power, false)); } -int16_t SX1272::setOutputPower(int8_t power, bool useRfo) { +int16_t SX1272::setOutputPower(int8_t power, bool forceRfo) { // check if power value is configurable + bool useRfo = (power < 2) || forceRfo; int16_t state = checkOutputPower(power, NULL, useRfo); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX1272.h b/src/modules/SX127x/SX1272.h index 142ee174..aa412efc 100644 --- a/src/modules/SX127x/SX1272.h +++ b/src/modules/SX127x/SX1272.h @@ -201,10 +201,11 @@ class SX1272: public SX127x { /*! \brief Sets transmission output power. Allowed values range from -1 to 14 dBm (RFO pin) or +2 to +20 dBm (PA_BOOST pin). \param power Transmission output power in dBm. - \param useRfo Whether to use the RFO (true) or the PA_BOOST (false) pin for the RF output. + \param forceRfo Whether to force using the RFO pin for the RF output (true) + or the lave the selection up to user (false) based on power output. \returns \ref status_codes */ - int16_t setOutputPower(int8_t power, bool useRfo); + int16_t setOutputPower(int8_t power, bool forceRfo); /*! \brief Check if output power is configurable. diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index 199d9696..308ad5c3 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -293,8 +293,9 @@ int16_t SX1278::setOutputPower(int8_t power) { return(this->setOutputPower(power, false)); } -int16_t SX1278::setOutputPower(int8_t power, bool useRfo) { +int16_t SX1278::setOutputPower(int8_t power, bool forceRfo) { // check if power value is configurable + bool useRfo = (power < 2) || forceRfo; int16_t state = checkOutputPower(power, NULL, useRfo); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX1278.h b/src/modules/SX127x/SX1278.h index 4b24e9dc..a43e99f4 100644 --- a/src/modules/SX127x/SX1278.h +++ b/src/modules/SX127x/SX1278.h @@ -213,10 +213,11 @@ class SX1278: public SX127x { \brief Sets transmission output power. Allowed values range from -4 to 15 dBm (RFO pin) or +2 to +17 dBm (PA_BOOST pin). High power +20 dBm operation is also supported, on the PA_BOOST pin. \param power Transmission output power in dBm. - \param useRfo Whether to use the RFO (true) or the PA_BOOST (false) pin for the RF output. + \param forceRfo Whether to force using the RFO pin for the RF output (true) + or the lave the selection up to user (false) based on power output. \returns \ref status_codes */ - int16_t setOutputPower(int8_t power, bool useRfo); + int16_t setOutputPower(int8_t power, bool forceRfo); /*! \brief Check if output power is configurable.