1
0
mirror of https://github.com/km4ack/patmenu2.git synced 2025-05-16 23:00:11 -07:00

Merge pull request #44 from km4ack/dev

Dev
This commit is contained in:
KM4ACK 2022-03-10 07:47:25 -06:00 committed by GitHub
commit a3bb36ab1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 239 additions and 34 deletions

View File

@ -1,7 +1,13 @@
release=2.6.1
release=2.7.0
Changelog
2.7.0 add mobi-pair script to assist with pairing mobilinkd devices
add mobilinkd wired modem connection (Doesn't work with version 2)
improve mobilinkd modem start
clean up initial config file
add new custom warning feature
fix path for repairing config file
2.6.1 improve GPS weather accuracy
update ARDOP modem start
update Packet modem start

21
config
View File

@ -1,19 +1,10 @@
#20191230 KM4ACK
#This setup is designed to work with a VOX soundcard (ie Signalink)
#If using a VOX soundcard or radio with a VOX soundcard built in
#simply edit the call sign below to yours and change
#RIGCONTROL=no to RIGCONTROL=yes below.
#Now test the setup. Be sure you have FLRIG open
#and configured for your radio.
#AMRRON operators see bottom of this file for trimode.
#last edit 04MARCH2022 KM4ACK
#change next line to your call sign
MYCALLSIGN=N0CALL
#enter your piardopc command on the line below
#Be sure to not delete the quotation marks.
#command to start ARDOP modem
ARDOP="$HOME/ardop/./piardopc 8515 plughw:1,0 plughw:1,0"
#Path to ardop-gui if installed
@ -52,22 +43,18 @@ MODEHF=USB
#Mode used for packet digital comms on your radio
MODE2M=FM
#port number used by pat html service
#pat default is 8080. I prefer 5000
#port number for pat inbox ie. 127.0.0.1:8080
PORT=8080
#Path to log file
LOG=$HOME/Documents/mylog.txt
#Below this line is only useful to AMRRON operators. Others shouldn't edit below this line.
#NOTE:The amrron portion of this script is still experimental.
#NOTE:The AMRRON portion of this script is still experimental.
#set next line to yes for tri-mode setup
AMRRON=no
#amrron operaters should save/exit this config file after setting above to yes and then run
# bash ~/patmenu/trimode
#to enable trimode ops

View File

@ -25,6 +25,8 @@ SETTINGS=$(yad --form --width=600 --text-align=center --center --title="Pat Menu
--field="Pat Port" "$PORT" \
--field="Log File Location" "$LOG" \
--field="AmRRON":CB "no|yes" \
--field="Custom Warning":CB "no|yes" \
--field="Warning Message" "$WARNMSG" \
--button="Create":2 \
--button="Cancel":1)
BUT=$?
@ -47,6 +49,8 @@ MODE2M=$(echo $SETTINGS | awk -F "|" '{print $11}')
PORT=$(echo $SETTINGS | awk -F "|" '{print $12}')
LOG=$(echo $SETTINGS | awk -F "|" '{print $13}')
AMRRON=$(echo $SETTINGS | awk -F "|" '{print $14}')
WARN=$(echo $SETTINGS | awk -F "|" '{print $15}')
WARNMSG=$(echo $SETTINGS | awk -F "|" '{print $16}')
NAME=$(yad --form --width=600 --text-align=center --center --title="Name?" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
@ -81,6 +85,8 @@ echo "MODE2M=$MODE2M" >> $CONFIGTMP
echo "PORT=$PORT" >> $CONFIGTMP
echo "LOG=$LOG" >> $CONFIGTMP
echo "AMRRON=$AMRRON" >> $CONFIGTMP
echo "WARN=$WARN" >> $CONFIGTMP
echo "WARNMSG=\"$WARNMSG\"" >> $CONFIGTMP
CHECKFILE=$(ls $MYPATH | grep $NEWCONFIG)
if [ -z "$CHECKFILE" ];then
cp $CONFIGTMP $MYPATH/$NEWCONFIG
@ -175,6 +181,12 @@ else
AMRRON="no|yes"
fi
if [ "$WARN" = 'yes' ]; then
WARN="yes|no"
else
WARN="no|yes"
fi
SETTINGS=$(yad --form --width=600 --text-align=center --center --title="Pat Menu Settings" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Menu Settings</b> by KM4ACK" \
@ -192,6 +204,8 @@ SETTINGS=$(yad --form --width=600 --text-align=center --center --title="Pat Menu
--field="Pat Port" "$PORT" \
--field="Log File Location" "$LOG" \
--field="AmRRON":CB "$AMRRON" \
--field="Custom Warning":CB "$WARN" \
--field="Warning Message" "$WARNMSG" \
--button="Update":2 \
--button="Cancel":1)
BUT=$?
@ -214,6 +228,8 @@ MODE2M=$(echo $SETTINGS | awk -F "|" '{print $11}')
PORT=$(echo $SETTINGS | awk -F "|" '{print $12}')
LOG=$(echo $SETTINGS | awk -F "|" '{print $13}')
AMRRON=$(echo $SETTINGS | awk -F "|" '{print $14}')
WARN=$(echo $SETTINGS | awk -F "|" '{print $15}')
WARNMSG=$(echo $SETTINGS | awk -F "|" '{print $16}')
echo "#Config file for Pat Menu" > $CONFIGTMP
echo "#20200429 KM4ACK" >> $CONFIGTMP
@ -231,6 +247,8 @@ echo "MODE2M=$MODE2M" >> $CONFIGTMP
echo "PORT=$PORT" >> $CONFIGTMP
echo "LOG=$LOG" >> $CONFIGTMP
echo "AMRRON=$AMRRON" >> $CONFIGTMP
echo "WARN=$WARN" >> $CONFIGTMP
echo "WARNMSG=\"$WARNMSG\"" >> $CONFIGTMP
cp $CONFIGTMP $CONFIG
rm $CONFIGTMP
$MAIN &

View File

@ -478,7 +478,7 @@ PATV=$(pat version | awk '{print $2}' | sed 's/v0.//' | awk -F "." '{print $1}')
if [ $PATV -le 11 ]; then
PATPATH=$HOME/.wl2k/
else
PATPATH=$XDGHOME_CONFIG_PATH/
PATPATH=$XDG_CONFIG_HOME/pat/
fi
fi

81
mobi-pair Executable file
View File

@ -0,0 +1,81 @@
#!/bin/bash
#this script attempts to pair a Mobilinkd TNC with the Pi.
#04MARCH2022 KM4ACK
EXISTING=`bluetoothctl paired-devices | grep Mobilinkd`
TMP=/run/user/$UID/mobi.txt
#see if we already have a TNC paired
if [ -n "$EXISTING" ]; then
clear;echo;echo
cat <<EOF
A Mobilinkd TNC is already paired with this pi.
Remove the existing pairing and try again.
EOF
sleep 3
exit 1
fi
if ! hash expect 2>/dev/null; then
echo "We are missing a dependency....expect"
echo "Hang on while it is installed"
echo "You can press ctrl+c to exit"
sleep 3
sudo apt update
sudo apt install -y expect
fi
#create connect script in RAM memory. (Called later from this script)
cat << "MYFILE" > /run/user/$UID/connect
#!/usr/bin/expect -f
set prompt "#"
set address [lindex $argv 0]
spawn sudo bluetoothctl
expect -re $prompt
send "scan on\r"
send_user "\nStandby\r"
sleep 10
send_user "\nStill working\r"
send "scan off\r"
expect "Controller"
send "pair $address\r"
sleep 5
send "1234\r"
sleep 3
send_user "\nShould be paired now.\r"
send "quit\r"
expect eof
MYFILE
chmod +x /run/user/$UID/connect
#give user some feedback
echo;echo; clear
cat <<EOF
####################################################################
# Please stand by while the pairing is attempted. #
# This process takes approximately 60 seconds to complete. #
####################################################################
EOF
#get the TNC of the mobilinkd
echo "Discovering nearby Mobilinkd device....please wait"
hcitool scan > $TMP
echo "Discovery complete. TNC found.";echo
MAC=`grep -i TNC /run/user/$UID/mobi.txt | awk '{print $1}'`
#verify we have a MAC address to work with
if [ -z "$MAC" ]; then
echo "TNC not found. Can't continue!"
echo "Confirm that the TNC is on and has"
echo "a fast flashing blue light."
sleep 5
exit 1
fi
echo "Starting the pairing process....please stand by"
#call the connect script
/run/user/$UID/connect $MAC >/dev/null 2>&1
echo;echo "The pairing was probably successful"
echo "Start the Mobilinkd modem again"
sleep 3

63
mobi-wired Executable file
View File

@ -0,0 +1,63 @@
#!/bin/bash
#This script will connect Mobilinkd TNC3 through a USB connection
#and make the TNC available with Pat through an ax25 connection.
#This script will NOT work with the Mobilinkd TNC2 as it did not
#support a USB connection.
#07MARCH2022 KM4ACK
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
KISS=$(pidof kissattach)
DIRE=$(pidof direwolf)
ARDOP=$(pidof piardopc)
MOBIUSB=$(ls -l /dev/serial/by-id | grep Mobilinkd | awk '{print $NF}' | sed 's/.*tty/tty/')
#verify mobilinkd is plugged in and detected
if [ -z "$MOBIUSB" ]; then
yad --title="Not Detected" --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 TNC wasn't detected. Please \
connect the Mobilinkd TNC to the Pi with a USB cable." \
--button=gtk-ok
exit 1
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
#create kissattach needed for winlink connections
sudo kissattach /dev/$MOBIUSB wl2k &
sleep 3
sudo kissparms -c 1 -p wl2k
#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 &

View File

@ -2,6 +2,7 @@
#script to connect mobilinkd TNC for ax25
#20200602
#20220304 last edit KM4ACK
################################################################
# #
# # # # # # # ##### # # #
@ -21,7 +22,41 @@ 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 \
@ -30,6 +65,7 @@ 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 \
@ -37,31 +73,28 @@ yad --center --timeout=10 --timeout-indicator=top --no-buttons --height=300 --wi
Another notice will appear once a connection to the device is established." &
#scan for bluetooth device and write to file
hcitool scan > $HOME/Desktop/scan.txt
echo "Scan complete"
hcitool scan > $TMPFILE
#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)
TNC2=$(grep -i TNC2 $TMPFILE)
TNC3=$(grep -i TNC3 $TMPFILE)
if [ -z "$TNC2" ]
then
MAC=$(cat $HOME/Desktop/scan.txt | grep -i mobi | awk '{ print $1 }')
MAC=$(grep -i mobi $TMPFILE | awk '{ print $1 }')
TNC=3
elif [ -z "$TNC3" ]
then
MAC=$(cat $HOME/Desktop/scan.txt | grep -i mobi | awk '{ print $1 }')
MAC=$(grep -i mobi $TMPFILE | awk '{ print $1 }')
TNC=2
fi
#set correct connection commmand
if [ $TNC = "2" ]
then
#CONNECT="sudo rfcomm connect /dev/rfcomm0 $MAC"
CONNECT="sudo rfcomm bind /dev/rfcomm0 $MAC"
elif [ $TNC = "3" ]
then
CONNECT="sudo rfcomm bind /dev/rfcomm0 $MAC 6"
#CONNECT="sudo rfcomm connect /dev/rfcomm0 $MAC 6"
fi
#See if device was found and connect if found
@ -71,27 +104,27 @@ 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 $HOME/Desktop/scan.txt
rm $TMPFILE
exit 1
else
#stop things that might conflict
sudo killall js8call kissattach direwolf >> /dev/null 2>&1
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 $HOME/Desktop/scan.txt
rm $TMPFILE
#create bluetooth->serial connection
$CONNECT &
sleep 5
echo "starting kissattach for winlink"
#create kissattach needed for winlink connections
sudo kissattach /dev/rfcomm0 wl2k &
echo "sleeping 3 seconds"; sleep 3
sleep 3
sudo kissparms -c 1 -p wl2k
fi
#verify that piardopc is running
#verify that kissattach is running
PIDPIC=$(pidof kissattach)
if [ -z "$PIDPIC" ]
then
@ -106,6 +139,13 @@ yad --title="Mobilinkd MODEM" --width=400 --height=100 \
--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 &

12
patmenu
View File

@ -24,6 +24,15 @@ yad --form --width=420 --text-align=center --center --title="Pat out of Date" --
exit
fi
if [ $WARN = 'yes' ] && [ ! -f /run/user/$UID/patwarn.txt ]; then
#give user warning message
yad --form --width=420 --text-align=center --center --title="WARNING!!" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>${WARNMSG}</b>" \
--button=gtk-ok
touch /run/user/$UID/patwarn.txt
fi
#verify call is set
if [ "$MYCALLSIGN" = "N0CALL" ]; then
yad --title="N0CALL" --width=400 --height=100 \
@ -37,7 +46,8 @@ yad --form --width=420 --text-align=center --center --title="Pat Menu" --text-al
--text="<b>Pat Menu</b> by KM4ACK\rv$VERSION" \
--field="Start ARDOP Modem":fbtn 'bash -c "$MYPATH/start-pat-ardop"' \
--field="Start Packet Modem":fbtn 'bash -c "$MYPATH/start-pat2m"' \
--field="Start Mobilinkd Modem (BETA)":fbtn 'bash -c "$MYPATH/mobilink"' \
--field="Start Mobilinkd Modem Bluetooth":fbtn 'bash -c "$MYPATH/mobilink"' \
--field="Start Mobilinkd Modem Wired":fbtn 'bash -c "$MYPATH/mobi-wired"' \
--field="Stop Modems":fbtn 'bash -c "$MYPATH/stop-modems"' \
--field="Find Winlink Gateways":fbtn 'bash -c "kill -USR1 $YAD_PID; $MYPATH/find2"' \
--field="Pat Auto Connect":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/pat-functions; AUTOPAT"' \