mirror of
https://github.com/femtofox/femtofox.git
synced 2026-10-25 18:40:20 -04:00
Continue refining lora settings menu
This commit is contained in:
parent
aaaa7d9e87
commit
3fc3c50f9a
5 changed files with 80 additions and 104 deletions
|
|
@ -62,10 +62,16 @@ ingest_data() { # usage: `ingest_data "command.sh -argument" key_width`
|
|||
}
|
||||
|
||||
check_meshtasticd_running() {
|
||||
if echo $(femto-utils.sh -C "meshtasticd") | grep -q "not running"; then
|
||||
if ! echo $(femto-utils.sh -C "meshtasticd") | sed 's/\x1b\[[0-9;]*m//g' | grep -q ", running"; then
|
||||
dialog --no-collapse --title "Meshtasticd service" --yesno "Meshtasticd service is not running but is required.\n\nStart service?" 9 50
|
||||
if [ $? -eq 0 ]; then #unless cancel/no
|
||||
femto-meshtasticd-config.sh -s
|
||||
echo "Waiting for meshtasticd service to start..."
|
||||
sleep 3
|
||||
if ! echo $(femto-utils.sh -C "meshtasticd") | sed 's/\x1b\[[0-9;]*m//g' | grep -q ", running"; then
|
||||
dialog --no-collapse --colors --title "Meshtasticd service" --msgbox "Meshtasticd service ($(femto-utils.sh -R "$(femto-utils.sh -C "meshtasticd")")) failed to run, but is required." 7 50
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
|
|
@ -186,12 +192,12 @@ networking_settings() {
|
|||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
elif [ $exit_status -eq 2 ]; then # Help ("extra") button
|
||||
dialog --no-collapse --colors --title "Meshtastic wifi sync service help" --msgbox "The Meshtastic wifi sync service synchronizes wifi settings with Meshtastic wifi settings. This allows you to use remote node administration to enable/disable Femtofox wifi.\n\nIn future, this will also allow you to reconfigure SSID and password.\n" 0 0
|
||||
dialog --no-collapse --colors --title "Meshtastic wifi sync service help" --msgbox "The Meshtastic wifi sync service synchronizes system wifi settings with Meshtastic wifi settings. This allows you to use Meshtastic's remote node administration feature to enable/disable wifi.\n\nIn future, this will also allow you to reconfigure SSID and password.\n" 0 0
|
||||
else
|
||||
case $choice in
|
||||
"View detailed service status")
|
||||
echo "Getting Meshtastic wifi sync service status..."
|
||||
dialog --no-collapse --no-shadow --title "Meshtastic wifi sync service status" --msgbox "$(systemctl status femto-wifi-mesh-control)" 0 0
|
||||
dialog --no-collapse --title "Meshtastic wifi sync service status" --msgbox "$(systemctl status femto-wifi-mesh-control)" 0 0
|
||||
;;
|
||||
"Start/restart service")
|
||||
dialog --no-collapse --title "$title" --yesno "Start/restart Meshtastic wifi sync service?" 7 45
|
||||
|
|
@ -383,7 +389,7 @@ legacy_admin() {
|
|||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
loading "Getting current legacy admin state..."
|
||||
choice=$(dialog --no-collapse --colors --title "Legacy Admin" --default-item "$choice" --help-button --item-help --menu "If the node you need to administer or be administered by is running 2.4.x or earlier, you should set this to Enabled.\n\nCurrent state: $(femto-utils.sh -R "$(femto-meshtasticd-config.sh -p)")" 16 65 5 \
|
||||
choice=$(dialog --no-collapse --colors --title "Legacy Admin" --default-item "$choice" --help-button --item-help --menu "If the node you Femtofox needs to administer or be administered by is running 2.4.x or earlier, you should set this to Enabled.\n\nCurrent state: $(femto-utils.sh -R "$(femto-meshtasticd-config.sh -p)")" 16 65 5 \
|
||||
1 "Enable" "" \
|
||||
2 "Disable (default)" "" \
|
||||
" " "" "" \
|
||||
|
|
@ -553,7 +559,7 @@ meshtastic_settings() {
|
|||
case $choice in
|
||||
"View detailed service status")
|
||||
echo "Getting Meshtasticd service status..."
|
||||
dialog --no-collapse --no-shadow --title "Meshtasticd service status" --msgbox "$(systemctl status meshtasticd)" 0 0
|
||||
dialog --no-collapse --title "Meshtasticd service status" --msgbox "$(systemctl status meshtasticd)" 0 0
|
||||
;;
|
||||
"Start/restart service")
|
||||
dialog --no-collapse --title "$title" --yesno "Start/restart Meshtasticd service?" 6 45
|
||||
|
|
@ -614,7 +620,7 @@ help_menu() {
|
|||
local title="Help / About"
|
||||
help_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$help_choice" --item-help --menu "$title" 0 0 7 \
|
||||
1 "About Femtofox" "" \
|
||||
2 "View pinout" "" \
|
||||
2 "Display pinout" "" \
|
||||
3 "Femtofox licensing info - short" "" \
|
||||
4 "Femtofox licensing info - long" "" \
|
||||
5 "Meshtastic licensing info" "" \
|
||||
|
|
@ -696,7 +702,7 @@ while getopts ":hlLwc" opt; do
|
|||
;;
|
||||
c) # Option -c (Check if Meshtasticd is running and warn the user if not)
|
||||
check_meshtasticd_running
|
||||
exit $? # relay exit status
|
||||
exit $?
|
||||
;;
|
||||
\?) # Unknown option)
|
||||
echo -e "Unknown argument $1.\n$help"
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ Options are:
|
|||
-S Get Meshtasticd service state
|
||||
-z Upgrade Meshtasticd
|
||||
-x Uninstall Meshtasticd
|
||||
-m Meshtastic update tool. Syntax: \`femto-meshtasticd-config.sh -m '--set security.admin_channel_enabled false' 10 'Disable legacy admin'\`
|
||||
-m Meshtastic update tool. Syntax: \`femto-meshtasticd-config.sh -m \"--set security.admin_channel_enabled false\" 10 \"Disable legacy admin\"\`
|
||||
Will retry the \`--set security.admin_channel_enabled false\` command until successful or up to 10 times, and tag status reports with \`Disable legacy admin\` via echo and to system log.
|
||||
EOF
|
||||
)
|
||||
|
|
@ -45,19 +45,17 @@ meshtastic_update() {
|
|||
local ref="$3: "
|
||||
echo "Submitting to Meshtastic..."
|
||||
for retries in $(seq 1 $attempts); do
|
||||
local output=$(meshtastic --host $command | tee /dev/tty) #>&2 lets meshtastic's output display on screen
|
||||
local output=$(meshtastic --host $command 2>&1 | tee $(if [ -e /dev/tty ]; then echo /dev/tty; else echo /dev/ttyFIQ0; fi))
|
||||
logger $output
|
||||
if echo "$output" | grep -qiE "Abort|invalid|Error|refused|Errno"; then
|
||||
if [ "$retries" -lt $attempts ]; then
|
||||
local msg="${ref:+$ref}Meshtastic command failed, retrying ($(($retries + 1))/$attempts)..."
|
||||
femto-meshtasticd-config.sh -s
|
||||
echo "$msg"
|
||||
logger "$msg"
|
||||
sleep 2 # Add a small delay before retrying
|
||||
fi
|
||||
else
|
||||
local success="true"
|
||||
echo -e "$output"
|
||||
msg="${ref:+$ref}Meshtastic command successful!"
|
||||
echo "$msg"
|
||||
logger "$msg"
|
||||
|
|
@ -85,44 +83,26 @@ while getopts ":higkl:q:uU:rR:aA:cpo:sM:Stwuxm" opt; do
|
|||
i) # Option -i (Get important node info)
|
||||
declare -a output_array
|
||||
output=$(meshtastic --host --info)
|
||||
output_array+=("Service=$(femto-meshtasticd-config.sh -S)")
|
||||
output_array+=("Version=$(echo "$output" | grep -oP '"firmwareVersion":\s*"\K[^"]+' | head -n 1)")
|
||||
output_array+=("Node name=$(echo "$output" | grep -oP 'Owner:\s*\K.*' | head -n 1)")
|
||||
output_array+=("NodeID=$(echo "!$(printf "%08x\n" $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1))")")
|
||||
output_array+=("Nodenum=$(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1)")
|
||||
output_array+=("TX enabled=$(echo "$output" | grep -oP '"txEnabled":\s*\K\w+')")
|
||||
use_preset=$(echo "$output" | grep -oP '"usePreset":\s*\K\w+')
|
||||
output_array+=("Use preset=$use_preset")
|
||||
if [ "$use_preset" = "true" ]; then # if use-preset is true, then display the preset
|
||||
output_array+=("Preset=$(echo "$output" | grep -oP '"modemPreset":\s*"\K[^"]+')")
|
||||
else # otherwise, display the lora settings
|
||||
output_array+=("Bandwidth=$(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')")
|
||||
output_array+=("Spread factor=$(echo "$output" | grep -oP '"spreadFactor":\s*\K\w+')")
|
||||
output_array+=("Coding rate=$(echo "$output" | grep -oP '"codingRate":\s*\K\w+')")
|
||||
fi
|
||||
output_array+=("Role=$(echo "$output" | grep -oP '"role":\s*"\K[^"]+' | head -n 1)")
|
||||
freq_offset=$(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')
|
||||
if [ "$freq_offset" != 0 ]; then # only display frequency offset if not 0
|
||||
output_array+=("Freq offset=$freq_offset")
|
||||
fi
|
||||
output_array+=("Region=$(echo "$output" | grep -oP '"region":\s*"\K[^"]+')")
|
||||
output_array+=("Hop limit=$(echo "$output" | grep -oP '"hopLimit":\s*\K\w+')")
|
||||
freq_slot=$(echo "$output" | grep -oP '"channelNum":\s*\K\d+' | head -n 1)
|
||||
if [ "$freq_slot" != 0 ]; then # only display frequency slot if not 0
|
||||
freq_slot+=("Freq slot=$freq_slot")
|
||||
fi
|
||||
override_freq=$(echo "$output" | grep -oP '"overrideFrequency":\s*\K[0-9.]+')
|
||||
if [ "$override_freq" != "0.0" ]; then # only display override frequency if not 0.0
|
||||
output_array+=("Override freq=$override_freq")
|
||||
fi
|
||||
output_array+=("Public key=$(echo "$output" | grep -oP '"publicKey":\s*"\K[^"]+' | head -n 1)")
|
||||
output_array+=("Nodes in db=$(echo "$output" | grep -oP '"![a-zA-Z0-9]+":\s*\{' | wc -l)")
|
||||
# now, echo the array
|
||||
for pair in "${output_array[@]}"; do
|
||||
key=$(echo "$pair" | cut -d'=' -f1)
|
||||
value=$(echo "$pair" | cut -d'=' -f2-)
|
||||
echo "$key:$value"
|
||||
done
|
||||
echo -e "\
|
||||
Service:$(femto-meshtasticd-config.sh -S)
|
||||
Version:$(echo "$output" | grep -oP '"firmwareVersion":\s*"\K[^"]+' | head -n 1)
|
||||
Node name:$(echo "$output" | grep -oP 'Owner:\s*\K.*' | head -n 1)
|
||||
NodeID:$(echo "!$(printf "%08x\n" $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1))")
|
||||
Nodenum:$(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1)
|
||||
TX enabled:$(echo "$output" | grep -oP '"txEnabled":\s*\K\w+')
|
||||
Use preset:$(echo "$output" | grep -oP '"usePreset":\s*\K\w+')
|
||||
Preset:$(echo "$output" | grep -oP '"modemPreset":\s*"\K[^"]+')
|
||||
Bandwidth:$(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')
|
||||
Spread factor:$(echo "$output" | grep -oP '"spreadFactor":\s*\K\w+')
|
||||
Coding rate:$(echo "$output" | grep -oP '"codingRate":\s*\K\w+')
|
||||
Role:$(echo "$output" | grep -oP '"role":\s*"\K[^"]+' | head -n 1)
|
||||
Freq offset:$(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')
|
||||
Region:$(echo "$output" | grep -oP '"region":\s*"\K[^"]+')
|
||||
Hop limit:$(echo "$output" | grep -oP '"hopLimit":\s*\K\w+')
|
||||
Freq slot:$(echo "$output" | grep -oP '"channelNum":\s*\K\d+' | head -n 1)
|
||||
Override freq:$(echo "$output" | grep -oP '"overrideFrequency":\s*\K[0-9.]+')
|
||||
Public key:$(echo "$output" | grep -oP '"publicKey":\s*"\K[^"]+' | head -n 1)
|
||||
Nodes in db:$(echo "$output" | grep -oP '"![a-zA-Z0-9]+":\s*\{' | wc -l)"
|
||||
;;
|
||||
g) # Option -g (get config URL)
|
||||
url=$(meshtastic --host --qr-all | grep -oP '(?<=Complete URL \(includes all channels\): )https://[^ ]+') #add look for errors
|
||||
|
|
@ -239,14 +219,16 @@ while getopts ":higkl:q:uU:rR:aA:cpo:sM:Stwuxm" opt; do
|
|||
x) # Option -x (uninstall meshtasticd)
|
||||
apt remove meshtasticd
|
||||
;;
|
||||
m) # Option -m (manual meshtastic command)
|
||||
m)
|
||||
external="true" # set a variable so the function knows it was called by an an external script and not locally
|
||||
meshtastic_update "$2" $3 "$4"
|
||||
;;
|
||||
\?) # Invalid option)
|
||||
echo -e "Unknown argument $1.\n$help"
|
||||
\?) # Invalid option
|
||||
echo "Invalid option: -$OPTARG"
|
||||
echo -e "$help"
|
||||
exit 1
|
||||
;;
|
||||
:) # Missing argument for option)
|
||||
:) # Missing argument for option
|
||||
echo "Option -$OPTARG requires a setting."
|
||||
echo -e "$help"
|
||||
exit 1
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ send_settings() {
|
|||
dialog --no-collapse --colors --title "$title" --msgbox "$(echo -e "\Z4Command Successful!\Zn\n\nLog:\n$output")" 0 0
|
||||
fi
|
||||
fi
|
||||
|
||||
[ "$1" = "wizard" ] && [ -z "$args" ] && dialog --no-collapse --title "$title" --colors --msgbox "Meshtastic LoRa Settings Wizard complete!" 6 50 # if in wizard mode AND there are no script arguments, display the message
|
||||
}
|
||||
|
||||
|
|
@ -102,21 +103,21 @@ set_lora_radio() {
|
|||
}
|
||||
|
||||
lora_settings_actions() {
|
||||
if [ "$1" = "set_lora_radio_model" ] || [ "$1" = "wizard" ]; then
|
||||
set_lora_radio $1
|
||||
fi
|
||||
|
||||
if femto-config -c; then
|
||||
if [ "$1" = "set_lora_radio_model" ] || [ "$1" = "wizard" ]; then
|
||||
set_lora_radio $1
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "wizard" ]; then
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "True" --item-help --menu "Meshtastic configuration method" 8 50 0 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "Cancel" --default-item "True" --item-help --menu "Meshtastic configuration method" 8 50 0 \
|
||||
"Automatic configuration with URL" "" "" \
|
||||
"Manual configuration" "" "" \
|
||||
" " "" "" \
|
||||
"$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" "" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] || [ "$choice" == "Cancel" ] || [ "$choice" == "Skip" ] || [ "$choice" == "Skip" ] && return # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
"Cancel" "" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] || [ "$choice" == "Cancel" ] && return # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
[ "$choice" == "" ] && continue #restart loop if no choice made
|
||||
[ "$choice" == "Manual configuration" ] && break
|
||||
[ "$choice" == "Automatic configuration with URL" ] && config_url "$1"
|
||||
|
|
@ -124,6 +125,11 @@ lora_settings_actions() {
|
|||
done
|
||||
fi
|
||||
|
||||
dialog --no-collapse --infobox "Getting current settings from Meshtasticd.\n\nThis can take a minute..." 6 50
|
||||
while IFS=: read -r key value; do
|
||||
declare "$(echo "$key" | tr '[:upper:]' '[:lower:]' | tr ' ' '_' | xargs)=$(echo "$value" | xargs)"
|
||||
done < <(femto-meshtasticd-config.sh -i)
|
||||
|
||||
if [ "$1" = "region" ] || [ "$1" = "wizard" ]; then
|
||||
options=("UNSET" "US" "EU_433" "EU_868" "CN" "JP" "ANZ" "KR" "TW" "RU" "IN" "NZ_865" "TH" "LORA_24" "UA_433" "UA_868" "MY_433" "MY_919" "SG_923")
|
||||
menu_items=()
|
||||
|
|
@ -137,20 +143,19 @@ lora_settings_actions() {
|
|||
done
|
||||
menu_items+=("" "" "" "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" "" "")
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "LONG_FAST" --item-help --menu "Sets the region for your node. Default is unset. As long as this is not set, the node screen will display a message and not transmit any packets.\n\nRegion (default: UNSET)?" 0 0 0 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "$region" --item-help --menu "Sets the region for your node. As long as this is not set, the node will display a message and not transmit any packets.\n\nRegion? (current: ${region:-unknown})" 0 0 0 \
|
||||
"${menu_items[@]}" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] || [ "$choice" == "Cancel" ] || [ "$choice" == "Skip" ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
[ "$choice" == "" ] && continue # Restart loop if no choice made
|
||||
command+="--set lora.region $choice "
|
||||
break
|
||||
done
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "use_modem_preset" ] || [ "$1" = "wizard" ]; then
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "True" --item-help --menu "Presets are pre-defined modem settings (Bandwidth, Spread Factor, and Coding Rate) which influence both message speed and range. The vast majority of users use a preset.\n\nUse modem preset?" 0 0 0 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "${use_preset^}" --item-help --menu "Presets are pre-defined modem settings (Bandwidth, Spread Factor, and Coding Rate) which influence both message speed and range. The vast majority of users use a preset.\n\nUse modem preset? (current: ${use_preset:-unknown})" 0 0 0 \
|
||||
"True" "(default)" "" \
|
||||
"False" "" "" \
|
||||
" " "" "" \
|
||||
|
|
@ -161,7 +166,6 @@ lora_settings_actions() {
|
|||
command+="--set lora.use_preset $(echo "$choice" | tr '[:upper:]' '[:lower:]') "
|
||||
break
|
||||
done
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "wizard" ] && [ "$using_preset" = "False" ]; then
|
||||
|
|
@ -180,14 +184,13 @@ lora_settings_actions() {
|
|||
done
|
||||
menu_items+=("" "" "" "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" "" "")
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "LONG_FAST" --item-help --menu "The default preset will provide a strong mixture of speed and range, for most users.\n\nPreset?" 0 0 0 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "$preset" --item-help --menu "The default preset will provide a strong mixture of speed and range, for most users.\n\nPreset? (current: ${preset:-unknown})" 0 0 0 \
|
||||
"${menu_items[@]}" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] || [ "$choice" == "Cancel" ] || [ "$choice" == "Skip" ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
[ "$choice" == "" ] && continue # Restart loop if no choice made
|
||||
command+="--set lora.modem_preset $choice "
|
||||
break
|
||||
done
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -196,11 +199,12 @@ lora_settings_actions() {
|
|||
else
|
||||
if [ "$1" = "bandwidth" ] || [ "$1" = "wizard" ]; then
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --item-help --default-item 250 --menu "Width of the frequency \"band\" used around the calculated center frequency. Only used if modem preset is disabled.\n\nBandwidth?" 0 0 0 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --item-help --default-item $bandwidth --menu "Width of the frequency \"band\" used around the calculated center frequency. Only used if modem preset is disabled.\n\nBandwidth? (current: ${bandwidth:-unknown})" 0 0 0 \
|
||||
0 "(default, automatic)" "" \
|
||||
31 "" "" \
|
||||
62 "" "" \
|
||||
125 "" "" \
|
||||
250 "(default)" "" \
|
||||
250 "" "" \
|
||||
500 "" "" \
|
||||
" " "" "" \
|
||||
"$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" "" "" 3>&1 1>&2 2>&3)
|
||||
|
|
@ -209,18 +213,18 @@ lora_settings_actions() {
|
|||
command+="--set lora.bandwidth $choice "
|
||||
break
|
||||
done
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "spread_factor" ] || [ "$1" = "wizard" ]; then
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --item-help --default-item 12 --menu "Indicates the number of chirps per symbol.\n\nSpread factor (only used if modem preset is disabled)?" 0 0 0 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --item-help --default-item $spread_factor --menu "Indicates the number of chirps per symbol. Only used if modem preset is disabled.\n\nSpread factor? (current: ${spread_factor:-unknown})" 0 0 0 \
|
||||
0 "(default, automatic)" "" \
|
||||
7 "" "" \
|
||||
8 "" "" \
|
||||
9 "" "" \
|
||||
10 "" "" \
|
||||
11 "" "" \
|
||||
12 "(default)" "" \
|
||||
12 "" "" \
|
||||
" " "" "" \
|
||||
"$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" "" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] || [ "$choice" == "Cancel" ] || [ "$choice" == "Skip" ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
|
|
@ -228,16 +232,16 @@ lora_settings_actions() {
|
|||
command+="--set lora.spread_factor $choice "
|
||||
break
|
||||
done
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "coding_rate" ] || [ "$1" = "wizard" ]; then
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --item-help --default-item 8 --menu "The proportion of each LoRa transmission that contains actual data - the rest is used for error correction.\n\nCoding rate (only used if modem preset is disabled)?" 0 0 0 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --item-help --default-item $coding_rate --menu "The proportion of each LoRa transmission that contains actual data - the rest is used for error correction.\n\nCoding rate (only used if modem preset is disabled)? (current: ${coding_rate:-unknown})" 0 0 0 \
|
||||
0 "(default, automatic)" "" \
|
||||
5 "" "" \
|
||||
6 "" "" \
|
||||
7 "" "" \
|
||||
8 "(default)" "" \
|
||||
8 "" "" \
|
||||
" " "" "" \
|
||||
"$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" "" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] || [ "$choice" == "Cancel" ] || [ "$choice" == "Skip" ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
|
|
@ -245,38 +249,35 @@ lora_settings_actions() {
|
|||
command+="--set lora.coding_rate $choice "
|
||||
break
|
||||
done
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "frequency_offset" ] || [ "$1" = "wizard" ]; then
|
||||
while true; do
|
||||
input=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --inputbox "This parameter is for advanced users with advanced test equipment.\n\nFrequency offset (default: 0)" 0 0 3>&1 1>&2 2>&3)
|
||||
input=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --inputbox "This parameter is for advanced users with advanced test equipment.\n\nFrequency offset (default: 0)" 0 0 $freq_offset 3>&1 1>&2 2>&3)
|
||||
[[ -z $input || ($input =~ ^([0-9]{1,6})(\.[0-9]+)?$ && $(echo "$input <= 1000000" | bc -l) -eq 1) ]] && break # exit loop if user input a number between 0 and 1000000. Decimals allowed
|
||||
dialog --no-collapse --title "$title" --msgbox "Must be between 0-1000000. Decimals allowed." 6 50
|
||||
done
|
||||
if [ $? -ne 1 ] && [ -n "$input" ]; then
|
||||
command+="--set lora.frequency_offset $input "
|
||||
fi
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "hop_limit" ] || [ "$1" = "wizard" ]; then
|
||||
while true; do
|
||||
input=$(dialog --no-collapse --colors --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --inputbox "The maximum number of intermediate nodes between Femtofox and a node it is sending to. Does not impact received messages.\n\n\Z1WARNING:\Zn Excessive hop limit increases congestion!\n\nHop limit. Must be 0-7 (default: 3)" 0 0 3>&1 1>&2 2>&3)
|
||||
input=$(dialog --no-collapse --colors --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --inputbox "The maximum number of intermediate nodes between Femtofox and a node it is sending to. Does not impact received messages.\n\n\Z1WARNING:\Zn Excessive hop limit increases congestion!\n\nHop limit. Must be 0-7 (default: 3)" 0 0 $hop_limit 3>&1 1>&2 2>&3)
|
||||
[[ -z $input || ($input =~ ^[0-7]$) ]] && break # exit loop if user input an integer between 0 and 7
|
||||
dialog --no-collapse --title "$title" --msgbox "Must be an integer between 0 and 7." 6 50
|
||||
done
|
||||
if [ $? -ne 1 ] && [ -n "$input" ]; then
|
||||
command+="--set lora.hop_limit $input "
|
||||
fi
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "tx_enabled" ] || [ "$1" = "wizard" ]; then
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "True" --item-help --menu "Enables/disables the radio chip. Useful for hot-swapping antennas.\n\nEnable TX?" 0 0 0 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "${tx_enabled^}" --item-help --menu "Enables/disables the radio chip. Useful for hot-swapping antennas.\n\nEnable TX? (current: ${tx_enabled:-unknown})" 0 0 0 \
|
||||
"True" "(default)" "" \
|
||||
"False" "" "" \
|
||||
" " "" "" \
|
||||
|
|
@ -286,7 +287,6 @@ lora_settings_actions() {
|
|||
command+="--set lora.tx_enabled $(echo "$choice" | tr '[:upper:]' '[:lower:]') "
|
||||
break
|
||||
done
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "tx_power" ] || [ "$1" = "wizard" ]; then
|
||||
|
|
@ -300,31 +300,29 @@ ERP above 36db violates US (unlicensed) law.\n\
|
|||
If 0, will use the maximum continuous power legal in your region.
|
||||
\n\
|
||||
\n\
|
||||
TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 3>&1 1>&2 2>&3)
|
||||
TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 ${tx_power:-0} 3>&1 1>&2 2>&3)
|
||||
[[ -z $input || ($input =~ ^[0-30]$) ]] && break # exit loop if user input an integer between 0 and 30
|
||||
dialog --no-collapse --title "$title" --msgbox "Must be an integer between 0 and 30." 6 50
|
||||
done
|
||||
if [ $? -ne 1 ] && [ -n "$input" ]; then
|
||||
command+="--set lora.tx_power $input "
|
||||
fi
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "frequency_slot" ] || [ "$1" = "wizard" ]; then
|
||||
while true; do
|
||||
input=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --inputbox "Determines the exact frequency the radio transmits and receives. If unset or set to 0, determined automatically by the primary channel name.\n\nFrequency slot (0 for automatic)" 0 0 3>&1 1>&2 2>&3)
|
||||
input=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --inputbox "Determines the exact frequency the radio transmits and receives. If unset or set to 0, determined automatically by the primary channel name.\n\nFrequency slot (0 for automatic)" 0 0 $freq_slot 3>&1 1>&2 2>&3)
|
||||
[[ -z $input || ($input =~ ^[0-9]+$) ]] && break # exit loop if user input an integer 0 or higher
|
||||
dialog --no-collapse --title "$title" --msgbox "Must be an integer 0 or higher." 6 50
|
||||
done
|
||||
if [ $? -ne 1 ] && [ -n "$input" ]; then
|
||||
command+="--set lora.channel_num $input "
|
||||
fi
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "override_duty_cycle" ] || [ "$1" = "wizard" ]; then
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "False" --item-help --menu "May have legal ramifications.\n\nOverride duty cycle?" 0 0 0 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "$(echo "${override_duty:-False}" | sed 's/^./\U&/')" --item-help --menu "May have legal ramifications.\n\nOverride duty cycle? (current: ${override_duty:-unknown})" 0 0 0 \
|
||||
"True" "" "" \
|
||||
"False" "(default)" "" \
|
||||
" " "" "" \
|
||||
|
|
@ -334,12 +332,11 @@ TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 3>&1 1>&2 2>&3)
|
|||
command+="--set lora.override_duty_cycle $(echo "$choice" | tr '[:upper:]' '[:lower:]') "
|
||||
break
|
||||
done
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "sx126x_rx_boosted_gain" ] || [ "$1" = "wizard" ]; then
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "True" --item-help --menu "This is an option specific to the SX126x chip series which allows the chip to consume a small amount of additional power to increase RX (receive) sensitivity.\n\nEnable SX126X RX boosted gain?" 0 0 0 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "$(echo "${sx126x_boost:-True}" | sed 's/^./\U&/')" --item-help --menu "This is an option specific to the SX126x chip series which allows the chip to consume a small amount of additional power to increase RX (receive) sensitivity.\n\nEnable SX126X RX boosted gain? (current: ${sx126x_boost:-unknown})" 0 0 0 \
|
||||
"True" "(default)" "" \
|
||||
"False" "" "" \
|
||||
" " "" "" \
|
||||
|
|
@ -349,12 +346,11 @@ TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 3>&1 1>&2 2>&3)
|
|||
command+="--set lora.sx126x_rx_boosted_gain $(echo "$choice" | tr '[:upper:]' '[:lower:]') "
|
||||
break
|
||||
done
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "override_frequency" ] || [ "$1" = "wizard" ]; then
|
||||
while true; do
|
||||
input=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --inputbox "Overrides frequency slot. May have legal ramifications.\n\nOverride frequency in MHz (0 for none)." 0 0 3>&1 1>&2 2>&3)
|
||||
input=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --inputbox "Overrides frequency slot. May have legal ramifications.\n\nOverride frequency in MHz (0 for none)." 0 0 ${override_freq:-0} 3>&1 1>&2 2>&3)
|
||||
[[ -z $input || ($input =~ ^[0-9]+(\.[0-9]+)?$) ]] && break # exit loop if user input a number 0 or higher (decimals allowed)
|
||||
dialog --no-collapse --title "$title" --msgbox "Must be a number 0 or higher. Decimals allowed." 6 53
|
||||
done
|
||||
|
|
@ -362,12 +358,11 @@ TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 3>&1 1>&2 2>&3)
|
|||
if [ $? -ne 1 ] && [ -n "$input" ]; then
|
||||
command+="--set lora.override_frequency $input "
|
||||
fi
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "ignore_mqtt" ] || [ "$1" = "wizard" ]; then
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "False" --item-help --menu "Ignores any messages it receives via LoRa that came via MQTT somewhere along the path towards the device.\n\nIgnore MQTT?" 0 0 0 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "$(echo "${ignore_mqtt:-False}" | sed 's/^./\U&/')" --item-help --menu "Ignores any messages it receives via LoRa that came via MQTT somewhere along the path towards the device.\n\nIgnore MQTT? (current: ${ignore_mqtt:-unknown})" 0 0 0 \
|
||||
"True" "" "" \
|
||||
"False" "(default)" "" \
|
||||
" " "" "" \
|
||||
|
|
@ -377,12 +372,11 @@ TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 3>&1 1>&2 2>&3)
|
|||
command+="--set lora.ignore_mqtt $(echo "$choice" | tr '[:upper:]' '[:lower:]') "
|
||||
break
|
||||
done
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
if [ "$1" = "ok_to_mqtt" ] || [ "$1" = "wizard" ]; then
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "False" --item-help --menu "Indicates that the user approves their packets to be uplinked to MQTT brokers.\n\nOK to MQTT?" 0 0 0 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "$(echo "${ok_to_mqtt:-False}" | sed 's/^./\U&/')" --item-help --menu "Indicates that the user approves their packets to be uplinked to MQTT brokers.\n\nOK to MQTT? (current: ${ok_to_mqtt:-unknown})" 0 0 0 \
|
||||
"True" "" "" \
|
||||
"False" "(default)" "" \
|
||||
" " "" "" \
|
||||
|
|
@ -392,15 +386,9 @@ TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 3>&1 1>&2 2>&3)
|
|||
command+="--set lora.config_ok_to_mqtt $(echo "$choice" | tr '[:upper:]' '[:lower:]') "
|
||||
break
|
||||
done
|
||||
[ "$1" != "wizard" ] && return
|
||||
fi
|
||||
|
||||
# if we're in wizard mode AND there are no script arguments, then display a message
|
||||
[ "$1" = "wizard" ] && [ -z "$args" ] && dialog --no-collapse --title "$title" --colors --msgbox "Meshtastic LoRa Settings Wizard complete!" 6 50
|
||||
|
||||
send_settings $1
|
||||
|
||||
[ "$1" = "wizard" ] && return # quit function if wizard
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ MAC address:$(ifconfig wlan0 | grep ether | awk '{print $2}')"
|
|||
Wi-Fi status:\033[4m\033[0;34menabled\033[0m\n\
|
||||
Connected to:$(iwconfig 2>/dev/null | grep -i 'ESSID' | awk -F 'ESSID:"' '{print $2}' | awk -F '"' '{print $1}' | sed 's/^$/none/')\n\
|
||||
Sig. strength:$(iwconfig 2>/dev/null | grep -i 'Signal level' | awk -F 'Signal level=' '{print $2}' | awk '{print $1}')\n\
|
||||
Current IP:$(hostname -I | awk '{print $1}')\n
|
||||
Current IP:$(ip addr show wlan0 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1)\n
|
||||
Hostname:$(hostname).local\n\
|
||||
$mac_address_line"
|
||||
else
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ for i in {1..5}; do
|
|||
echo "Time Zone updated to:\n$(timedatectl show --property=Timezone --value) $(date +%Z) (UTC$(date +%:z))\nSystem time updated to:\n$(date)\n\nNew time successfully saved to RTC.\nTime & date are also set automatically from internet, if connected."
|
||||
return 0
|
||||
else
|
||||
echo "System time updated to:\n$(date) ($(date +"UTC%z" | sed -E 's/GMT([+-])0?([0-9]{1,2})00/GMT\1\2/'))\n\nUnable to communicate with RTC module. An RTC module can remember system time between reboots/power outages.\nTime & date are also set automatically from internet, if connected."
|
||||
echo "System time updated to:\n$(date +"%B %d, %Y %H:%M:%S") $(timedatectl show --property=Timezone --value) ($(date +"UTC%z" | sed -E 's/GMT([+-])0?([0-9]{1,2})00/GMT\1\2/'))\n\nUnable to communicate with RTC module. An RTC module can remember system time between reboots/power outages.\nTime & date are also set automatically from internet, if connected."
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
|
@ -64,7 +64,7 @@ Current system time:\n\
|
|||
$(date +"%B %d, %Y %H:%M:%S") $(timedatectl show --property=Timezone --value) ($(date +"UTC%z" | sed -E 's/GMT([+-])0?([0-9]{1,2})00/GMT\1\2/'))\n\
|
||||
$(hwclock >/dev/null 2>&1 && echo "RTC module found!" || echo "RTC module not found.")\n\
|
||||
\n\
|
||||
Set new time and timezone?" 10 70
|
||||
Set new time and timezone?" 10 50
|
||||
if [ $? -eq 1 ]; then #unless cancel/no
|
||||
exit 0
|
||||
fi
|
||||
|
|
@ -83,7 +83,7 @@ Set new time and timezone?" 10 70
|
|||
# Show timezone selection menu with preselection of current timezone
|
||||
selected_timezone=$(dialog --title "Set Time Zone" \
|
||||
--default-item "$current_timezone" \
|
||||
--menu "Current time zone: $current_timezone (UTC$(date +%z))" 20 60 10 \
|
||||
--menu "Current time zone: $current_timezone (UTC$(date +%z))" 20 50 10 \
|
||||
$(printf "%s " "${options[@]}") 3>&1 1>&2 2>&3)
|
||||
exit_status=$?
|
||||
if [[ $exit_status -eq 0 && -n "$selected_timezone" ]]; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue