diff options
| author | Sylvain Miermont <smiermont@semtech.com> | 2014-03-28 16:58:48 +0100 |
|---|---|---|
| committer | Sylvain Miermont <smiermont@semtech.com> | 2014-03-28 16:58:48 +0100 |
| commit | f991b0e35ad1bd3b999c70e68c518bae91bd36a6 (patch) | |
| tree | 7e098ae53dc1401d88efa12de3bfc24ff405d88c | |
| parent | 0e2b2cfa32767e516870a4e6a2ce0b6cce827910 (diff) | |
| download | lora_gateway-f991b0e35ad1bd3b999c70e68c518bae91bd36a6.tar.gz lora_gateway-f991b0e35ad1bd3b999c70e68c518bae91bd36a6.tar.bz2 lora_gateway-f991b0e35ad1bd3b999c70e68c518bae91bd36a6.zip | |
v1.3.0v1.3.0
- Added TX power management.
- Added full support for SX1301 reference board.
- Changed build system with configuration for multiple chip/radio/band support.
- SX125x bandwidth set to 1MHz by default (was 800 kHz).
- Solved warnings with 64b integer printf when compiling on x86_64.
- Renamed helper programs to reduce the concentrator vs. gateway confusion.
67 files changed, 3507 insertions, 2331 deletions
diff --git a/loragw_pkt_logger/LICENSE.TXT b/LICENSE index 2007c51..62de0d4 100644 --- a/loragw_pkt_logger/LICENSE.TXT +++ b/LICENSE @@ -1,28 +1,3 @@ ---- For the parson library (parson.c and parson.h) --- - - Parson ( http://kgabis.github.com/parson/ ) - Copyright (c) 2012 Krzysztof Gabis - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - - --- For the rest of the code : Revised BSD License --- - Copyright (c) 2013, SEMTECH S.A. All rights reserved. @@ -47,3 +22,28 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +--- For the parson library used by the packet logger --- + +Parson ( http://kgabis.github.com/parson/ ) +Copyright (c) 2012 Krzysztof Gabis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +ITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5afee5d --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +### Environment constants + +CROSS_COMPILE := +export + +### general build targets + +all: + $(MAKE) all -e -C libloragw + $(MAKE) all -e -C util_band_survey + $(MAKE) all -e -C util_pkt_logger + $(MAKE) all -e -C util_spi_stress + $(MAKE) all -e -C util_tx_test + +clean: + $(MAKE) clean -e -C libloragw + $(MAKE) clean -e -C util_band_survey + $(MAKE) clean -e -C util_pkt_logger + $(MAKE) clean -e -C util_spi_stress + $(MAKE) clean -e -C util_tx_test + +### EOF
\ No newline at end of file @@ -1,76 +0,0 @@ - / _____) _ | | - ( (____ _____ ____ _| |_ _____ ____| |__ - \____ \| ___ | (_ _) ___ |/ ___) _ \ - _____) ) ____| | | || |_| ____( (___| | | | - (______/|_____)_|_|_| \__)_____)\____)_| |_| - ©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. - -3. 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 @@ -0,0 +1 @@ +1.3.0
\ No newline at end of file diff --git a/libloragw/doc/99-libftdi.rules b/libloragw/99-libftdi.rules index 8487413..8487413 100644 --- a/libloragw/doc/99-libftdi.rules +++ b/libloragw/99-libftdi.rules diff --git a/libloragw/Makefile b/libloragw/Makefile index 2b91fa8..9d5660b 100644 --- a/libloragw/Makefile +++ b/libloragw/Makefile @@ -1,84 +1,190 @@ -# putting the configuration in a separate file +### get external defined data + +LIBLORAGW_VERSION := `cat ../VERSION` include library.cfg -# constant symbols -CROSS_COMPILE= -CC=gcc -CFLAGS=-O2 -Wall -Wextra -Iinc -I. -C99FLAGS=-O2 -Wall -Wextra -std=c99 -Iinc -I. +### constant symbols -# configuration-dependant symbols -ifeq ($(LGW_PHY),native) -LDFLAGS=-lrt -endif -ifeq ($(LGW_PHY),ftdi) -LDFLAGS=-lrt -lmpsse -endif +CROSS_COMPILE := +CC := $(CROSS_COMPILE)gcc +AR := $(CROSS_COMPILE)ar -# general build targets +CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I. -all: libloragw.a test_loragw_spi test_loragw_reg test_loragw_hal test_loragw_gps +### library.cfg configuration file processing -clean: - rm -f *.a - rm -f test_* - rm -f obj/*.o - rm -f .conf_ok +ifeq ($(CFG_SPI),native) + CFG_SPI_MSG := Linux native SPI driver (/dev/spidev0.0) + CFG_SPI_OPT := CFG_SPI_NATIVE +else ifeq ($(CFG_SPI),ftdi) + CFG_SPI_MSG := FTDI SPI-over-USB bridge using libmpsse/libftdi/libusb + CFG_SPI_OPT := CFG_SPI_FTDI +else + $(error No SPI physical layer selected, check ../target.cfg file.) +endif + +ifeq ($(CFG_CHIP),sx1301) + CFG_CHIP_MSG := Semtech SX1301 production chip + CFG_CHIP_OPT := CFG_CHIP_1301 +else ifeq ($(CFG_CHIP),fpga1301) + CFG_CHIP_MSG := FPGA containing the SX1301 IP + CFG_CHIP_OPT := CFG_CHIP_FPGA +else + $(error No concentrator chip selected, check library.cfg file.) +endif -.conf_ok: library.cfg - @echo "*** Checking Lora gateway HAL library config ***" - @rm -f .conf_ok -ifeq ($(LGW_PHY),native) - @echo "Selected SPI interface type: Linux native driver" +ifeq ($(CFG_RADIO),sx1257) + CFG_RADIO_MSG := Dual SX1257 transceivers, covering 860-1000 MHz + CFG_RADIO_OPT := CFG_RADIO_1257 +else ifeq ($(CFG_RADIO),sx1255) + CFG_RADIO_MSG := Dual SX1255 transceivers, covering 400-510 MHz + CFG_RADIO_OPT := CFG_RADIO_1255 else -ifeq ($(LGW_PHY),ftdi) - @echo "Selected SPI interface type: FTDI SPI-over-USB bridge" + $(error No radio chip selected, check library.cfg file.) +endif + +ifeq ($(CFG_BAND),full) + CFG_BAND_MSG := Full range supported by the radio(s) + CFG_BAND_OPT := CFG_BAND_FULL +else ifeq ($(CFG_BAND),eu868) + ifeq ($(CFG_RADIO),sx1257) + CFG_BAND_MSG := ETSI 868 (866) MHz band + CFG_BAND_OPT := CFG_BAND_868 + else + $(error The selected radio(s) cannot work in the selected band.) + endif +else ifeq ($(CFG_BAND),us915) + ifeq ($(CFG_RADIO),sx1257) + CFG_BAND_MSG := FCC 915 MHz band + CFG_BAND_OPT := CFG_BAND_915 + else + $(error The selected radio(s) cannot work in the selected band.) + endif +else ifeq ($(CFG_BAND),cn470) + ifeq ($(CFG_RADIO),sx1255) + CFG_BAND_MSG := China 470 MHz band + CFG_BAND_OPT := CFG_BAND_470 + else + $(error The selected radio(s) cannot work in the selected band.) + endif +else ifeq ($(CFG_BAND),eu433) + ifeq ($(CFG_RADIO),sx1255) + CFG_BAND_MSG := ETSI 433 MHz band + CFG_BAND_OPT := CFG_BAND_433 + else + $(error The selected radio(s) cannot work in the selected band.) + endif else - $(error No SPI physical layer selected) + $(warning [Warning] No frequency band selected, full radio capability assumed.) + CFG_BAND_MSG := Full range supported by the radio(s) + CFG_BAND_OPT := CFG_BAND_FULL endif + +ifeq ($(CFG_BRD),dev_nano_868) + CFG_BRD_MSG := FPGA-based nano-concentrator, with 868 MHz SAW filter + CFG_BRD_OPT := CFG_BRD_NANO868 +else ifeq ($(CFG_BRD),ref_1301_57nf) + CFG_BRD_MSG := SX1301 reference board with SX1257 radios, no filters + CFG_BRD_OPT := CFG_BRD_REF1301 +else + $(info [Info] No specific board selected.) + CFG_BRD_MSG := None + CFG_BRD_OPT := CFG_BRD_NONE endif - @echo "*** Config seems ok ***" - @echo "" - @touch .conf_ok -# static library +### linking options -libloragw.a: obj/loragw_hal.o obj/loragw_gps.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_gps.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o +ifeq ($(CFG_SPI),native) + LIBS := -lloragw -lrt +else ifeq ($(CFG_SPI),ftdi) + LIBS := -lloragw -lrt -lmpsse +endif -# library module target +### general build targets -obj/loragw_aux.o: .conf_ok src/loragw_aux.c inc/loragw_aux.h - $(CROSS_COMPILE)$(CC) -c $(CFLAGS) src/loragw_aux.c -o obj/loragw_aux.o $(FLAG_AUX) +all: libloragw.a test_loragw_spi test_loragw_reg test_loragw_hal test_loragw_gps -obj/loragw_spi.o: .conf_ok src/loragw_spi.native.c src/loragw_spi.ftdi.c inc/loragw_spi.h -ifeq ($(LGW_PHY),native) - $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) src/loragw_spi.native.c -o obj/loragw_spi.o $(FLAG_SPI) -endif -ifeq ($(LGW_PHY),ftdi) - $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) src/loragw_spi.ftdi.c -o obj/loragw_spi.o $(FLAG_SPI) +clean: + rm -f libloragw.a + rm -f test_loragw_* + rm -f obj/*.o + rm -f inc/config.h + +### transpose library.cfg into a C header file : config.h + +inc/config.h: ../VERSION library.cfg + @echo "*** Checking libloragw library configuration ***" + @rm -f $@ + # File initialization + @echo "#ifndef _LORAGW_CONFIGURATION_H" >> $@ + @echo "#define _LORAGW_CONFIGURATION_H" >> $@ + # Release version + @echo "Release version : $(LIBLORAGW_VERSION)" + @echo " #define LIBLORAGW_VERSION "\"$(LIBLORAGW_VERSION)\""" >> $@ + # SPI interface + @echo "SPI interface : $(CFG_SPI_MSG)" + @echo " #define $(CFG_SPI_OPT) 1" >> $@ + # Concentrator chip + @echo "Concentrator chip : $(CFG_CHIP_MSG)" + @echo " #define $(CFG_CHIP_OPT) 1" >> $@ + # Radio chip(s) + @echo "Radio chip(s) : $(CFG_RADIO_MSG)" + @echo " #define $(CFG_RADIO_OPT) 1" >> $@ + # Frequency band + @echo "Frequency band : $(CFG_BAND_MSG)" + @echo " #define $(CFG_BAND_OPT) 1" >> $@ + # Board misc. parameters + @echo "Board misc. param : $(CFG_BRD_MSG)" + @echo " #define $(CFG_BRD_OPT) 1" >> $@ + # Debug options + @echo " #define DEBUG_AUX $(DEBUG_AUX)" >> $@ + @echo " #define DEBUG_SPI $(DEBUG_SPI)" >> $@ + @echo " #define DEBUG_REG $(DEBUG_REG)" >> $@ + @echo " #define DEBUG_HAL $(DEBUG_HAL)" >> $@ + @echo " #define DEBUG_GPS $(DEBUG_GPS)" >> $@ + # end of file + @echo "#endif" >> $@ + @echo "*** Configuration seems ok ***" + +### library module target + +obj/loragw_aux.o: src/loragw_aux.c inc/loragw_aux.h inc/config.h + $(CC) -c $(CFLAGS) $< -o $@ + +ifeq ($(CFG_SPI),native) +obj/loragw_spi.o: src/loragw_spi.native.c inc/loragw_spi.h inc/config.h + $(CC) -c $(CFLAGS) $< -o $@ +else ifeq ($(CFG_SPI),ftdi) +obj/loragw_spi.o: src/loragw_spi.ftdi.c inc/loragw_spi.h inc/config.h + $(CC) -c $(CFLAGS) $< -o $@ endif -obj/loragw_reg.o: .conf_ok src/loragw_reg.c inc/loragw_reg.h inc/loragw_spi.h - $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) src/loragw_reg.c -o obj/loragw_reg.o $(FLAG_REG) +obj/loragw_reg.o: src/loragw_reg.c inc/loragw_reg.h inc/loragw_spi.h inc/config.h + $(CC) -c $(CFLAGS) $< -o $@ -obj/loragw_hal.o: .conf_ok src/loragw_hal.c inc/loragw_hal.h inc/loragw_reg.h inc/loragw_aux.h VERSION src/arb_fw.var src/agc_fw.var - $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) src/loragw_hal.c -o obj/loragw_hal.o -D LGW_PHY="\"$(LGW_PHY)\"" $(FLAG_HAL) +obj/loragw_hal.o: src/loragw_hal.c inc/loragw_hal.h inc/loragw_reg.h inc/loragw_aux.h src/arb_fw.var src/agc_fw.var inc/config.h + $(CC) -c $(CFLAGS) $< -o $@ -obj/loragw_gps.o: .conf_ok src/loragw_gps.c inc/loragw_gps.h - $(CROSS_COMPILE)$(CC) -c $(C99FLAGS) src/loragw_gps.c -o obj/loragw_gps.o $(FLAG_GPS) +obj/loragw_gps.o: src/loragw_gps.c inc/loragw_gps.h inc/config.h + $(CC) -c $(CFLAGS) $< -o $@ + +### static library + +libloragw.a: obj/loragw_hal.o obj/loragw_gps.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o + $(AR) rcs $@ $^ -# test programs +### test programs -test_loragw_spi: tst/test_loragw_spi.c obj/loragw_spi.o - $(CROSS_COMPILE)$(CC) $(C99FLAGS) tst/test_loragw_spi.c obj/loragw_spi.o -o test_loragw_spi $(LDFLAGS) +test_loragw_spi: tst/test_loragw_spi.c libloragw.a + $(CC) $(CFLAGS) -L. $< -o $@ $(LIBS) -test_loragw_reg: tst/test_loragw_reg.c obj/loragw_reg.o obj/loragw_spi.o - $(CROSS_COMPILE)$(CC) $(C99FLAGS) tst/test_loragw_reg.c obj/loragw_reg.o obj/loragw_spi.o -o test_loragw_reg $(LDFLAGS) +test_loragw_reg: tst/test_loragw_reg.c libloragw.a + $(CC) $(CFLAGS) -L. $< -o $@ $(LIBS) -test_loragw_hal: tst/test_loragw_hal.c obj/loragw_hal.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o - $(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) +test_loragw_hal: tst/test_loragw_hal.c libloragw.a + $(CC) $(CFLAGS) -L. $< -o $@ $(LIBS) -test_loragw_gps: tst/test_loragw_gps.c obj/loragw_gps.o obj/loragw_hal.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o - $(CROSS_COMPILE)$(CC) $(C99FLAGS) tst/test_loragw_gps.c obj/loragw_gps.o obj/loragw_hal.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o -o test_loragw_gps $(LDFLAGS) +test_loragw_gps: tst/test_loragw_gps.c libloragw.a + $(CC) $(CFLAGS) -L. $< -o $@ $(LIBS) +### EOF
\ No newline at end of file diff --git a/libloragw/README b/libloragw/README deleted file mode 100644 index 821eff6..0000000 --- a/libloragw/README +++ /dev/null @@ -1,32 +0,0 @@ -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. - -*EOF*
\ No newline at end of file diff --git a/libloragw/VERSION b/libloragw/VERSION deleted file mode 100644 index e7ee96c..0000000 --- a/libloragw/VERSION +++ /dev/null @@ -1,20 +0,0 @@ -/* Software library version: */ -#define VERSION_LIBRARY "1.2.2" - -/* API version */ -#define VERSION_API "1" - -/* Accepted value of CHIP_ID (SPI registers) must match reg default value in loragw_reg.c */ -#define ACCEPT_CHIP_ID "1" - -/* Accepted value of VERSION (SPI registers) must match reg default value in loragw_reg.c */ -#define ACCEPT_VERSION_REG "103" - -/* Accepted radio components */ -#define INFO_RADIO_CHIP "dual SX1257" - -/* Radio constants |
