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 /libloragw | |
| 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.
Diffstat (limited to 'libloragw')
26 files changed, 2076 insertions, 1575 deletions
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 defined for the following bands */ -#define INFO_RF_PARAM "863-870 MHz TX&RX" - -/* Library validated on the following concentrator boards */ -#define INFO_REF_HARDWARE "Semtech Nano Concentrator v1 and v2" diff --git a/libloragw/doc/CHANGELOG.TXT b/libloragw/doc/CHANGELOG.TXT deleted file mode 100644 index a03e7e0..0000000 --- a/libloragw/doc/CHANGELOG.TXT +++ /dev/null @@ -1,80 +0,0 @@ -Lora Gateway HAL changelog -========================== - - v1.2.2 ---------------------- - - * Added a GPIO toggle on the FTDI SPI module to reset the SX1301 board. - - v1.2.1 ---------------------- - - * Fixed 'floating point exception' crash when concentrator returned a packet with SF=0 (CRC error on Lora header) - * Fixed buggy timezone handling - - v1.2.0 ---------------------- - - * Added feature: new GPS module in the library for synchronization - * Removed feature: no more missed deadline detection in TX because of incompatibility with GPS - * Added documentation for GPS and legal notice - * Added flags in Makefiles for easier cross-compilation - - v1.1.0 ---------------------- - - * Fixed bug 'no TX on radio B' (rfch 1) - * Added feature: concentrator processing delay compensation in the receive() function for accurate 'end of packet' even timestamping - * Added feature: TX 'start delay' compensation in the send() function to emit packet exactly on target timestamp - * Added feature: timestamp counter verification in send() function, return an error if scheduling was too late - * Switched license to 'Revised BSD' - - v1.0.0 (from beta 8) ---------------------- - - * switched FTDI as default SPI phy layer in library.cfg - * fixed a bug in TX power control; still only two TW power available, 14 and 24 dBm - * changed library directory name from loragw_hal to libloragw to follow usual conventions - - Beta 8 (from beta 7) ---------------------- - - * API: lgw_receive now return info on RX frequency and RF path for each packet (no need to keep track of RF/IF settings) - * Unified some portion of the code with the 470 MHz variant of the HAL (use SX1255 radios instead of SX1257) - * Improved AGC and ARB firmwares - * Adding -Wall -Wextra for compilation, fixing all the new warnings for cleaner code - * Fixed bugs in handling of FSK datarate - * test_loragw_hal now dumps the content of all Lora registers after configuration in reg_dump.log - - Beta 7 (from beta 5) ---------------------- - - * Reduced number of SPI transactions to fetch a packet (improved number a packets par second that can be downloaded from gateway) - * Streamlined build process, main target is now a static library: libloragw.a - * Change memory allocation for payload: they are now part of the struct for TX/RX, no need to malloc/free - * All RX chains can use any of the two radios now - * FSK is available and working in TX and RX (variable length mode) - * Calibrated RSSI for FSK - * lgw_connect now check the CHIP_ID - * Added a license file and a changelog - * Added a function returning a version string to allow identification of the version/options once compiled - - Beta 6 -------- - -Not a mainline release, not taken into account in that changelog. - - Beta 5 (from beta 4) ---------------------- - - * Updated registers, firmware and configuration to align with r986 bitstream revision - * Calibrated RSSI for Lora "multi" and Lora "stand alone" modems - * Renamed some confusing TX status code - * Preliminary FSK support - - Beta 4 (from beta 3) ---------------------- - - * Unified build environment with selectable SPI layer (Linux native or FTDI SPI-over-USB bridge) - * Remove the 500 kHz limit on radio bandwith, back to the nominal 800 kHz - * Renamed debug flags diff --git a/libloragw/doc/LICENSE.TXT b/libloragw/doc/LICENSE.TXT deleted file mode 100644 index ff287f3..0000000 --- a/libloragw/doc/LICENSE.TXT +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2013, SEMTECH S.A. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Semtech corporation nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL SEMTECH S.A. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -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. diff --git a/libloragw/inc/loragw_aux.h b/libloragw/inc/loragw_aux.h index 8f485b4..feb0594 100644 --- a/libloragw/inc/loragw_aux.h +++ b/libloragw/inc/loragw_aux.h @@ -4,10 +4,10 @@ \____ \| ___ | (_ _) ___ |/ ___) _ \ _____) ) ____| | | || |_| ____( (___| | | | (______/|_____)_|_|_| \__)_____)\____)_| |_| - ©2013 Semtech-Cycleo + (C)2013 Semtech-Cycleo Description: - Lora gateway library common auxiliary functions + LoRa concentrator HAL common auxiliary functions License: Revised BSD License, see LICENSE.TXT file include in the project Maintainer: Sylvain Miermont @@ -18,6 +18,11 @@ Maintainer: Sylvain Miermont #define _LORAGW_AUX_H /* -------------------------------------------------------------------------- */ +/* --- DEPENDANCIES --------------------------------------------------------- */ + +#include "config.h" /* library configuration options (dynamically generated) */ + +/* -------------------------------------------------------------------------- */ /* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */ /** diff --git a/libloragw/inc/loragw_gps.h b/libloragw/inc/loragw_gps.h index 3884fd5..3f771e4 100644 --- a/libloragw/inc/loragw_gps.h +++ b/libloragw/inc/loragw_gps.h @@ -4,7 +4,7 @@ \____ \| ___ | (_ _) ___ |/ ___) _ \ _____) ) ____| | | || |_| ____( (___| | | | (______/|_____)_|_|_| \__)_____)\____)_| |_| - ©2013 Semtech-Cycleo + (C)2013 Semtech-Cycleo Description: Library of functions to manage a GNSS module (typically GPS) for accurate @@ -33,6 +33,8 @@ Maintainer: Sylvain Miermont #include <time.h> /* time library */ #include <termios.h> /* speed_t */ +#include "config.h" /* library configuration options (dynamically generated) */ + /* -------------------------------------------------------------------------- */ /* --- PUBLIC TYPES --------------------------------------------------------- */ @@ -44,7 +46,7 @@ struct tref { time_t systime; /*!> system time when solution was calculated */ uint32_t count_us; /*!> reference concentrator internal timestamp */ struct timespec utc; /*!> reference UTC time (from GPS) */ - double xtal_err; /*!> clock error estimation (eg. <1 'slow' XTAL) */ + double xtal_err; /*!> raw clock error (eg. <1 'slow' XTAL) */ }; /** @@ -119,7 +121,7 @@ lock must be acquired before calling either function. enum gps_msg lgw_parse_nmea(char* serial_buff, int buff_size); /** -@brief Get the GPS solution (space & time) for the gateway +@brief Get the GPS solution (space & time) for the concentrator @param utc pointer to store UTC time, with ns precision (NULL to ignore) @param loc pointer to store coordinates (NULL to ignore) @@ -150,7 +152,7 @@ int lgw_gps_sync(struct tref* ref, uint32_t count_us, struct timespec utc); @brief Convert concentrator timestamp counter value to UTC time @param ref time reference structure required for time conversion -@param count_us internal timestamp counter of a Lora gateway +@param count_us internal timestamp counter of the LoRa concentrator @param utc pointer to store UTC time, with ns precision (leap seconds ignored) @return success if the function was able to convert timestamp to UTC @@ -165,7 +167,7 @@ int lgw_cnt2utc(struct tref ref, uint32_t count_us, struct timespec* utc); @param ref time reference structure required for time conversion @param utc UTC time, with ns precision (leap seconds are ignored) -@param count_us pointer to store internal timestamp counter of a Lora gateway +@param count_us pointer to store internal timestamp counter of LoRa concentrator @return success if the function was able to convert UTC to timestamp This function is typically used when a packet must be sent at an accurate time diff --git a/libloragw/inc/loragw_hal.h b/libloragw/inc/loragw_hal.h index 022313f..27ca1a2 100644 --- a/libloragw/inc/loragw_hal.h +++ b/libloragw/inc/loragw_hal.h @@ -4,10 +4,10 @@ \____ \| ___ | (_ _) ___ |/ ___) _ \ _____) ) ____| | | || |_| ____( (___| | | | (______/|_____)_|_|_| \__)_____)\____)_| |_| - ©2013 Semtech-Cycleo + (C)2013 Semtech-Cycleo Description: - Lora gateway Hardware Abstraction Layer + LoRa concentrator Hardware Abstraction Layer License: Revised BSD License, see LICENSE.TXT file include in the project Maintainer: Sylvain Miermont @@ -23,12 +23,14 @@ Maintainer: Sylvain Miermont #include <stdint.h> /* C99 types */ #include <stdbool.h> /* bool type */ +#include "config.h" /* library configuration options (dynamically generated) */ + /* -------------------------------------------------------------------------- */ /* --- PUBLIC MACROS -------------------------------------------------------- */ #define IS_LORA_BW(bw) ((bw == BW_125KHZ) || (bw == BW_250KHZ) || (bw == BW_500KHZ)) #define IS_LORA_STD_DR(dr) ((dr == DR_LORA_SF7) || (dr == DR_LORA_SF8) || (dr == DR_LORA_SF9) || (dr == DR_LORA_SF10) || (dr == DR_LORA_SF11) || (dr == DR_LORA_SF12)) -#define IS_LORA_MULTI_DR(dr) ((dr & ~DR_LORA_MULTI) == 0) /* ones outside of DR_LORA_MULTI bitmask -> not a combination of Lora datarates */ +#define IS_LORA_MULTI_DR(dr) ((dr & ~DR_LORA_MULTI) == 0) /* ones outside of DR_LORA_MULTI bitmask -> not a combination of LoRa datarates */ #define IS_LORA_CR(cr) ((cr == CR_LORA_4_5) || (cr == CR_LORA_4_6) || (cr == CR_LORA_4_7) || (cr == CR_LORA_4_8)) #define IS_FSK_BW(bw) ((bw >= 1) && (bw <= 7)) @@ -43,42 +45,104 @@ Maintainer: Sylvain Miermont #define LGW_HAL_SUCCESS 0 #define LGW_HAL_ERROR -1 -/* hardware characteristics */ -#define LGW_RF_CHAIN_NB 2 /* number of RF chains */ -#define LGW_IF_CHAIN_NB 10 /* number of IF+modem RX chains */ -#define LGW_MULTI_NB 4 /* number of Lora 'multi SF' chains */ - -#define LGW_PKT_FIFO_SIZE 8 /* depth of the RX packet FIFO */ -#define LGW_DATABUFF_SIZE 1024 /* size in bytes of the RX data buffer (contains payload & metadata) */ -#define LGW_REF_BW 125000 /* typical bandwidth of data channel */ -#define LGW_XTAL_FREQU 32000000 /* frequency of the RF reference oscillator */ +/* radio-specific parameters */ +#if ((CFG_RADIO_1257 == 1) || (CFG_RADIO_1255 == 1)) + #define LGW_XTAL_FREQU 32000000 /* frequency of the RF reference oscillator */ + #define LGW_RF_CHAIN_NB 2 /* number of RF chains */ + #define LGW_RF_RX_BANDWIDTH { 1000000, 1000000} /* bandwidth of the radios */ +#endif -/* to use those parameters, declare a local constant, and use 'rf_chain' as index */ -#define LGW_RF_RX_LOWFREQ {863000000, 863000000} /* lower limit of the usable band in RX for each radio */ -#define LGW_RF_RX_UPFREQ {870000000, 870000000} /* upper limit of the usable band in RX for each radio */ -#define LGW_RF_RX_BANDWIDTH {800000, 800000} /* bandwidth of the radios */ -#define LGW_RF_TX_LOWFREQ {863000000, 863000000} /* lower limit of the usable band in TX for each radio */ -#define LGW_RF_TX_UPFREQ {870000000, 870000000} /* upper limit of the usable band in TX for each radio */ +/* band-specific parameters */ +/* to use array parameters, declare a local const and use 'rf_chain' as index */ +#if (CFG_BAND_FULL == 1) + #if (CFG_RADIO_1257 == 1) + #define LGW_RF_RX_LOWFREQ { 862000000, 862000000} /* lower limit of the usable band in RX for each radio */ + #define LGW_RF_RX_UPFREQ {1020000000,1020000000} /* upper limit of the usable band in RX for each radio */ + #define LGW_RF_TX_LOWFREQ { 862000000, 862000000} /* lower limit of the usable band in TX for each radio */ + #define LGW_RF_TX_UPFREQ {1020000000,1020000000} /* upper limit of the usable band in TX for each radio */ + #elif (CFG_RADIO_1255 == 1) + #define LGW_RF_RX_LOWFREQ { 400000000, 400000000} + #define LGW_RF_RX_UPFREQ { 510000000, 510000000} + #define LGW_RF_TX_LOWFREQ { 400000000, 400000000} + #define LGW_RF_TX_UPFREQ { 510000000, 510000000} + #endif +#elif (CFG_BAND_868 == 1) + #define LGW_RF_RX_LOWFREQ { 863000000, 863000000} + #define LGW_RF_RX_UPFREQ { 870000000, 870000000} + #define LGW_RF_TX_LOWFREQ { 863000000, 863000000} + #define LGW_RF_TX_UPFREQ { 870000000, 870000000} +#elif (CFG_BAND_915 == 1) + #define LGW_RF_RX_LOWFREQ { 902000000, 902000000} + #define LGW_RF_RX_UPFREQ { 928000000, 928000000} + #define LGW_RF_TX_LOWFREQ { 902000000, 902000000} + #define LGW_RF_TX_UPFREQ { 928000000, 928000000} +#elif (CFG_BAND_470 == 1) + #define LGW_RF_RX_LOWFREQ { 470000000, 470000000} + #define LGW_RF_RX_UPFREQ { 510000000, 510000000} + #define LGW_RF_TX_LOWFREQ { 470000000, 470000000} + #define LGW_RF_TX_UPFREQ { 510000000, 510000000} +#elif (CFG_BAND_433 == 1) + #define LGW_RF_RX_LOWFREQ { 433050000, 433050000} + #define LGW_RF_RX_UPFREQ { 434790000, 434790000} + #define LGW_RF_TX_LOWFREQ { 433050000, 433050000} + #define LGW_RF_TX_UPFREQ { 434790000, 434790000} +#endif /* type of if_chain + modem */ #define IF_UNDEFINED 0 -#define IF_LORA_STD 0x10 /* if + standard single-SF Lora modem */ -#define IF_LORA_MULTI 0x11 /* if + Lora receiver with multi-SF capability */ +#define IF_LORA_STD 0x10 /* if + standard single-SF LoRa modem */ +#define IF_LORA_MULTI 0x11 /* if + LoRa receiver with multi-SF capability */ #define IF_FSK_STD 0x20 /* if + standard FSK modem */ -/* configuration of available IF chains and modems on the hardware */ -/* to use, declare a local constant, and use 'if_chain' as index */ -#define LGW_IFMODEM_CONFIG {\ - IF_LORA_MULTI, \ - IF_LORA_MULTI, \ - IF_LORA_MULTI, \ - IF_LORA_MULTI, \ - IF_UNDEFINED, \ - IF_UNDEFINED, \ - IF_UNDEFINED, \ - IF_UNDEFINED, \ - IF_LORA_STD, \ - IF_FSK_STD } +/* concentrator chipset-specific parameters */ +/* to use array parameters, declare a local const and use 'if_chain' as index */ +#if ((CFG_CHIP_1301 == 1) || (CFG_CHIP_FPGA == 1)) + #define LGW_IF_CHAIN_NB 10 /* number of IF+modem RX chains */ + #define LGW_PKT_FIFO_SIZE 8 /* depth of the RX packet FIFO */ + #define LGW_DATABUFF_SIZE 1024 /* size in bytes of the RX data buffer (contains payload & metadata) */ + #define LGW_REF_BW 125000 /* typical bandwidth of data channel */ +#endif + +#if (CFG_CHIP_1301 == 1) + #define LGW_MULTI_NB 8 /* number of LoRa 'multi SF' chains */ + #define LGW_IFMODEM_CONFIG {\ + IF_LORA_MULTI, \ + IF_LORA_MULTI, \ + IF_LORA_MULTI, \ + IF_LORA_MULTI, \ + IF_LORA_MULTI, \ + IF_LORA_MULTI, \ + IF_LORA_MULTI, \ + IF_LORA_MULTI, \ + IF_LORA_STD, \ + IF_FSK_STD } /* configuration of available IF chains and modems on the hardware */ +#elif (CFG_CHIP_FPGA == 1) + #define LGW_MULTI_NB 4 /* number of LoRa 'multi SF' chains */ + #define LGW_IFMODEM_CONFIG {\ + IF_LORA_MULTI, \ + IF_LORA_MULTI, \ + IF_LORA_MULTI, \ + IF_LORA_MULTI, \ + IF_UNDEFINED, \ + IF_UNDEFINED, \ + IF_UNDEFINED, \ + IF_UNDEFINED, \ + IF_LORA_STD, \ + IF_FSK_STD } /* configuration of available IF chains and modems on the hardware */ +#endif + +/* board-specific parameters */ +/* to use array parameters, declare a local const and use 'rf_chain' as index */ +#if (CFG_BRD_NANO868 == 1) + #define LGW_RF_TX_ENABLE { true, true} /* both radio A and B are usable in TX */ + #define LGW_RF_CLKOUT { true, true} /* both radios have clkout enabled */ +#elif (CFG_BRD_REF1301 == 1) + #define LGW_RF_TX_ENABLE { true,false} /* radio B TX output is disconnected */ + #define LGW_RF_CLKOUT {false, true} /* radio A clkout disabled for spur optimization */ +#elif (CFG_BRD_NONE == 1) + #define LGW_RF_TX_ENABLE { true, true} /* both radio A and B are usable in TX */ + #define LGW_RF_CLKOUT { true, true} /* both radios have clkout enabled */ +#endif /* values available for the 'modulation' parameters */ /* NOTE: arbitrary values */ @@ -86,7 +150,7 @@ Maintainer: Sylvain Miermont #define MOD_LORA 0x10 #define MOD_FSK 0x20 -/* values available for the 'bandwidth' parameters (Lora & FSK) */ +/* values available for the 'bandwidth' parameters (LoRa & FSK) */ /* NOTE: directly encode FSK RX bandwidth, do not change */ #define BW_UNDEFINED 0 #define BW_500KHZ 0x01 @@ -98,7 +162,7 @@ Maintainer: Sylvain Miermont #define BW_7K8HZ 0x07 /* values available for the 'datarate' parameters */ -/* NOTE: Lora values used directly to code SF bitmask in 'multi' modem, do not change */ +/* NOTE: LoRa values used directly to code SF bitmask in 'multi' modem, do not change */ #define DR_UNDEFINED 0 #define DR_LORA_SF7 0x02 #define DR_LORA_SF8 0x04 @@ -111,7 +175,7 @@ Maintainer: Sylvain Miermont #define DR_FSK_MIN 500 #define DR_FSK_MAX 250000 -/* values available for the 'coderate' parameters (Lora only) */ +/* values available for the 'coderate' parameters (LoRa only) */ /* NOTE: arbitrary values */ #define CR_UNDEFINED 0 #define CR_LORA_4_5 0x01 @@ -185,16 +249,16 @@ struct lgw_pkt_rx_s { uint32_t freq_hz; /*!> central frequency of the IF chain */ uint8_t if_chain; /*!> by which IF chain was packet received */ uint8_t status; /*!> status of the received packet */ - uint32_t count_us; /*!> internal gateway counter for timestamping, 1 microsecond resolution */ + uint32_t count_us; /*!> internal concentrator counter for timestamping, 1 microsecond resolution */ uint8_t rf_chain; /*!> through which RF chain the packet was received */ uint8_t modulation; /*!> modulation used by the packet */ - uint8_t bandwidth; /*!> modulation bandwidth (Lora only) */ - uint32_t datarate; /*!> RX datarate of the packet (SF for Lora) */ - uint8_t coderate; /*!> error-correcting code of the packet (Lora only) */ + uint8_t bandwidth; /*!> modulation bandwidth (LoRa only) */ + uint32_t datarate; /*!> RX datarate of the packet (SF for LoRa) */ + uint8_t coderate; /*!> error-correcting code of the packet (LoRa only) */ float rssi; /*!> average packet RSSI in dB */ - float snr; /*!> average packet SNR, in dB (Lora only) */ - float snr_min; /*!> minimum packet SNR, in dB (Lora only) |
