summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrecipes-connectivity/lora/lora-network-server/lora-network-server.init32
-rwxr-xr-xrecipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.init59
2 files changed, 12 insertions, 79 deletions
diff --git a/recipes-connectivity/lora/lora-network-server/lora-network-server.init b/recipes-connectivity/lora/lora-network-server/lora-network-server.init
index 3c2764a..862f97a 100755
--- a/recipes-connectivity/lora/lora-network-server/lora-network-server.init
+++ b/recipes-connectivity/lora/lora-network-server/lora-network-server.init
@@ -59,33 +59,19 @@ dual_cards_installed=false
gps_path="/dev/gps0"
read_lora_hw_info() {
- set +e
-
- hw_id=$(mts-io-sysfs show hw-version)
+ hw_id=$(mts-io-sysfs show product-id 2> /dev/null)
# product-id of first lora card
lora_id=$(mts-io-sysfs show lora/product-id 2> /dev/null)
- if [ $? -ne 0 ]; then
- lora_id="NONE"
- fi
lora_eui=$(mts-io-sysfs show lora/eui 2> /dev/null)
- if [ $? -ne 0 ]; then
- lora_eui=$(mts-io-sysfs show mac-eth)
- lora_eui=${lora_eui:0:8}":FF:FF"${lora_eui:8:16}
- fi
# remove all colons
lora_eui_raw=${lora_eui//:}
lora_hw=$(mts-io-sysfs show lora/hw-version 2> /dev/null)
- if [ $? -ne 0 ]; then
- lora_hw="NONE"
- fi
if [ -d $port1 ] && [[ $(cat $port1/hw-version) =~ "LORA-1.5" ]] && [ -d $port2 ] && [[ $(cat $port2/hw-version) =~ "LORA-1.5" ]]; then
dual_cards_installed=true
elif [ -d $port1 ] && [[ $(cat $port1/hw-version) =~ "MTAC-003" ]] && [ -d $port2 ] && [[ $(cat $port2/hw-version) =~ "MTAC-003" ]]; then
dual_cards_installed=true
- elif [ -d $port1 ] && [[ $(cat $port1/hw-version) =~ "LORA-2G4" ]] && [ -d $port2 ] && [[ $(cat $port2/hw-version) =~ "LORA-2G4" ]]; then
- dual_cards_installed=true
fi
if [[ "$dual_cards_installed" = "true" ]] && [ -d $port2 ] && [[ $(cat $port2/hw-version) =~ "LORA-1.5" || $(cat $port2/hw-version) =~ "LORA-2G4" || $(cat $port2/hw-version) =~ "MTAC-003" ]]; then
@@ -97,20 +83,6 @@ read_lora_hw_info() {
lora_2_eui_raw=${lora_2_eui//:}
fi
- set -e
-
- # Check USB id for Semtech Card
- if [[ $(lsusb | grep 05c9:5740) =~ "05c9:5740" ]] && [[ ! "$lora_id" =~ "$lora_mtac_2g4_id" ]]; then
- lora_id=$lora_mtac_2g4_id
- lora_hw=$lora_2g4_hw
- lora_eui=$(mts-io-sysfs show mac-eth)
- lora_eui=${lora_eui:0:8}":FF:FF"${lora_eui:8:16}
- LORA_CAPABLE=true
- # Check USB id for Semtech Card in Bootloader mode
- elif [[ $(lsusb | grep 0483:df11) =~ "0483:df11" ]]; then
- echo "Semtech 2g4 MTAC card detected in Bootloader Mode, remove power from Conduit and restore"
- return 1
- fi
}
setup_mtcdt3() {
@@ -372,7 +344,7 @@ do_stop() {
start-stop-daemon --stop --quiet --oknodo --pidfile $net_server_pidfile --retry TERM/60/KILL/5
start-stop-daemon --stop --quiet --oknodo --pidfile $pkt_fwd_pidfile --retry 5
start-stop-daemon --stop --quiet --oknodo --pidfile $pkt_fwd_2_pidfile --retry 5
- rm -f $net_server_pidfile $pkt_fwd_pidfile $pkt_fwd_2_pidfile
+ rm -f $net_server_pidfile $pkt_fwd_pidfile
echo "OK"
}
diff --git a/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.init b/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.init
index 6320d2a..6aaf26f 100755
--- a/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.init
+++ b/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.init
@@ -2,7 +2,6 @@
NAME="lora-packet-forwarder"
-LOCK="/var/lock/$NAME"
ENABLED="yes"
@@ -73,33 +72,19 @@ pkt_fwd_options=""
gps_path="/dev/gps0"
read_lora_hw_info() {
- set +e
-
- hw_id=$(mts-io-sysfs show hw-version)
+ hw_id=$(mts-io-sysfs show product-id 2> /dev/null)
# product-id of first lora card
lora_id=$(mts-io-sysfs show lora/product-id 2> /dev/null)
- if [ $? -ne 0 ]; then
- lora_id="NONE"
- fi
lora_eui=$(mts-io-sysfs show lora/eui 2> /dev/null)
- if [ $? -ne 0 ]; then
- lora_eui=$(mts-io-sysfs show mac-eth)
- lora_eui=${lora_eui:0:8}":FF:FF"${lora_eui:8:16}
- fi
# remove all colons
lora_eui_raw=${lora_eui//:}
lora_hw=$(mts-io-sysfs show lora/hw-version 2> /dev/null)
- if [ $? -ne 0 ]; then
- lora_hw="NONE"
- fi
if [ -d $port1 ] && [[ $(cat $port1/hw-version) =~ "LORA-1.5" ]] && [ -d $port2 ] && [[ $(cat $port2/hw-version) =~ "LORA-1.5" ]]; then
dual_cards_installed=true
elif [ -d $port1 ] && [[ $(cat $port1/hw-version) =~ "MTAC-003" ]] && [ -d $port2 ] && [[ $(cat $port2/hw-version) =~ "MTAC-003" ]]; then
dual_cards_installed=true
- elif [ -d $port1 ] && [[ $(cat $port1/hw-version) =~ "LORA-2G4" ]] && [ -d $port2 ] && [[ $(cat $port2/hw-version) =~ "LORA-2G4" ]]; then
- dual_cards_installed=true
fi
if [[ "$dual_cards_installed" = "true" ]] && [ -d $port2 ] && [[ $(cat $port2/hw-version) =~ "LORA-1.5" || $(cat $port2/hw-version) =~ "LORA-2G4" || $(cat $port2/hw-version) =~ "MTAC-003" ]]; then
@@ -111,20 +96,6 @@ read_lora_hw_info() {
lora_2_eui_raw=${lora_2_eui//:}
fi
- set -e
-
- # Check USB id for Semtech Card
- if [[ $(lsusb | grep 05c9:5740) =~ "05c9:5740" ]] && [[ ! "$lora_id" =~ "$lora_mtac_2g4_id" ]]; then
- lora_id=$lora_mtac_2g4_id
- lora_hw=$lora_2g4_hw
- lora_eui=$(mts-io-sysfs show mac-eth)
- lora_eui=${lora_eui:0:8}":FF:FF"${lora_eui:8:16}
- LORA_CAPABLE=true
- # Check USB id for Semtech Card in Bootloader mode
- elif [[ $(lsusb | grep 0483:df11) =~ "0483:df11" ]]; then
- echo "Semtech 2g4 MTAC card detected in Bootloader Mode, remove power from Conduit and restore"
- return 1
- fi
}
hardware_found() {
@@ -437,44 +408,34 @@ do_stop() {
echo -n "Stopping $NAME: "
start-stop-daemon --stop --quiet --oknodo --pidfile $pkt_fwd_pidfile --retry 5
start-stop-daemon --stop --quiet --oknodo --pidfile $pkt_fwd_2_pidfile --retry 5
- rm -f $pkt_fwd_pidfile $pkt_fwd_2_pidfile
+ rm -f $pkt_fwd_pidfile
echo "OK"
}
-force_stop() {
- do_stop
- rm -fr $LOCK
-}
+if [ "$ENABLED" != "yes" ]; then
+ echo "$NAME: disabled in /etc/default"
+ exit
+fi
-function try_lock() {
- if mkdir $LOCK; then
- trap "rm -fr $LOCK" EXIT
- else
- echo "Lora Network Server lock not acquired, resource in use"
- exit 1
- fi
-}
case "$1" in
"start")
- try_lock
- do_start
+ do_start
;;
"stop")
- force_stop
+ do_stop
;;
"restart")
## Stop the service and regardless of whether it was
## running or not, start it again.
- try_lock
do_stop
- sleep 5
do_start
;;
*)
## If no parameters are given, print which are avaiable.
echo "Usage: $0 {start|stop|restart}"
exit 1
- ;;
+ ;;
esac
+