Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
> #### New features

* Added support for USB interface between the HOST and the concentrator,
for sx1250 based concentrator only.
* Added support for Listen-Before-Talk for AS923 region, using the additional
sx1261 radio from the Semtech Corecell reference design v3.
* Added support for Spectral Scan with additional sx1261 radio from the Semtech
Corecell reference design v3.
* Added support for SX1303 chip, for further Fine Timestamping support.
* Merged the master-fdd-cn490 branch to bring support for CN490 Full-Duplex
reference design. It is an integration of the releases v1.1.0, v1.1.1, v1.1.2
described below.

> #### Changes

* HAL: Reworked the complete communication layer. A new loragw_com module has
been introduced to handle switching from a USB or a SPI communication interface,
aligned function prototypes for sx125x, sx1250 and sx1261 radios. For USB, a
mode has been added to group SPI write commands request to the STM32 MCU, in
order to optimize latency during time critical configuration phases.
* HAL: Added preliminary support for Fine Timestamping for TDOA localization.
* HAL: Updated AGC firmware to v6: add configurable delay for PA to start, add
Listen-Before-Talk support.
* HAL: Added new API function lgw_demod_setconf() to set global demodulator
settings.
* HAL: Added new API functions for Spectral Scan.
* Packet Forwarder: The type of interface is configurable in the
global_conf.json file: com_type can be "USB" or "SPI".
* Packet Forwarder: Changed the parameters to configure fine timestamping in the
global_conf.json.
* Packet Forwarder: Added sections to configure the spectral scan and
Listen-Before-Talk features.
* Packet Forwarder: Added a new thread for background spectral scan example,
to show how to use the spectral scan API provided by the HAL, without
interfering with the main tasks of the gateway (aka Receive uplinks and transmit
downlinks).
* Packet Forwarder: Added "nhdr" field parsing from "txpk" JSON downlink request
in order to be able to send beacon request from Network Server.
* Packet Forwarder: Added chan_multiSF_All in global_conf.json to choose which
spreading factors to enable for multi-sf demodulators.
* Packet Forwarder: Updated PROTOCOL.md to v1.6.
* Tools: added util_spectral_scan, a standalone spectral scanner utility.

> #### Notes

* This release has been validated on the Semtech Corecell reference design v3
with USB interface.

v1.1.2

> Integrated in ***v2.0.0*** from ***master-fdd-cn490*** branch.

* packet forwarder: updated global_conf.json.sx1255.CN490.full-duplex with RSSI
temperature compensation coefficients, and updated RSSI offset for radio 1.

v1.1.1

> Integrated in ***v2.0.0*** from ***master-fdd-cn490*** branch.

* HAL: Updated SX1302 LNA/PA LUT configuration for Full Duplex CN490 reference
design.
* test_loragw_hal_rx/tx: added --fdd option to enable Full Duplex
* packet forwarder: updated global_conf.json.sx1255.CN490.full-duplex for CN490
reference design.

v1.1.0

> Integrated in ***v2.0.0*** from ***master-fdd-cn490*** branch.

* HAL: Added support for CN490 full duplex reference design.
  • Loading branch information
mcoracin committed Dec 9, 2020
1 parent 6291e62 commit 2c14708
Show file tree
Hide file tree
Showing 107 changed files with 13,529 additions and 3,262 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ libloragw/inc/config.h
libloragw/test_loragw_*
packet_forwarder/lora_pkt_fwd
util_chip_id/chip_id
util_net_downlink/net_downlink
util_net_downlink/net_downlink
util_boot/boot
util_spectral_scan/spectral_scan
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export

### general build targets

.PHONY: all clean install install_conf libtools libloragw packet_forwarder util_net_downlink util_chip_id
.PHONY: all clean install install_conf libtools libloragw packet_forwarder util_net_downlink util_chip_id util_boot util_spectral_scan

all: libtools libloragw packet_forwarder util_net_downlink util_chip_id
all: libtools libloragw packet_forwarder util_net_downlink util_chip_id util_boot util_spectral_scan

libtools:
$(MAKE) all -e -C $@
Expand All @@ -25,18 +25,28 @@ util_net_downlink: libtools
util_chip_id: libloragw
$(MAKE) all -e -C $@

util_boot: libloragw
$(MAKE) all -e -C $@

