pi-scripts/mobi-connect

117 lines
2.7 KiB
Text
Raw Permalink Normal View History

2019-09-24 08:49:42 -05:00
#!/bin/bash
2019-10-21 13:34:43 -05:00
#REQUIREMENTS
#Mobilinkd TNC 2 or 3
#Pat Winlink (Must already be configured for 2M Packet)
#Help Installing Pat - https://bit.ly/2m42271
#Xastir
#connect to mobilinkd device via bluetooth
#and set for bluetooth->serial connection
#for APRS using xastir or Packet Winlink using Pat
#special thanks to Rich for loaning me a TNC3 to test with
#KM4ACK 20190907
#Last edit 20191021 to add support for mobilinkd TNC3
2019-09-24 08:49:42 -05:00
clear
2019-10-21 13:34:43 -05:00
PAT=$(dpkg --get-selections | grep -w "pat")
XASTIR=$(dpkg --get-selections | grep -w "xastir")
2019-10-21 13:34:43 -05:00
#check if Pat is installed
if [ -z "$PAT" ]
then
echo "Pat was not found on the system"
echo "Pat Winlink is needed for this script"
echo "Please install Pat Winlink"
exit 0
else
echo "Pat Winlink found"
fi
2019-10-21 13:34:43 -05:00
#check if xastir is installed
if [ -z "$XASTIR" ]
then
echo "Xastir is not installed"
echo "Xastir is needed for this script"
echo "Please install Xastir"
exit 0
else
echo "Xastir found"
fi
2019-10-21 13:34:43 -05:00
#give user some feedback
2019-09-24 08:49:42 -05:00
echo "Please Wait"
echo "Scanning for device....this takes ~20 seconds"
2019-10-21 13:34:43 -05:00
2019-09-24 08:49:42 -05:00
#scan for bluetooth device and write to file
2019-10-21 13:34:43 -05:00
hcitool scan > $HOME/Desktop/scan.txt
2019-09-24 08:49:42 -05:00
echo "Scan complete"
2019-10-21 13:34:43 -05:00
#Decide if its a TNC 2 or 3
TNC2=$(cat $HOME/Desktop/scan.txt | grep -i TNC2)
TNC3=$(cat $HOME/Desktop/scan.txt | grep -i TNC3)
if [ -z "$TNC2" ]
then
MAC=$(cat $HOME/Desktop/scan.txt | grep -i mobi | awk '{ print $1 }')
TNC=3
elif [ -z "$TNC3" ]
then
MAC=$(cat $HOME/Desktop/scan.txt | grep -i mobi | awk '{ print $1 }')
TNC=2
fi
#set correct connection commmand
if [ $TNC = "2" ]
then
CONNECT="sudo rfcomm connect /dev/rfcomm0 $MAC"
elif [ $TNC = "3" ]
then
CONNECT="sudo rfcomm connect /dev/rfcomm0 $MAC 6"
fi
2019-09-24 08:49:42 -05:00
#See if device was found and connect if found
2019-10-21 13:34:43 -05:00
if [ -z "$MAC" ]
2019-09-24 08:49:42 -05:00
then
echo "Mobilinkd not found"
2019-10-21 13:34:43 -05:00
rm $HOME/Desktop/scan.txt
2019-09-24 08:49:42 -05:00
else
2019-10-21 13:34:43 -05:00
#stop things that might conflict
sudo killall js8call kissattach direwolf >> /dev/null 2>&1
echo "Mobilinkd TNC $TNC detected"
2019-09-24 08:49:42 -05:00
echo "Creating the connection"
2019-10-21 13:34:43 -05:00
rm $HOME/Desktop/scan.txt
#create bluetooth->serial connection
$CONNECT &
2019-09-24 08:49:42 -05:00
sleep 5
2019-10-21 13:34:43 -05:00
echo ""
echo ""
echo ""
echo "If you choose to not start a Winlink Session"
2019-09-24 08:49:42 -05:00
echo "Then APRS will be started instead"
read -p "Would you like to run a Winlink Session? y/n " winlink
if [ $winlink = "y" ]
then
echo "starting kissattach for winlink"
2019-10-21 13:34:43 -05:00
#create kissattach needed for winlink connections
2019-09-24 08:49:42 -05:00
sudo kissattach /dev/rfcomm0 wl2k &
sleep 2
2019-10-21 13:34:43 -05:00
#start pat winlink
2019-10-27 09:31:18 -05:00
pat http
2019-09-24 08:49:42 -05:00
sleep 1
2019-10-21 13:34:43 -05:00
echo ""
echo ""
2019-09-24 08:49:42 -05:00
echo "Both services started and ready"
else
2019-10-21 13:34:43 -05:00
echo ""
echo ""
2019-09-24 08:49:42 -05:00
echo "winlink not started"
echo "Start xastir for APRS-Digipeater"
sleep 1
2019-10-21 13:34:43 -05:00
#start xastir
2019-10-27 09:31:18 -05:00
sudo xastir
2019-09-24 08:49:42 -05:00
fi
fi
exit 0