summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Sharma <harsh.sharma@multitech.com>2019-10-03 12:01:18 -0500
committerHarsh Sharma <harsh.sharma@multitech.com>2019-10-03 12:01:18 -0500
commitc224e6e47cab24e39554765cafb3b21b302df40b (patch)
tree9666d5908bf5a761da93ff91d99b22ed66ad72a6
parent5ae0deec6af66f26e84b34366ca1663261498c63 (diff)
downloadpacket_forwarder_mtac_full-c224e6e47cab24e39554765cafb3b21b302df40b.tar.gz
packet_forwarder_mtac_full-c224e6e47cab24e39554765cafb3b21b302df40b.tar.bz2
packet_forwarder_mtac_full-c224e6e47cab24e39554765cafb3b21b302df40b.zip
Added rety with pin reset when concentrator does not start and changed build version to be based on git describe and commit
-rw-r--r--lora_pkt_fwd/Makefile6
-rw-r--r--lora_pkt_fwd/src/lora_pkt_fwd.c27
2 files changed, 28 insertions, 5 deletions
diff --git a/lora_pkt_fwd/Makefile b/lora_pkt_fwd/Makefile
index dda589e..069fc0a 100644
--- a/lora_pkt_fwd/Makefile
+++ b/lora_pkt_fwd/Makefile
@@ -15,15 +15,15 @@ INCLUDES = $(wildcard inc/*.h)
# must get library build option to know if mpsse must be linked or not
include $(LGW_PATH)/library.cfg
-RELEASE_VERSION := `cat ../VERSION`
-
+RELEASE_VERSION := $(shell git describe)
+RELEASE_COMMIT := $(shell git rev-parse --short HEAD)
### Constant symbols
CC := $(CROSS_COMPILE)gcc
AR := $(CROSS_COMPILE)ar
MORECFLAGS := -Wall -Wextra -std=c99 -Iinc -I. -isystem =/usr/include/gps
-VFLAG := -D VERSION_STRING="\"$(RELEASE_VERSION)\""
+VFLAG := -D VERSION_STRING="\"$(RELEASE_VERSION)-$(RELEASE_COMMIT)\""
### Constants for Lora concentrator HAL library
# List the library sub-modules that are used by the application
diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c
index fc15302..8fbbd7b 100644
--- a/lora_pkt_fwd/src/lora_pkt_fwd.c
+++ b/lora_pkt_fwd/src/lora_pkt_fwd.c
@@ -144,6 +144,12 @@ Maintainer: Michael Coracin
#define HISTOGRAM_READY_TIMEOUT 1000
#define LGW_RECEIVE_TIMEOUT 100
+#define MTS_IO_SYS "mts-io-sysfs store"
+#define LORA_PIN_LOW "/reset 0"
+#define LORA_PIN_HIGH "/reset 1"
+#define LORA_PATH_AP1 "/dev/spidev32766.2"
+#define LORA_PATH_AP2 "/dev/spidev32765.2"
+
/* -------------------------------------------------------------------------- */
/* --- PRIVATE VARIABLES (GLOBAL) ------------------------------------------- */
@@ -1466,8 +1472,14 @@ int main(int argc, char** argv)
}
freeaddrinfo(result);
+ char lora_port[5] = "lora"; /* path mapping for mts-io */
/* set custom SPI device path if configured */
if (strlen(spi_device_path) > 0)
+ if (strcmp(spi_device_path, LORA_PATH_AP1) == 0) {
+ snprintf(lora_port, sizeof lora_port, "%s", "ap1");
+ } else if (strcmp(spi_device_path, LORA_PATH_AP2) == 0) {
+ snprintf(lora_port, sizeof lora_port, "%s", "ap2");
+ }
lgw_spi_set_path(spi_device_path);
@@ -1476,8 +1488,19 @@ int main(int argc, char** argv)
if (i == LGW_HAL_SUCCESS) {
MSG("INFO: [main] concentrator started, packet can now be received\n");
} else {
- MSG("ERROR: [main] failed to start the concentrator\n");
- exit(EXIT_FAILURE);
+ MSG("ERROR: [main] failed to start the concentrator, resetting %s and trying again\n", lora_port);
+ char cmd_pin_low[64];
+ char cmd_pin_high[64];
+ snprintf(cmd_pin_low, sizeof cmd_pin_low, "%s %s%s", MTS_IO_SYS, lora_port, LORA_PIN_LOW);
+ snprintf(cmd_pin_high, sizeof cmd_pin_high, "%s %s%s", MTS_IO_SYS, lora_port, LORA_PIN_HIGH);
+ system(cmd_pin_low);
+ wait_ms(250);
+ system(cmd_pin_high);
+ i = lgw_start();
+ if (i != LGW_HAL_SUCCESS) {
+ MSG("ERROR: [main] concentrator cannot be started, exiting\n");
+ exit(EXIT_FAILURE);
+ }
}
/* spawn threads to manage upstream and downstream */