#!/bin/bash # # Author : Gaston Gonzalez # Date : 28 June 2026 # Purpose : Wrapper script for starting modem73 with PnP support # # Preconditions: # 1. Supported radio and audio interface are connected and properly detected # # Postconditions: # 1. modem73 started with sane defaults MODEM73_CONF_FILE=${ET_HOME}/conf/template.d/modem73/settings.default usage() { echo "usage: $(basename $0) " echo " " echo " start - Start modem73 in selected mode" echo " update-config - Update configuration for selected mode" echo "" echo " " echo " default - QPSK, normal frames, 1/2 code rate (recommended)" } if [[ $# -ne 2 ]]; then usage exit 1 fi MODE=$2 case "${MODE}" in default) et-log "Configuration updates not yet implemented." ;; *) et-log "Can't started modem73. Mode '${MODE}' not supported" usage exit 1 ;; esac notify_user() { notify-send \ -t 10000 \ --app-name="EmComm Tools" \ "$1" } [ -z ${ET_LOG_DIR} ] && ET_LOG_DIR="${HOME}/.local/share/emcomm-tools" [ ! -e ${ET_LOG_DIR} ] && mkdir -p ${ET_LOG_DIR} start() { update_config if [ $? -eq 0 ]; then systemctl is-active --quiet rigctld if [ $? -ne 0 ]; then et-log "Can't start modem73. rigctld not running. Ensure radio is selected." notify_user "Can't start modem73. rigctld not running." exit 1 fi ALSA_DEVICE=$(et-system-info et-audio-card) INPUT_AUDIO=$(modem73 --list-audio | grep input | grep $ALSA_DEVICE | cut -d":" -f3) OUTPUT_AUDIO=$(modem73 --list-audio | grep output| grep $ALSA_DEVICE | cut -d":" -f3) CMD="modem73 --input-device ${INPUT_AUDIO} --output-device ${OUTPUT_AUDIO} --ptt rigctl --headless" et-log "Starting modem73 with: '${CMD}'" echo ${CMD} else et-log "Error updating configuration. Can't start modem73" exit 1 fi } update_config () { et-log "Attempting to start modem73 in mode: '${MODE}'" [ -z "$ET_USER_CONFIG" ] && ET_USER_CONFIG="${HOME}/.config/emcomm-tools/user.json" CALLSIGN=$(cat ${ET_USER_CONFIG} | jq -r .callsign) # 1. Check if the symlink was created by the udev rules if [ -e /dev/et-audio ]; then # 2. Check that this device was properly tagged with the ET_AUDIO env variable with a udev rule APLAY_OUT=$(arecord -l | grep ET_AUDIO) if [ $? -eq 0 ]; then # Configure ALSA settings for sound card /opt/emcomm-tools/bin/et-audio update-config else et-log "No ET_AUDIO device detected." notify_user "Can't start modem73. No ET_AUDIO device detected." exit 1 fi else et-log "No ET_AUDIO device plugged in." notify_user "Can't start modem73. No supported audio device plugged in." exit 1 fi } case $1 in start) start ;; update-config) update_config ;; *) echo "Invalid command." usage exit 1 ;; esac