-
Notifications
You must be signed in to change notification settings - Fork 9
/
mobilink
executable file
·154 lines (131 loc) · 4.94 KB
/
mobilink
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
#script to connect mobilinkd TNC for ax25
#20200602
#20230304 last edit KM4ACK
################################################################
# #
# # # # # # # ##### # # #
# # # # # # # ## # # # # # #
# # # # # # # # # # # # # #
# ## # # ##### ####### # ## #
# # # # # # # # # # # #
# # # # # # # # # # # #
# # # # # # # # ##### # # #
# #
################################################################
#special thanks to Rich for loaning me a TNC3 to test with
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
clear
KISS=$(pidof kissattach)
DIRE=$(pidof direwolf)
ARDOP=$(pidof piardopc)
TMPFILE=/run/user/$UID/scan.txt
EXISTING=`bluetoothctl paired-devices | grep Mobilinkd`
#see if we already have a TNC paired
#if [ -z "$EXISTING" ]; then
#yad --title="Mobilinkd Error" --width=400 --height=100 \
#--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center --on-top \
#--center --form --text="\r\r\r\rNo Mobilinkd devices paired with this pi. \
#To pair, turn your Mobilinkd on, open a terminal window, and run\r <b>~/patmenu2/mobi-pair</b>\rand then start \
#the mobilinkd modem again." \
#--button=gtk-ok
#exit 1
#fi
#see if we already have a TNC paired
if [ -z "$EXISTING" ]; then
yad --title="Mobilinkd Error" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center --on-top \
--center --form --text="\r\r\r\rNo Mobilinkd devices paired with this pi. \
Turn on your Mobilinkd before attempting to pair." \
--button="Pair Now:1" \
--button="Exit:2"
BUT=$?
if [ "$BUT" = '2' ] || [ "$BUT" = '252' ]; then
exit
elif [ "$BUT" = '1' ]; then
lxterminal -e $HOME/patmenu2/mobi-pair
exit
fi
fi
#verify other services that might interfere aren't running
if [ -n "$KISS" ] || [ -n "$DIRE" ] || [ -n "$ARDOP" ]; then
yad --title="Stop Modems" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center --on-top \
--center --form --text="\r\r\r\rIt appears that other modems are running. Please \
stop all modems and try again." \
--button=gtk-ok
exit 1
fi
#give user some feedback
yad --center --timeout=10 --timeout-indicator=top --no-buttons --height=300 --width=300 \
--title="Scanning" --image $LOGO --window-icon=$LOGO --image-on-top \
--text="Scanning for device. This takes about 20 seconds to complete. \
Another notice will appear once a connection to the device is established." &
#scan for bluetooth device and write to file
hcitool scan > $TMPFILE
#Decide if its a TNC 2 or 3
TNC2=$(grep -i TNC2 $TMPFILE)
TNC3=$(grep -i TNC3 $TMPFILE)
TNC4=$(grep -i TNC4 $TMPFILE)
if [ -n "$TNC2" ]; then
MAC=$(grep -i mobi $TMPFILE | awk '{ print $1 }')
TNC=2
elif [ -n "$TNC3" ]; then
MAC=$(grep -i mobi $TMPFILE | awk '{ print $1 }')
TNC=3
elif [ -n "$TNC4" ]; then
MAC=$(grep -i mobi $TMPFILE | awk '{ print $1 }')
TNC=4
fi
#set correct connection commmand
if [ $TNC = "2" ]; then
CONNECT="sudo rfcomm bind /dev/rfcomm0 $MAC"
elif [ $TNC = "3" ]; then
CONNECT="sudo rfcomm bind /dev/rfcomm0 $MAC 6"
elif [ $TNC = "4" ]; then
CONNECT="sudo rfcomm bind /dev/rfcomm0 $MAC"
fi
#See if device was found and connect if found
if [ -z "$MAC" ]
then
yad --title="Mobilinkd MODEM" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center --on-top \
--center --form --text="\r\r\r\rMobilinkd NOT FOUND" \
--button=gtk-ok
rm $TMPFILE
exit 1
else
#stop things that might conflict
sudo killall kissattach direwolf >> /dev/null 2>&1
yad --center --timeout=6 --timeout-indicator=top --no-buttons --height=300 --width=300 \
--title="Detected" --image $LOGO --window-icon=$LOGO --image-on-top \
--text="Mobilinkd TNC $TNC detected. Just a few more seconds." &
rm $TMPFILE
#create bluetooth->serial connection
$CONNECT &
sleep 5
#create kissattach needed for winlink connections
sudo kissattach /dev/rfcomm0 wl2k &
sleep 3
sudo kissparms -c 1 -p wl2k
fi
#verify that kissattach is running
PIDPIC=$(pidof kissattach)
if [ -z "$PIDPIC" ]
then
yad --title="FAILED" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="The Mobilinkd Modem FAILED to Start" \
--button=gtk-ok
else
yad --title="Mobilinkd MODEM" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center --on-top \
--center --form --text="\r\r\r\rThe Mobilinkd Modem has Started" \
--button=gtk-ok &
fi
#restart pat so terminal window correctly reflects rig control
sudo systemctl restart pat@`whoami`
source $HOME/patmenu2/config
#open pat inbox in browser
export DISPLAY=:0 && xdg-open http://127.0.0.1:$PORT > /dev/null 2>&1 &