mirror of
https://github.com/meshtastic/firmware.git
synced 2025-07-31 02:45:41 +00:00
Log TX power after limits applyng and store it in config (#7065)
* Log and save in config lora tx_power after limits applyng * Log and save in config lora tx_power after limits applyng * Trunk fmt * Remove duplicate logic --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
parent
baf0e9c7e6
commit
3ea96bb6e1
@ -71,10 +71,7 @@ template <typename T> bool LR11x0Interface<T>::init()
|
|||||||
|
|
||||||
RadioLibInterface::init();
|
RadioLibInterface::init();
|
||||||
|
|
||||||
limitPower();
|
limitPower(LR1110_MAX_POWER);
|
||||||
|
|
||||||
if (power > LR1110_MAX_POWER) // Clamp power to maximum defined level
|
|
||||||
power = LR1110_MAX_POWER;
|
|
||||||
|
|
||||||
if ((power > LR1120_MAX_POWER) &&
|
if ((power > LR1120_MAX_POWER) &&
|
||||||
(config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) { // clamp again if wide freq range
|
(config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) { // clamp again if wide freq range
|
||||||
|
@ -122,10 +122,7 @@ bool RF95Interface::init()
|
|||||||
power = dacDbValues.db;
|
power = dacDbValues.db;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
limitPower();
|
limitPower(RF95_MAX_POWER);
|
||||||
|
|
||||||
if (power > RF95_MAX_POWER) // This chip has lower power limits than some
|
|
||||||
power = RF95_MAX_POWER;
|
|
||||||
|
|
||||||
iface = lora = new RadioLibRF95(&module);
|
iface = lora = new RadioLibRF95(&module);
|
||||||
|
|
||||||
|
@ -611,7 +611,7 @@ uint32_t RadioInterface::computeSlotTimeMsec()
|
|||||||
* Some regulatory regions limit xmit power.
|
* Some regulatory regions limit xmit power.
|
||||||
* This function should be called by subclasses after setting their desired power. It might lower it
|
* This function should be called by subclasses after setting their desired power. It might lower it
|
||||||
*/
|
*/
|
||||||
void RadioInterface::limitPower()
|
void RadioInterface::limitPower(int8_t loraMaxPower)
|
||||||
{
|
{
|
||||||
uint8_t maxPower = 255; // No limit
|
uint8_t maxPower = 255; // No limit
|
||||||
|
|
||||||
@ -628,6 +628,13 @@ void RadioInterface::limitPower()
|
|||||||
power -= TX_GAIN_LORA;
|
power -= TX_GAIN_LORA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (power > loraMaxPower) // Clamp power to maximum defined level
|
||||||
|
power = loraMaxPower;
|
||||||
|
|
||||||
|
if (TX_GAIN_LORA == 0) { // Setting power in config with defined TX_GAIN_LORA will cause decreasing power on each reboot
|
||||||
|
config.lora.tx_power = power; // Set limited power in config
|
||||||
|
}
|
||||||
|
|
||||||
LOG_INFO("Final Tx power: %d dBm", power);
|
LOG_INFO("Final Tx power: %d dBm", power);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ class RadioInterface
|
|||||||
* Some regulatory regions limit xmit power.
|
* Some regulatory regions limit xmit power.
|
||||||
* This function should be called by subclasses after setting their desired power. It might lower it
|
* This function should be called by subclasses after setting their desired power. It might lower it
|
||||||
*/
|
*/
|
||||||
void limitPower();
|
void limitPower(int8_t MAX_POWER);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the frequency we selected for later reuse.
|
* Save the frequency we selected for later reuse.
|
||||||
|
@ -25,10 +25,7 @@ bool STM32WLE5JCInterface::init()
|
|||||||
|
|
||||||
lora.setRfSwitchTable(rfswitch_pins, rfswitch_table);
|
lora.setRfSwitchTable(rfswitch_pins, rfswitch_table);
|
||||||
|
|
||||||
limitPower();
|
limitPower(STM32WLx_MAX_POWER);
|
||||||
|
|
||||||
if (power > STM32WLx_MAX_POWER) // This chip has lower power limits than some
|
|
||||||
power = STM32WLx_MAX_POWER;
|
|
||||||
|
|
||||||
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage);
|
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage);
|
||||||
|
|
||||||
|
@ -69,10 +69,7 @@ template <typename T> bool SX126xInterface<T>::init()
|
|||||||
|
|
||||||
RadioLibInterface::init();
|
RadioLibInterface::init();
|
||||||
|
|
||||||
limitPower();
|
limitPower(SX126X_MAX_POWER);
|
||||||
|
|
||||||
if (power > SX126X_MAX_POWER) // Clamp power to maximum defined level
|
|
||||||
power = SX126X_MAX_POWER;
|
|
||||||
|
|
||||||
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage, useRegulatorLDO);
|
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage, useRegulatorLDO);
|
||||||
// \todo Display actual typename of the adapter, not just `SX126x`
|
// \todo Display actual typename of the adapter, not just `SX126x`
|
||||||
|
@ -62,10 +62,7 @@ template <typename T> bool SX128xInterface<T>::init()
|
|||||||
|
|
||||||
RadioLibInterface::init();
|
RadioLibInterface::init();
|
||||||
|
|
||||||
limitPower();
|
limitPower(SX128X_MAX_POWER);
|
||||||
|
|
||||||
if (power > SX128X_MAX_POWER) // This chip has lower power limits than some
|
|
||||||
power = SX128X_MAX_POWER;
|
|
||||||
|
|
||||||
preambleLength = 12; // 12 is the default for this chip, 32 does not RX at all
|
preambleLength = 12; // 12 is the default for this chip, 32 does not RX at all
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user