From b665027754e4a050b5c3ea2da999dce8bf3ab710 Mon Sep 17 00:00:00 2001 From: Sylvain Miermont Date: Thu, 12 Dec 2013 15:31:52 +0100 Subject: v1.1.1 - bugfix: fixed some range checks that did not prevent segfaults - test: removed systematic register dump in test_loragw_hal.c - modified Makefiles for easier cross-compilation - added root README and removed TXT extension of other READMEs --- README | 54 +++++++++++++++++++++++++ libloragw/Makefile | 19 ++++----- libloragw/README | 55 ++++++++++++++++++++++++++ libloragw/README.TXT | 30 -------------- libloragw/doc/MANUAL.TXT | 16 ++++---- libloragw/src/loragw_hal.c | 20 ++++++---- libloragw/tst/test_loragw_hal.c | 21 ++++++---- loragw_band_survey/Makefile | 6 +-- loragw_band_survey/README | 57 ++++++++++++++++++++++++++ loragw_band_survey/README.TXT | 57 -------------------------- loragw_pkt_logger/Makefile | 8 ++-- loragw_pkt_logger/README | 88 +++++++++++++++++++++++++++++++++++++++++ loragw_pkt_logger/README.TXT | 88 ----------------------------------------- loragw_spi_stress/Makefile | 6 +-- loragw_spi_stress/README | 68 +++++++++++++++++++++++++++++++ loragw_spi_stress/README.TXT | 64 ------------------------------ loragw_tx_test/Makefile | 6 +-- loragw_tx_test/README | 72 +++++++++++++++++++++++++++++++++ loragw_tx_test/README.TXT | 72 --------------------------------- 19 files changed, 451 insertions(+), 356 deletions(-) create mode 100644 README create mode 100644 libloragw/README delete mode 100644 libloragw/README.TXT create mode 100644 loragw_band_survey/README delete mode 100644 loragw_band_survey/README.TXT create mode 100644 loragw_pkt_logger/README delete mode 100644 loragw_pkt_logger/README.TXT create mode 100644 loragw_spi_stress/README delete mode 100644 loragw_spi_stress/README.TXT create mode 100644 loragw_tx_test/README delete mode 100644 loragw_tx_test/README.TXT diff --git a/README b/README new file mode 100644 index 0000000..52f7ab2 --- /dev/null +++ b/README @@ -0,0 +1,54 @@ + / _____) _ | | + ( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | + (______/|_____)_|_|_| \__)_____)\____)_| |_| + ©2013 Semtech-Cycleo + +Lora Gateway HAL project +========================= + +1. Core library: libloragw +--------------------------- + +This directory contains the sources of the library to build a gateway based on +a Semtech Lora multi-channel RF receiver. +Once compiled all the code is contained in the libloragw.a file that will be +statically linked (ie. integrated in the final executable). + +The library also comes with a bunch of basic tests programs that are used to +test the different sub-modules of the library. + +2. Helper programs +------------------- + +Those programs are included in the project to provide examples on how to use +the HAL library, and to help the system builder test different parts of it. + +### 2.1. loragw_band_survey ### + +This software is used to scan the RF band and measure background RSSI and some +measurement of interferer pattern. + +### 2.2. loragw_pkt_logger ### + +This software is used to set up a Lora concentrator using a JSON configuration +file and then record all the packets received in a log file, indefinitely, until +the user stops the application. + +### 2.3. loragw_spi_stress ### + +This software is used to check the reliability of the link between the host +platform (on which the program is run) and the Lora concentrator register file +that is the interface through which all interaction with the Lora concentrator +happens. + +### 2.4. loragw_tx_test ### + +This software is used to send test packets with a Lora concentrator. The packets +contain little information, on no protocol (ie. MAC address) information but +can be used to assess the functionality of a gateway downlink using other +gateways as receivers. + + +*EOF* \ No newline at end of file diff --git a/libloragw/Makefile b/libloragw/Makefile index b910c92..db45383 100644 --- a/libloragw/Makefile +++ b/libloragw/Makefile @@ -2,6 +2,7 @@ include library.cfg # constant symbols +CROSS_COMPILE= CC=gcc CFLAGS=-O2 -Wall -Wextra -Iinc -I. C99FLAGS=-O2 -Wall -Wextra -std=c99 -Iinc -I. @@ -43,35 +44,35 @@ endif # static library libloragw.a: obj/loragw_hal.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o - ar rcs libloragw.a obj/loragw_hal.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o + $(CROSS_COMPILE)ar rcs libloragw.a obj/loragw_hal.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o # library module target obj/loragw_aux.o: .conf_ok src/loragw_aux.c inc/loragw_aux.h - $(CC) -c $(CFLAGS) src/loragw_aux.c -o obj/loragw_aux.o $(FLAG_AUX) + $(CROSS_COMPILE)$(CC) -c $(CFLAGS) src/loragw_aux.c -o obj/loragw_aux.o $(FLAG_AUX) obj/loragw_spi.o: .conf_ok src/loragw_spi.native.c src/loragw_spi.ftdi.c inc/loragw_spi.h ifeq ($(LGW_PHY),native) - $(CC) -c $(C99FLAGS) src/loragw_spi.native.c -o obj/loragw_spi.o $(FLAG_SPI) + $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) src/loragw_spi.native.c -o obj/loragw_spi.o $(FLAG_SPI) endif ifeq ($(LGW_PHY),ftdi) - $(CC) -c $(C99FLAGS) src/loragw_spi.ftdi.c -o obj/loragw_spi.o $(FLAG_SPI) + $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) src/loragw_spi.ftdi.c -o obj/loragw_spi.o $(FLAG_SPI) endif obj/loragw_reg.o: .conf_ok src/loragw_reg.c inc/loragw_reg.h inc/loragw_spi.h - $(CC) -c $(C99FLAGS) src/loragw_reg.c -o obj/loragw_reg.o $(FLAG_REG) + $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) src/loragw_reg.c -o obj/loragw_reg.o $(FLAG_REG) obj/loragw_hal.o: .conf_ok VERSION src/loragw_hal.c src/arb_fw.var src/agc_fw.var inc/loragw_hal.h inc/loragw_reg.h inc/loragw_spi.h inc/loragw_aux.h - $(CC) -c $(C99FLAGS) src/loragw_hal.c -o obj/loragw_hal.o -D LGW_PHY="\"$(LGW_PHY)\"" $(FLAG_HAL) + $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) src/loragw_hal.c -o obj/loragw_hal.o -D LGW_PHY="\"$(LGW_PHY)\"" $(FLAG_HAL) # test programs test_loragw_spi: tst/test_loragw_spi.c obj/loragw_spi.o - $(CC) $(C99FLAGS) tst/test_loragw_spi.c obj/loragw_spi.o -o test_loragw_spi $(LDFLAGS) + $(CROSS_COMPILE)$(CC) $(C99FLAGS) tst/test_loragw_spi.c obj/loragw_spi.o -o test_loragw_spi $(LDFLAGS) test_loragw_reg: tst/test_loragw_reg.c obj/loragw_reg.o obj/loragw_spi.o - $(CC) $(C99FLAGS) tst/test_loragw_reg.c obj/loragw_reg.o obj/loragw_spi.o -o test_loragw_reg $(LDFLAGS) + $(CROSS_COMPILE)$(CC) $(C99FLAGS) tst/test_loragw_reg.c obj/loragw_reg.o obj/loragw_spi.o -o test_loragw_reg $(LDFLAGS) test_loragw_hal: tst/test_loragw_hal.c obj/loragw_hal.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o - $(CC) $(C99FLAGS) tst/test_loragw_hal.c obj/loragw_hal.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o -o test_loragw_hal $(LDFLAGS) + $(CROSS_COMPILE)$(CC) $(C99FLAGS) tst/test_loragw_hal.c obj/loragw_hal.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o -o test_loragw_hal $(LDFLAGS) diff --git a/libloragw/README b/libloragw/README new file mode 100644 index 0000000..da4cd4d --- /dev/null +++ b/libloragw/README @@ -0,0 +1,55 @@ +Lora Gateway HAL library +========================= + +1. Content of subdirectories +----------------------------- + +### 1.1. doc ### + +Contains the user manual, licensing informations, udev rules, etc. + +### 1.2. inc ### + +Contain C header files for the different sub-modules of the library. + +You *MUST* include loragw_hal.h in your application. +You *MAY* include loragw_reg.h in your application if you need direct registers +access. + +### 1.3. obj ### + +Contained the compiled intermediary objects. + +### 1.4. src ### + +Contain library C sources. + +### 1.5. tst ### + +Contain the C sources for test programs to validate SPI link, register access +and hardware functionality. + +2. Legal notice +---------------- + +The information presented in this project documentation does not form part of +any quotation or contract, is believed to be accurate and reliable and may be +changed without notice. No liability will be accepted by the publisher for any +consequence of its use. Publication thereof does not convey nor imply any +license under patent or other industrial or intellectual property rights. +Semtech assumes no responsibility or liability whatsoever for any failure or +unexpected operation resulting from misuse, neglect improper installation, +repair or improper handling or unusual physical or electrical stress +including, but not limited to, exposure to parameters beyond the specified +maximum ratings or operation outside the specified range. + +SEMTECH PRODUCTS ARE NOT DESIGNED, INTENDED, AUTHORIZED OR WARRANTED TO BE +SUITABLE FOR USE IN LIFE-SUPPORT APPLICATIONS, DEVICES OR SYSTEMS OR OTHER +CRITICAL APPLICATIONS. INCLUSION OF SEMTECH PRODUCTS IN SUCH APPLICATIONS IS +UNDERSTOOD TO BE UNDERTAKEN SOLELY AT THE CUSTOMER’S OWN RISK. Should a +customer purchase or use Semtech products for any such unauthorized +application, the customer shall indemnify and hold Semtech and its officers, +employees, subsidiaries, affiliates, and distributors harmless against all +claims, costs damages and attorney fees which could arise. + +*EOF* \ No newline at end of file diff --git a/libloragw/README.TXT b/libloragw/README.TXT deleted file mode 100644 index 9d13a4a..0000000 --- a/libloragw/README.TXT +++ /dev/null @@ -1,30 +0,0 @@ -Lora Gateway HAL library - Content of subdirectories -==================================================== - -## 1. doc ## - -Contains the user manual, licensing informations, udev rules, etc. - -## 2. inc ## - -Contain C header files for the different sub-modules of the library. - -You *MUST* include loragw_hal.h in your application. -You *MAY* include loragw_reg.h in your application if you need direct registers -access. - -## 3. obj ## - -Contained the compiled intermediary objects. - -## 4. src ## - -Contain library C sources. - -## 5. tst ## - -Contain the C sources for test programs to validate SPI link, register access -and hardware functionality. - - -*EOF* \ No newline at end of file diff --git a/libloragw/doc/MANUAL.TXT b/libloragw/doc/MANUAL.TXT index 1659f03..a086761 100644 --- a/libloragw/doc/MANUAL.TXT +++ b/libloragw/doc/MANUAL.TXT @@ -200,14 +200,14 @@ started A typical application flow for using the HAL is the following: - - -loop { - - - -} - + + + loop { + + + + } + **/!\ Warning** The lgw_send function is non-blocking and returns while the Lora gateway is still sending the packet, or even before the packet has started diff --git a/libloragw/src/loragw_hal.c b/libloragw/src/loragw_hal.c index 5d9138d..c2329fc 100644 --- a/libloragw/src/loragw_hal.c +++ b/libloragw/src/loragw_hal.c @@ -454,11 +454,13 @@ int lgw_rxrf_setconf(uint8_t rf_chain, struct lgw_conf_rxrf_s conf) { return LGW_HAL_ERROR; } - /* check input parameters */ - if (rf_chain > LGW_RF_CHAIN_NB) { + /* check input range (segfault prevention) */ + if (rf_chain >= LGW_RF_CHAIN_NB) { DEBUG_MSG("ERROR: NOT A VALID RF_CHAIN NUMBER\n"); return LGW_HAL_ERROR; } + + /* check input parameters */ if (conf.freq_hz > rf_rx_upfreq[rf_chain]) { DEBUG_MSG("ERROR: FREQUENCY TOO HIGH FOR THAT RF_CHAIN\n"); return LGW_HAL_ERROR; @@ -483,6 +485,12 @@ int lgw_rxif_setconf(uint8_t if_chain, struct lgw_conf_rxif_s conf) { return LGW_HAL_ERROR; } + /* check input range (segfault prevention) */ + if (if_chain >= LGW_IF_CHAIN_NB) { + DEBUG_PRINTF("ERROR: %d NOT A VALID IF_CHAIN NUMBER\n", if_chain); + return LGW_HAL_ERROR; + } + /* if chain is disabled, don't care about most parameters */ if (conf.enable == false) { if_enable[if_chain] = false; @@ -492,10 +500,6 @@ int lgw_rxif_setconf(uint8_t if_chain, struct lgw_conf_rxif_s conf) { } /* check 'general' parameters */ - if (if_chain > LGW_IF_CHAIN_NB) { - DEBUG_PRINTF("ERROR: %d NOT A VALID IF_CHAIN NUMBER\n", if_chain); - return LGW_HAL_ERROR; - } if (ifmod_config[if_chain] == IF_UNDEFINED) { DEBUG_PRINTF("ERROR: IF CHAIN %d NOT CONFIGURABLE\n", if_chain); } @@ -954,11 +958,13 @@ int lgw_send(struct lgw_pkt_tx_s pkt_data) { return LGW_HAL_ERROR; } - /* check input variables */ + /* check input range (segfault prevention) */ if (pkt_data.rf_chain >= LGW_RF_CHAIN_NB) { DEBUG_MSG("ERROR: INVALID RF_CHAIN TO SEND PACKETS\n"); return LGW_HAL_ERROR; } + + /* check input variables */ if (rf_enable[pkt_data.rf_chain] == false) { DEBUG_MSG("ERROR: SELECTED RF_CHAIN IS DISABLED\n"); return LGW_HAL_ERROR; diff --git a/libloragw/tst/test_loragw_hal.c b/libloragw/tst/test_loragw_hal.c index c777597..6881760 100644 --- a/libloragw/tst/test_loragw_hal.c +++ b/libloragw/tst/test_loragw_hal.c @@ -82,8 +82,6 @@ int main() unsigned long loop_cnt = 0; uint8_t status_var = 0; - FILE * reg_dump = NULL; - /* configure signal handling */ sigemptyset(&sigact.sa_mask); sigact.sa_flags = 0; @@ -180,14 +178,21 @@ int main() printf("*** Library version information ***\n%s\n***\n", lgw_version_info()); /* connect, configure and start the Lora gateway */ - lgw_start(); + i = lgw_start(); + if (i == LGW_HAL_SUCCESS) { + printf("*** Concentrator started ***\n"); + } else { + printf("*** Impossible to start concentrator ***\n"); + return -1; + } /* once configured, dump content of registers to a file, for reference */ - reg_dump = fopen("reg_dump.log", "w"); - if (reg_dump != NULL) { - lgw_reg_check(reg_dump); - fclose(reg_dump); - } + // FILE * reg_dump = NULL; + // reg_dump = fopen("reg_dump.log", "w"); + // if (reg_dump != NULL) { + // lgw_reg_check(reg_dump); + // fclose(reg_dump); + // } while ((quit_sig != 1) && (exit_sig != 1)) { loop_cnt++; diff --git a/loragw_band_survey/Makefile b/loragw_band_survey/Makefile index 4ae2f2e..22d1f87 100644 --- a/loragw_band_survey/Makefile +++ b/loragw_band_survey/Makefile @@ -3,7 +3,7 @@ APP_NAME=loragw_band_survey ### constant symbols - +CROSS_COMPILE= CC=gcc CFLAGS=-O2 -Wall -Wextra -Iinc C99FLAGS=-O2 -Wall -Wextra -std=c99 -Iinc @@ -31,7 +31,7 @@ clean: ### main program compilation and assembly obj/$(APP_NAME).o: src/$(APP_NAME).c src/rssi_fw.var - $(CC) -c $(C99FLAGS) -o obj/$(APP_NAME).o $(LGW_INC) src/$(APP_NAME).c $(FLAG_AUX) + $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) -o obj/$(APP_NAME).o $(LGW_INC) src/$(APP_NAME).c $(FLAG_AUX) $(APP_NAME): $(LGW_PATH)/libloragw.a obj/$(APP_NAME).o - $(CC) -o $(APP_NAME) obj/$(APP_NAME).o -L$(LGW_PATH) $(LGW_LNK) + $(CROSS_COMPILE)$(CC) -o $(APP_NAME) obj/$(APP_NAME).o -L$(LGW_PATH) $(LGW_LNK) diff --git a/loragw_band_survey/README b/loragw_band_survey/README new file mode 100644 index 0000000..a34134d --- /dev/null +++ b/loragw_band_survey/README @@ -0,0 +1,57 @@ + / _____) _ | | + ( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | + (______/|_____)_|_|_| \__)_____)\____)_| |_| + ©2013 Semtech-Cycleo + +Lora Gateway RF band survey application +======================================== + +1. Introduction +---------------- + +This software is used to scan the RF band and measure background RSSI and some +measurement of interferer pattern. +The RSSI is purposefully skew towards high values, to detect high power +interferers (eg. a gateway installed in the beam of a powerful base station), +and not to characterize the noise floor, or accurately measure the time-domain +profile of interferers. + +2. Dependencies +---------------- + +This software call functions in the loragw_reg and loragw_reg sub-modules of +loragwlib. loragw_spi is used indirectly, and the loragw_hal sub-module is not +used at all, except for constants define at the top level. + +It has been qualified with the Lora Getway HAL library version 1.0.0, and should +be compatible with any compatible later version that use the same API, or a +downward-compatible one. + +Because some non-public functions from loragw_hal had to be re-implemented, any +change in the IP might affect this program even if an updated Lora Getway HAL +library is provided. +Connecting an incompatible concentrator board should give you the error: +"ERROR: fail to connect to concentrator board" + +3. Usage +--------- + +To stop the application before the end of the measurement, press Ctrl+C. + +By default, the program scans the whole band (start and stop frequency defined in +the loragw_hal.h file) with a 200 kHz measurement step. +Use -f option to change start and stop frequency, and measurement step. + +The resolution bandwidth of the scan is 200 kHz and cannot be set by the user. + +The measurement results are put in a CSV file whose name include a UTC timestamp +of measurement starting time in ISO 8601 recommended compact format: +yyyymmddThhmmssZ (eg. 20131009T172345Z for October 9th, 2013 at 5:23:45PM UTC) + +4. Changelog +------------- + +2013-10-24, v1 +Initial version. diff --git a/loragw_band_survey/README.TXT b/loragw_band_survey/README.TXT deleted file mode 100644 index a34134d..0000000 --- a/loragw_band_survey/README.TXT +++ /dev/null @@ -1,57 +0,0 @@ - / _____) _ | | - ( (____ _____ ____ _| |_ _____ ____| |__ - \____ \| ___ | (_ _) ___ |/ ___) _ \ - _____) ) ____| | | || |_| ____( (___| | | | - (______/|_____)_|_|_| \__)_____)\____)_| |_| - ©2013 Semtech-Cycleo - -Lora Gateway RF band survey application -======================================== - -1. Introduction ----------------- - -This software is used to scan the RF band and measure background RSSI and some -measurement of interferer pattern. -The RSSI is purposefully skew towards high values, to detect high power -interferers (eg. a gateway installed in the beam of a powerful base station), -and not to characterize the noise floor, or accurately measure the time-domain -profile of interferers. - -2. Dependencies ----------------- - -This software call functions in the loragw_reg and loragw_reg sub-modules of -loragwlib. loragw_spi is used indirectly, and the loragw_hal sub-module is not -used at all, except for constants define at the top level. - -It has been qualified with the Lora Getway HAL library version 1.0.0, and should -be compatible with any compatible later version that use the same API, or a -downward-compatible one. - -Because some non-public functions from loragw_hal had to be re-implemented, any -change in the IP might affect this program even if an updated Lora Getway HAL -library is provided. -Connecting an incompatible concentrator board should give you the error: -"ERROR: fail to connect to concentrator board" - -3. Usage ---------- - -To stop the application before the end of the measurement, press Ctrl+C. - -By default, the program scans the whole band (start and stop frequency defined in -the loragw_hal.h file) with a 200 kHz measurement step. -Use -f option to change start and stop frequency, and measurement step. - -The resolution bandwidth of the scan is 200 kHz and cannot be set by the user. - -The measurement results are put in a CSV file whose name include a UTC timestamp -of measurement starting time in ISO 8601 recommended compact format: -yyyymmddThhmmssZ (eg. 20131009T172345Z for October 9th, 2013 at 5:23:45PM UTC) - -4. Changelog -------------- - -2013-10-24, v1 -Initial version. diff --git a/loragw_pkt_logger/Makefile b/loragw_pkt_logger/Makefile index 761ab03..8946c5b 100644 --- a/loragw_pkt_logger/Makefile +++ b/loragw_pkt_logger/Makefile @@ -3,7 +3,7 @@ APP_NAME=loragw_pkt_logger ### constant symbols - +CROSS_COMPILE= CC=gcc CFLAGS=-O2 -Wall -Wextra -Iinc C99FLAGS=-O2 -Wall -Wextra -std=c99 -Iinc @@ -29,12 +29,12 @@ clean: ### sub-modules compilation obj/parson.o: src/parson.c - $(CC) -c $(C99FLAGS) -o obj/parson.o $(LGW_INC) src/parson.c $(FLAG_AUX) + $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) -o obj/parson.o $(LGW_INC) src/parson.c $(FLAG_AUX) ### main program compilation and assembly obj/$(APP_NAME).o: src/$(APP_NAME).c - $(CC) -c $(C99FLAGS) -o obj/$(APP_NAME).o $(LGW_INC) src/$(APP_NAME).c $(FLAG_AUX) + $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) -o obj/$(APP_NAME).o $(LGW_INC) src/$(APP_NAME).c $(FLAG_AUX) $(APP_NAME): $(LGW_PATH)/libloragw.a obj/$(APP_NAME).o obj/parson.o - $(CC) -o $(APP_NAME) obj/$(APP_NAME).o obj/parson.o -L$(LGW_PATH) $(LGW_LNK) + $(CROSS_COMPILE)$(CC) -o $(APP_NAME) obj/$(APP_NAME).o obj/parson.o -L$(LGW_PATH) $(LGW_LNK) diff --git a/loragw_pkt_logger/README b/loragw_pkt_logger/README new file mode 100644 index 0000000..9469904 --- /dev/null +++ b/loragw_pkt_logger/README @@ -0,0 +1,88 @@ + / _____) _ | | + ( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | + (______/|_____)_|_|_| \__)_____)\____)_| |_| + ©2013 Semtech-Cycleo + +Lora Gateway packet logger +=========================== + +1. Introduction +---------------- + +This software is used to set up a Lora concentrator using a JSON configuration +file and then record all the packets received in a log file, indefinitely, until +the user stops the application. +No filtering is done and all packets that are Lora packets with the correct RF +parameters (frequency, datarate, bandwidth) should appear in the log. + +2. Dependencies +---------------- + +This program uses the Parson library (http://kgabis.github.com/parson/) by +Krzysztof Gabis for JSON parsing. +Many thanks to him for that very practical and well written library. + +This program is a typical example of Lora Gateway HAL usage for receiving +packets. + +Only high-level functions are used (the ones contained in loragw_hal) so there +is no hardware dependencies assuming the HAL is matched with the proper version +of the hardware. +Data structures of the received packets are accessed by name (ie. not at a +binary level) so new functionalities can be added to the API without affecting +that program at all. + +It was tested with v1.0.0 of the libloragw library, and should be compatible +with any later version of the library assuming the API is downward-compatible. + +3. Usage +--------- + +To stop the application, press Ctrl+C. + +The only optional parameter when launching the application is the log rotation +time (in seconds). + +The way the program takes configuration files into account is the following: + * if there is a debug_conf.json parse it, others are ignored + * if there is a global_conf.json parse it, look for the next file + * if there is a local_conf.json parse it +If some parameters are defined in both global and local configuration files, the +local definition overwrites the global definition. + +The global configuration file should be exactly the same throughout your +network, contain all global parameters (parameters for "sensor" radio channels) +and preferably default "safe" values for parameters that are specific for each +gateway (eg. specify a default MAC address). + +The local configuration file should contain parameters that are specific to each +gateway (eg. MAC address, frequency for backhaul radio channels). + +In each configuration file, the program looks for a JSON object named +"SX1301_conf" that should contain the parameters for the Lora concentrator board +(RF channels definition, modem parameters, etc) and another JSON object called +"gateway_conf" that should contain the gateway parameters (gateway MAC address, +IP address of the Lora MAC controller, network authentication parameters, etc). + +To learn more about the JSON configuration format, read the provided JSON files +and the API documentation. A dedicated document will be available later on. + +The received packets are put in a CSV file whose name include the MAC address of +the gateway in hexadecimal format and a UTC timestamp of log starting time in +ISO 8601 recommended compact format: +yyyymmddThhmmssZ (eg. 20131009T172345Z for October 9th, 2013 at 5:23:45PM UTC) + +To able continuous monitoring, the current log file is closed is closed and a +new one is opened every hour (by default, rotation interval is settable by the +user using -r command line option). +No packet is lost during that rotation of log file. +Every log file but the current one can then be modified, uploaded and/or deleted +without any consequence for the program execution. + +4. Changelog +------------- + +2013-10-24, v1 +Initial version. diff --git a/loragw_pkt_logger/README.TXT b/loragw_pkt_logger/README.TXT deleted file mode 100644 index 9469904..0000000 --- a/loragw_pkt_logger/README.TXT +++ /dev/null @@ -1,88 +0,0 @@ - / _____) _ | | - ( (____ _____ ____ _| |_ _____ ____| |__ - \____ \| ___ | (_ _) ___ |/ ___) _ \ - _____) ) ____| | | || |_| ____( (___| | | | - (______/|_____)_|_|_| \__)_____)\____)_| |_| - ©2013 Semtech-Cycleo - -Lora Gateway packet logger -=========================== - -1. Introduction ----------------- - -This software is used to set up a Lora concentrator using a JSON configuration -file and then record all the packets received in a log file, indefinitely, until -the user stops the application. -No filtering is done and all packets that are Lora packets with the correct RF -parameters (frequency, datarate, bandwidth) should appear in the log. - -2. Dependencies ----------------- - -This program uses the Parson library (http://kgabis.github.com/parson/) by -Krzysztof Gabis for JSON parsing. -Many thanks to him for that very practical and well written library. - -This program is a typical example of Lora Gateway HAL usage for receiving -packets. - -Only high-level functions are used (the ones contained in loragw_hal) so there -is no hardware dependencies assuming the HAL is matched with the proper version -of the hardware. -Data structures of the received packets are accessed by name (ie. not at a -binary level) so new functionalities can be added to the API without affecting -that program at all. - -It was tested with v1.0.0 of the libloragw library, and should be compatible -with any later version of the library assuming the API is downward-compatible. - -3. Usage ---------- - -To stop the application, press Ctrl+C. - -The only optional parameter when launching the application is the log rotation -time (in seconds). - -The way the program takes configuration files into account is the following: - * if there is a debug_conf.json parse it, others are ignored - * if there is a global_conf.json parse it, look for the next file - * if there is a local_conf.json parse it -If some parameters are defined in both global and local configuration files, the -local definition overwrites the global definition. - -The global configuration file should be exactly the same throughout your -network, contain all global parameters (parameters for "sensor" radio channels) -and preferably default "safe" values for parameters that are specific for each -gateway (eg. specify a default MAC address). - -The local configuration file should contain parameters that are specific to each -gateway (eg. MAC address, frequency for backhaul radio channels). - -In each configuration file, the program looks for a JSON object named -"SX1301_conf" that should contain the parameters for the Lora concentrator board -(RF channels definition, modem parameters, etc) and another JSON object called -"gateway_conf" that should contain the gateway parameters (gateway MAC address, -IP address of the Lora MAC controller, network authentication parameters, etc). - -To learn more about the JSON configuration format, read the provided JSON files -and the API documentation. A dedicated document will be available later on. - -The received packets are put in a CSV file whose name include the MAC address of -the gateway in hexadecimal format and a UTC timestamp of log starting time in -ISO 8601 recommended compact format: -yyyymmddThhmmssZ (eg. 20131009T172345Z for October 9th, 2013 at 5:23:45PM UTC) - -To able continuous monitoring, the current log file is closed is closed and a -new one is opened every hour (by default, rotation interval is settable by the -user using -r command line option). -No packet is lost during that rotation of log file. -Every log file but the current one can then be modified, uploaded and/or deleted -without any consequence for the program execution. - -4. Changelog -------------- - -2013-10-24, v1 -Initial version. diff --git a/loragw_spi_stress/Makefile b/loragw_spi_stress/Makefile index b19eee9..4006dc3 100644 --- a/loragw_spi_stress/Makefile +++ b/loragw_spi_stress/Makefile @@ -3,7 +3,7 @@ APP_NAME=loragw_spi_stress ### constant symbols - +CROSS_COMPILE= CC=gcc CFLAGS=-O2 -Wall -Wextra -Iinc C99FLAGS=-O2 -Wall -Wextra -std=c99 -Iinc @@ -29,7 +29,7 @@ clean: ### main program compilation and assembly obj/$(APP_NAME).o: src/$(APP_NAME).c - $(CC) -c $(C99FLAGS) -o obj/$(APP_NAME).o $(LGW_INC) src/$(APP_NAME).c $(FLAG_AUX) + $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) -o obj/$(APP_NAME).o $(LGW_INC) src/$(APP_NAME).c $(FLAG_AUX) $(APP_NAME): $(LGW_PATH)/libloragw.a obj/$(APP_NAME).o - $(CC) -o $(APP_NAME) obj/$(APP_NAME).o -L$(LGW_PATH) $(LGW_LNK) + $(CROSS_COMPILE)$(CC) -o $(APP_NAME) obj/$(APP_NAME).o -L$(LGW_PATH) $(LGW_LNK) diff --git a/loragw_spi_stress/README b/loragw_spi_stress/README new file mode 100644 index 0000000..98c4f40 --- /dev/null +++ b/loragw_spi_stress/README @@ -0,0 +1,68 @@ + / _____) _ | | + ( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | + (______/|_____)_|_|_| \__)_____)\____)_| |_| + ©2013 Semtech-Cycleo + +Lora Gateway SPI stress test +============================= + +1. Introduction +---------------- + +This software is used to check the reliability of the link between the host +platform (on which the program is run) and the Lora concentrator register file +that is the interface through which all interaction with the Lora concentrator +happens. + +2. Dependencies +---------------- + +This program only access the Lora gateway HAL library through its loragw_reg +"named registers" access sub-module. + +It was tested with v1.0.0 of the libloragw library, and should be compatible +with any later version of the library and the hardware, assuming the registers +used for the tests are still present. + +The registers used are: + * LGW_VERSION + * LGW_IMPLICIT_PAYLOAD_LENGHT + * LGW_FSK_REF_PATTERN_LSB + * LGW_RX_DATA_BUF_ADDR + * LGW_RX_DATA_BUF_DATA + +A data buffer accessible through the 2 registers above must be implemented. + +3. Usage +--------- + +The tests run forever or until an error is detected. +Press Ctrl+C to stop the application. + +When an error is detected, diagnosis information are displayed. Please refer to +the source code for more details on what is displayed for diagnosis. + +All tests use pseudo-random data generated by the rand() function. The random +generator is not seeded, and the same sequence of data will be use each time the +program is launched. + +Basically, some random data is written, read back and then compared to the +initial written data. Some "useless" read on others registers might be inserted +to be sure that the data read back is coming from the hardware, and not from the +internal buffer(s) of the software driver(s). + +Test 1 > R/W on a simple 8-bit register + +Test 2 > R/W on a simple 8-bit register with interstitial reads on VERSION + +Test 3 > R/W on a 32-bit register (short SPI bursts access) + +Test 4 > data buffer R/W (long SPI bursts access) + +4. Changelog +------------- + +2013-10-24, v1 +Initial version. diff --git a/loragw_spi_stress/README.TXT b/loragw_spi_stress/README.TXT deleted file mode 100644 index 605fed6..0000000 --- a/loragw_spi_stress/README.TXT +++ /dev/null @@ -1,64 +0,0 @@ - / _____) _ | | - ( (____ _____ ____ _| |_ _____ ____| |__ - \____ \| ___ | (_ _) ___ |/ ___) _ \ - _____) ) ____| | | || |_| ____( (___| | | | - (______/|_____)_|_|_| \__)_____)\____)_| |_| - ©2013 Semtech-Cycleo - -Lora Gateway SPI stress test -============================= - -1. Introduction ----------------- - -This software is used to check the reliability of the link between the host -platform (on which the program is run) and the Lora concentrator register file -that is the interface through which all interaction with the Lora concentrator -happens. - -2. Dependencies ----------------- - -This program only access the Lora gateway HAL library through its loragw_reg -"named registers" access sub-module. - -It was tested with v1.0.0 of the libloragw library, and should be compatible -with any later version of the library and the hardware, assuming the registers -used for the tests are still present. - -The registers used are: -LGW_VERSION -LGW_IMPLICIT_PAYLOAD_LENGHT -LGW_FSK_REF_PATTERN_LSB -LGW_RX_DATA_BUF_ADDR -LGW_RX_DATA_BUF_DATA -A data buffer accessible through the 2 registers above must be implemented. - -3. Usage ---------- - -The tests run forever or until an error is detected. -Press Ctrl+C to stop the application. - -When an error is detected, diagnosis information are displayed. Please refer to -the source code for more details on what is displayed for diagnosis. - -All tests use pseudo-random data generated by the rand() function. The random -generator is not seeded, and the same sequence of data will be use each time the -program is launched. - -Basically, some random data is written, read back and then compared to the -initial written data. Some "useless" read on others registers might be inserted -to be sure that the data read back is coming from the hardware, and not from the -internal buffer(s) of the software driver(s). - -Test 1 > R/W on a simple 8-bit register -Test 2 > R/W on a simple 8-bit register with interstitial reads on VERSION -Test 3 > R/W on a 32-bit register (short SPI bursts access) -Test 4 > data buffer R/W (long SPI bursts access) - -4. Changelog -------------- - -2013-10-24, v1 -Initial version. diff --git a/loragw_tx_test/Makefile b/loragw_tx_test/Makefile index 8ece9b9..3de440b 100644 --- a/loragw_tx_test/Makefile +++ b/loragw_tx_test/Makefile @@ -3,7 +3,7 @@ APP_NAME=loragw_tx_test ### constant symbols - +CROSS_COMPILE= CC=gcc CFLAGS=-O2 -Wall -Wextra -Iinc C99FLAGS=-O2 -Wall -Wextra -std=c99 -Iinc @@ -29,7 +29,7 @@ clean: ### main program compilation and assembly obj/$(APP_NAME).o: src/$(APP_NAME).c - $(CC) -c $(C99FLAGS) -o obj/$(APP_NAME).o $(LGW_INC) src/$(APP_NAME).c $(FLAG_AUX) + $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) -o obj/$(APP_NAME).o $(LGW_INC) src/$(APP_NAME).c $(FLAG_AUX) $(APP_NAME): $(LGW_PATH)/libloragw.a obj/$(APP_NAME).o - $(CC) -o $(APP_NAME) obj/$(APP_NAME).o -L$(LGW_PATH) $(LGW_LNK) + $(CROSS_COMPILE)$(CC) -o $(APP_NAME) obj/$(APP_NAME).o -L$(LGW_PATH) $(LGW_LNK) diff --git a/loragw_tx_test/README b/loragw_tx_test/README new file mode 100644 index 0000000..435b162 --- /dev/null +++ b/loragw_tx_test/README @@ -0,0 +1,72 @@ + / _____) _ | | + ( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | + (______/|_____)_|_|_| \__)_____)\____)_| |_| + ©2013 Semtech-Cycleo + +Lora Gateway packet sender +=========================== + +1. Introduction +---------------- + +This software is used to send test packets with a Lora concentrator. The packets +contain little information, on no protocol (ie. MAC address) information but +can be used to assess the functionality of a gateway downlink using other +gateways as receivers. + +2. Dependencies +---------------- + +This program is a typical example of Lora Gateway HAL usage for sending packets. + +Only high-level functions are used (the ones contained in loragw_hal) so there +is no hardware dependencies assuming the HAL is matched with the proper version +of the hardware. +Data structures of the sent packets are accessed by name (ie. not at a +binary level) so new functionalities can be added to the API without affecting +that program at all. + +It was tested with v1.0.0 of the libloragw library, and should be compatible +with any later version of the library assuming the API is downward-compatible. + +3. Usage +--------- + +The application runs until the specified number of packets have been sent. +Press Ctrl+C to stop the application before that. + +Use the -f option followed by a real number (decimal point and scientific +'E notation' are OK) to specify the modulation central frequency. + +Use the -s option to specify the Spreading Factor of Lora modulation (values 7 +to 12 are valid). + +Use the -b option to set Lora modulation bandwidth in kHz (accepted values: 125, +250 or 500). + +Use the -p option to set the concentrator TX power in dBm. Not all values are +supported by hardware (typically 14 et 20 dBm are supported, other values might +not give expected power). Check with a RF power meter before connecting any +sensitive equipment. + +Use the -t option to specify the number of milliseconds of pause between +packets. Using zero will result in a quasi-continuous emission. + +Use the -x option to specify how many packets should be sent. + +Use the -i option to invert the Lora modulation polarity. + +The packets are 20 bytes long, and protected by the smallest supported ECC. + +The payload content is: +[T][E][S][T][packet counter MSB][packet counter LSB] followed by ASCII padding. +All Lora data is whitened, so the padding has no influence whatsoever on the +packet error rate. + +4. Changelog +------------- + +2013-10-24, v1 +Initial version. diff --git a/loragw_tx_test/README.TXT b/loragw_tx_test/README.TXT deleted file mode 100644 index 435b162..0000000 --- a/loragw_tx_test/README.TXT +++ /dev/null @@ -1,72 +0,0 @@ - / _____) _ | | - ( (____ _____ ____ _| |_ _____ ____| |__ - \____ \| ___ | (_ _) ___ |/ ___) _ \ - _____) ) ____| | | || |_| ____( (___| | | | - (______/|_____)_|_|_| \__)_____)\____)_| |_| - ©2013 Semtech-Cycleo - -Lora Gateway packet sender -=========================== - -1. Introduction ----------------- - -This software is used to send test packets with a Lora concentrator. The packets -contain little information, on no protocol (ie. MAC address) information but -can be used to assess the functionality of a gateway downlink using other -gateways as receivers. - -2. Dependencies ----------------- - -This program is a typical example of Lora Gateway HAL usage for sending packets. - -Only high-level functions are used (the ones contained in loragw_hal) so there -is no hardware dependencies assuming the HAL is matched with the proper version -of the hardware. -Data structures of the sent packets are accessed by name (ie. not at a -binary level) so new functionalities can be added to the API without affecting -that program at all. - -It was tested with v1.0.0 of the libloragw library, and should be compatible -with any later version of the library assuming the API is downward-compatible. - -3. Usage ---------- - -The application runs until the specified number of packets have been sent. -Press Ctrl+C to stop the application before that. - -Use the -f option followed by a real number (decimal point and scientific -'E notation' are OK) to specify the modulation central frequency. - -Use the -s option to specify the Spreading Factor of Lora modulation (values 7 -to 12 are valid). - -Use the -b option to set Lora modulation bandwidth in kHz (accepted values: 125, -250 or 500). - -Use the -p option to set the concentrator TX power in dBm. Not all values are -supported by hardware (typically 14 et 20 dBm are supported, other values might -not give expected power). Check with a RF power meter before connecting any -sensitive equipment. - -Use the -t option to specify the number of milliseconds of pause between -packets. Using zero will result in a quasi-continuous emission. - -Use the -x option to specify how many packets should be sent. - -Use the -i option to invert the Lora modulation polarity. - -The packets are 20 bytes long, and protected by the smallest supported ECC. - -The payload content is: -[T][E][S][T][packet counter MSB][packet counter LSB] followed by ASCII padding. -All Lora data is whitened, so the padding has no influence whatsoever on the -packet error rate. - -4. Changelog -------------- - -2013-10-24, v1 -Initial version. -- cgit v1.2.3