-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhotspot-frequency
More file actions
59 lines (47 loc) · 1.89 KB
/
Copy pathhotspot-frequency
File metadata and controls
59 lines (47 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
TERM=xterm-256color
run() {
exec=$1
printf "\x1b[38;5;104m --> ${exec}\x1b[39m\n"
eval ${exec}
}
say () {
say=$1
printf "\x1b[38;5;220m${say}\x1b[38;5;255m\n"
}
# Extract existing values from current hotspot script
OLDFREQ=$(grep -m1 'sa818 .* radio' /usr/sbin/hotspot | sed -n 's/.*--frequency \([^ ]*\).*/\1/p')
CPVOL=$(grep -m1 'sa818 .* volume' /usr/sbin/hotspot | sed -n 's/.*--level \([^ ]*\).*/\1/p')
# Extract full --ctcss parameter (exactly as written)
CTCSS=$(grep -m1 'sa818 .* radio' /usr/sbin/hotspot | sed -n 's/.*\(--ctcss [^ ]*\).*/\1/p')
# Preserve the install-time --port and the full filter line so re-running
# hotspot-frequency doesn't clobber what hotspot-config-online chose
# (in particular: 4th-gen boards keep their chip-side filters enabled).
SERIAL_PORT=$(grep -m1 'sa818 .* radio' /usr/sbin/hotspot | sed -n 's/.*--port \([^ ]*\).*/\1/p')
if [[ -z "${SERIAL_PORT}" ]]; then
if [ -e /dev/serial0 ]; then SERIAL_PORT="/dev/serial0"
elif [ -e /dev/ttyAMA0 ]; then SERIAL_PORT="/dev/ttyAMA0"
else SERIAL_PORT="/dev/ttyS0"
fi
fi
FILTER_LINE=$(grep -m1 'sa818 .* filters' /usr/sbin/hotspot)
if [[ -z "${FILTER_LINE}" ]]; then
FILTER_LINE="sa818 --port ${SERIAL_PORT} filters --emphasis disable --highpass disable --lowpass disable"
fi
gum style --border normal --margin "1" --padding "1 2" \
--border-foreground "#04B575" \
"$(gum style --foreground 3 'RF.')Guru $(gum style --foreground 3 '-') Hotspot Frequency"
gum style --foreground "#04B575" "Frequency:"
FREQ=$(gum input --value "${OLDFREQ}")
gum style --foreground 212 "${FREQ}"
rm /usr/sbin/hotspot
say "Configuring hotspot"
{
echo "#!/bin/bash"
echo ""
echo "sa818 --port ${SERIAL_PORT} radio --bw 0 --frequency ${FREQ} ${CTCSS} --squelch 8"
echo "${FILTER_LINE}"
echo "sa818 --port ${SERIAL_PORT} volume --level ${CPVOL}"
} > /usr/sbin/hotspot
chmod +x /usr/sbin/hotspot
run "/usr/sbin/hotspot"