diff options
author | Harsh Sharma <harsh.sharma@multitech.com> | 2019-10-29 16:48:34 -0500 |
---|---|---|
committer | Harsh Sharma <harsh.sharma@multitech.com> | 2019-10-29 16:48:34 -0500 |
commit | 963a35fe0d6668e5b66d6bd1ff9659be8bf7d7bd (patch) | |
tree | d6a81b07760c56a0c314963244b5ecec2152208a | |
parent | c05674a9613e5acd5e0bdee9d1298a780189a459 (diff) | |
download | lora_gateway_mtac_full-963a35fe0d6668e5b66d6bd1ff9659be8bf7d7bd.tar.gz lora_gateway_mtac_full-963a35fe0d6668e5b66d6bd1ff9659be8bf7d7bd.tar.bz2 lora_gateway_mtac_full-963a35fe0d6668e5b66d6bd1ff9659be8bf7d7bd.zip |
Changed tx power to be limited from max tx power variable
-rw-r--r-- | libloragw/src/loragw_hal.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libloragw/src/loragw_hal.c b/libloragw/src/loragw_hal.c index 48bc3b0..88bd874 100644 --- a/libloragw/src/loragw_hal.c +++ b/libloragw/src/loragw_hal.c @@ -135,6 +135,7 @@ static uint64_t fsk_sync_word= 0xC194C1; /* default FSK sync word (ALIGNED RIGHT static bool lorawan_public = false; static uint8_t rf_clkout = 0; +static uint8_t max_tx_power = 32; /* default uncalibrated max tx power */ static struct lgw_tx_gain_lut_s txgain_lut = { .size = 2, @@ -423,8 +424,13 @@ int lgw_board_setconf(struct lgw_conf_board_s conf) { /* set internal config according to parameters */ lorawan_public = conf.lorawan_public; rf_clkout = conf.clksrc; - - DEBUG_PRINTF("Note: board configuration; lorawan_public:%d, clksrc:%d\n", lorawan_public, rf_clkout); + if (fpga_supports_attenuator()) { + max_tx_power = conf.max_tx_power; + printf("-------MAX TX POWER %d\n", max_tx_power); + DEBUG_PRINTF("Note: board configuration; lorawan_public:%d, clksrc:%d, max_tx_power:%d\n", lorawan_public, rf_clkout, max_tx_power); + } else { + DEBUG_PRINTF("Note: board configuration; lorawan_public:%d, clksrc:%d \n", lorawan_public, rf_clkout); + } return LGW_HAL_SUCCESS; } @@ -1418,7 +1424,7 @@ int lgw_send(struct lgw_pkt_tx_s pkt_data) { /* Power is set to max and the attenuator brings down the level to match the packet's request */ target_mix_gain = 15; /* Mixer gain is not used for setting power*/ lgw_reg_w(LGW_TX_GAIN, 0); /* Dig gain is not used for setting power */ - x = lgw_set_attenuation((float)(32.0 - pkt_data.rf_power)); + x = lgw_set_attenuation((float)(max_tx_power - pkt_data.rf_power)); if (x != LGW_HAL_SUCCESS) { DEBUG_MSG("ERROR: Failed to set attenuation value\n"); return LGW_HAL_ERROR; |