diff --git a/src/configuration.h b/src/configuration.h index 6dcca72dc..eab2d0120 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -81,6 +81,12 @@ along with this program. If not, see . // Override user saved region, for producing region-locked builds // #define REGULATORY_LORA_REGIONCODE meshtastic_Config_LoRaConfig_RegionCode_SG_923 +// Total system gain in dBm to subtract from Tx power to remain within regulatory ERP limit for non-licensed operators +// This value should be set in variant.h and is PA gain + antenna gain (if system ships with an antenna) +#ifndef REGULATORY_GAIN +#define REGULATORY_GAIN 0 +#endif + // ----------------------------------------------------------------------------- // Feature toggles // ----------------------------------------------------------------------------- diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 7a1fcfb94..8e77beee4 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -478,8 +478,8 @@ void RadioInterface::applyModemConfig() power = loraConfig.tx_power; - if ((power == 0) || ((power > myRegion->powerLimit) && !devicestate.owner.is_licensed)) - power = myRegion->powerLimit; + if ((power == 0) || ((power + REGULATORY_GAIN > myRegion->powerLimit) && !devicestate.owner.is_licensed)) + power = myRegion->powerLimit - REGULATORY_GAIN; if (power == 0) power = 17; // Default to this power level if we don't have a valid regional power limit (powerLimit of myRegion defaults