util_spectral_scan: libloragw
$(MAKE) all -e -C $@

clean:
$(MAKE) clean -e -C libtools
$(MAKE) clean -e -C libloragw
$(MAKE) clean -e -C packet_forwarder
$(MAKE) clean -e -C util_net_downlink
$(MAKE) clean -e -C util_chip_id
$(MAKE) clean -e -C util_boot
$(MAKE) clean -e -C util_spectral_scan

install:
$(MAKE) install -e -C libloragw
$(MAKE) install -e -C packet_forwarder
$(MAKE) install -e -C util_net_downlink
$(MAKE) install -e -C util_chip_id
$(MAKE) install -e -C util_boot
$(MAKE) install -e -C util_spectral_scan

install_conf:
$(MAKE) install_conf -e -C packet_forwarder
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.5
2.0.0
81 changes: 66 additions & 15 deletions libloragw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,20 @@ LIBS := -lloragw -ltinymt32 -lrt -lm

### general build targets

all: libloragw.a test_loragw_spi test_loragw_i2c test_loragw_reg test_loragw_hal_tx test_loragw_hal_rx test_loragw_cal test_loragw_capture_ram test_loragw_spi_sx1250 test_loragw_counter test_loragw_gps
all: libloragw.a \
test_loragw_com \
test_loragw_i2c \
test_loragw_reg \
test_loragw_hal_tx \
test_loragw_hal_rx \
test_loragw_cal_sx125x \
test_loragw_capture_ram \
test_loragw_com_sx1250 \
test_loragw_com_sx1261 \
test_loragw_counter \
test_loragw_gps \
test_loragw_toa \
test_loragw_sx1261_rssi

clean:
rm -f libloragw.a
Expand Down Expand Up @@ -60,17 +73,19 @@ inc/config.h: ../VERSION library.cfg
@echo "Release version : $(LIBLORAGW_VERSION)"
@echo " #define LIBLORAGW_VERSION "\"$(LIBLORAGW_VERSION)\""" >> $@
# Debug options
@echo " #define DEBUG_AUX $(DEBUG_AUX)" >> $@
@echo " #define DEBUG_SPI $(DEBUG_SPI)" >> $@
@echo " #define DEBUG_I2C $(DEBUG_I2C)" >> $@
@echo " #define DEBUG_REG $(DEBUG_REG)" >> $@
@echo " #define DEBUG_HAL $(DEBUG_HAL)" >> $@
@echo " #define DEBUG_GPS $(DEBUG_GPS)" >> $@
@echo " #define DEBUG_GPIO $(DEBUG_GPIO)" >> $@
@echo " #define DEBUG_LBT $(DEBUG_LBT)" >> $@
@echo " #define DEBUG_RAD $(DEBUG_RAD)" >> $@
@echo " #define DEBUG_CAL $(DEBUG_CAL)" >> $@
@echo " #define DEBUG_AUX $(DEBUG_AUX)" >> $@
@echo " #define DEBUG_COM $(DEBUG_COM)" >> $@
@echo " #define DEBUG_MCU $(DEBUG_MCU)" >> $@
@echo " #define DEBUG_I2C $(DEBUG_I2C)" >> $@
@echo " #define DEBUG_REG $(DEBUG_REG)" >> $@
@echo " #define DEBUG_HAL $(DEBUG_HAL)" >> $@
@echo " #define DEBUG_GPS $(DEBUG_GPS)" >> $@
@echo " #define DEBUG_GPIO $(DEBUG_GPIO)" >> $@
@echo " #define DEBUG_LBT $(DEBUG_LBT)" >> $@
@echo " #define DEBUG_RAD $(DEBUG_RAD)" >> $@
@echo " #define DEBUG_CAL $(DEBUG_CAL)" >> $@
@echo " #define DEBUG_SX1302 $(DEBUG_SX1302)" >> $@
@echo " #define DEBUG_FTIME $(DEBUG_FTIME)" >> $@
# end of file
@echo "#endif" >> $@
@echo "*** Configuration seems ok ***"
Expand All @@ -85,12 +100,39 @@ $(OBJDIR)/%.o: src/%.c $(INCLUDES) inc/config.h | $(OBJDIR)

### static library

