diff options
author | Andrii Pientsov <andrii.pientsov@globallogic.com> | 2020-05-27 15:01:52 +0300 |
---|---|---|
committer | Andrii Pientsov <andrii.pientsov@globallogic.com> | 2020-05-27 15:01:52 +0300 |
commit | 432af19f672a64228e1b70b0b25abb5a0ee7ee30 (patch) | |
tree | ae3b3b0c6748c55cee7b86fec5b12e38f1312d58 /recipes-connectivity/lora/lora-network-server | |
parent | 1cf08fc9f3c0d5be9318e8b09718b0b379678ca4 (diff) | |
download | meta-mlinux-432af19f672a64228e1b70b0b25abb5a0ee7ee30.tar.gz meta-mlinux-432af19f672a64228e1b70b0b25abb5a0ee7ee30.tar.bz2 meta-mlinux-432af19f672a64228e1b70b0b25abb5a0ee7ee30.zip |
Move lora-related changes from meta-mlinux (branch multiarch5-thud)
Diffstat (limited to 'recipes-connectivity/lora/lora-network-server')
-rwxr-xr-x | recipes-connectivity/lora/lora-network-server/lora-network-server.init | 84 |
1 files changed, 63 insertions, 21 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 3ec02a0..61af0f4 100755 --- a/recipes-connectivity/lora/lora-network-server/lora-network-server.init +++ b/recipes-connectivity/lora/lora-network-server/lora-network-server.init @@ -38,6 +38,12 @@ lora_mtcap_id="MTCAP-LORA" lora_mtcap_id868="MTCAP-LORA-868" lora_mtcap_id915="MTCAP-LORA-915" +mtcdt3_id="MTCDT3" +lora_mtcdt3_id="MTCDT3-LORA" +lora_mtcdt3_id868="MTCDT3-LORA-868" +lora_mtcdt3_id915="MTCDT3-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" @@ -49,6 +55,8 @@ dual_cards_installed=false gps_path="/dev/gps0" read_lora_hw_info() { + 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) lora_eui=$(mts-io-sysfs show lora/eui 2> /dev/null) @@ -69,8 +77,22 @@ read_lora_hw_info() { fi } +setup_mtcdt3() { + dual_cards_installed=true + ln -sf /opt/lora/lora_pkt_fwd $pkt_fwd + ln -sf /opt/lora/lora_pkt_fwd $pkt_fwd_2 + + lora_eui=$(mts-io-sysfs show lora/eui) + lora_2_eui=$(mts-io-sysfs show lora-2/eui) + + lora_2_hw=$lora_hw + lora_2_id=$lora_id +} + hardware_found() { - if [[ "$lora_id" =~ "$lora_mtac_g_id" ]]; then + if [[ "$hw_id" =~ "$mtcdt3_id" ]]; then + setup_mtcdt3 + elif [[ "$lora_id" =~ "$lora_mtac_g_id" ]]; then setup_mtcdt_2_1 elif [[ "$lora_id" =~ "$lora_mtac_id" ]]; then setup_mtcdt @@ -181,16 +203,30 @@ 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 + + if [[ "$hw_id" =~ "$mtcdt3_id" ]]; then + mts-io-sysfs store lora/reset 0 + mts-io-sysfs store lora-2/reset 0 + sleep 0.25 + mts-io-sysfs store lora/reset 1 + mts-io-sysfs store lora-2/reset 1 + sleep 0.25 + elif [[ "$lora_id" =~ "$lora_mtac_g_id" ]]; then + echo Resetting 2.1 LoRa + /usr/sbin/mts-util-lora2-reset -g -f >/dev/null 2>&1 + sleep 0.25 + else + 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 fi - sleep 0.25 else echo "$0: Lora hardware not detected" # Use MAC Address for lora eui @@ -215,7 +251,11 @@ do_start() { if [ "$no_lora_hw" != "true" ]; then # start packet forwarder - sleep 2 + if [[ "$hw_id" =~ "$mtcdt3_id" ]]; then + sleep 0.5 + else + sleep 4 + fi /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" @@ -223,13 +263,14 @@ do_start() { 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" + -- -c "exec $angel $pkt_fwd_2 $pkt_fwd_options -l $pkt_fwd_2_log" fi fi - renice -n -20 -p $(pgrep lora-network-se) - renice -n -20 -p $(pgrep $(basename $pkt_fwd)) - + if [[ ! "$hw_id" =~ "$mtcdt3_id" ]]; then + renice -n -20 -p $(pgrep lora-network-se) + renice -n -20 -p $(pgrep $(basename $pkt_fwd)) + fi echo "OK" } @@ -239,6 +280,7 @@ do_stop() { echo -n "Stopping $NAME: " 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 echo "OK" } @@ -249,12 +291,12 @@ if [ "$ENABLED" != "yes" ]; then exit fi -force_stop() { - do_stop - rm -fr $LOCK -} - -function try_lock() { +force_stop() { + do_stop + rm -fr $LOCK +} + +function try_lock() { if mkdir $LOCK; then trap "rm -fr $LOCK" EXIT else |