From 2127cf20cbc9c28e5efe81cf034a716892bfc8e5 Mon Sep 17 00:00:00 2001 From: Jason Reiss Date: Thu, 8 Apr 2021 14:38:17 -0500 Subject: load lut into lgw when temp comp is enabled --- lora_pkt_fwd/src/lora_pkt_fwd.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c index 87eaaa0..80bd66a 100644 --- a/lora_pkt_fwd/src/lora_pkt_fwd.c +++ b/lora_pkt_fwd/src/lora_pkt_fwd.c @@ -374,7 +374,7 @@ void lookup_power_settings(float tx_pwr, int8_t* rf_power, int8_t* dig_gain) { for (int i = 0; i < TEMP_LUT_SIZE_MAX; i++) { // If the current temp is lower than the first temp or we reach the end of the table - if ((tx_temp_lut->dig[0].temp > tx_temp_lut->temp_comp_value || i == TEMP_LUT_SIZE_MAX-1) || + if ((tx_temp_lut.lut[0].temp > temp_comp_value || i == TEMP_LUT_SIZE_MAX-1) || (tx_temp_lut.lut[i].temp <= temp_comp_value && tx_temp_lut.lut[i+1].temp > temp_comp_value)) { for (int j = 0; j < TX_GAIN_LUT_SIZE_MAX; j++) { for (int h = 0; h < 4; h++) { @@ -849,6 +849,7 @@ static int parse_SX1301_configuration(const char * conf_file) { MSG("INFO: Loading temperature compensated LUT values\n"); for (i = 0; i < TX_GAIN_LUT_SIZE_MAX; i++) { + txlut.size++; txlut.lut[i].rf_power = tx_temp_lut.base[i].rf_power; txlut.lut[i].pa_gain = tx_temp_lut.base[i].pa_gain; txlut.lut[i].mix_gain = tx_temp_lut.base[i].mix_gain; @@ -856,6 +857,17 @@ static int parse_SX1301_configuration(const char * conf_file) { txlut.lut[i].dac_gain = 3; MSG("LUT %d RF: %d PA: %d MIX: %d DIG: %d DAC: %d\n", i, txlut.lut[i].rf_power, txlut.lut[i].pa_gain, txlut.lut[i].mix_gain, txlut.lut[i].dig_gain, txlut.lut[i].dac_gain); } + + /* all parameters parsed, submitting configuration to the HAL */ + if (txlut.size > 0) { + MSG("INFO: Configuring TX LUT with %u indexes\n", txlut.size); + if (lgw_txgain_setconf(&txlut) != LGW_HAL_SUCCESS) { + MSG("ERROR: Failed to configure concentrator TX Gain LUT\n"); + return -1; + } + } else { + MSG("WARNING: No TX gain LUT defined\n"); + } } else { /* set configuration for tx gains */ -- cgit v1.2.3