libloragw.a: $(OBJDIR)/loragw_spi.o $(OBJDIR)/loragw_i2c.o $(OBJDIR)/loragw_aux.o $(OBJDIR)/loragw_reg.o $(OBJDIR)/loragw_sx1250.o $(OBJDIR)/loragw_sx125x.o $(OBJDIR)/loragw_sx1302.o $(OBJDIR)/loragw_cal.o $(OBJDIR)/loragw_debug.o $(OBJDIR)/loragw_hal.o $(OBJDIR)/loragw_stts751.o $(OBJDIR)/loragw_gps.o $(OBJDIR)/loragw_sx1302_timestamp.o $(OBJDIR)/loragw_sx1302_rx.o
libloragw.a: $(OBJDIR)/loragw_spi.o \
$(OBJDIR)/loragw_usb.o \
$(OBJDIR)/loragw_com.o \
$(OBJDIR)/loragw_mcu.o \
$(OBJDIR)/loragw_i2c.o \
$(OBJDIR)/sx125x_spi.o \
$(OBJDIR)/sx125x_com.o \
$(OBJDIR)/sx1250_spi.o \
$(OBJDIR)/sx1250_usb.o \
$(OBJDIR)/sx1250_com.o \
$(OBJDIR)/sx1261_spi.o \
$(OBJDIR)/sx1261_usb.o \
$(OBJDIR)/sx1261_com.o \
$(OBJDIR)/loragw_aux.o \
$(OBJDIR)/loragw_reg.o \
$(OBJDIR)/loragw_sx1250.o \
$(OBJDIR)/loragw_sx1261.o \
$(OBJDIR)/loragw_sx125x.o \
$(OBJDIR)/loragw_sx1302.o \
$(OBJDIR)/loragw_cal.o \
$(OBJDIR)/loragw_debug.o \
$(OBJDIR)/loragw_hal.o \
$(OBJDIR)/loragw_lbt.o \
$(OBJDIR)/loragw_stts751.o \
$(OBJDIR)/loragw_gps.o \
$(OBJDIR)/loragw_sx1302_timestamp.o \
$(OBJDIR)/loragw_sx1302_rx.o \
$(OBJDIR)/loragw_ad5338r.o
$(AR) rcs $@ $^

### test programs

test_loragw_spi: tst/test_loragw_spi.c libloragw.a
test_loragw_com: tst/test_loragw_com.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_i2c: tst/test_loragw_i2c.c libloragw.a
Expand All @@ -108,10 +150,13 @@ test_loragw_hal_rx: tst/test_loragw_hal_rx.c libloragw.a
test_loragw_capture_ram: tst/test_loragw_capture_ram.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_cal: tst/test_loragw_cal.c libloragw.a
test_loragw_cal_sx125x: tst/test_loragw_cal_sx125x.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_spi_sx1250: tst/test_loragw_spi_sx1250.c libloragw.a
test_loragw_com_sx1250: tst/test_loragw_com_sx1250.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_com_sx1261: tst/test_loragw_com_sx1261.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_counter: tst/test_loragw_counter.c libloragw.a
Expand All @@ -120,4 +165,10 @@ test_loragw_counter: tst/test_loragw_counter.c libloragw.a
test_loragw_gps: tst/test_loragw_gps.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_toa: tst/test_loragw_toa.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_sx1261_rssi: tst/test_loragw_sx1261_rssi.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

