From 1d7df5598e3d0f3a7c0698596fafc776d5eb8737 Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Tue, 25 Apr 2023 15:34:25 -0500 Subject: Bug fix: lns init script --- .../lora-network-server/lora-network-server.init | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'recipes-connectivity/lora/lora-network-server') 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 862f97a..3c2764a 100755 --- a/recipes-connectivity/lora/lora-network-server/lora-network-server.init +++ b/recipes-connectivity/lora/lora-network-server/lora-network-server.init @@ -59,19 +59,33 @@ dual_cards_installed=false gps_path="/dev/gps0" read_lora_hw_info() { - hw_id=$(mts-io-sysfs show product-id 2> /dev/null) + set +e + + hw_id=$(mts-io-sysfs show hw-version) # 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 @@ -83,6 +97,20 @@ 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() { @@ -344,7 +372,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 + rm -f $net_server_pidfile $pkt_fwd_pidfile $pkt_fwd_2_pidfile echo "OK" } -- cgit v1.2.3