From e9eb32b3abd1d8936fc7c915cf37e73c29737b86 Mon Sep 17 00:00:00 2001 From: Kimmo Vaisanen Date: Wed, 25 Apr 2018 11:53:53 +0300 Subject: [PATCH] Lora: Fix max tx power check In LoRa TX power value 0 means the maximum allowed TX power and values >0 are limiting the allowed TX power to lower. tx_config was incorrectly checking the power level and causing the maximum TX power to be always used. Lora gateway can request node to use lower TX power with LinkAdrReq MAC command. --- features/lorawan/lorastack/phy/LoRaPHY.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/features/lorawan/lorastack/phy/LoRaPHY.cpp b/features/lorawan/lorastack/phy/LoRaPHY.cpp index 6f5e15a5a4..ee88f74b93 100644 --- a/features/lorawan/lorastack/phy/LoRaPHY.cpp +++ b/features/lorawan/lorastack/phy/LoRaPHY.cpp @@ -880,9 +880,7 @@ bool LoRaPHY::tx_config(tx_config_params_t* tx_conf, int8_t* tx_power, band_t *bands = (band_t *)phy_params.bands.table; // limit TX power if set to too much - if (tx_conf->tx_power > bands[band_idx].max_tx_pwr) { - tx_conf->tx_power = bands[band_idx].max_tx_pwr; - } + tx_conf->tx_power = MAX(tx_conf->tx_power, bands[band_idx].max_tx_pwr); uint8_t bandwidth = get_bandwidth(tx_conf->datarate); int8_t phy_tx_power = 0;