2024-10-11 13:48:26 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
#
|
|
|
|
|
# Author : Gaston Gonzalez
|
|
|
|
|
# Date : 11 October 2024
|
2025-12-13 12:30:58 -07:00
|
|
|
# Updated : 13 December 2025
|
2024-10-11 13:48:26 -07:00
|
|
|
# Purpose : A script for managaing plug-and-play radios
|
2025-03-17 11:34:33 -07:00
|
|
|
source /opt/emcomm-tools/bin/et-common
|
2024-10-11 13:48:26 -07:00
|
|
|
|
2024-10-11 14:49:19 -07:00
|
|
|
ACTIVE_RADIO="${ET_HOME}/conf/radios.d/active-radio.json"
|
|
|
|
|
|
2024-10-28 11:37:40 -07:00
|
|
|
NO_RADIO_ID="no-radio"
|
2024-10-11 14:49:19 -07:00
|
|
|
|
2024-10-28 11:37:40 -07:00
|
|
|
options=()
|
|
|
|
|
options+=("${NO_RADIO_ID}" "No radio")
|
|
|
|
|
while IFS= read -r radio; do
|
|
|
|
|
ID=$(cat $radio | jq -r .id)
|
|
|
|
|
VENDOR=$(cat $radio | jq -r .vendor)
|
|
|
|
|
MODEL=$(cat $radio | jq -r .model)
|
2024-10-11 14:49:19 -07:00
|
|
|
|
2025-12-13 12:30:58 -07:00
|
|
|
# Hack to simplify PnP support for the X6200. It is the same as
|
|
|
|
|
# the X6100. No need to mess with a new JSON radio configuration,
|
|
|
|
|
# audio scripts, or udev rules. Just let the user know in the
|
|
|
|
|
# menu selection that there is support for the X6100/X6200.
|
|
|
|
|
if [[ "${MODEL}" == "X6100" ]]; then
|
|
|
|
|
MODEL="X6100/X6200"
|
|
|
|
|
fi
|
|
|
|
|
|
2024-10-28 11:37:40 -07:00
|
|
|
options+=("$ID" "$VENDOR $MODEL")
|
2025-10-13 11:24:23 -07:00
|
|
|
done < <(find $ET_HOME/conf/radios.d -type f -name \*.json | grep -v "bt.json" | sort)
|
2024-10-11 14:49:19 -07:00
|
|
|
|
2024-12-13 06:31:31 -07:00
|
|
|
SELECTED_RADIO=$(dialog --clear --menu "Select a radio:" 21 60 10 "${options[@]}" 3>&1 1>&2 2>&3)
|
2024-10-28 11:37:40 -07:00
|
|
|
exit_status=$?
|
2024-10-11 14:49:19 -07:00
|
|
|
|
2024-10-28 11:37:40 -07:00
|
|
|
tput sgr 0 && clear
|
2024-10-11 14:49:19 -07:00
|
|
|
|
2024-10-28 11:37:40 -07:00
|
|
|
if [ $exit_status -eq 0 ]; then
|
2024-10-24 05:30:51 -07:00
|
|
|
|
2024-10-28 11:37:40 -07:00
|
|
|
# Special case to run without a radio configured
|
|
|
|
|
if [ ${SELECTED_RADIO} == ${NO_RADIO_ID} ]; then
|
|
|
|
|
[ -e ${ACTIVE_RADIO} ] && rm ${ACTIVE_RADIO}
|
|
|
|
|
echo "Set active radio to: $SELECTED_RADIO"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
2024-10-16 06:15:33 -07:00
|
|
|
|
2024-10-28 11:37:40 -07:00
|
|
|
RADIO_CONF="${ET_HOME}/conf/radios.d/$SELECTED_RADIO.json"
|
|
|
|
|
[ -e ${ACTIVE_RADIO} ] && rm ${ACTIVE_RADIO}
|
|
|
|
|
ln -s ${RADIO_CONF} ${ACTIVE_RADIO}
|
|
|
|
|
echo "Set active radio to: $SELECTED_RADIO"
|
2024-10-16 06:15:33 -07:00
|
|
|
|
2024-10-28 11:37:40 -07:00
|
|
|
ID=$(cat ${ACTIVE_RADIO} | jq -r .id)
|
|
|
|
|
VENDOR=$(cat ${ACTIVE_RADIO} | jq -r .vendor)
|
|
|
|
|
MODEL=$(cat ${ACTIVE_RADIO} | jq -r .model)
|
2024-10-16 06:15:33 -07:00
|
|
|
|
2025-02-03 16:48:33 -07:00
|
|
|
BLUETOOTH_TNC_CHECK=$(ps -ef | grep "[r]fcomm connect")
|
|
|
|
|
if [[ $? -eq 0 ]]; then
|
|
|
|
|
et-log "Killing running processes for Bluetooth TNC"
|
2025-03-17 11:34:33 -07:00
|
|
|
sudo /opt/emcomm-tools/bin/et-kill-bt
|
2025-02-03 16:48:33 -07:00
|
|
|
fi
|
|
|
|
|
|
2024-10-28 11:37:40 -07:00
|
|
|
printf "%-20s %-10s %-10s\n" "Radio ID" "Vendor" "Model"
|
2024-11-10 09:09:29 -07:00
|
|
|
printf "%-20s %-10s %-10s\n\n" $ID "$VENDOR" "$MODEL"
|
2024-10-16 06:15:33 -07:00
|
|
|
|
2024-11-10 09:09:29 -07:00
|
|
|
printf "${YELLOW}RADIO CONFIGURATION NOTES\n"
|
2024-10-28 11:37:40 -07:00
|
|
|
cat ${ACTIVE_RADIO} | jq -r '.notes[] | "* \(.)"'
|
2024-11-10 09:09:29 -07:00
|
|
|
echo -e "${NC}"
|
2024-11-03 10:27:54 -07:00
|
|
|
|
2024-11-10 09:09:29 -07:00
|
|
|
printf "${GREEN}REQUIRED ACTIONS\n"
|
|
|
|
|
printf "1. Apply the settings above to your radio.\n"
|
2024-12-14 04:13:16 -07:00
|
|
|
printf "2. Plug in the USB cable for your radio. If it is already\n"
|
|
|
|
|
printf " connected, reconnect it.\n"
|
2024-11-10 09:09:29 -07:00
|
|
|
printf "3. Run 'et-mode' and select the desired mode of operation.\n\n"
|
|
|
|
|
printf " Note: JS8Call does not require a mode to be selected.\n"
|
|
|
|
|
echo -e "${NC}"
|
2024-10-28 11:37:40 -07:00
|
|
|
else
|
|
|
|
|
echo "No radio selected."
|
|
|
|
|
fi
|