summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README54
-rw-r--r--libloragw/Makefile19
-rw-r--r--libloragw/README55
-rw-r--r--libloragw/README.TXT30
-rw-r--r--libloragw/doc/MANUAL.TXT16
-rw-r--r--libloragw/src/loragw_hal.c20
-rw-r--r--libloragw/tst/test_loragw_hal.c21
-rw-r--r--loragw_band_survey/Makefile6
-rw-r--r--loragw_band_survey/README (renamed from loragw_band_survey/README.TXT)0
-rw-r--r--loragw_pkt_logger/Makefile8
-rw-r--r--loragw_pkt_logger/README (renamed from loragw_pkt_logger/README.TXT)0
-rw-r--r--loragw_spi_stress/Makefile6
-rw-r--r--loragw_spi_stress/README (renamed from loragw_spi_stress/README.TXT)14
-rw-r--r--loragw_tx_test/Makefile6
-rw-r--r--loragw_tx_test/README (renamed from loragw_tx_test/README.TXT)0
15 files changed, 175 insertions, 80 deletions
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:
-<configure the radios and IF+modems>
-<start the Lora gateway>
-loop {
- <fetch packets that were received by the gateway>
- <process, store and/or forward received packets>
- <send packets through the gateway>
-}
-<stop the gateway>
+ <configure the radios and IF+modems>
+ <start the Lora gateway>
+ loop {
+ <fetch packets that were received by the gateway>
+ <process, store and/or forward received packets>
+ <send packets through the gateway>
+ }
+ <stop the gateway>
**/!\ 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.TXT b/loragw_band_survey/README
index a34134d..a34134d 100644
--- a/loragw_band_survey/README.TXT
+++ b/loragw_band_survey/README
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.TXT b/loragw_pkt_logger/README
index 9469904..9469904 100644
--- a/loragw_pkt_logger/README.TXT
+++ b/loragw_pkt_logger/README
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.TXT b/loragw_spi_stress/README
index 605fed6..98c4f40 100644
--- a/loragw_spi_stress/README.TXT
+++ b/loragw_spi_stress/README
@@ -27,11 +27,12 @@ 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
+ * 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
@@ -53,8 +54,11 @@ 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
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.TXT b/loragw_tx_test/README
index 435b162..435b162 100644
--- a/loragw_tx_test/README.TXT
+++ b/loragw_tx_test/README