diff --git a/overlay/opt/emcomm-tools/bin/et-chattervox b/overlay/opt/emcomm-tools/bin/et-chattervox new file mode 100755 index 0000000..a165c03 --- /dev/null +++ b/overlay/opt/emcomm-tools/bin/et-chattervox @@ -0,0 +1,105 @@ +#!/bin/bash +# +# Author : Gaston Gonzalez +# Date : 5 December 2024 +# Purpose : Wrapper script for starting chattervox with PnP support +# +# Preconditions: +# 1. Supported radio and audio interface are connected and properly detected +# 2. Dire Wolf is started +# +# Postconditions: +# 1. Callsign and KISS host updated +# 2. chattervox is started + +CHATTERVOX_CONF_DIR=${HOME}/.chattervox +CHATTERVOX_CONF_FILE=${CHATTERVOX_CONF_DIR}/config.json + +usage() { + echo "usage: $(basename $0) " + echo " " + echo " start - Start chat" + echo " update-config - Update configuration for selected mode" +} + +if [ $# -ne 1 ]; then + usage + exit 1 +fi + +notify_user() { + notify-send \ + -t 5000 \ + --app-name="EmComm Tools" \ + "$1" +} + +start() { + update-config + + if [ $? -eq 0 ]; then + + RIGCTLD_OUT=$(ps -ef | grep [d]irewolf) + if [ $? -ne 0 ]; then + et-log "Can't start chattervox. Dire Wolf not running." + notify_user "Can't start chattervox. Dire Wolf not running." + exit 1 + fi + + CWD_DIR=$(pwd) + + CMD="chattervox chat" + et-log "Starting chattervox with: ${CMD}" + + ${CMD} + + else + et-log "Error updating configuration. Can't start chattervox" + exit 1 + fi +} + +update-config () { + + [ -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 + notify_user "Can't start chattervox. No callsign set. Run: et-user." + exit 1 + fi + + [ ! -e ${CHATTERVOX_CONF_DIR} ] && mkdir ${CHATTERVOX_CONF_DIR} + + if [ ! -e ${CHATTERVOX_CONF_FILE} ]; then + et-log "chattervox configuration does not exist creating: ${CHATTERVOX_CONF_FILE}..." + +cat < "${CHATTERVOX_CONF_FILE}" +{ + "version": 3, + "callsign": "${CALLSIGN}", + "ssid": 0, + "keystoreFile": "${HOME}/.chattervox/keystore.json", + "kissPort": "kiss://localhost:8001", + "kissBaud": 9600, + "feedbackDebounce": 20000 +} +EOF + + fi +} + +case $1 in + start) + start + ;; + update-config) + update-config + ;; + *) + echo "Invalid command." + usage + exit 1 + ;; +esac diff --git a/overlay/opt/emcomm-tools/bin/et-mode b/overlay/opt/emcomm-tools/bin/et-mode index 9e3681f..9b3d988 100755 --- a/overlay/opt/emcomm-tools/bin/et-mode +++ b/overlay/opt/emcomm-tools/bin/et-mode @@ -105,7 +105,7 @@ if [ $exit_status -eq 0 ]; then ${MODE_ID_CHAT_CLIENT}) start_and_wait_for_service et-service-direwolf-simple et-log "Starting chattervox" - chattervox chat + et-chattervox start ;; ${MODE_ID_PACKET_DIGIPEATER}) systemctl --user start et-service-direwolf-packet-digipeater