From 519d08801f16b38c3980443047aa6f5165d2af23 Mon Sep 17 00:00:00 2001 From: Michael Coracin Date: Fri, 12 Jun 2015 17:12:25 +0200 Subject: [PATCH] v3.0.2 - Bugfix: Fixed frequency calculation on uplinks: lgw_receive() function was using a variable to calculate the frequency before it was initialized with correct value. - Bugfix: util_pkt_logger crashed when no gateway_ID is not defined in global_conf.json --- VERSION | 2 +- libloragw/src/loragw_hal.c | 10 ++++++---- readme.md | 10 ++++++++++ util_pkt_logger/src/util_pkt_logger.c | 16 ++++++++++------ 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/VERSION b/VERSION index cb2b00e4..b5021469 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.0.1 +3.0.2 diff --git a/libloragw/src/loragw_hal.c b/libloragw/src/loragw_hal.c index 90c1084d..aeffa4b1 100644 --- a/libloragw/src/loragw_hal.c +++ b/libloragw/src/loragw_hal.c @@ -1188,6 +1188,9 @@ int lgw_receive(uint8_t max_pkt, struct lgw_pkt_rx_s *pkt_data) { } CHECK_NULL(pkt_data); + /* Initialize buffer */ + memset (buff, 0, sizeof buff); + /* iterate max_pkt times at most */ for (nb_pkt_fetch = 0; nb_pkt_fetch < max_pkt; ++nb_pkt_fetch) { @@ -1214,14 +1217,13 @@ int lgw_receive(uint8_t max_pkt, struct lgw_pkt_rx_s *pkt_data) { /* copy payload to result struct */ memcpy((void *)p->payload, (void *)buff, sz); - /* get back info from configuration so that application doesn't have to keep track of it */ - p->rf_chain = (uint8_t)if_rf_chain[p->if_chain]; - p->freq_hz = (uint32_t)((int32_t)rf_rx_freq[p->rf_chain] + if_freq[p->if_chain]); - /* process metadata */ p->if_chain = buff[sz+0]; ifmod = ifmod_config[p->if_chain]; DEBUG_PRINTF("[%d %d]\n", p->if_chain, ifmod); + + p->rf_chain = (uint8_t)if_rf_chain[p->if_chain]; + p->freq_hz = (uint32_t)((int32_t)rf_rx_freq[p->rf_chain] + if_freq[p->if_chain]); p->rssi = (float)buff[sz+5] + rf_rssi_offset[p->rf_chain]; if ((ifmod == IF_LORA_MULTI) || (ifmod == IF_LORA_STD)) { diff --git a/readme.md b/readme.md index 72379cb5..2c51626f 100644 --- a/readme.md +++ b/readme.md @@ -56,6 +56,16 @@ for spectral measurement. 3. Changelog ------------- +### v3.0.2 ### + +* Bugfix: Fixed frequency calculation on uplinks: lgw_receive() function was using a variable to calculate the frequency before it was initialized with correct value. +* Bugfix: util_pkt_logger crashed when no gateway_ID is not defined in global_conf.json + +### v3.0.1 ### + +* Bufgix: Fixed util_tx_continuous compilation issue, by adding empty obj directory +* Bugfix: Fixed HAL compilation issue for CFG_SPI=ftdi, removed dependency on loragw_gpio in this case + ### v3.0.0 ### * Added new HAL function lgw_board_setconf() to configure board/concentrator specific parameters: network type (LoRa public or private), concentrator clock source. Note: those parameters are not any more set from the library.cfg file configuration (CFG_NET, CFG_BRD), and should be passed at initialization by the application. diff --git a/util_pkt_logger/src/util_pkt_logger.c b/util_pkt_logger/src/util_pkt_logger.c index 253b6c35..9e452812 100644 --- a/util_pkt_logger/src/util_pkt_logger.c +++ b/util_pkt_logger/src/util_pkt_logger.c @@ -300,8 +300,9 @@ int parse_gateway_configuration(const char * conf_file) { JSON_Value *root_val; JSON_Object *root = NULL; JSON_Object *conf = NULL; + const char *str; /* pointer to sub-strings in the JSON data */ unsigned long long ull = 0; - + /* try to parse JSON */ root_val = json_parse_file_with_comments(conf_file); root = json_value_get_object(root_val); @@ -316,12 +317,15 @@ int parse_gateway_configuration(const char * conf_file) { } else { MSG("INFO: %s does contain a JSON object named %s, parsing gateway parameters\n", conf_file, conf_obj); } - + /* getting network parameters (only those necessary for the packet logger) */ - sscanf(json_object_dotget_string(conf, "gateway_ID"), "%llx", &ull); - lgwm = ull; - MSG("INFO: gateway MAC address is configured to %016llX\n", ull); - + str = json_object_get_string(conf, "gateway_ID"); + if (str != NULL) { + sscanf(str, "%llx", &ull); + lgwm = ull; + MSG("INFO: gateway MAC address is configured to %016llX\n", ull); + } + json_value_free(root_val); return 0; }