summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--recipes-connectivity/lora/lora-basic-station-sx1303/lora-basic-station.default2
-rwxr-xr-xrecipes-connectivity/lora/lora-basic-station-sx1303/lora-basic-station.init158
-rw-r--r--recipes-connectivity/lora/lora-basic-station-sx1303/mtcap-station.conf47
-rw-r--r--recipes-connectivity/lora/lora-basic-station-sx1303/mtcdt-station.conf47
-rw-r--r--recipes-connectivity/lora/lora-basic-station-sx1303/setup.gmk91
-rw-r--r--recipes-connectivity/lora/lora-basic-station-sx1303/tc.uri1
-rw-r--r--recipes-connectivity/lora/lora-basic-station-sx1303_2.0.6-5.bb56
-rw-r--r--recipes-connectivity/lora/lora-gateway-sx1303_2.0.19.bb (renamed from recipes-connectivity/lora/lora-gateway-sx1303_2.0.17.bb)0
8 files changed, 402 insertions, 0 deletions
diff --git a/recipes-connectivity/lora/lora-basic-station-sx1303/lora-basic-station.default b/recipes-connectivity/lora/lora-basic-station-sx1303/lora-basic-station.default
new file mode 100644
index 0000000..0f92640
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station-sx1303/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-sx1303/lora-basic-station.init b/recipes-connectivity/lora/lora-basic-station-sx1303/lora-basic-station.init
new file mode 100755
index 0000000..7ebeea2
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station-sx1303/lora-basic-station.init
@@ -0,0 +1,158 @@
+#!/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() {
+ 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-sx1303/mtcap-station.conf b/recipes-connectivity/lora/lora-basic-station-sx1303/mtcap-station.conf
new file mode 100644
index 0000000..baa9793
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station-sx1303/mtcap-station.conf
@@ -0,0 +1,47 @@
+{
+ "SX1301_conf": {
+ "lorawan_public": true,
+ "clksrc": 0,
+ "pps": true,
+ "device": "/dev/spidev0.0",
+ "chan_FSK": {"bandwidth": 125000, "datarate": 50000, "enable": true, "if": 300000, "radio": 0},
+ "chan_Lora_std": {"bandwidth": 250000, "enable": true, "if": -200000, "radio": 0, "spread_factor": 7},
+ "chan_multiSF_0": {"enable": true, "if": -400000, "radio": 0},
+ "chan_multiSF_1": {"enable": true, "if": -200000, "radio": 0},
+ "chan_multiSF_2": {"enable": true, "if": 0, "radio": 0},
+ "chan_multiSF_3": {"enable": true, "if": -400000, "radio": 1},
+ "chan_multiSF_4": {"enable": true, "if": -200000, "radio": 1},
+ "chan_multiSF_5": {"enable": true, "if": 0, "radio": 1},
+ "chan_multiSF_6": {"enable": true, "if": 200000, "radio": 1},
+ "chan_multiSF_7": {"enable": true, "if": 400000, "radio": 1},
+ "radio_0": {"enable": true, "freq": 923600000, "rssi_offset": -162, "tx_enable": true, "type": "SX1257"},
+ "radio_1": {"enable": true, "freq": 922600000, "rssi_offset": -162, "tx_enable": false, "type": "SX1257"},
+ "tx_gain_lut": [
+ {"dac_gain": 3,"dig_gain":2,"mix_gain":15,"pa_gain":1,"rf_power":10},
+ {"dac_gain": 3,"dig_gain":3,"mix_gain":8,"pa_gain":3,"rf_power":11},
+ {"dac_gain": 3,"dig_gain":2,"mix_gain":11,"pa_gain":2,"rf_power":12},
+ {"dac_gain": 3,"dig_gain":0,"mix_gain":10,"pa_gain":2,"rf_power":13},
+ {"dac_gain": 3,"dig_gain":3,"mix_gain":14,"pa_gain":2,"rf_power":14},
+ {"dac_gain": 3,"dig_gain":1,"mix_gain":12,"pa_gain":2,"rf_power":15},
+ {"dac_gain": 3,"dig_gain":0,"mix_gain":12,"pa_gain":2,"rf_power":16},
+ {"dac_gain": 3,"dig_gain":2,"mix_gain":14,"pa_gain":2,"rf_power":17},
+ {"dac_gain": 3,"dig_gain":2,"mix_gain":15,"pa_gain":2,"rf_power":18},
+ {"dac_gain": 3,"dig_gain":1,"mix_gain":15,"pa_gain":2,"rf_power":19},
+ {"dac_gain": 3,"dig_gain":0,"mix_gain":9,"pa_gain":3,"rf_power":20},
+ {"dac_gain": 3,"dig_gain":1,"mix_gain":10,"pa_gain":3,"rf_power":21},
+ {"dac_gain": 3,"dig_gain":0,"mix_gain":10,"pa_gain":3,"rf_power":22},
+ {"dac_gain": 3,"dig_gain":0,"mix_gain":11,"pa_gain":3,"rf_power":23},
+ {"dac_gain": 3,"dig_gain":2,"mix_gain":14,"pa_gain":3,"rf_power":24},
+ {"dac_gain": 3,"dig_gain":0,"mix_gain":15,"pa_gain":3,"rf_power":25}
+ ]
+ },
+ "station_conf": {
+ "routerid": "<WILL-BE-AUTO-REPLACED-WITH-LORA-EUI>",
+ "euiprefix": "::0",
+ "log_file": "stderr",
+ "log_level": "INFO",
+ "log_size": 100000,
+ "log_rotate": 3,
+ "TC_TIMEOUT": "2s"
+ }
+}
diff --git a/recipes-connectivity/lora/lora-basic-station-sx1303/mtcdt-station.conf b/recipes-connectivity/lora/lora-basic-station-sx1303/mtcdt-station.conf
new file mode 100644
index 0000000..8cfa72d
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station-sx1303/mtcdt-station.conf
@@ -0,0 +1,47 @@
+{
+ "SX1301_conf": {
+ "lorawan_public": true,
+ "clksrc": 0,
+ "pps": true,
+ "device": "/dev/spidev0.0",
+ "chan_FSK": {"bandwidth": 125000, "datarate": 50000, "enable": true, "if": 300000, "radio": 0},
+ "chan_Lora_std": {"bandwidth": 250000, "enable": true, "if": -200000, "radio": 0, "spread_factor": 7},
+ "chan_multiSF_0": {"enable": true, "if": -400000, "radio": 0},
+ "chan_multiSF_1": {"enable": true, "if": -200000, "radio": 0},
+ "chan_multiSF_2": {"enable": true, "if": 0, "radio": 0},
+ "chan_multiSF_3": {"enable": true, "if": -400000, "radio": 1},
+ "chan_multiSF_4": {"enable": true, "if": -200000, "radio": 1},
+ "chan_multiSF_5": {"enable": true, "if": 0, "radio": 1},
+ "chan_multiSF_6": {"enable": true, "if": 200000, "radio": 1},
+ "chan_multiSF_7": {"enable": true, "if": 400000, "radio": 1},
+ "radio_0": {"enable": true, "freq": 923600000, "rssi_offset": -162, "tx_enable": true, "type": "SX1257"},
+ "radio_1": {"enable": true, "freq": 922600000, "rssi_offset": -162, "tx_enable": false, "type": "SX1257"},
+ "tx_gain_lut": [
+ {"dig_gain": 0, "mix_gain": 11, "pa_gain": 0, "dac_gain": 3, "rf_power": -6},
+ {"dig_gain": 0, "mix_gain": 13, "pa_gain": 0, "dac_gain": 3, "rf_power": -3},
+ {"dig_gain": 0, "mix_gain": 9, "pa_gain": 1, "dac_gain": 3, "rf_power": 0},
+ {"dig_gain": 0, "mix_gain": 10, "pa_gain": 1, "dac_gain": 3, "rf_power": 3},
+ {"dig_gain": 0, "mix_gain": 12, "pa_gain": 1, "dac_gain": 3, "rf_power": 6},
+ {"dig_gain": 0, "mix_gain": 10, "pa_gain": 2, "dac_gain": 3, "rf_power": 10},
+ {"dig_gain": 0, "mix_gain": 11, "pa_gain": 2, "dac_gain": 3, "rf_power": 11},
+ {"dig_gain": 0, "mix_gain": 11, "pa_gain": 2, "dac_gain": 3, "rf_power": 12},
+ {"dig_gain": 2, "mix_gain": 12, "pa_gain": 2, "dac_gain": 3, "rf_power": 13},
+ {"dig_gain": 0, "mix_gain": 13, "pa_gain": 2, "dac_gain": 3, "rf_power": 14},
+ {"dig_gain": 0, "mix_gain": 15, "dac_gain": 3, "pa_gain": 2, "rf_power": 16},
+ {"dig_gain": 0, "mix_gain": 10, "pa_gain": 3, "dac_gain": 3, "rf_power": 20},
+ {"dig_gain": 0, "mix_gain": 12, "dac_gain": 3, "pa_gain": 3, "rf_power": 23},
+ {"dig_gain": 0, "dac_gain": 3, "mix_gain": 13, "pa_gain": 3, "rf_power": 25},
+ {"dig_gain": 0, "dac_gain": 3, "mix_gain": 15, "pa_gain": 3, "rf_power": 26},
+ {"dig_gain": 0, "mix_gain": 15, "dac_gain": 3, "pa_gain": 3, "rf_power": 27}
+ ]
+ },
+ "station_conf": {
+ "routerid": "<WILL-BE-AUTO-REPLACED-WITH-LORA-EUI>",
+ "euiprefix": "::0",
+ "log_file": "stderr",
+ "log_level": "INFO",
+ "log_size": 100000,
+ "log_rotate": 3,
+ "TC_TIMEOUT": "2s"
+ }
+}
diff --git a/recipes-connectivity/lora/lora-basic-station-sx1303/setup.gmk b/recipes-connectivity/lora/lora-basic-station-sx1303/setup.gmk
new file mode 100644
index 0000000..5811673
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station-sx1303/setup.gmk
@@ -0,0 +1,91 @@
+# -*- makefile -*-
+
+# Top dir of s2core
+# - override accordingly in makefile including this setup.gmk
+
+platform ?= mlinux
+variant ?= sx1303
+
+
+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 no_leds ral_lgw prod sx1302 lgw1
+
+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-sx1303/tc.uri b/recipes-connectivity/lora/lora-basic-station-sx1303/tc.uri
new file mode 100644
index 0000000..62ad13e
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station-sx1303/tc.uri
@@ -0,0 +1 @@
+wss://127.0.0.1:9002
diff --git a/recipes-connectivity/lora/lora-basic-station-sx1303_2.0.6-5.bb b/recipes-connectivity/lora/lora-basic-station-sx1303_2.0.6-5.bb
new file mode 100644
index 0000000..35e13a6
--- /dev/null
+++ b/recipes-connectivity/lora/lora-basic-station-sx1303_2.0.6-5.bb
@@ -0,0 +1,56 @@
+DESCRIPTION = "LoRa Basic Station"
+HOMEPAGE = "https://github.com/lorabasics/basicstation"
+PRIORITY = "optional"
+SECTION = "console/utils"
+# Semtech license is a modified BSD-style license
+LICENSE = "Proprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=26699ffb0048fefa02c871c2485867ee"
+DEPENDS = "lora-gateway-sx1303 logrotate lora-logging mbedtls"
+RDEPENDS_${PN} += "bash"
+PR = "r4"
+
+# SRCREV = "9bf824154731cbe78366cbffa1b0c6bd0354b66f"
+SRCREV = "${PV}"
+
+SRC_URI = "git://github.com/MultiTechSystems/basicstation.git;protocol=https;branch=master; \
+ file://setup.gmk \
+ file://lora-basic-station.init \
+ file://lora-basic-station.default \
+ file://tc.uri \
+ file://mtcap-station.conf \
+ file://mtcdt-station.conf \
+"
+
+S = "${WORKDIR}/git"
+B = "${S}"
+
+LORA_DIR = "/opt/lora"
+
+export LGW_PATH = "${STAGING_LIBDIR}/lora"
+export LGW_INC = "${STAGING_INCDIR}/lora"
+
+CFLAGS += "-DNODEBUG -I${STAGING_INCDIR} -I${WORKDIR}/git/libtools -I${STAGING_INCDIR}/lora -I${STAGING_INCDIR}/lora/lgw-sx1303 -I${WORKDIR}/git/deps -Iinc -I. -std=gnu11 -L${WORKDIR}/git/libtools -L${STAGING_LIBDIR}/lora/lgw-sx1303/lgw/ -L${STAGING_LIBDIR}/lora"
+
+do_compile() {
+ cp ${WORKDIR}/setup.gmk ${S}/setup.gmk
+ oe_runmake
+}
+
+do_install() {
+ install -d ${D}${LORA_DIR}
+ install -m 755 ${S}/build-mlinux-sx1303/bin/station ${D}${LORA_DIR}/station-sx1303
+}
+
+do_install_append_mtcdt() {
+ install -d ${D}${LORA_DIR}
+ install -m 755 ${WORKDIR}/mtcdt-station.conf ${D}${LORA_DIR}/station-sx1303.conf
+}
+
+
+
+FILES_${PN} += "${LORA_DIR}"
+
+# disable this on purpose for dev purposes
+do_rm_work() {
+ echo "skipping"
+}
diff --git a/recipes-connectivity/lora/lora-gateway-sx1303_2.0.17.bb b/recipes-connectivity/lora/lora-gateway-sx1303_2.0.19.bb
index 312eda4..312eda4 100644
--- a/recipes-connectivity/lora/lora-gateway-sx1303_2.0.17.bb
+++ b/recipes-connectivity/lora/lora-gateway-sx1303_2.0.19.bb