summaryrefslogtreecommitdiff
path: root/recipes-connectivity/lora/lora-gateway
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-connectivity/lora/lora-gateway')
-rw-r--r--recipes-connectivity/lora/lora-gateway/library_4.0.cfg13
-rw-r--r--recipes-connectivity/lora/lora-gateway/ln-lora-spi-dev.sh12
-rw-r--r--recipes-connectivity/lora/lora-gateway/lora-gateway-add-fpga-version-28-31-33.patch30
-rw-r--r--recipes-connectivity/lora/lora-gateway/lora-gateway-add-fpga-version-28.patch13
-rw-r--r--recipes-connectivity/lora/lora-gateway/lora-gateway-add-spi-path-function.patch57
-rw-r--r--recipes-connectivity/lora/lora-gateway/lora-gateway-change-util-tx-continuous-clksrc.patch13
-rw-r--r--recipes-connectivity/lora/lora-gateway/lora-gateway-gpsd.patch636
-rw-r--r--recipes-connectivity/lora/lora-gateway/lora-gateway-semtech-sf12.patch16
-rw-r--r--recipes-connectivity/lora/lora-gateway/lora-gateway-spectral-scan-skip-fpga-reset.patch86
-rw-r--r--recipes-connectivity/lora/lora-gateway/lora-gateway-v28-skip-IQ-invert.patch24
10 files changed, 0 insertions, 900 deletions
diff --git a/recipes-connectivity/lora/lora-gateway/library_4.0.cfg b/recipes-connectivity/lora/lora-gateway/library_4.0.cfg
deleted file mode 100644
index 4126bf3..0000000
--- a/recipes-connectivity/lora/lora-gateway/library_4.0.cfg
+++ /dev/null
@@ -1,13 +0,0 @@
-# That file will be included in the Makefile files that have hardware dependencies
-
-### Debug options ###
-# Set the DEBUG_* to 1 to activate debug mode in individual modules.
-# Warning: that makes the module *very verbose*, do not use for production
-
-DEBUG_AUX= 0
-DEBUG_SPI= 0
-DEBUG_REG= 0
-DEBUG_HAL= 0
-DEBUG_LBT= 0
-DEBUG_GPS= 0
-
diff --git a/recipes-connectivity/lora/lora-gateway/ln-lora-spi-dev.sh b/recipes-connectivity/lora/lora-gateway/ln-lora-spi-dev.sh
deleted file mode 100644
index c350fff..0000000
--- a/recipes-connectivity/lora/lora-gateway/ln-lora-spi-dev.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-port1=/sys/devices/platform/mts-io/ap1
-port2=/sys/devices/platform/mts-io/ap2
-
-lora_hw=$(mts-io-sysfs show lora/hw-version 2> /dev/null)
-
-if [ -d $port1 ] && [[ $(cat $port1/hw-version) = $lora_hw ]]; then
- ln -sf /dev/spidev32766.2 /dev/spidev0.0
-elif [ -d $port2 ] && [[ $(cat $port2/hw-version) = $lora_hw ]]; then
- ln -sf /dev/spidev32765.2 /dev/spidev0.0
-fi
diff --git a/recipes-connectivity/lora/lora-gateway/lora-gateway-add-fpga-version-28-31-33.patch b/recipes-connectivity/lora/lora-gateway/lora-gateway-add-fpga-version-28-31-33.patch
deleted file mode 100644
index 7e73263..0000000
--- a/recipes-connectivity/lora/lora-gateway/lora-gateway-add-fpga-version-28-31-33.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-diff --git a/libloragw/src/loragw_reg.c b/libloragw/src/loragw_reg.c
-index 7e396bc..478f46a 100644
---- a/libloragw/src/loragw_reg.c
-+++ b/libloragw/src/loragw_reg.c
-@@ -48,7 +48,7 @@ Maintainer: Sylvain Miermont
- #define PAGE_ADDR 0x00
- #define PAGE_MASK 0x03
-
--const uint8_t FPGA_VERSION[] = { 31, 33 }; /* several versions could be supported */
-+const uint8_t FPGA_VERSION[] = { 28, 31, 33 }; /* several versions could be supported */
-
- /*
- auto generated register mapping for C code : 11-Jul-2013 13:20:40
-@@ -415,6 +415,16 @@ bool check_fpga_version(uint8_t version) {
- return false;
- }
-
-+uint8_t read_fpga_version() {
-+ uint8_t u = 0;
-+ uint8_t spi_stat = lgw_spi_r(lgw_spi_target, LGW_SPI_MUX_MODE1, LGW_SPI_MUX_TARGET_FPGA, loregs[LGW_VERSION].addr, &u);
-+ if (spi_stat != LGW_SPI_SUCCESS) {
-+ DEBUG_MSG("ERROR READING VERSION REGISTER\n");
-+ return LGW_REG_ERROR;
-+ }
-+ return u;
-+}
-+
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
- int reg_w_align32(void *spi_target, uint8_t spi_mux_mode, uint8_t spi_mux_target, struct lgw_reg_s r, int32_t reg_value) {
diff --git a/recipes-connectivity/lora/lora-gateway/lora-gateway-add-fpga-version-28.patch b/recipes-connectivity/lora/lora-gateway/lora-gateway-add-fpga-version-28.patch
deleted file mode 100644
index c5f47dd..0000000
--- a/recipes-connectivity/lora/lora-gateway/lora-gateway-add-fpga-version-28.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/libloragw/src/loragw_reg.c b/libloragw/src/loragw_reg.c
-index 7fe0f67..dc90d93 100644
---- a/libloragw/src/loragw_reg.c
-+++ b/libloragw/src/loragw_reg.c
-@@ -48,7 +48,7 @@ Maintainer: Sylvain Miermont
- #define PAGE_ADDR 0x00
- #define PAGE_MASK 0x03
-
--const uint8_t FPGA_VERSION[] = { 27 }; /* several versions could be supported */
-+const uint8_t FPGA_VERSION[] = { 27, 28 }; /* several versions could be supported */
-
- /*
- auto generated register mapping for C code : 11-Jul-2013 13:20:40
diff --git a/recipes-connectivity/lora/lora-gateway/lora-gateway-add-spi-path-function.patch b/recipes-connectivity/lora/lora-gateway/lora-gateway-add-spi-path-function.patch
deleted file mode 100644
index fa5e68c..0000000
--- a/recipes-connectivity/lora/lora-gateway/lora-gateway-add-spi-path-function.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-diff --git a/libloragw/inc/loragw_spi.h b/libloragw/inc/loragw_spi.h
-index fef1f48..74ef251 100644
---- a/libloragw/inc/loragw_spi.h
-+++ b/libloragw/inc/loragw_spi.h
-@@ -46,6 +46,14 @@ Maintainer: Sylvain Miermont
- /* -------------------------------------------------------------------------- */
- /* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */
-
-+/* set SPI device */
-+/**
-+@brief LoRa concentrator SPI path configuration for spidev
-+@param path pointer to spidev device
-+@return LGW_SPI_SUCCESS if path is valid, LGW_SPI_ERROR if not
-+*/
-+int lgw_spi_set_path(const char *path);
-+
- /**
- @brief LoRa concentrator SPI setup (configure I/O and peripherals)
- @param spi_target_ptr pointer on a generic pointer to SPI target (implementation dependant)
-diff --git a/libloragw/src/loragw_spi.native.c b/libloragw/src/loragw_spi.native.c
-index c01ed1c..3472133 100644
---- a/libloragw/src/loragw_spi.native.c
-+++ b/libloragw/src/loragw_spi.native.c
-@@ -56,10 +56,24 @@ Maintainer: Sylvain Miermont
- #define SPI_SPEED 8000000
- #define SPI_DEV_PATH "/dev/spidev0.0"
- //#define SPI_DEV_PATH "/dev/spidev32766.0"
-+char* spi_dev_path = SPI_DEV_PATH;
-
- /* -------------------------------------------------------------------------- */
- /* --- PUBLIC FUNCTIONS DEFINITION ------------------------------------------ */
-
-+/* set SPI device */
-+int lgw_spi_set_path(const char *path) {
-+ if (path) {
-+ spi_dev_path = path;
-+ return LGW_SPI_SUCCESS;
-+ }
-+ else {
-+ return LGW_SPI_ERROR;
-+ }
-+}
-+
-+
-+
- /* SPI initialization and configuration */
- int lgw_spi_open(void **spi_target_ptr) {
- int *spi_device = NULL;
-@@ -78,7 +92,7 @@ int lgw_spi_open(void **spi_target_ptr) {
- }
-
- /* open SPI device */
-- dev = open(SPI_DEV_PATH, O_RDWR);
-+ dev = open(spi_dev_path, O_RDWR);
- if (dev < 0) {
- DEBUG_PRINTF("ERROR: failed to open SPI device %s\n", SPI_DEV_PATH);
- return LGW_SPI_ERROR;
diff --git a/recipes-connectivity/lora/lora-gateway/lora-gateway-change-util-tx-continuous-clksrc.patch b/recipes-connectivity/lora/lora-gateway/lora-gateway-change-util-tx-continuous-clksrc.patch
deleted file mode 100644
index bdc05ad..0000000
--- a/recipes-connectivity/lora/lora-gateway/lora-gateway-change-util-tx-continuous-clksrc.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/util_tx_continuous/src/util_tx_continuous.c b/util_tx_continuous/src/util_tx_continuous.c
-index 31f45ac..f9cf033 100644
---- a/util_tx_continuous/src/util_tx_continuous.c
-+++ b/util_tx_continuous/src/util_tx_continuous.c
-@@ -297,7 +297,7 @@ int main(int argc, char **argv)
- /* Board config */
- memset(&boardconf, 0, sizeof(boardconf));
- boardconf.lorawan_public = true;
-- boardconf.clksrc = 1; /* Radio B is source by default */
-+ boardconf.clksrc = 0; /* Radio B is source by default */
- lgw_board_setconf(boardconf);
-
- /* RF config */
diff --git a/recipes-connectivity/lora/lora-gateway/lora-gateway-gpsd.patch b/recipes-connectivity/lora/lora-gateway/lora-gateway-gpsd.patch
deleted file mode 100644
index 08d566c..0000000
--- a/recipes-connectivity/lora/lora-gateway/lora-gateway-gpsd.patch
+++ /dev/null
@@ -1,636 +0,0 @@
-diff --git a/libloragw/Makefile b/libloragw/Makefile
-index 53c33d9..4575bdc 100644
---- a/libloragw/Makefile
-+++ b/libloragw/Makefile
-@@ -10,14 +10,14 @@ CROSS_COMPILE ?=
- CC := $(CROSS_COMPILE)gcc
- AR := $(CROSS_COMPILE)ar
-
--CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I.
-+CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I. -isystem =/usr/include/gps
-
- OBJDIR = obj
- INCLUDES = $(wildcard inc/*.h)
-
- ### linking options
-
--LIBS := -lloragw -lrt -lm
-+LIBS := -lloragw -lrt -lm -lgps
-
- ### general build targets
-
-diff --git a/libloragw/inc/loragw_gps.h b/libloragw/inc/loragw_gps.h
-index 6dbd30b..59b2d37 100644
---- a/libloragw/inc/loragw_gps.h
-+++ b/libloragw/inc/loragw_gps.h
-@@ -27,9 +27,11 @@ Maintainer: Michael Coracin
- #include <time.h> /* time library */
- #include <termios.h> /* speed_t */
- #include <unistd.h> /* ssize_t */
-+#include <gpsd.h>
-+#include <gpsdclient.h>
-+#include <errno.h> /* error messages */
-
- #include "config.h" /* library configuration options (dynamically generated) */
--
- /* -------------------------------------------------------------------------- */
- /* --- PUBLIC TYPES --------------------------------------------------------- */
-
-@@ -83,6 +85,7 @@ enum gps_msg {
- UBX_NAV_TIMEUTC /*!> UTC Time Solution */
- };
-
-+// struct gps_data_t gpsdata;
- /* -------------------------------------------------------------------------- */
- /* --- PUBLIC CONSTANTS ----------------------------------------------------- */
-
-@@ -99,21 +102,19 @@ enum gps_msg {
- /**
- @brief Configure a GPS module
-
--@param tty_path path to the TTY connected to the GPS
--@param gps_familly parameter (eg. ubx6 for uBlox gen.6)
--@param target_brate target baudrate for communication (0 keeps default target baudrate)
--@param fd_ptr pointer to a variable to receive file descriptor on GPS tty
--@return success if the function was able to connect and configure a GPS module
-+@param gpsdata handler for gpsd data
-+@param source source for setup of gpsd
-+@return success if the function was able to connect and configure a GPSD stream
- */
--int lgw_gps_enable(char* tty_path, char* gps_familly, speed_t target_brate, int* fd_ptr);
-+int lgw_gps_enable(struct gps_data_t *gpsdata, struct fixsource_t *source);
-
- /**
- @brief Restore GPS serial configuration and close serial device
-
--@param fd file descriptor on GPS tty
-+@param gpsdata handler for gpsd data
- @return success if the function was able to complete
- */
--int lgw_gps_disable(int fd);
-+int lgw_gps_disable(struct gps_data_t *gpsdata);
-
- /**
- @brief Parse messages coming from the GPS system (or other GNSS)
-diff --git a/libloragw/src/loragw_gps.c b/libloragw/src/loragw_gps.c
-index c0e0ded..f4774be 100644
---- a/libloragw/src/loragw_gps.c
-+++ b/libloragw/src/loragw_gps.c
-@@ -84,6 +84,7 @@ static double gps_mlo = 0.0; /* minutes of longitude */
- static char gps_olo = 0; /* orientation (E-W) of longitude */
- static short gps_alt = 0; /* altitude */
- static bool gps_pos_ok = false;
-+static bool gps_lock_ok = false;
-
- static char gps_mod = 'N'; /* GPS mode (N no fix, A autonomous, D differential) */
- static short gps_sat = 0; /* number of satellites used for fix */
-@@ -251,109 +252,22 @@ int str_chop(char *s, int buff_size, char separator, int *idx_ary, int max_idx)
- /* -------------------------------------------------------------------------- */
- /* --- PUBLIC FUNCTIONS DEFINITION ------------------------------------------ */
-
--int lgw_gps_enable(char *tty_path, char *gps_family, speed_t target_brate, int *fd_ptr) {
-- int i;
-- struct termios ttyopt; /* serial port options */
-- int gps_tty_dev; /* file descriptor to the serial port of the GNSS module */
-- uint8_t ubx_cmd_timegps[UBX_MSG_NAVTIMEGPS_LEN] = {
-- 0xB5, 0x62, /* UBX Sync Chars */
-- 0x06, 0x01, /* CFG-MSG Class/ID */
-- 0x08, 0x00, /* Payload length */
-- 0x01, 0x20, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, /* Enable NAV-TIMEGPS output on serial */
-- 0x32, 0x94 }; /* Checksum */
-- ssize_t num_written;
-+int lgw_gps_enable(struct gps_data_t *gpsdata, struct fixsource_t *source) {
-
-- /* check input parameters */
-- CHECK_NULL(tty_path);
-- CHECK_NULL(fd_ptr);
-+ unsigned int flags;
-+ fd_set fds;
-+ flags = WATCH_ENABLE;
-+ flags |= WATCH_RAW;
-+ flags |= WATCH_NMEA;
-+ gpsd_source_spec(NULL, source);
-
-- /* open TTY device */
-- gps_tty_dev = open(tty_path, O_RDWR | O_NOCTTY);
-- if (gps_tty_dev <= 0) {
-- DEBUG_MSG("ERROR: TTY PORT FAIL TO OPEN, CHECK PATH AND ACCESS RIGHTS\n");
-+ if (gps_open(source->server, source->port, gpsdata) != 0) {
-+ DEBUG_MSG("gpspipe: could not connect to gpsd %s:%s, %s(%d)\n",
-+ source->server, source->port, gps_errstr(errno), errno);
- return LGW_GPS_ERROR;
- }
-- *fd_ptr = gps_tty_dev;
--
-- /* manage the different GPS modules families */
-- if (gps_family == NULL) {
-- DEBUG_MSG("WARNING: this version of GPS module may not be supported\n");
-- } else if (strncmp(gps_family, "ubx7", 4) != 0) {
-- /* The current implementation relies on proprietary messages from U-Blox */
-- /* GPS modules (UBX, NAV-TIMEGPS...) and has only be tested with a u-blox 7. */
-- /* Those messages allow to get NATIVE GPS time (no leap seconds) required */
-- /* for class-B handling and GPS synchronization */
-- /* see lgw_parse_ubx() function for details */
-- DEBUG_MSG("WARNING: this version of GPS module may not be supported\n");
-- }
-
-- /* manage the target bitrate */
-- if (target_brate != 0) {
-- DEBUG_MSG("WARNING: target_brate parameter ignored for now\n"); // TODO
-- }
--
-- /* get actual serial port configuration */
-- i = tcgetattr(gps_tty_dev, &ttyopt);
-- if (i != 0) {
-- DEBUG_MSG("ERROR: IMPOSSIBLE TO GET TTY PORT CONFIGURATION\n");
-- return LGW_GPS_ERROR;
-- }
--
-- /* Save current serial port configuration for restoring later */
-- memcpy(&ttyopt_restore, &ttyopt, sizeof ttyopt);
--
-- /* update baudrates */
-- cfsetispeed(&ttyopt, DEFAULT_BAUDRATE);
-- cfsetospeed(&ttyopt, DEFAULT_BAUDRATE);
--
-- /* update terminal parameters */
-- /* The following configuration should allow to:
-- - Get ASCII NMEA messages
-- - Get UBX binary messages
-- - Send UBX binary commands
-- Note: as binary data have to be read/written, we need to disable
-- various character processing to avoid loosing data */
-- /* Control Modes */
-- ttyopt.c_cflag |= CLOCAL; /* local connection, no modem control */
-- ttyopt.c_cflag |= CREAD; /* enable receiving characters */
-- ttyopt.c_cflag |= CS8; /* 8 bit frames */
-- ttyopt.c_cflag &= ~PARENB; /* no parity */
-- ttyopt.c_cflag &= ~CSTOPB; /* one stop bit */
-- /* Input Modes */
-- ttyopt.c_iflag |= IGNPAR; /* ignore bytes with parity errors */
-- ttyopt.c_iflag &= ~ICRNL; /* do not map CR to NL on input*/
-- ttyopt.c_iflag &= ~IGNCR; /* do not ignore carriage return on input */
-- ttyopt.c_iflag &= ~IXON; /* disable Start/Stop output control */
-- ttyopt.c_iflag &= ~IXOFF; /* do not send Start/Stop characters */
-- /* Output Modes */
-- ttyopt.c_oflag = 0; /* disable everything on output as we only write binary */
-- /* Local Modes */
-- ttyopt.c_lflag &= ~ICANON; /* disable canonical input - cannot use with binary input */
-- ttyopt.c_lflag &= ~ISIG; /* disable check for INTR, QUIT, SUSP special characters */
-- ttyopt.c_lflag &= ~IEXTEN; /* disable any special control character */
-- ttyopt.c_lflag &= ~ECHO; /* do not echo back every character typed */
-- ttyopt.c_lflag &= ~ECHOE; /* does not erase the last character in current line */
-- ttyopt.c_lflag &= ~ECHOK; /* do not echo NL after KILL character */
--
-- /* settings for non-canonical mode
-- read will block for until the lesser of VMIN or requested chars have been received */
-- ttyopt.c_cc[VMIN] = LGW_GPS_MIN_MSG_SIZE;
-- ttyopt.c_cc[VTIME] = 0;
--
-- /* set new serial ports parameters */
-- i = tcsetattr(gps_tty_dev, TCSANOW, &ttyopt);
-- if (i != 0){
-- DEBUG_MSG("ERROR: IMPOSSIBLE TO UPDATE TTY PORT CONFIGURATION\n");
-- return LGW_GPS_ERROR;
-- }
-- tcflush(gps_tty_dev, TCIOFLUSH);
--
-- /* Send UBX CFG NAV-TIMEGPS message to tell GPS module to output native GPS time */
-- /* This is a binary message, serial port has to be properly configured to handle this */
-- num_written = write (gps_tty_dev, ubx_cmd_timegps, UBX_MSG_NAVTIMEGPS_LEN);
-- if (num_written != UBX_MSG_NAVTIMEGPS_LEN) {
-- DEBUG_MSG("ERROR: Failed to write on serial port (written=%d)\n", (int) num_written);
-- }
-+ (void)gps_stream(gpsdata, flags, source->device);
-
- /* get timezone info */
- tzset();
-@@ -368,20 +282,13 @@ int lgw_gps_enable(char *tty_path, char *gps_family, speed_t target_brate, int *
-
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
--int lgw_gps_disable(int fd) {
-+int lgw_gps_disable(struct gps_data_t *gpsdata) {
- int i;
-
-- /* restore serial ports parameters */
-- i = tcsetattr(fd, TCSANOW, &ttyopt_restore);
-- if (i != 0){
-- DEBUG_MSG("ERROR: IMPOSSIBLE TO RESTORE TTY PORT CONFIGURATION\n");
-- return LGW_GPS_ERROR;
-- }
-- tcflush(fd, TCIOFLUSH);
--
-- i = close(fd);
-- if (i <= 0) {
-- DEBUG_MSG("ERROR: TTY PORT FAIL TO CLOSE\n");
-+ /* ends the session */
-+ i = gps_close(gpsdata);
-+ if (i != 0) {
-+ DEBUG_MSG("ERROR: GPSD FAILED TO CLOSE\n");
- return LGW_GPS_ERROR;
- }
-
-@@ -457,7 +364,8 @@ enum gps_msg lgw_parse_ubx(const char *serial_buff, size_t buff_size, size_t *ms
- gps_week = (uint8_t)serial_buff[14];
- gps_week |= (uint8_t)serial_buff[15] << 8; /* GPS week number */
-
-- gps_time_ok = true;
-+
-+
- #if 0
- /* For debug */
- {
-@@ -472,11 +380,24 @@ enum gps_msg lgw_parse_ubx(const char *serial_buff, size_t buff_size, size_t *ms
- printf(" GPS time = %02d:%02d:%02d\n", ubx_gps_hou, ubx_gps_min, ubx_gps_sec);
- }
- #endif
-- } else { /* valid */
-+ if (gps_lock_ok)
-+ gps_time_ok = true;
-+
-+ return UBX_NAV_TIMEGPS;
-+ } else {
- gps_time_ok = false;
-+ return INVALID;
-+ }
-+ } else if ((serial_buff[2] == 0x01) && (serial_buff[3] == 0x04)) {
-+ if (serial_buff[10] == 0x0F && serial_buff[11] == 0x27
-+ && serial_buff[10] == 0x0F && serial_buff[11] == 0x27
-+ && serial_buff[10] == 0x0F && serial_buff[11] == 0x27
-+ && serial_buff[10] == 0x0F && serial_buff[11] == 0x27) {
-+ gps_time_ok = false;
-+ gps_lock_ok = false;
- }
-
-- return UBX_NAV_TIMEGPS;
-+ return UBX_NAV_TIMEUTC;
- } else if ((serial_buff[2] == 0x05) && (serial_buff[3] == 0x00)) {
- DEBUG_MSG("NOTE: UBX ACK-NAK received\n");
- return IGNORED;
-@@ -526,7 +447,7 @@ enum gps_msg lgw_parse_nmea(const char *serial_buff, int buff_size) {
- } else if (!validate_nmea_checksum(serial_buff, buff_size)) {
- DEBUG_MSG("Warning: invalid NMEA sentence (bad checksum)\n");
- return INVALID;
-- } else if (match_label(serial_buff, "$G?RMC", 6, '?')) {
-+ } else if (match_label(serial_buff, "G?RMC", 5, '?')) {
- /*
- NMEA sentence format: $xxRMC,time,status,lat,NS,long,EW,spd,cog,date,mv,mvEW,posMode*cs<CR><LF>
- Valid fix: $GPRMC,083559.34,A,4717.11437,N,00833.91522,E,0.004,77.52,091202,,,A*00
-@@ -535,33 +456,32 @@ enum gps_msg lgw_parse_nmea(const char *serial_buff, int buff_size) {
- memcpy(parser_buf, serial_buff, buff_size);
- parser_buf[buff_size] = '\0';
- nb_fields = str_chop(parser_buf, buff_size, ',', str_index, ARRAY_SIZE(str_index));
-- if (nb_fields != 13) {
-+ if (nb_fields != 12) {
- DEBUG_MSG("Warning: invalid RMC sentence (number of fields)\n");
- return IGNORED;
- }
- /* parse GPS status */
-- gps_mod = *(parser_buf + str_index[12]); /* get first character, no need to bother with sscanf */
-+ gps_mod = *(parser_buf + str_index[2]); /* get first character, no need to bother with sscanf */
- if ((gps_mod != 'N') && (gps_mod != 'A') && (gps_mod != 'D')) {
- gps_mod = 'N';
- }
- /* parse complete time */
- i = sscanf(parser_buf + str_index[1], "%2hd%2hd%2hd%4f", &gps_hou, &gps_min, &gps_sec, &gps_fra);
- j = sscanf(parser_buf + str_index[9], "%2hd%2hd%2hd", &gps_day, &gps_mon, &gps_yea);
-- if ((i == 4) && (j == 3)) {
-+ if ((i == 3) && (j == 3)) {
- if ((gps_mod == 'A') || (gps_mod == 'D')) {
-- gps_time_ok = true;
-+ gps_lock_ok = true;
- DEBUG_MSG("Note: Valid RMC sentence, GPS locked, date: 20%02d-%02d-%02dT%02d:%02d:%06.3fZ\n", gps_yea, gps_mon, gps_day, gps_hou, gps_min, gps_fra + (float)gps_sec);
- } else {
-- gps_time_ok = false;
-+ gps_lock_ok = false;
- DEBUG_MSG("Note: Valid RMC sentence, no satellite fix, estimated date: 20%02d-%02d-%02dT%02d:%02d:%06.3fZ\n", gps_yea, gps_mon, gps_day, gps_hou, gps_min, gps_fra + (float)gps_sec);
- }
- } else {
- /* could not get a valid hour AND date */
-- gps_time_ok = false;
- DEBUG_MSG("Note: Valid RMC sentence, mode %c, no date\n", gps_mod);
- }
- return NMEA_RMC;
-- } else if (match_label(serial_buff, "$G?GGA", 6, '?')) {
-+ } else if (match_label(serial_buff, "G?GGA", 5, '?')) {
- /*
- NMEA sentence format: $xxGGA,time,lat,NS,long,EW,quality,numSV,HDOP,alt,M,sep,M,diffAge,diffStation*cs<CR><LF>
- Valid fix: $GPGGA,092725.00,4717.11399,N,00833.91590,E,1,08,1.01,499.6,M,48.0,M,,*5B
-@@ -587,6 +507,8 @@ enum gps_msg lgw_parse_nmea(const char *serial_buff, int buff_size) {
- } else {
- /* could not get a valid latitude, longitude AND altitude */
- gps_pos_ok = false;
-+ gps_time_ok = false;
-+ gps_lock_ok = false;
- DEBUG_MSG("Note: Valid GGA sentence, %d sat, no coordinates\n", gps_sat);
- }
- return NMEA_GGA;
-@@ -662,72 +580,60 @@ int lgw_gps_get(struct timespec *utc, struct timespec *gps_time, struct coord_s
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
- int lgw_gps_sync(struct tref *ref, uint32_t count_us, struct timespec utc, struct timespec gps_time) {
-+ bool update = false;
- double cnt_diff; /* internal concentrator time difference (in seconds) */
- double utc_diff; /* UTC time difference (in seconds) */
-- double slope; /* time slope between new reference and old reference (for sanity check) */
--
-- bool aber_n0; /* is the update value for synchronization aberrant or not ? */
-- static bool aber_min1 = false; /* keep track of whether value at sync N-1 was aberrant or not */
-- static bool aber_min2 = false; /* keep track of whether value at sync N-2 was aberrant or not */
-+ double slope = 1.0; /* time slope between new reference and old reference (for sanity check) */
-+ static bool calibrating = true;
-
- CHECK_NULL(ref);
-
- /* calculate the slope */
-
-- cnt_diff = (double)(count_us - ref->count_us) / (double)(TS_CPS); /* uncorrected by xtal_err */
-- utc_diff = (double)(utc.tv_sec - (ref->utc).tv_sec) + (1E-9 * (double)(utc.tv_nsec - (ref->utc).tv_nsec));
-+ if (ref->systime != 0) {
-+
-+ cnt_diff = (double)(count_us - ref->count_us) / (double)(TS_CPS); /* uncorrected by xtal_err */
-+ utc_diff = (double)(utc.tv_sec - (ref->utc).tv_sec) + (1E-9 * (double)(utc.tv_nsec - (ref->utc).tv_nsec));
-
-- /* detect aberrant points by measuring if slope limits are exceeded */
-- if (utc_diff != 0) { // prevent divide by zero
-- slope = cnt_diff/utc_diff;
-- if ((slope > PLUS_10PPM) || (slope < MINUS_10PPM)) {
-- DEBUG_MSG("Warning: correction range exceeded\n");
-- aber_n0 = true;
-+ if (cnt_diff != 0 && utc_diff != 0) { // prevent divide by zero
-+ slope = cnt_diff/utc_diff;
- } else {
-- aber_n0 = false;
-+ slope = 0.0;
-+ }
-+
-+ if (gps_lock_ok && gps_time_ok && cnt_diff > 1.5) {
-+ update = true;
-+ }
-+
-+ update = (slope >= MINUS_10PPM && slope <= PLUS_10PPM);
-+
-+ if (!calibrating && utc_diff < 10.0) {
-+ return LGW_GPS_ERROR;
- }
-+
-+ if (calibrating && !update && utc_diff > 1.5) {
-+ update = true;
-+ } else if (update) {
-+ calibrating = false;
-+ }
-+
- } else {
-- DEBUG_MSG("Warning: aberrant UTC value for synchronization\n");
-- aber_n0 = true;
-+ update = true;
-+ slope = 0.0;
- }
-
-- /* watch if the 3 latest sync point were aberrant or not */
-- if (aber_n0 == false) {
-- /* value no aberrant -> sync with smoothed slope */
-- ref->systime = time(NULL);
-+ if (update || calibrating) {
-+ ref->systime = time(NULL);
- ref->count_us = count_us;
- ref->utc.tv_sec = utc.tv_sec;
- ref->utc.tv_nsec = utc.tv_nsec;
- ref->gps.tv_sec = gps_time.tv_sec;
- ref->gps.tv_nsec = gps_time.tv_nsec;
- ref->xtal_err = slope;
-- aber_min2 = aber_min1;
-- aber_min1 = aber_n0;
- return LGW_GPS_SUCCESS;
-- } else if (aber_n0 && aber_min1 && aber_min2) {
-- /* 3 successive aberrant values -> sync reset (keep xtal_err) */
-- ref->systime = time(NULL);
-- ref->count_us = count_us;
-- ref->utc.tv_sec = utc.tv_sec;
-- ref->utc.tv_nsec = utc.tv_nsec;
-- ref->gps.tv_sec = gps_time.tv_sec;
-- ref->gps.tv_nsec = gps_time.tv_nsec;
-- /* reset xtal_err only if the present value is out of range */
-- if ((ref->xtal_err > PLUS_10PPM) || (ref->xtal_err < MINUS_10PPM)) {
-- ref->xtal_err = 1.0;
-- }
-- DEBUG_MSG("Warning: 3 successive aberrant sync attempts, sync reset\n");
-- aber_min2 = aber_min1;
-- aber_min1 = aber_n0;
-- return LGW_GPS_SUCCESS;
-- } else {
-- /* only 1 or 2 successive aberrant values -> ignore and return an error */
-- aber_min2 = aber_min1;
-- aber_min1 = aber_n0;
-- return LGW_GPS_ERROR;
- }
-
-- return LGW_GPS_SUCCESS;
-+ return LGW_GPS_ERROR;
- }
-
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-diff --git a/libloragw/tst/test_loragw_gps.c b/libloragw/tst/test_loragw_gps.c
-index a4164a3..e4b1546 100644
---- a/libloragw/tst/test_loragw_gps.c
-+++ b/libloragw/tst/test_loragw_gps.c
-@@ -31,6 +31,8 @@ Maintainer: Michael Coracin
- #include <signal.h> /* sigaction */
- #include <stdlib.h> /* exit */
- #include <unistd.h> /* read */
-+#include <gps.h>
-+#include <gpsd.h>
-
- #include "loragw_hal.h"
- #include "loragw_gps.h"
-@@ -41,7 +43,8 @@ Maintainer: Michael Coracin
-
- static int exit_sig = 0; /* 1 -> application terminates cleanly (shut down hardware, close open files, etc) */
- static int quit_sig = 0; /* 1 -> application terminates without shutting down the hardware */
--
-+static struct gps_data_t gpsdata;
-+static struct fixsource_t source;
- struct tref ppm_ref;
-
- /* -------------------------------------------------------------------------- */
-@@ -149,6 +152,10 @@ int main()
- /* NMEA/UBX variables */
- enum gps_msg latest_msg; /* keep track of latest NMEA/UBX message parsed */
-
-+ fd_set fds;
-+ char delim[4] = "$";
-+ char *token[254];
-+
- /* configure signal handling */
- sigemptyset(&sigact.sa_mask);
- sigact.sa_flags = 0;
-@@ -162,7 +169,7 @@ int main()
- printf("*** Library version information ***\n%s\n***\n", lgw_version_info());
-
- /* Open and configure GPS */
-- i = lgw_gps_enable("/dev/ttyAMA0", "ubx7", 0, &gps_tty_dev);
-+ i = lgw_gps_enable(&gpsdata, &source);
- if (i != LGW_GPS_SUCCESS) {
- printf("ERROR: IMPOSSIBLE TO ENABLE GPS\n");
- exit(EXIT_FAILURE);
-@@ -192,92 +199,87 @@ int main()
-
- /* loop until user action */
- while ((quit_sig != 1) && (exit_sig != 1)) {
-- size_t rd_idx = 0;
-- size_t frame_end_idx = 0;
--
-- /* blocking non-canonical read on serial port */
-- ssize_t nb_char = read(gps_tty_dev, serial_buff + wr_idx, LGW_GPS_MIN_MSG_SIZE);
-- if (nb_char <= 0) {
-- printf("WARNING: [gps] read() returned value %d\n", nb_char);
-+ int r = 0;
-+ struct timeval tv;
-+ tv.tv_sec = 0;
-+ tv.tv_usec = 100000;
-+ FD_ZERO(&fds);
-+ FD_SET(gpsdata.gps_fd, &fds);
-+ errno = 0;
-+ r = select(gpsdata.gps_fd+1, &fds, NULL, NULL, &tv);
-+ if (r == -1 && errno != EINTR) {
-+ printf("gpspipe: select error %s(%d)\n", strerror(errno), errno);
-+ exit(EXIT_FAILURE);
-+ } else if (r == 0)
- continue;
-- }
-- wr_idx += (size_t)nb_char;
-
-- /*******************************************
-- * Scan buffer for UBX/NMEA sync chars and *
-- * attempt to decode frame if one is found *
-- *******************************************/
-- while (rd_idx < wr_idx) {
-+ /* reading directly from the socket avoids decode overhead */
-+ errno = 0;
-+ r = (int)read(gpsdata.gps_fd, serial_buff, sizeof(serial_buff));
-+ if (r > 0) {
-+ int i = 0;
- size_t frame_size = 0;
--
-- /* Scan buffer for UBX sync char */
-- if (serial_buff[rd_idx] == LGW_GPS_UBX_SYNC_CHAR) {
--
-- /***********************
-- * Found UBX sync char *
-- ***********************/
-- latest_msg = lgw_parse_ubx(&serial_buff[rd_idx], (wr_idx - rd_idx), &frame_size);
--
-- if (frame_size > 0) {
-- if (latest_msg == INCOMPLETE) {
-- /* UBX header found but frame appears to be missing bytes */
-- frame_size = 0;
-- } else if (latest_msg == INVALID) {
-- /* message header received but message appears to be corrupted */
-- printf("WARNING: [gps] could not get a valid message from GPS (no time)\n");
-- frame_size = 0;
-- } else if (latest_msg == UBX_NAV_TIMEGPS) {
-- printf("\n~~ UBX NAV-TIMEGPS sentence, triggering synchronization attempt ~~\n");
-- gps_process_sync();
-+ for (i = 0; i < r; i++) {
-+ if (serial_buff[i] == (char)LGW_GPS_UBX_SYNC_CHAR) {
-+ /***********************
-+ * Found UBX sync char *
-+ ***********************/
-+ size_t ubx_size = (uint8_t)serial_buff[i+4];
-+ ubx_size |= (uint8_t)serial_buff[i+5] << 8;
-+ ubx_size += 8;
-+ if (ubx_size < 27){
-+ latest_msg = lgw_parse_ubx(&serial_buff[i], ubx_size , &frame_size);
- }
-- }
-- } else if(serial_buff[rd_idx] == LGW_GPS_NMEA_SYNC_CHAR) {
-- /************************
-- * Found NMEA sync char *
-- ************************/
-- /* scan for NMEA end marker (LF = 0x0a) */
-- char* nmea_end_ptr = memchr(&serial_buff[rd_idx],(int)0x0a, (wr_idx - rd_idx));
--
-- if (nmea_end_ptr) {
-- /* found end marker */
-- frame_size = nmea_end_ptr - &serial_buff[rd_idx] + 1;
-- latest_msg = lgw_parse_nmea(&serial_buff[rd_idx], frame_size);
--
-- if(latest_msg == INVALID || latest_msg == UNKNOWN) {
-- /* checksum failed */
-- frame_size = 0;
-- } else if (latest_msg == NMEA_RMC) { /* Get location from RMC frames */
-- gps_process_coords();
-+ if (frame_size > 0) {
-+ if(latest_msg == INVALID || latest_msg == UNKNOWN) {
-+ /* checksum failed */
-+ frame_size = 0;
-+ } else if (latest_msg == UBX_NAV_TIMEGPS) {
-+ gps_process_sync();
-+ }
-+ }
-+ } else if((serial_buff[i] == LGW_GPS_NMEA_SYNC_CHAR) && (serial_buff[i+1] == 0x47) && (serial_buff[i+2] == 0x50)){
-+ /************************
-+ * Found NMEA sync char *
-+ ************************/
-+ int k, l= 0;
-+ token[0] = strtok(serial_buff, delim);
-+
-+ while (token[l] != NULL) {
-+ l++;
-+ token[l] = strtok(NULL, delim);
- }
-+ for (k=0; k<=l-1; k++) {
-+ if ((strlen(token[k]) > 66) && (strlen(token[k]) < 74)){
-+ lgw_parse_nmea(token[k], strlen(token[k]));
-+ if(latest_msg == INVALID || latest_msg == UNKNOWN) {
-+ /* checksum failed */
-+ frame_size = 0;
-+ } else if (latest_msg == NMEA_RMC) {
-+ /* Get location from RMC frames */
-+ gps_process_coords();
-+ }
-+ }
-+ }
- }
- }
--
-- if (frame_size > 0) {
-- /* At this point message is a checksum verified frame
-- we're processed or ignored. Remove frame from buffer */
-- rd_idx += frame_size;
-- frame_end_idx = rd_idx;
-+ } else {
-+ if (r == -1) {
-+ if (errno == EAGAIN)
-+ continue;
-+ else {
-+ printf(stderr, "gpspipe: read error %s(%d)\n", strerror(errno), errno);
-+ exit(EXIT_FAILURE);
-+ }
- } else {
-- rd_idx++;
-+ exit(EXIT_SUCCESS);
- }
-- } /* ...for(rd_idx = 0... */
--
-- if (frame_end_idx) {
-- /* Frames have been processed. Remove bytes to end of last processed frame */
-- memcpy(serial_buff,&serial_buff[frame_end_idx],wr_idx - frame_end_idx);
-- wr_idx -= frame_end_idx;
-- } /* ...for(rd_idx = 0... */
--
-- /* Prevent buffer overflow */
-- if ((sizeof(serial_buff) - wr_idx) < LGW_GPS_MIN_MSG_SIZE) {
-- memcpy(serial_buff,&serial_buff[LGW_GPS_MIN_MSG_SIZE],wr_idx - LGW_GPS_MIN_MSG_SIZE);
-- wr_idx -= LGW_GPS_MIN_MSG_SIZE;
- }
- }
-
- /* clean up before leaving */
- if (exit_sig == 1) {
-- lgw_gps_disable(gps_tty_dev);
-+ lgw_gps_disable(&gpsdata);
- lgw_stop();
- }
-
diff --git a/recipes-connectivity/lora/lora-gateway/lora-gateway-semtech-sf12.patch b/recipes-connectivity/lora/lora-gateway/lora-gateway-semtech-sf12.patch
deleted file mode 100644
index 7ea09d2..0000000
--- a/recipes-connectivity/lora/lora-gateway/lora-gateway-semtech-sf12.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-t a/libloragw/src/loragw_hal.c b/libloragw/src/loragw_hal.c
-index 7271eac..e5770df 100644
---- a/libloragw/src/loragw_hal.c
-+++ b/libloragw/src/loragw_hal.c
-@@ -305,6 +305,11 @@ void lgw_constant_adjust(void) {
- // lgw_reg_w(LGW_MBWSSF_TRACKING_INTEGRAL,0); /* default 0 */
- // lgw_reg_w(LGW_MBWSSF_AGC_FREEZE_ON_DETECT,1); /* default 1 */
-
-+ /* Improvement of reference clock frequency error tolerance */
-+ lgw_reg_w(LGW_ADJUST_MODEM_START_OFFSET_RDX4, 1); /* default 0 */
-+ lgw_reg_w(LGW_ADJUST_MODEM_START_OFFSET_SF12_RDX4, 4094); /* default 4092 */
-+ lgw_reg_w(LGW_CORR_MAC_GAIN, 7); /* default 5 */
-+
- /* FSK datapath setup */
- lgw_reg_w(LGW_FSK_RX_INVERT,1); /* default 0 */
- lgw_reg_w(LGW_FSK_MODEM_INVERT_IQ,1); /* default 0 */
diff --git a/recipes-connectivity/lora/lora-gateway/lora-gateway-spectral-scan-skip-fpga-reset.patch b/recipes-connectivity/lora/lora-gateway/lora-gateway-spectral-scan-skip-fpga-reset.patch
deleted file mode 100644
index 0b53fd0..0000000
--- a/recipes-connectivity/lora/lora-gateway/lora-gateway-spectral-scan-skip-fpga-reset.patch
+++ /dev/null
@@ -1,86 +0,0 @@
-diff --git a/util_spectral_scan/src/util_spectral_scan.c b/util_spectral_scan/src/util_spectral_scan.c
-index d2aecda..cbc8377 100644
---- a/util_spectral_scan/src/util_spectral_scan.c
-+++ b/util_spectral_scan/src/util_spectral_scan.c
-@@ -30,6 +30,7 @@ Maintainer: Michael Coracin
- #include <stdlib.h> /* EXIT atoi */
- #include <unistd.h> /* getopt */
- #include <string.h>
-+#include <signal.h>
-
- #include "loragw_aux.h"
- #include "loragw_reg.h"
-@@ -66,11 +67,22 @@ Maintainer: Michael Coracin
- /* -------------------------------------------------------------------------- */
- /* --- GLOBAL VARIABLES ----------------------------------------------------- */
-
-+bool shutdown_signal_recv = false;
-+
-+void signalHandler() {
-+ shutdown_signal_recv = true;
-+}
-+
-+
- /* -------------------------------------------------------------------------- */
- /* --- MAIN FUNCTION -------------------------------------------------------- */
-
- int main( int argc, char ** argv )
- {
-+
-+ signal(SIGINT, signalHandler);
-+ signal(SIGTERM, signalHandler);
-+
- int i, j, k; /* loop and temporary variables */
- int x; /* return code for functions */
- int32_t reg_val;
-@@ -200,6 +212,10 @@ int main( int argc, char ** argv )
- }
- }
-
-+ if (shutdown_signal_recv) {
-+ return 0;
-+ }
-+
- /* Start message */
- printf("+++ Start spectral scan of LoRa gateway channels +++\n");
-
-@@ -264,7 +280,7 @@ int main( int argc, char ** argv )
- printf("ERROR: Failed to disconnect from FPGA\n");
- return EXIT_FAILURE;
- }
-- x = lgw_connect(false, LGW_DEFAULT_NOTCH_FREQ); /* FPGA reset/configure */
-+ x = lgw_connect(true, LGW_DEFAULT_NOTCH_FREQ); /* FPGA reset/configure */
- if(x != 0) {
- printf("ERROR: Failed to connect to FPGA\n");
- return EXIT_FAILURE;
-@@ -324,6 +340,9 @@ int main( int argc, char ** argv )
- do {
- wait_ms(10);
- lgw_fpga_reg_r(LGW_FPGA_STATUS, &reg_val);
-+ if (shutdown_signal_recv) {
-+ break;
-+ }
- }
- while((TAKE_N_BITS_FROM((uint8_t)reg_val, 0, 5)) != 1); /* Clear has started */
-
-@@ -346,6 +365,9 @@ int main( int argc, char ** argv )
- do {
- wait_ms(1000);
- lgw_fpga_reg_r(LGW_FPGA_STATUS, &reg_val);
-+ if (shutdown_signal_recv) {
-+ break;
-+ }
- }
- while((TAKE_N_BITS_FROM((uint8_t)reg_val, 5, 1)) != 1);
-
-@@ -382,6 +404,10 @@ int main( int argc, char ** argv )
- }
- fprintf(log_file, "\n");
- printf("\n");
-+
-+ if (shutdown_signal_recv) {
-+ break;
-+ }
- }
- fclose(log_file);
-
diff --git a/recipes-connectivity/lora/lora-gateway/lora-gateway-v28-skip-IQ-invert.patch b/recipes-connectivity/lora/lora-gateway/lora-gateway-v28-skip-IQ-invert.patch
deleted file mode 100644
index 25065df..0000000
--- a/recipes-connectivity/lora/lora-gateway/lora-gateway-v28-skip-IQ-invert.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/libloragw/src/loragw_fpga.c b/libloragw/src/loragw_fpga.c
-index fa83a2a..7e667e3 100644
---- a/libloragw/src/loragw_fpga.c
-+++ b/libloragw/src/loragw_fpga.c
-@@ -144,11 +144,14 @@ int lgw_fpga_configure(uint32_t tx_notch_freq) {
- return LGW_REG_ERROR;
- }
-
-- /* Required for Semtech AP2 reference design */
-- x = lgw_fpga_reg_w(LGW_FPGA_CTRL_INVERT_IQ, 1);
-- if (x != LGW_REG_SUCCESS) {
-- DEBUG_MSG("ERROR: Failed to configure FPGA polarity\n");
-- return LGW_REG_ERROR;
-+
-+ if (read_fpga_version() > 28) {
-+ /* Required for Semtech AP2 reference design and AP1.5 > v28 */
-+ x = lgw_fpga_reg_w(LGW_FPGA_CTRL_INVERT_IQ, 1);
-+ if (x != LGW_REG_SUCCESS) {
-+ DEBUG_MSG("ERROR: Failed to configure FPGA polarity\n");
-+ return LGW_REG_ERROR;
-+ }
- }
-
- /* Configure TX notch filter */