Fix erroneous limiting of power in Ham Mode

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.
This commit is contained in:
Tom Fifield 2025-10-13 09:16:07 +11:00
parent 7537d28419
commit 653c1876e6
No known key found for this signature in database

View File

@ -647,23 +647,24 @@ void RadioInterface::limitPower(int8_t loraMaxPower)
} }
#ifndef NUM_PA_POINTS #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); LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", power, TX_GAIN_LORA);
power -= TX_GAIN_LORA; power -= TX_GAIN_LORA;
} }
#else #else
// we have an array of PA gain values. Find the highest power setting that works. if (!devicestate.owner.is_licensed) {
const uint16_t tx_gain[NUM_PA_POINTS] = {TX_GAIN_LORA}; // we have an array of PA gain values. Find the highest power setting that works.
for (int radio_dbm = 0; radio_dbm < NUM_PA_POINTS; radio_dbm++) { const uint16_t tx_gain[NUM_PA_POINTS] = {TX_GAIN_LORA};
if (((radio_dbm + tx_gain[radio_dbm]) > power) || for (int radio_dbm = 0; radio_dbm < NUM_PA_POINTS; radio_dbm++) {
((radio_dbm == (NUM_PA_POINTS - 1)) && ((radio_dbm + tx_gain[radio_dbm]) <= power))) { if (((radio_dbm + tx_gain[radio_dbm]) > power) ||
// we've exceeded the power limit, or hit the max we can do ((radio_dbm == (NUM_PA_POINTS - 1)) && ((radio_dbm + tx_gain[radio_dbm]) <= power))) {
LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", power, tx_gain[radio_dbm]); // we've exceeded the power limit, or hit the max we can do
power -= tx_gain[radio_dbm]; LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", power, tx_gain[radio_dbm]);
break; power -= tx_gain[radio_dbm];
break;
}
} }
} }
#endif #endif
if (power > loraMaxPower) // Clamp power to maximum defined level if (power > loraMaxPower) // Clamp power to maximum defined level
power = loraMaxPower; power = loraMaxPower;