From 963a35fe0d6668e5b66d6bd1ff9659be8bf7d7bd Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Tue, 29 Oct 2019 16:48:34 -0500 Subject: Changed tx power to be limited from max tx power variable --- libloragw/src/loragw_hal.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'libloragw') 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; -- cgit v1.2.3