summaryrefslogtreecommitdiff
path: root/recipes-connectivity/lora/lora-basic-station
diff options
context:
space:
mode:
authorJason Reiss <jreiss@multitech.com>2020-03-12 12:41:38 -0500
committerJason Reiss <jreiss@multitech.com>2020-03-12 12:41:38 -0500
commitd47e6d997a114e5b2899bd3d4a0359843dd211d2 (patch)
tree24f149cc19a84d2bf92164ebd5397efac8c5ce15 /recipes-connectivity/lora/lora-basic-station
parent4f6244cf5d3310724cc0d1cbff8b864055332af2 (diff)
downloadmeta-mlinux-d47e6d997a114e5b2899bd3d4a0359843dd211d2.tar.gz
meta-mlinux-d47e6d997a114e5b2899bd3d4a0359843dd211d2.tar.bz2
meta-mlinux-d47e6d997a114e5b2899bd3d4a0359843dd211d2.zip
lora: add MTCAP2 global_conf files, adjust init scripts to detect MTCAP2
Diffstat (limited to 'recipes-connectivity/lora/lora-basic-station')
-rw-r--r--recipes-connectivity/lora/lora-basic-station/lora-basic-station-disable-device-mode.patch15
-rw-r--r--recipes-connectivity/lora/lora-basic-station/lora-basic-station-fix-clksrc-0.patch14
-rw-r--r--recipes-connectivity/lora/lora-basic-station/lora-basic-station-sys-linux-log-fix.patch14
-rw-r--r--recipes-connectivity/lora/lora-basic-station/lora-basic-station.default2
-rwxr-xr-xrecipes-connectivity/lora/lora-basic-station/lora-basic-station.init165
-rw-r--r--recipes-connectivity/lora/lora-basic-station/setup.gmk91
-rw-r--r--recipes-connectivity/lora/lora-basic-station/tc.uri1
7 files changed, 302 insertions, 0 deletions
diff --git a/recipes-connectivity/lora/lora-basic-station/lora-basic-station-disable-device-mode.patch b/recipes-connectivity/lora/lora-basic-station/lora-basic-station-disable-device-mode.patch
new file mode 100644
index 0000000..d81d041
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station/lora-basic-station-disable-device-mode.patch
@@ -0,0 +1,15 @@
+diff --git a/src/sx1301conf.c b/src/sx1301conf.c
+index bca649c..c2681a4 100644
+--- a/src/sx1301conf.c
++++ b/src/sx1301conf.c
+@@ -433,7 +433,10 @@ int sx1301conf_start (struct sx1301conf* sx1301conf, u4_t cca_region) {
+ }
+
+ LOG(MOD_RAL|INFO, "Station device: %s (PPS capture %sabled)", sx1301conf->device, sx1301conf->pps ? "en":"dis");
++
++#ifndef CFG_prod
+ lgwx_device_mode = sys_deviceMode;
++#endif
+ int err = lgw_start();
+ if( err == LGW_HAL_SUCCESS ) {
+ lgw_reg_w(LGW_GPS_EN, sx1301conf->pps ? 1 : 0);
diff --git a/recipes-connectivity/lora/lora-basic-station/lora-basic-station-fix-clksrc-0.patch b/recipes-connectivity/lora/lora-basic-station/lora-basic-station-fix-clksrc-0.patch
new file mode 100644
index 0000000..c534460
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station/lora-basic-station-fix-clksrc-0.patch
@@ -0,0 +1,14 @@
+diff --git a/src/sx1301conf.c b/src/sx1301conf.c
+index bca649c..fe62351 100644
+--- a/src/sx1301conf.c
++++ b/src/sx1301conf.c
+@@ -193,7 +193,8 @@ static void parse_sx1301_conf (ujdec_t* D, struct sx1301conf* sx1301conf) {
+ break;
+ }
+ case J_clksrc: {
+ sx1301conf->boardconf.clksrc = uj_intRange(D, 0, LGW_RF_CHAIN_NB-1);
++ sx1301conf->boardconf.clksrc = 0;
+ break;
+ }
+ case J_tx_gain_lut: {
+
diff --git a/recipes-connectivity/lora/lora-basic-station/lora-basic-station-sys-linux-log-fix.patch b/recipes-connectivity/lora/lora-basic-station/lora-basic-station-sys-linux-log-fix.patch
new file mode 100644
index 0000000..83be080
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station/lora-basic-station-sys-linux-log-fix.patch
@@ -0,0 +1,14 @@
+diff --git a/src-linux/sys_linux.c b/src-linux/sys_linux.c
+index f8286c8..7afc073 100644
+--- a/src-linux/sys_linux.c
++++ b/src-linux/sys_linux.c
+@@ -724,7 +724,7 @@ static int parseStationConf () {
+ case J_nodc:
+ case J_nodwell:
+ case J_device_mode: {
+- LOG(MOD_S2E|WARNING, "Feature not supported in production level code (station.conf) - ignored: %s", D->field.name);
+- uj_skipValue(D);
++ LOG(MOD_S2E|WARNING, "Feature not supported in production level code (station.conf) - ignored: %s", D.field.name);
++ uj_skipValue(&D);
+ break;
+ }
diff --git a/recipes-connectivity/lora/lora-basic-station/lora-basic-station.default b/recipes-connectivity/lora/lora-basic-station/lora-basic-station.default
new file mode 100644
index 0000000..0f92640
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station/lora-basic-station.default
@@ -0,0 +1,2 @@
+# set to "yes" or "no" to control starting on boot
+ENABLED="no"
diff --git a/recipes-connectivity/lora/lora-basic-station/lora-basic-station.init b/recipes-connectivity/lora/lora-basic-station/lora-basic-station.init
new file mode 100755
index 0000000..45c6eee
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station/lora-basic-station.init
@@ -0,0 +1,165 @@
+#!/bin/bash
+
+
+NAME="lora-basic-station"
+ENABLED="yes"
+
+
+[ -f /etc/default/$NAME ] && source /etc/default/$NAME
+
+run_dir=/var/run/lora
+opt_conf_dir=/opt/lora
+conf_dir=/var/config/lora
+conf_file=$conf_dir/station.conf
+tc_uri_file=$conf_dir/tc.uri
+tc_key_file=$conf_dir/tc.key
+tc_trust_file=$conf_dir/tc.trust
+
+pkt_fwd=$run_dir/1/station
+pkt_fwd_pidfile=$run_dir/station.pid
+
+port1=/sys/devices/platform/mts-io/ap1
+port2=/sys/devices/platform/mts-io/ap2
+
+lora_mtac_id="MTAC-LORA"
+lora_1_0_hw="MTAC-LORA-1.0"
+lora_1_5_h_hw="MTAC-LORA-1.5"
+lora_2_1_hw="MTAC-LORA-2.1"
+
+lora_mtac_id="MTAC-LORA"
+lora_mtac_id915="MTAC-LORA-915"
+lora_mtac_id868="MTAC-LORA-868"
+lora_mtac_h_id915="MTAC-LORA-H-915"
+lora_mtac_h_id868="MTAC-LORA-H-868"
+
+lora_mtcap_id="MTCAP-LORA"
+lora_mtcap_id868="MTCAP-LORA-868"
+lora_mtcap_id915="MTCAP-LORA-915"
+
+lora_mtac_g_id="MTAC-LORA-G"
+lora_mtac_g16_id868="MTAC-LORA-G16-868"
+lora_mtac_g16_id915="MTAC-LORA-G16-915"
+lora_mtac_g64_id868="MTAC-LORA-G64-868"
+lora_mtac_g64_id915="MTAC-LORA-G64-915"
+
+pkt_fwd_options=""
+
+gps_path="/dev/gps0"
+
+read_lora_hw_info() {
+ lora_id=$(mts-io-sysfs show lora/product-id 2> /dev/null)
+ lora_hw=$(mts-io-sysfs show lora/hw-version 2> /dev/null)
+ lora_eui=$(mts-io-sysfs show lora/eui 2> /dev/null)
+ lora_eui_raw=${lora_eui//:/}
+}
+
+hardware_found() {
+ if [[ "$lora_id" =~ "$lora_mtac_g_id" ]]; then
+ setup_mtcdt_2_1
+ elif [[ "$lora_id" =~ "$lora_mtcap_id" ]]; then
+ setup_mtcap
+ elif [[ "$lora_id" =~ "$lora_mtac_id" ]]; then
+ setup_mtcdt
+ else
+ return 1
+ fi
+ return 0
+}
+
+setup_mtcdt() {
+ 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
+
+ ln -sf /opt/lora/station $pkt_fwd
+}
+
+setup_mtcap() {
+
+ ln -sf /opt/lora/station $pkt_fwd
+}
+
+setup_mtcdt_2_1() {
+ echo LORA-2.1 not supported
+ return 1
+}
+
+do_start() {
+
+ mkdir -p $run_dir/1
+ rm -rf $run_dir/1/*
+
+ read_lora_hw_info
+
+ if hardware_found; then
+ echo "Found $lora_id with $lora_hw hardware. Configuring"
+ else
+ echo "$0: LORA card not detected"
+ exit 1
+ fi
+
+ if ! [ -f $conf_file ]; then
+ echo "$0: $conf_file missing"
+ exit 1
+ fi
+
+ #
+ # copy conf files to the run directory
+ #
+ cp $conf_file $run_dir/1/
+ cp $tc_uri_file $run_dir/1/
+ cp $tc_key_file $run_dir/1/
+ cp $tc_trust_file $run_dir/1/
+
+ sed -i.bak "s/\(.*routerid\"\s*\:\s*\"\)<.*>[^\"]*\(.*\)/\1${lora_eui_raw}\2/g" /var/run/lora/1/station.conf
+
+ #
+ # start packet forwarder
+ #
+ echo -n "Starting $NAME: "
+
+ /usr/sbin/start-stop-daemon --chdir $run_dir/1 --background --start --make-pidfile \
+ --pidfile $pkt_fwd_pidfile --startas /bin/bash -- -c "exec $pkt_fwd $pkt_fwd_options"
+
+ renice -n -20 -p $(pgrep $(basename $pkt_fwd))
+
+ echo "OK"
+}
+
+
+do_stop() {
+ echo -n "Stopping $NAME: "
+ start-stop-daemon --stop --quiet --oknodo --pidfile $pkt_fwd_pidfile --retry 5
+ rm -f $pkt_fwd_pidfile
+ echo "OK"
+}
+
+
+if [ "$ENABLED" != "yes" ]; then
+ echo "$NAME: disabled in /etc/default"
+ exit
+fi
+
+
+case "$1" in
+ "start")
+ do_start
+ ;;
+ "stop")
+ do_stop
+ ;;
+ "restart")
+ ## Stop the service and regardless of whether it was
+ ## running or not, start it again.
+ do_stop
+ do_start
+ ;;
+ *)
+ ## If no parameters are given, print which are avaiable.
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+ ;;
+esac
+
diff --git a/recipes-connectivity/lora/lora-basic-station/setup.gmk b/recipes-connectivity/lora/lora-basic-station/setup.gmk
new file mode 100644
index 0000000..1319e79
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station/setup.gmk
@@ -0,0 +1,91 @@
+# -*- makefile -*-
+
+# Top dir of s2core
+# - override accordingly in makefile including this setup.gmk
+
+platform ?= mlinux
+variant ?= std
+
+
+ARCH ?=
+CROSS_COMPILE ?=
+export
+
+# TOOLPREFIX=${CROSS_COMPILE}
+
+
+BD=build-${platform}-${variant}
+
+# -- Architecture specific
+CFG.arm-linux-gnueabihf = mlinux
+# CFG.x86_64-linux-gnu = linux
+
+# -- Variant specific
+# testsim runs libloragw inside master process
+# testms uses a master slave model
+#CFG.testsim = logini_lvl=DEBUG selftests tlsdebug lgwsim ral_lgw
+#CFG.testms = logini_lvl=DEBUG selftests tlsdebug lgwsim ral_master_slave
+#CFG.testfs = logini_lvl=DEBUG selftests tlsdebug lgwsim ral_lgw
+#CFG.testpin = logini_lvl=INFO tlsdebug ral_lgw testpin
+#CFG.std = logini_lvl=INFO tlsdebug ral_lgw
+#CFG.stdn = logini_lvl=INFO tlsdebug ral_master_slave
+#CFG.debug = logini_lvl=DEBUG selftests tlsdebug ral_lgw
+#CFG.debugn = logini_lvl=DEBUG selftests tlsdebug ral_master_slave
+
+# -- Platform specific
+CFG.linux = linux lgw1 no_leds
+CFG.rpi = linux lgw1 no_leds
+CFG.kerlink = linux lgw1 no_leds
+CFG.mlinux = linux lgw1 no_leds ral_lgw prod
+
+SD.default = src-linux
+
+SD = $(or ${SD.${platform}}, ${SD.default})
+
+UTILS.linux = mtuns
+
+UTILS = $(or ${UTILS.${platform}}, ${UTILS.default})
+
+PERSO.default =
+PERSO = $(or ${PERSO.${platform}}, ${PERSO.default})
+PERSOH = $(if ${PERSO},perso.h,)
+
+# Paths to dependencies
+MBEDLIBS = -lmbedtls -lmbedx509 -lmbedcrypto
+
+# -lm: Needed for lgw which uses pow/ceil
+ifneq (minihub,$(platform))
+SYSLIBS = -lm
+endif
+
+CFLAGS.linux.testsim = -g -O0 --coverage
+CFLAGS.linux.testms = -g -O0 --coverage
+CFLAGS.linux.testfs = -g -O0 --coverage
+CFLAGS.linux.testpin = -g -O3
+CFLAGS.linux.std = -g -O3
+CFLAGS.mlinux.std = -g -O3
+
+LIBS.mlinux = -lloragw ${MBEDLIBS} -lrt -lm -lpthread
+LIBS.linux = -llgw ${MBEDLIBS} -lpthread
+LIBS.rpi = -llgw ${MBEDLIBS} -lpthread
+LIBS.kerlink = -llgw ${MBEDLIBS} -lrt -lpthread
+
+xCFG = ${CFG.${ARCH}} ${CFG.${platform}} ${CFG.${variant}} ${CFG.${platform}.${variant}}
+xCFLAGS = ${CFLAGS.${ARCH}} ${CFLAGS.${platform}} ${CFLAGS.${variant}} ${CFLAGS.${platform}.${variant}}
+xINCS = ${INCS.${ARCH}} ${INCS.${platform}} ${INCS.${variant}}
+xLDFLAGS = ${LDFLAGS.${ARCH}} ${LDFLAGS.${platform}} ${LDFLAGS.${variant}}
+xLIBS = ${LIBS.${ARCH}} ${LIBS.${platform}} ${LIBS.${variant}}
+xFILES = ${FILES.${ARCH}} ${FILES.${platform}} ${FILES.${variant}}
+xOCFLAGS = ${OCFLAGS.${ARCH}} ${OCFLAGS.${platform}} ${OCFLAGS.${variant}}
+
+DEFS = -DCFG_platform_${platform} -DCFG_platform=\"${platform}\" -DCFG_variant_${variant} -DCFG_variant=\"${variant}\"
+DEFS += -DCFG_bdate='"$(shell date -u '+%Y-%m-%d %H:%M:%S')"'
+DEFS += -DCFG_version='"$(shell if [ -f ${TD}/VERSION.txt ]; then cat ${TD}/VERSION.txt; else git describe --tag; fi)(${platform}/${variant})"'
+DEFS += -DCFG_commit='"$(shell if git rev-parse --git-dir >/dev/null 2>&1; then git rev-parse --short HEAD; else echo -; fi)"'
+DEFS += ${xCFG:%=-DCFG_%}
+INCS = ${VPATH:%=-I%} -I ${TD}/${BD}/include ${xINCS}
+CFLAGS += -std=gnu11 ${INCS} ${DEFS} ${xCFLAGS} ${MORECFLAGS}
+LDFLAGS += -L ${TD}/${BD}/lib ${xLDFLAGS}
+LIBS = ${xLIBS} ${SYSLIBS}
+FILES = ${xFILES}
+OCFLAGS = ${xOCFLAGS}
diff --git a/recipes-connectivity/lora/lora-basic-station/tc.uri b/recipes-connectivity/lora/lora-basic-station/tc.uri
new file mode 100644
index 0000000..62ad13e
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station/tc.uri
@@ -0,0 +1 @@
+wss://127.0.0.1:9002