### EOF
43 changes: 43 additions & 0 deletions libloragw/inc/loragw_ad5338r.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
/ _____) _ | |
( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
(C)2020 Semtech
Description:
Basic driver for Analog AD5338R DAC.
License: Revised BSD License, see LICENSE.TXT file include in the project
*/


#ifndef _LORAGW_AD5338R_H
#define _LORAGW_AD5338R_H

#include <stdint.h> /* C99 types */
#include <stdbool.h> /* bool type */

#include "config.h" /* library configuration options (dynamically generated) */

/* -------------------------------------------------------------------------- */
/* --- PRIVATE MACROS ------------------------------------------------------- */

#define VOLTAGE2HEX_H(a) ( (a)*1024/5/4 )
#define VOLTAGE2HEX_L(a) ( (((int)((a)*1024/5)) & 0x3) * 64 )

/* -------------------------------------------------------------------------- */
/* --- PRIVATE CONSTANTS ---------------------------------------------------- */

#define I2C_PORT_DAC_AD5338R 0x0C

#define AD5338R_CMD_SIZE 3

/* -------------------------------------------------------------------------- */
/* --- PUBLIC FUNCTIONS ----------------------------------------------------- */

int ad5338r_configure(int i2c_fd, uint8_t i2c_addr);
int ad5338r_write(int i2c_fd, uint8_t i2c_addr, uint8_t buf[static AD5338R_CMD_SIZE]);

#endif
89 changes: 88 additions & 1 deletion libloragw/inc/loragw_aux.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,23 @@ License: Revised BSD License, see LICENSE.TXT file include in the project
/* -------------------------------------------------------------------------- */
/* --- DEPENDANCIES --------------------------------------------------------- */

#include "config.h" /* library configuration options (dynamically generated) */
#include <stdint.h> /* C99 types */
#include <stdbool.h> /* bool type */
#include <sys/time.h> /* gettimeofday, structtimeval */

#include "config.h" /* library configuration options (dynamically generated) */

/* -------------------------------------------------------------------------- */
/* --- PUBLIC CONSTANTS ----------------------------------------------------- */

#define DEBUG_PERF 0 /* Debug timing performances: level [0..4] */

/* -------------------------------------------------------------------------- */
/* --- PUBLIC MACROS -------------------------------------------------------- */

#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

/**
@brief Get a particular bit value from a byte
@param b [in] Any byte from which we want a bit value
Expand All @@ -33,6 +45,22 @@ License: Revised BSD License, see LICENSE.TXT file include in the project
*/
#define TAKE_N_BITS_FROM(b, p, n) (((b) >> (p)) & ((1 << (n)) - 1))

/**
@brief Substract struct timeval values
@param a [in] struct timeval a
@param b [in] struct timeval b
@param b [out] struct timeval resulting from (a - b)
*/
#define TIMER_SUB(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
if ((result)->tv_usec < 0) { \
--(result)->tv_sec; \
(result)->tv_usec += 1000000; \
} \
} while (0)

/* -------------------------------------------------------------------------- */
/* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */

Expand All @@ -42,6 +70,65 @@ License: Revised BSD License, see LICENSE.TXT file include in the project
*/
void wait_ms(unsigned long t);

/**
@brief Wait for a certain time (microsencond accuracy)
@param t number of microseconds to wait.
*/
void wait_us(unsigned long t);

/**
@brief Calculate the time on air of a LoRa packet in microseconds
@param bw packet bandwidth
@param sf packet spreading factor
@param cr packet coding rate
@param n_symbol_preamble packet preamble length (number of symbols)
@param no_header true if packet has no header
@param no_crc true if packet has no CRC
@param size packet size in bytes
@param nb_symbols pointer to return the total number of symbols in packet
@param nb_symbols_payload pointer to return the number of symbols in packet payload
@param t_symbol_us pointer to return the duration of a symbol in microseconds
@return the packet time on air in microseconds
*/
uint32_t lora_packet_time_on_air( const uint8_t bw,
const uint8_t sf,
const uint8_t cr,
const uint16_t n_symbol_preamble,
const bool no_header,
const bool no_crc,
const uint8_t size,
double * nb_symbols,
uint32_t * nb_symbols_payload,
uint16_t * t_symbol_us);

/**
@brief Record the current time, for measure start
@param tm Pointer to the current time value
*/
void _meas_time_start(struct timeval *tm);

/**
@brief Measure the ellapsed time since given time
@param debug_level debug print debug level to be used
@param start_time start time of the measure to be used
@param str string to be used for debug print
*/
void _meas_time_stop(int debug_level, struct timeval start_time, const char *str);

/**
@brief Get the current time for later timeout check
@param start contains the current time to be used as start time for timeout
*/
void timeout_start(struct timeval * start);

/**
@brief Check if the given timeout time in milliseconds has ellapsed compared to start time
@param start reference start time
@param timeout_ms the timeout duration in milliseconds
@return -1 if the timeout has exceeded, 0 otherwise
*/
int timeout_check(struct timeval start, uint32_t timeout_ms);

#endif

/* --- EOF ------------------------------------------------------------------ */
Loading

0 comments on commit 2c14708

Please sign in to comment.