From 358730476a08e9e0fc891c60c8e95e07674b5e58 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Wed, 1 Jan 2025 15:39:40 -0700 Subject: [PATCH] BTECH UV PRO - Initial support for connecting to the Bluetooth serial device on the BTECH UV PRO. --- overlay/etc/adduser.conf | 2 +- overlay/etc/skel/notes/btech-uv-pro.md | 82 ++++++++++++++++++++ overlay/etc/sudoers.d/et-rfcomm | 7 ++ overlay/opt/emcomm-tools/bin/et-uv-pro | 102 +++++++++++++++++++++++++ scripts/install-packet.sh | 5 ++ 5 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 overlay/etc/skel/notes/btech-uv-pro.md create mode 100644 overlay/etc/sudoers.d/et-rfcomm create mode 100755 overlay/opt/emcomm-tools/bin/et-uv-pro diff --git a/overlay/etc/adduser.conf b/overlay/etc/adduser.conf index 47cc83b..b1fb999 100644 --- a/overlay/etc/adduser.conf +++ b/overlay/etc/adduser.conf @@ -79,7 +79,7 @@ USERS_GID=1981 # new users to other groups. # This is the list of groups that new non-system users will be added to # Default: -EXTRA_GROUPS="dialout cdrom floppy audio video plugdev users" +EXTRA_GROUPS="bluetooth dialout cdrom floppy audio video plugdev users" # If ADD_EXTRA_GROUPS is set to something non-zero, the EXTRA_GROUPS # option above will be default behavior for adding new, non-system users diff --git a/overlay/etc/skel/notes/btech-uv-pro.md b/overlay/etc/skel/notes/btech-uv-pro.md new file mode 100644 index 0000000..89c5a65 --- /dev/null +++ b/overlay/etc/skel/notes/btech-uv-pro.md @@ -0,0 +1,82 @@ +# BTECH UV Pro Bluetooth TNC Notes + +## Linux Packet Configuration + +Edit `/etc/ax25/axports` has root and add the following line. + +``` +PKT1200 KT7RUN 1200 255 2 145.710 +``` + +## Radio Configuration + +* KISS TNC > Enable KISS TNC = checked + +## Pair Radio and Computer + +1. On the radio, start the pairing process by navigating to + Menu > Pairing. + +2. + +3. On the computer, run `bluetoothctl` + +``` +> power on +> scan on +> pair 38:D2:00:00:ED:C8 +> trust 38:D2:00:00:ED:C8 +> quit +``` + +## If you're already paired + +1. Kill any instances of rfcomm if they are running + +``` +sudo killall rfcomm +``` + +2. + +``` +$ sudo rfcomm connect /dev/rfcomm0 38:D2:00:00:ED:C8 +Connected /dev/rfcomm0 to 38:D2:00:00:ED:C8 on channel 1 +Press CTRL-C for hangup +``` + +3. In another window, check that you are connected. + +``` +bluetoothctl info 38:D2:00:00:ED:C8 | grep Connected | awk '{print $2}' +``` + +4. Kill any instances of kissattach if they are running. + +``` +sudo killall kissattach +``` + +5. Attach to the desired AX.25 port. + +``` +$ sudo kissattach /dev/rfcomm0 PKT1200 +AX.25 port PKT1200 bound to device ax0 +``` + +6. Connect to the BBS + +``` +axcall PKT1200 TTPBBS +``` + +Listen to incoming and outgoing packets and capture the time +stamps for the traffic. + +``` +$ sudo axlisten -a -t +``` + +## Troubleshooting + +1. systemctl status bluetooth diff --git a/overlay/etc/sudoers.d/et-rfcomm b/overlay/etc/sudoers.d/et-rfcomm new file mode 100644 index 0000000..b0704af --- /dev/null +++ b/overlay/etc/sudoers.d/et-rfcomm @@ -0,0 +1,7 @@ +%bluetooth ALL=(ALL) NOPASSWD: /usr/bin/rfcomm * +%bluetooth ALL=(ALL) NOPASSWD: /usr/sbin/kissattach /dev/rfcomm0 * +%bluetooth ALL=(ALL) NOPASSWD: /usr/sbin/kissparms * + +%bluetooth ALL=(ALL) NOPASSWD: /usr/bin/killall kissattach +%bluetooth ALL=(ALL) NOPASSWD: /usr/bin/killall kissattach +%bluetooth ALL=(ALL) NOPASSWD: /usr/bin/killall rfcomm diff --git a/overlay/opt/emcomm-tools/bin/et-uv-pro b/overlay/opt/emcomm-tools/bin/et-uv-pro new file mode 100755 index 0000000..c46e37f --- /dev/null +++ b/overlay/opt/emcomm-tools/bin/et-uv-pro @@ -0,0 +1,102 @@ +#!/bin/bash +# +# Author : Gaston Gonzalez +# Date : 1 January 2025 +# Purpose : Utility for accessing the Bluetooth TNC on the BTECH +# UV Pro. + +# TODO: read from file +CONF_FILE="${HOME}/.config/emcomm-tools/btech-uv-pro.json" +MAC="38:D2:00:00:ED:C8" + +# TODO: Write to /etc/ax25/axports + +BT_DEVICE="/dev/rfcomm0" +AX25_PORT="pkt1200" + +RED='\x1B[1;31m' +BLUE='\x1B[1;34m' +CYAN='\x1B[1;36m' +GREEN='\x1B[1;32m' +YELLOW='\x1B[1;33m' +NC='\x1B[0m' + +function usage() { + echo "Usage: $(basename $0) " + echo " connect - Connect to radio via Bluetooth" + echo " pair - Pair radio via Bluetooth" + echo " unpair - Unpair radio via Bluetooth" +} + +if [ $# -ne 1 ]; then + usage + exit 1 +fi + + +stop_all_services() { + + PS_OUT=$(ps -ef | grep [k]issattach) + if [ $? -eq 0 ]; then + echo -e "${BLUE}Killing kissattach process(es)...${NC}" + sudo killall kissattach + fi + + sleep 3 + + PS_OUT=$(ps -ef | grep [r]fcomm) + if [ $? -eq 0 ]; then + echo -e "${BLUE}Killing rfcomm process(es)...${NC}" + sudo killall rfcomm + fi + +} + +case $1 in + connect) + echo -e "${YELLOW}" + read -p "Turn on BTech UV Pro, then press [ENTER] when on." + + is_paired=$(bluetoothctl info ${MAC} | grep "Paired" | awk '{print $2}') + if [ "${is_paired}" != "yes" ]; then + echo -e "${RED}" + et-log "UV Pro is not paired. Run: '$(basename $0) pair'" + echo -e "${NC}" + exit 1 + fi + + echo -e "${GREEN}Found UV Pro with MAC address: ${MAC}" + stop_all_services + + echo -e "${BLUE}Connecting to radio..." + sudo rfcomm connect /dev/rfcomm0 ${MAC} 1>/dev/null 2>&1 & + + sleep 10 && reset + + if [ -e /dev/rfcomm0 ]; then + echo -e "${GREEN}UV Pro connected via Bluetooth serial${NC}" + else + echo -e "${RED}UV Pro failed to connect via Bluetooth serial${NC}" + exit 1 + fi + + echo -e "${BLUE}Connecting KISS interface using ${BT_DEVICE} and AX.25 port: ${AX25_PORT}${NC}" + KISS_OUT=$(sudo kissattach ${BT_DEVICE} ${AX25_PORT}) + + if [ $? -eq 0 ]; then + echo -e "${GREEN}Packet port ready" + else + echo -e "${RED}Failed to setup radio for packet.${NC}" + exit 1 + fi + + KISS_OUT=$(sudo kissparms -c 1 -p ${AX25_PORT}) + + echo -e "${YELLOW}\nRun: axcall pkt1200 ${NC}" + ;; + *) + et-log "Invalid command." + usage + exit 1 + ;; +esac diff --git a/scripts/install-packet.sh b/scripts/install-packet.sh index 3ddd631..9faa7fe 100755 --- a/scripts/install-packet.sh +++ b/scripts/install-packet.sh @@ -1,6 +1,7 @@ #!/bin/bash # Author : Gaston Gonzalez # Date : 27 March 2023 +# Updated : 1 January 2025 # Purpose : Install packet packages set -e @@ -9,3 +10,7 @@ apt install \ ax25-tools \ ax25-apps \ -y + +et-log "Installing rfcomm sudoers rules..." +cp -v ../overlay/etc/sudoers.d/* /etc/sudoers.d/ +