diff options
author | Harsh Sharma <harsh.sharma@multitech.com> | 2021-01-29 16:43:34 -0600 |
---|---|---|
committer | Harsh Sharma <harsh.sharma@multitech.com> | 2021-01-29 16:43:34 -0600 |
commit | 5ab2ffb580da0a84cb6ffe88545ec5e4f3d2e6f3 (patch) | |
tree | a0155012b7478230f518d020c8a3d5c4a18ba7f4 /util_tx_test | |
parent | 03a003c56355b7597c68711ce95424285b66d311 (diff) | |
download | lora_gateway_mtac_full-5ab2ffb580da0a84cb6ffe88545ec5e4f3d2e6f3.tar.gz lora_gateway_mtac_full-5ab2ffb580da0a84cb6ffe88545ec5e4f3d2e6f3.tar.bz2 lora_gateway_mtac_full-5ab2ffb580da0a84cb6ffe88545ec5e4f3d2e6f3.zip |
Added pa, mix, dig and dac options to utiltx test
Diffstat (limited to 'util_tx_test')
-rw-r--r-- | util_tx_test/src/util_tx_test.c | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/util_tx_test/src/util_tx_test.c b/util_tx_test/src/util_tx_test.c index 0ac8244..f217d16 100644 --- a/util_tx_test/src/util_tx_test.c +++ b/util_tx_test/src/util_tx_test.c @@ -153,6 +153,10 @@ void usage(void) { printf(" --lbt-sctm <uint> lbt scan time in usec to be applied to all channels [128, 5000]\n"); printf(" --lbt-rssi <int> lbt rssi target in dBm [-128..0]\n"); printf(" --lbt-rssi-offset <int> rssi offset in dB to be applied to SX127x RSSI [-128..127]\n"); + printf(" --pa <uint> pa gain\n"); + printf(" --mix <uint> mix gain\n"); + printf(" --dig <uint> dig gain\n"); + printf(" --dac <uint> dac gain\n"); printf(" --path <string> path of SPIDEV e.g. /dev/spidev0.0\n"); } @@ -193,6 +197,11 @@ int main(int argc, char **argv) uint8_t lbt_nb_channel = 1; uint32_t sx1301_count_us; uint32_t tx_notch_freq = DEFAULT_NOTCH_FREQ; + bool force_tx_lut = false; + uint8_t dig_gain = 0; /*!> 2 bits, control of the digital gain of SX1301 */ + uint8_t pa_gain = 0; /*!> 2 bits, control of the external PA (SX1301 I/O) */ + uint8_t dac_gain = 0; /*!> 2 bits, control of the radio DAC */ + uint8_t mix_gain = 0; /*!> 4 bits, control of the radio mixer */ /* RF configuration (TX fail if RF chain is not enabled) */ enum lgw_radio_type_e radio_type = LGW_RADIO_TYPE_NONE; @@ -215,7 +224,10 @@ int main(int argc, char **argv) {"lbt-rssi", required_argument, 0, 0}, {"lbt-nbch", required_argument, 0, 0}, {"lbt-rssi-offset", required_argument, 0, 0}, - {"path", required_argument, 0, 0}, + {"pa", required_argument, 0, 0}, + {"mix", required_argument, 0, 0}, + {"dig", required_argument, 0, 0}, + {"dac", required_argument, 0, 0}, {0, 0, 0, 0} }; @@ -472,6 +484,46 @@ int main(int argc, char **argv) usage(); return EXIT_FAILURE; } + } else if( strcmp(long_options[option_index].name, "pa") == 0 ) { /* <uint> */ + i = sscanf(optarg, "%i", &xi); + if ((i != 1) || (xi < 0)) { + MSG("ERROR: invalid PA gain\n"); + usage(); + return EXIT_FAILURE; + } else { + pa_gain = xi; + force_tx_lut = true; + } + } else if( strcmp(long_options[option_index].name, "dig") == 0 ) { /* <uint> */ + i = sscanf(optarg, "%i", &xi); + if ((i != 1) || (xi < 0)) { + MSG("ERROR: invalid Dig gain\n"); + usage(); + return EXIT_FAILURE; + } else { + dig_gain = xi; + force_tx_lut = true; + } + } else if( strcmp(long_options[option_index].name, "dac") == 0 ) { /* <uint> */ + i = sscanf(optarg, "%i", &xi); + if ((i != 1) || (xi < 0)) { + MSG("ERROR: invalid Dac gain\n"); + usage(); + return EXIT_FAILURE; + } else { + dac_gain = xi; + force_tx_lut = true; + } + } else if( strcmp(long_options[option_index].name, "mix") == 0 ) { /* <uint> */ + i = sscanf(optarg, "%i", &xi); + if ((i != 1) || (xi < 0)) { + MSG("ERROR: invalid mix gain\n"); + usage(); + return EXIT_FAILURE; + } else { + mix_gain = xi; + force_tx_lut = true; + } } else if (strcmp(long_options[option_index].name,"path") == 0) { /* <string> Path to spi device */ i = sscanf(optarg, "%s", arg_s); if ((i != 1) || (strncmp(arg_s, "/dev/", 5 ) != 0)) { @@ -555,7 +607,22 @@ int main(int argc, char **argv) } /* TX gain config */ - lgw_txgain_setconf(&txgain_lut); + if (force_tx_lut) { + struct lgw_tx_gain_lut_s txgain_lut_forced = { + .size = 1, + .lut[0] = { + .dig_gain = dig_gain, + .pa_gain = pa_gain, + .dac_gain = dac_gain, + .mix_gain = mix_gain, + .rf_power = 0 + } + }; + lgw_txgain_setconf(&txgain_lut_forced); + MSG("settings forced dig_gain%d pa_gain%d dac_gain%d mix_gain%d", dig_gain, pa_gain, dac_gain, mix_gain); + } else { + lgw_txgain_setconf(&txgain_lut); + } /* Start concentrator */ i = lgw_start(); |