From 4d07ee8f52fa57199faf24aa60d87f023d0e98e7 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Wed, 1 Jan 2025 16:50:49 -0700 Subject: [PATCH] BTECH UV PRO - Added support for configuring the ax25 ports file on each start using the current et-user --- overlay/opt/emcomm-tools/bin/et-uv-pro | 40 +++++++++++++++++++++++--- scripts/install-packet.sh | 4 +++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/overlay/opt/emcomm-tools/bin/et-uv-pro b/overlay/opt/emcomm-tools/bin/et-uv-pro index c46e37f..eeb112a 100755 --- a/overlay/opt/emcomm-tools/bin/et-uv-pro +++ b/overlay/opt/emcomm-tools/bin/et-uv-pro @@ -9,10 +9,9 @@ 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" +AX25_CONF_FILE="/etc/ax25/axports" RED='\x1B[1;31m' BLUE='\x1B[1;34m' @@ -33,6 +32,29 @@ if [ $# -ne 1 ]; then exit 1 fi +update_ax25_conf() { + + [ -z "$ET_USER_CONFIG" ] && ET_USER_CONFIG="${HOME}/.config/emcomm-tools/user.json" + + CALLSIGN=$(cat ${ET_USER_CONFIG} | jq -r .callsign) + + if [ "${CALLSIGN}" = "N0CALL" ]; then + echo -e "${RED}No callsign set. Run et-user first.${NC}" + exit 1 + fi + + GREP_OUT=$(grep ${AX25_PORT} ${AX25_CONF_FILE}) + if [ $? -eq 0 ]; then + # Delete all existing pkt1200 entries. Note: we can't use sed here + # since we do not have permission to create a temporary file with + # inline replacement. ed modifies the file directly. + printf "g/^pkt1200/d\nw\nq\n" | ed ${AX25_CONF_FILE} > /dev/null 2>&1 + + fi + + echo -e "${BLUE}Adding AX25 port for ${CALLSIGN}${NC}" + echo "pkt1200 ${CALLSIGN} 1200 255 2 1200 Packet" >> ${AX25_CONF_FILE} +} stop_all_services() { @@ -55,7 +77,9 @@ stop_all_services() { case $1 in connect) echo -e "${YELLOW}" - read -p "Turn on BTech UV Pro, then press [ENTER] when on." + echo -e "1. Turn on the BTECH UV PRO" + echo -e "2. Menu > General Settings > KISS TNC = checked" + read -p "3. Press [ENTER] when done." is_paired=$(bluetoothctl info ${MAC} | grep "Paired" | awk '{print $2}') if [ "${is_paired}" != "yes" ]; then @@ -68,6 +92,8 @@ case $1 in echo -e "${GREEN}Found UV Pro with MAC address: ${MAC}" stop_all_services + update_ax25_conf + echo -e "${BLUE}Connecting to radio..." sudo rfcomm connect /dev/rfcomm0 ${MAC} 1>/dev/null 2>&1 & @@ -92,7 +118,13 @@ case $1 in KISS_OUT=$(sudo kissparms -c 1 -p ${AX25_PORT}) - echo -e "${YELLOW}\nRun: axcall pkt1200 ${NC}" + echo -e "${YELLOW}" + echo -e "SAMPLE COMMANDS DESCRIPTION " + echo -e "------------------------------- --------------------------------" + echo -e "axcall pkt1200 Connect directly to a node " + echo -e "axcall pkt1200 Connect to node via a digipeater" + echo -e "${NC}" + ;; *) et-log "Invalid command." diff --git a/scripts/install-packet.sh b/scripts/install-packet.sh index 9faa7fe..e6a2269 100755 --- a/scripts/install-packet.sh +++ b/scripts/install-packet.sh @@ -14,3 +14,7 @@ apt install \ et-log "Installing rfcomm sudoers rules..." cp -v ../overlay/etc/sudoers.d/* /etc/sudoers.d/ +et-log "Updating AX.25 port permissions..." +chgrp -v -R $ET_GROUP /etc/ax25/axports +chmod -v 664 /etc/ax25/axports +