summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Sharma <harsh.sharma@multitech.com>2018-12-31 17:00:04 -0600
committerJohn Klug <john.klug@multitech.com>2019-07-03 17:08:20 -0500
commitb455a1f595ba91e32734a9347028481029cbc407 (patch)
treecde440ac5e31e6af20da37e4c80518a539636cd7
parentad1ae93dae00cec18c681b699801b14a697bcf14 (diff)
downloadmeta-mlinux-b455a1f595ba91e32734a9347028481029cbc407.tar.gz
meta-mlinux-b455a1f595ba91e32734a9347028481029cbc407.tar.bz2
meta-mlinux-b455a1f595ba91e32734a9347028481029cbc407.zip
Added 2.1 and dual card support to lns init script
-rwxr-xr-xrecipes-connectivity/lora/lora-network-server/lora-network-server.init195
1 files changed, 141 insertions, 54 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 a55be0b..88ea271 100755
--- a/recipes-connectivity/lora/lora-network-server/lora-network-server.init
+++ b/recipes-connectivity/lora/lora-network-server/lora-network-server.init
@@ -13,29 +13,41 @@ run_dir=/var/run/lora
conf_dir=/var/config/lora
conf_file=$conf_dir/lora-network-server.conf
-
net_server=/opt/lora/lora-network-server
net_server_log=/var/log/lora-network-server.log
net_server_pidfile=$run_dir/$NAME.pid
-
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
+pkt_fwd_2=$run_dir/2/lora_pkt_fwd
+pkt_fwd_2_log=/var/log/lora-pkt-fwd-2.log
+pkt_fwd_2_pidfile=$run_dir/lora-pkt-fwd-2.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_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=""
+dual_cards_installed=false
+gps_path="/dev/gps0"
+
read_lora_hw_info() {
# product-id of first lora card
lora_id=$(mts-io-sysfs show lora/product-id 2> /dev/null)
@@ -43,62 +55,112 @@ read_lora_hw_info() {
# remove all colons
lora_eui_raw=${lora_eui//:}
lora_hw=$(mts-io-sysfs show lora/hw-version 2> /dev/null)
-}
+ if [ -d $port2 ] && [[ $(cat $port2/hw-version) =~ "LORA-1.5" ]]; then
+ # product-id of first lora card
+ lora_2_id=$(mts-io-sysfs show lora-2/product-id 2> /dev/null)
+ lora_2_hw=$(mts-io-sysfs show lora-2/hw-version 2> /dev/null)
+ lora_2_eui=$(mts-io-sysfs show lora-2/eui 2> /dev/null)
+ # remove all colons
+ lora_2_eui_raw=${lora_2_eui//:}
+ 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
+ fi
+}
hardware_found() {
- # MTCDT only
+ if [[ "$lora_id" =~ "$lora_mtac_g_id" ]]; then
+ setup_mtcdt_2_1
+ elif [[ "$lora_id" =~ "$lora_mtac_id" ]]; then
+ setup_mtcdt
+ elif [[ "$lora_id" =~ "$lora_mtcap_id" ]]; then
+ setup_mtcap
+ else
+ return 1
+ fi
+}
+
+setup_mtcdt_2_1() {
+ ln -sf /dev/spidev32766.2 /dev/spidev0.0
+
+ if [[ "$lora_id" = "$lora_mtac_g16_id868" ]]; then
+ GLOBAL_CONF=/opt/lora/global_conf.json.MTAC_LORA_2_1_loc_single_antenna_16ch_EU868
+ elif [[ "$lora_id" = "$lora_mtac_g16_id915" ]]; then
+ GLOBAL_CONF=/opt/lora/global_conf.json.MTAC_LORA_2_1_loc_single_antenna_16ch_US915
+ elif [[ "$lora_id" = "$lora_mtac_g16_id868" ]]; then
+ GLOBAL_CONF=/opt/lora/global_conf.json.MTAC_LORA_2_1_test_single_antenna_64ch_8x8_EU868
+ elif [[ "$lora_id" = "$lora_mtac_g64_id915" ]]; then
+ GLOBAL_CONF=/opt/lora/global_conf.json.MTAC_LORA_2_1_loc_single_antenna_64ch_US915
+ else
+ return 1
+ fi
+
+ set +e
+ diff $GLOBAL_CONF /opt/lora/global_conf.json 1>/dev/null
+ if [ $? -ne 0 ]; then
+ cp $GLOBAL_CONF /opt/lora/global_conf.json
+ fi
+ set -e
+
+ ln -sf /opt/lora/pkt_forwarder $pkt_fwd
+
+ pkt_fwd_options=" -g"
+}
+
+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
-
- if [[ "$lora_id" =~ "$lora_mtac_id" ]]; then
- GLOBAL_CONF=/opt/lora/global_conf.json.MTAC_LORA_1_0
- if [ "$lora_hw" = "$lora_1_0_hw" ] && [[ ! "$lora_id" =~ .*-SPI ]]; then
- ln -sf /opt/lora/basic_pkt_fwd-usb $pkt_fwd
- else
- if [ "$lora_hw" = "$lora_1_5_h_hw" ]; then
- GLOBAL_CONF=/opt/lora/global_conf.json.MTAC_LORA_1_5
- fi
- ln -sf /opt/lora/lora_pkt_fwd $pkt_fwd
- fi
-
- diff $GLOBAL_CONF /opt/lora/global_conf.json &> /dev/null
- if [ $? -ne 0 ]; then
- cp $GLOBAL_CONF /opt/lora/global_conf.json
- fi
-
- return 0
- elif [[ "$lora_id" =~ "$lora_mtcap_id" ]]; then
- if [ "$lora_id" = "$lora_mtcap_id868" ]; then
- GLOBAL_CONF=/opt/lora/global_conf.json.MTCAP_LORA_1_5.EU868
- elif [ "$lora_id" = "$lora_mtcap_id915" ]; then
- GLOBAL_CONF=/opt/lora/global_conf.json.MTCAP_LORA_1_5.US915
- else
- return 1
+ GLOBAL_CONF=/opt/lora/global_conf.json.MTAC_LORA_1_0
+ if [ "$lora_hw" = "$lora_1_0_hw" ] && [[ ! "$lora_id" =~ .*-SPI ]]; then
+ ln -sf /opt/lora/basic_pkt_fwd-usb $pkt_fwd
+ else
+ if [ "$lora_hw" = "$lora_1_5_h_hw" ]; then
+ GLOBAL_CONF=/opt/lora/global_conf.json.MTAC_LORA_1_5
fi
-
ln -sf /opt/lora/lora_pkt_fwd $pkt_fwd
+ ln -sf /opt/lora/lora_pkt_fwd $pkt_fwd_2
+ fi
- diff $GLOBAL_CONF /opt/lora/global_conf.json &> /dev/null
- if [ $? -ne 0 ]; then
- cp $GLOBAL_CONF /opt/lora/global_conf.json
- fi
+ # ignore error of diff command
+ set +e
+ diff $GLOBAL_CONF /opt/lora/global_conf.json 1>/dev/null
+ if [ $? -ne 0 ]; then
+ cp $GLOBAL_CONF /opt/lora/global_conf.json
+ fi
+ set -e
+
+ return 0
+}
- return 0
+setup_mtcap() {
+ if [ "$lora_id" = "$lora_mtcap_id868" ]; then
+ GLOBAL_CONF=/opt/lora/global_conf.json.MTCAP_LORA_1_5.EU868
+ elif [ "$lora_id" = "$lora_mtcap_id915" ]; then
+ GLOBAL_CONF=/opt/lora/global_conf.json.MTCAP_LORA_1_5.US915
else
- echo Lora hardware not detected
return 1
fi
-}
+ ln -sf /opt/lora/lora_pkt_fwd $pkt_fwd
+
+ set +e
+ diff $GLOBAL_CONF /opt/lora/global_conf.json 1>/dev/null
+ if [ $? -ne 0 ]; then
+ cp $GLOBAL_CONF /opt/lora/global_conf.json
+ fi
+ set -e
+
+ return 0
+}
do_start() {
# create run directory
mkdir -p $run_dir/1
- rm -rf $run_dir/1/*
+ mkdir -p $run_dir/2
read_lora_hw_info
@@ -109,23 +171,51 @@ do_start() {
if hardware_found; then
echo "Found $lora_id with $lora_hw hardware"
+ mts-io-sysfs store lora/reset 0
+ if [ "$dual_cards_installed" == true ]; then
+ mts-io-sysfs store lora-2/reset 0
+ fi
+ sleep 0.25
+ mts-io-sysfs store lora/reset 1
+ if [ "$dual_cards_installed" == true ]; then
+ mts-io-sysfs store lora-2/reset 1
+ fi
+ sleep 0.25
else
echo "$0: Lora hardware not detected"
- exit 1
+ # Use MAC Address for lora eui
+ lora_eui=$(mts-io-sysfs show mac-eth)
+ lora_eui=${lora_eui:0:8}":FF:FF"${lora_eui:8:16}
+ lora_hw=$lora_mtcap_id915
+ lora_id=$lora_1_5_h_hw
+ no_lora_hw=true
fi
+
+ if [ "$dual_cards_installed" == "true" ]; then
+ lora_2_args="--lora-hw-2 $lora_2_hw --lora-prod-2 $lora_2_id --lora-eui-2 $lora_2_eui"
+ fi
+
echo -n "Starting $NAME: "
# start network server
- start-stop-daemon --start --background --make-pidfile \
- --pidfile $net_server_pidfile --startas /bin/bash -- -c "exec $net_server \
- -c $conf_file --lora-eui $lora_eui --lora-prod-1 $lora_id --lora-hw-1 $lora_hw \
+ start-stop-daemon --start --background --make-pidfile \
+ --pidfile $net_server_pidfile --startas /bin/bash -- -c "exec $angel $net_server \
+ -c $conf_file --lora-eui $lora_eui --lora-hw-1 $lora_hw --lora-prod-1 $lora_id $lora_2_args \
--lora-path $run_dir \
- --noconsole -l $net_server_log >> $net_server_log 2>&1"
-
- sleep 4
-
- # start packet forwarder
- /usr/sbin/start-stop-daemon --chdir $run_dir/1 --background --start --make-pidfile \
- --pidfile $pkt_fwd_pidfile --startas /bin/bash -- -c "exec $pkt_fwd "
+ --noconsole 2>&1"
+
+ if [ "$no_lora_hw" != "true" ]; then
+ # start packet forwarder
+ sleep 2
+ /usr/sbin/start-stop-daemon --chdir $run_dir/1 --start --background --make-pidfile \
+ --pidfile $pkt_fwd_pidfile --startas /bin/bash \
+ -- -c "exec $angel $pkt_fwd $pkt_fwd_options 2>&1 >> $pkt_fwd_log"
+
+ if [ "$dual_cards_installed" == "true" ]; then
+ /usr/sbin/start-stop-daemon --chdir $run_dir/2 --start --background --make-pidfile \
+ --pidfile $pkt_fwd_2_pidfile --startas /bin/bash \
+ -- -c "exec $angel $pkt_fwd_2 $pkt_fwd_options 2>&1 >> $pkt_fwd_2_log"
+ fi
+ fi
renice -n -20 -p $(pgrep lora-network-se)
renice -n -20 -p $(pgrep $(basename $pkt_fwd))
@@ -163,9 +253,6 @@ function try_lock() {
fi
}
-
-
-
case "$1" in
"start")
try_lock