diff options
author | Harsh Sharma <harsh.sharma@multitech.com> | 2019-11-15 14:02:18 -0600 |
---|---|---|
committer | Harsh Sharma <harsh.sharma@multitech.com> | 2019-11-15 14:02:18 -0600 |
commit | f870877782ba8a279580f2df0ab7c244a4849ab0 (patch) | |
tree | 2ec9a30033436ebecd05cf2e2d3df1b477c0e57f | |
parent | 408ecd322635e37c710006c95a22dddc455e7f08 (diff) | |
download | lora_gateway_mtac_full-f870877782ba8a279580f2df0ab7c244a4849ab0.tar.gz lora_gateway_mtac_full-f870877782ba8a279580f2df0ab7c244a4849ab0.tar.bz2 lora_gateway_mtac_full-f870877782ba8a279580f2df0ab7c244a4849ab0.zip |
Changed attenuator power to be int instead of float
-rw-r--r-- | libloragw/inc/loragw_fpga.h | 2 | ||||
-rw-r--r-- | libloragw/src/loragw_fpga.c | 2 | ||||
-rw-r--r-- | libloragw/src/loragw_hal.c | 2 | ||||
-rw-r--r-- | util_tx_continuous/src/util_tx_continuous.c | 14 |
4 files changed, 10 insertions, 10 deletions
diff --git a/libloragw/inc/loragw_fpga.h b/libloragw/inc/loragw_fpga.h index d5b6f9d..722438c 100644 --- a/libloragw/inc/loragw_fpga.h +++ b/libloragw/inc/loragw_fpga.h @@ -135,6 +135,6 @@ int lgw_fpga_reg_wb(uint16_t register_id, uint8_t *data, uint16_t size); */ int lgw_fpga_reg_rb(uint16_t register_id, uint8_t *data, uint16_t size); -int lgw_set_attenuation(float *attn); +int lgw_set_attenuation(uint8_t *attn); #endif /* --- EOF ------------------------------------------------------------------ */ diff --git a/libloragw/src/loragw_fpga.c b/libloragw/src/loragw_fpga.c index 368fe37..906f4b5 100644 --- a/libloragw/src/loragw_fpga.c +++ b/libloragw/src/loragw_fpga.c @@ -366,7 +366,7 @@ int lgw_fpga_reg_rb(uint16_t register_id, uint8_t *data, uint16_t size) { /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -int lgw_set_attenuation(float *attn) { +int lgw_set_attenuation(uint8_t *attn) { if (*attn < 0) { return LGW_HAL_ERROR; } diff --git a/libloragw/src/loragw_hal.c b/libloragw/src/loragw_hal.c index 386bd6d..9355cb8 100644 --- a/libloragw/src/loragw_hal.c +++ b/libloragw/src/loragw_hal.c @@ -1423,7 +1423,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 */ - float attn = (float)(max_tx_power - pkt_data.rf_power); + uint8_t attn = (uint8_t)(max_tx_power - pkt_data.rf_power); x = lgw_set_attenuation(&attn); if (x != LGW_HAL_SUCCESS) { DEBUG_MSG("ERROR: Failed to set attenuation value\n"); diff --git a/util_tx_continuous/src/util_tx_continuous.c b/util_tx_continuous/src/util_tx_continuous.c index 275c3eb..54d77f7 100644 --- a/util_tx_continuous/src/util_tx_continuous.c +++ b/util_tx_continuous/src/util_tx_continuous.c @@ -59,7 +59,7 @@ Maintainer: Matthieu Leurent #define DEFAULT_FDEV_KHZ 25 #define DEFAULT_BT 2 #define DEFAULT_NOTCH_FREQ 129000U -#define DEFAULT_ATTENUATION 0.0 +#define DEFAULT_ATTENUATION 0 /* -------------------------------------------------------------------------- */ /* --- GLOBAL VARIABLES ----------------------------------------------------- */ @@ -109,7 +109,7 @@ int main(int argc, char **argv) uint8_t g_dac = DEFAULT_DAC_GAIN; uint8_t g_mix = DEFAULT_MIXER_GAIN; uint8_t g_pa = DEFAULT_PA_GAIN; - float g_atten = DEFAULT_ATTENUATION; + uint8_t g_atten = DEFAULT_ATTENUATION; char mod[64] = DEFAULT_MODULATION; uint8_t sf = DEFAULT_SF; unsigned int bw_khz = DEFAULT_BW_KHZ; @@ -267,13 +267,13 @@ int main(int argc, char **argv) } } else if (strcmp(long_options[option_index].name,"attn") == 0) { - i = sscanf(optarg, "%f", &arg_f); - if ((i != 1) || (arg_f < 0.0) ) { + i = sscanf(optarg, "%u", &arg_u); + if ((i != 1) || (arg_f > 127) ) { printf("ERROR: argument parsing of --attn argument. Use -h to print help\n"); return EXIT_FAILURE; } else { - g_atten = arg_f; + g_atten = arg_u; } } else { @@ -363,9 +363,9 @@ int main(int argc, char **argv) txpkt.tx_mode = IMMEDIATE; txpkt.rf_chain = TX_RF_CHAIN; if (fpga_supports_attenuator()) { - txpkt.rf_power = 32.0 - g_atten; + txpkt.rf_power = 32 - g_atten; } else { - txpkt.rf_power = 0.0; + txpkt.rf_power = 0; } if (strcmp(mod, "FSK") == 0) { |