From 130833b5be168f0c78c25d32fe87f6b1496da11a Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Mon, 13 Oct 2025 23:50:57 +1100 Subject: [PATCH] Fix erroneous limiting of power in Ham Mode (#8322) Ham Mode ignores region regulatory limits, so regardless of whether we set a single TX_GAIN_LORA or an array with a non-linear PA, we shouldn't limit the power. Co-authored-by: Ben Meadors --- src/mesh/RadioInterface.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 88218e406..31ec5acc5 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -647,23 +647,24 @@ void RadioInterface::limitPower(int8_t loraMaxPower) } #ifndef NUM_PA_POINTS - if (TX_GAIN_LORA > 0) { + if (TX_GAIN_LORA > 0 && !devicestate.owner.is_licensed) { LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", power, TX_GAIN_LORA); power -= TX_GAIN_LORA; } #else - // we have an array of PA gain values. Find the highest power setting that works. - const uint16_t tx_gain[NUM_PA_POINTS] = {TX_GAIN_LORA}; - for (int radio_dbm = 0; radio_dbm < NUM_PA_POINTS; radio_dbm++) { - if (((radio_dbm + tx_gain[radio_dbm]) > power) || - ((radio_dbm == (NUM_PA_POINTS - 1)) && ((radio_dbm + tx_gain[radio_dbm]) <= power))) { - // we've exceeded the power limit, or hit the max we can do - LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", power, tx_gain[radio_dbm]); - power -= tx_gain[radio_dbm]; - break; + if (!devicestate.owner.is_licensed) { + // we have an array of PA gain values. Find the highest power setting that works. + const uint16_t tx_gain[NUM_PA_POINTS] = {TX_GAIN_LORA}; + for (int radio_dbm = 0; radio_dbm < NUM_PA_POINTS; radio_dbm++) { + if (((radio_dbm + tx_gain[radio_dbm]) > power) || + ((radio_dbm == (NUM_PA_POINTS - 1)) && ((radio_dbm + tx_gain[radio_dbm]) <= power))) { + // we've exceeded the power limit, or hit the max we can do + LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", power, tx_gain[radio_dbm]); + power -= tx_gain[radio_dbm]; + break; + } } } - #endif if (power > loraMaxPower) // Clamp power to maximum defined level power = loraMaxPower;