summaryrefslogtreecommitdiff
path: root/recipes-connectivity/lora/lora-packet-forwarder/mtcdt
diff options
context:
space:
mode:
authorMykyta Dorokhin <mykyta.dorokhin@globallogic.com>2017-05-26 13:46:04 -0500
committerMykyta Dorokhin <mykyta.dorokhin@globallogic.com>2017-05-26 13:47:02 -0500
commitfdffad3583c0c6621284e4d4e9183ef10c3c7c66 (patch)
tree152b370474e1e7ba132a1290e96796962d759388 /recipes-connectivity/lora/lora-packet-forwarder/mtcdt
parent92782f6ed4f50ae753534a9c095e09a8f89fa4d3 (diff)
downloadmeta-mlinux-fdffad3583c0c6621284e4d4e9183ef10c3c7c66.tar.gz
meta-mlinux-fdffad3583c0c6621284e4d4e9183ef10c3c7c66.tar.bz2
meta-mlinux-fdffad3583c0c6621284e4d4e9183ef10c3c7c66.zip
merge lora-packet-forwarder mtcdt and mtcap init scripts into one
Diffstat (limited to 'recipes-connectivity/lora/lora-packet-forwarder/mtcdt')
-rwxr-xr-xrecipes-connectivity/lora/lora-packet-forwarder/mtcdt/lora-packet-forwarder.init121
1 files changed, 0 insertions, 121 deletions
diff --git a/recipes-connectivity/lora/lora-packet-forwarder/mtcdt/lora-packet-forwarder.init b/recipes-connectivity/lora/lora-packet-forwarder/mtcdt/lora-packet-forwarder.init
deleted file mode 100755
index fa4e1b4..0000000
--- a/recipes-connectivity/lora/lora-packet-forwarder/mtcdt/lora-packet-forwarder.init
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/bin/bash
-
-
-NAME="lora-packet-forwarder"
-ENABLED="yes"
-
-
-[ -f /etc/default/$NAME ] && source /etc/default/$NAME
-
-run_dir=/var/run/lora
-conf_dir=/var/config/lora
-conf_file=$conf_dir/global_conf.json
-
-pkt_fwd=$run_dir/1/lora_pkt_fwd
-pkt_fwd_log=/var/log/lora-pkt-fwd-1.log
-pkt_fwd_pidfile=$run_dir/lora-pkt-fwd-1.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"
-
-
-read_card_info() {
- # product-id of first lora card
- lora_id=$(mts-io-sysfs show lora/product-id 2> /dev/null)
- lora_eui=$(mts-io-sysfs show lora/eui 2> /dev/null)
- # remove all colons
- lora_eui_raw=${lora_eui//:/}
- lora_hw=$(mts-io-sysfs show lora/hw-version 2> /dev/null)
-}
-
-card_found() {
- 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
-
- if [[ "$lora_id" =~ "$lora_mtac_id" ]]; then
- if [ "$lora_hw" = "$lora_1_0_hw" ] && [[ ! "$lora_id" =~ .*-SPI ]]; then
- ln -sf /opt/lora/basic_pkt_fwd-usb $pkt_fwd
- else
- ln -sf /opt/lora/lora_pkt_fwd $pkt_fwd
- fi
-
- return 0
- else
- return 1
- fi
-}
-
-
-do_start() {
-
- mkdir -p $run_dir/1
- read_card_info
-
- if ! [ -f $conf_file ]; then
- echo "$0: $conf_file missing"
- exit 1
- fi
-
-
- if card_found; then
- echo "Found $lora_id with $lora_hw hardware"
- else
- echo "$0: MTAC-LORA not detected"
- exit 1
- fi
- echo -n "Starting $NAME: "
- # start packet forwarder
- cp $conf_dir/global_conf.json $run_dir/1/global_conf.json
- /usr/sbin/start-stop-daemon --chdir $run_dir/1 --background --start --make-pidfile \
- --pidfile $pkt_fwd_pidfile --startas /bin/bash -- -c "exec $pkt_fwd"
-
- 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
-