|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +echo -e "\nCommand and Control script for CubeSatSim v1.3.2\n" |
| 4 | + |
| 5 | + FILE=/home/pi/CubeSatSim/command_control |
| 6 | + if [ -f "$FILE" ]; then |
| 7 | + echo "Radio command and control is ON" |
| 8 | +# echo "Turning Command and control to OFF" |
| 9 | +# sudo rm /home/pi/CubeSatSim/command_control |
| 10 | +# echo "rebooting" |
| 11 | +# sudo systemctl stop rpitx |
| 12 | +# sudo reboot now |
| 13 | +# fi |
| 14 | + |
| 15 | + else |
| 16 | + echo "Radio command and control is OFF" |
| 17 | + |
| 18 | + while true |
| 19 | + do |
| 20 | + sleep 60 |
| 21 | + done |
| 22 | + |
| 23 | +# exit 1 |
| 24 | + fi |
| 25 | + |
| 26 | +if [ "$1" = "d" ]; then |
| 27 | + |
| 28 | + echo "debug mode" |
| 29 | + |
| 30 | + debug=1 |
| 31 | + |
| 32 | +else |
| 33 | + |
| 34 | + debug=0 |
| 35 | + |
| 36 | +fi |
| 37 | + |
| 38 | +echo "Waiting 20 seconds for USB" |
| 39 | + |
| 40 | +sleep 20 |
| 41 | + |
| 42 | +FILE=/home/pi/CubeSatSim/command_control_direwolf |
| 43 | +if [[ $(arecord -l | grep "USB Audio Device") ]] && [ -f "$FILE" ]; then |
| 44 | + |
| 45 | + echo "Starting Direwolf DTMF and APRS Command and Control" |
| 46 | + |
| 47 | + if [ "$debug" = "1" ]; then |
| 48 | + |
| 49 | + echo "debug mode" |
| 50 | + |
| 51 | + direwolf -c /home/pi/CubeSatSim/direwolf-cc.conf -t 0l | python3 /home/pi/CubeSatSim/dtmf_aprs_cc.py d |
| 52 | + |
| 53 | + else |
| 54 | + |
| 55 | + direwolf -c /home/pi/CubeSatSim/direwolf-cc.conf -t 0l | python3 /home/pi/CubeSatSim/dtmf_aprs_cc.py |
| 56 | + |
| 57 | + fi |
| 58 | +else |
| 59 | + |
| 60 | + if [ -f "$FILE" ]; then |
| 61 | + |
| 62 | + echo "Direwolf mode set but no USB soundcard detected!" |
| 63 | + |
| 64 | +# echo "Trying RTL-FM" |
| 65 | + |
| 66 | + timeout 1 rtl_test &> out.txt |
| 67 | + if [[ $(grep "No supported" out.txt) ]] ; then |
| 68 | + |
| 69 | + echo "No RTL-SDR detected. Command and control is OFF" |
| 70 | +# sleep 60 |
| 71 | + exit |
| 72 | + |
| 73 | + else |
| 74 | + |
| 75 | + echo "RTL-SDR detected." |
| 76 | + sudo modprobe snd-aloop |
| 77 | + |
| 78 | + value=`aplay -l | grep "Loopback"` |
| 79 | + echo "$value" > /dev/null |
| 80 | + set -- $value |
| 81 | + |
| 82 | + rtl_fm -M fm -f 435M -s 48k | aplay -D hw:${2:0:1},0,0 -r 48000 -t raw -f S16_LE -c 1 & |
| 83 | + |
| 84 | + if [ "$debug" = "1" ]; then |
| 85 | + |
| 86 | + echo "debug mode" |
| 87 | + |
| 88 | + direwolf -r 48000 -c /home/pi/CubeSatSim/groundstation/direwolf/direwolf.conf -t 0l | python3 /home/pi/CubeSatSim/dtmf_aprs_cc.py d |
| 89 | + |
| 90 | + else |
| 91 | + |
| 92 | + direwolf -r 48000 -c /home/pi/CubeSatSim/groundstation/direwolf/direwolf.conf -t 0l | python3 /home/pi/CubeSatSim/dtmf_aprs_cc.py |
| 93 | + |
| 94 | + fi |
| 95 | + |
| 96 | + sleep 5 |
| 97 | + fi |
| 98 | + rm out.txt |
| 99 | + else |
| 100 | + |
| 101 | + echo "Starting Carrier (squelch) Command and Control" |
| 102 | + |
| 103 | + fi |
| 104 | + |
| 105 | + if [ "$1" = "d" ]; then |
| 106 | + |
| 107 | + echo "debug mode" |
| 108 | + |
| 109 | + python3 /home/pi/CubeSatSim/squelch_cc.py d |
| 110 | + |
| 111 | + else |
| 112 | + |
| 113 | + python3 /home/pi/CubeSatSim/squelch_cc.py |
| 114 | + |
| 115 | + fi |
| 116 | +fi |
| 117 | + |
| 118 | +sudo killall -9 direwolf &>/dev/null |
| 119 | +sudo killall -9 rtl_fm &>/dev/null |
| 120 | + |
0 commit comments