mirror of
https://github.com/femtofox/femtofox.git
synced 2026-10-25 18:40:20 -04:00
Revamp settings ingest
This commit is contained in:
parent
3fc3c50f9a
commit
ee461842ec
3 changed files with 154 additions and 44 deletions
|
|
@ -21,7 +21,7 @@ loading() {
|
|||
}
|
||||
|
||||
## function to pull data from various femto scripts and convert it to the contents of a read only dialog --form
|
||||
# ingest_data() { # usage: `ingest_data "command.sh -argument" key_width value_width`
|
||||
# ingest_form_data() { # usage: `ingest_form_data "command.sh -argument" key_width value_width`
|
||||
# unset output_array #debug code, delete me
|
||||
# declare -a output_array
|
||||
# # Read the output from femto-meshtasticd-config.sh and store it in the array
|
||||
|
|
@ -42,7 +42,7 @@ loading() {
|
|||
# echo "$form_contents" | sed 's/\x1b\[[0-9;]*m//g'
|
||||
# }
|
||||
## CODE TO USE THIS FUNCTION:
|
||||
# eval "$(echo -e "dialog --no-collapse --no-cancel --form \"Meshtastic node info\" 0 0 0 $(ingest_data "femto-meshtasticd-config.sh -i" 18 0) 2>/dev/null")"
|
||||
# eval "$(echo -e "dialog --no-collapse --no-cancel --form \"Meshtastic node info\" 0 0 0 $(ingest_form_data "femto-meshtasticd-config.sh -i" 18 0) 2>/dev/null")"
|
||||
|
||||
|
||||
# function to pull data from various femto scripts and convert it a simple text string, with dialog colors
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ help=$(cat <<EOF
|
|||
Options are:
|
||||
-h This message
|
||||
-i Get important node info
|
||||
-C "all" Get node configuration, by category. Multiple categories can be selected by comma delineation. \`quiet\`: do not echo to console. Options are \`quiet\`, \`all\`, \`nodeinfo\`, \`settings\`, \`channels\`
|
||||
-g Gets the current configuration URL and QR code
|
||||
-k Get current LoRa radio selection
|
||||
-l "RADIO" Choose LoRa radio model. Options are \`lr1121_tcxo\`, \`sx1262_tcxo\`, \`sx1262_xtal\`, \`none\` (simradio)
|
||||
|
|
@ -52,6 +53,7 @@ meshtastic_update() {
|
|||
local msg="${ref:+$ref}Meshtastic command failed, retrying ($(($retries + 1))/$attempts)..."
|
||||
echo "$msg"
|
||||
logger "$msg"
|
||||
femto-meshtasticd-config.sh -s
|
||||
sleep 2 # Add a small delay before retrying
|
||||
fi
|
||||
else
|
||||
|
|
@ -74,35 +76,144 @@ meshtastic_update() {
|
|||
fi
|
||||
}
|
||||
|
||||
get_meshtastic_settings() {
|
||||
for retries in $(seq 1 3); do
|
||||
if meshtastic_info=$(meshtastic --host --info); then # if successful
|
||||
success="true"
|
||||
break
|
||||
else # if failed
|
||||
if [ "$retries" -lt 3 ]; then # if under 3 retries
|
||||
echo "Meshtastic command failed, retrying ($(($retries + 1))/3)..."
|
||||
femto-meshtasticd-config.sh -s
|
||||
sleep 2 # Add a small delay before retrying
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ -z "$success" ]; then # if failed all retries
|
||||
echo "Meshtastic command FAILED."
|
||||
exit 1 # always exit script if failed
|
||||
fi
|
||||
|
||||
if [[ "$1" == *"all"* ]] || [[ "$1" == *"nodeinfo"* ]]; then
|
||||
# myInfo
|
||||
eval "myInfo_owner='$(echo "$meshtastic_info" | grep "^Owner: " | sed 's/^Owner: //')'"
|
||||
[[ "$1" != *"quiet"* ]] && echo "myInfo_owner:$myInfo_owner"
|
||||
while IFS="=" read -r varname value; do
|
||||
eval "myInfo_$varname='$value'" # Create a variable with the formatted name
|
||||
[[ "$1" != *"quiet"* ]] && echo "myInfo_$varname:$value"
|
||||
done < <(
|
||||
echo "$(echo "$meshtastic_info" | grep '^My info: ' | sed 's/^My info: //')" |
|
||||
jq -r 'to_entries[] | "\(.key)=\(.value)"'
|
||||
)
|
||||
|
||||
# metadata
|
||||
while IFS="=" read -r varname value; do
|
||||
eval "metadata_$varname='$value'" # Create a variable with the formatted name
|
||||
[[ "$1" != *"quiet"* ]] && echo "metadata_$varname:$value"
|
||||
done < <(
|
||||
echo "$(echo "$meshtastic_info" | grep '^Metadata: ' | sed 's/^Metadata: //')" |
|
||||
jq -r 'to_entries[] | "\(.key)=\(.value)"'
|
||||
)
|
||||
metadata_nodedbCount=$(echo "$meshtastic_info" | grep -oP '"![a-zA-Z0-9]+":\s*\{' | wc -l)
|
||||
[[ "$1" != *"quiet"* ]] && echo "metadata_nodedbCount:$metadata_nodedbCount"
|
||||
|
||||
# nodeinfo
|
||||
while IFS='=' read -r var value; do
|
||||
eval "nodeinfo_$var=\"$value\""
|
||||
[[ "$1" != *"quiet"* ]] && echo "nodeinfo_$var:$value"
|
||||
done < <(echo "$(echo "$meshtastic_info" | sed -n '/Nodes in mesh:/,$p' | sed '1s/^Nodes in mesh: *//' | sed '/^[[:space:]]*$/q' | jq -r 'to_entries | .[0] | "\(.key)=\(.value)"' | sed 's/^[^=]*=//;s/^[ \t]*}//')" | jq -r '
|
||||
def recurse:
|
||||
if type == "object" then
|
||||
to_entries | .[] | "\(.key)=\(.value | recurse)"
|
||||
elif type == "array" then
|
||||
. | tostring
|
||||
else
|
||||
.
|
||||
end;
|
||||
recurse' | sed '/=/ {s/\(.*\)=\(.*\)=/\1_\2=/; }'
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ "$1" == *"all"* ]] || [[ "$1" == *"settings"* ]]; then
|
||||
# settings
|
||||
while IFS="=" read -r varname value; do
|
||||
eval "$varname='$value'"
|
||||
[[ "$1" != *"quiet"* ]] && echo "$varname:$value"
|
||||
done < <(
|
||||
echo "$(echo "$meshtastic_info" | sed -n '/Preferences: {/,$p' | sed '1s/.*/{/; /^[[:space:]]*$/q')" |
|
||||
jq -r 'to_entries[] | select(.value | type == "object") | .key as $block | .value | to_entries[] | "\($block)_\(.key)=\(.value)"'
|
||||
)
|
||||
|
||||
# module settings
|
||||
while IFS="=" read -r varname value; do
|
||||
eval "$varname='$value'"
|
||||
[[ "$1" != *"quiet"* ]] && echo "$varname:$value"
|
||||
done < <(
|
||||
echo "$(echo "$meshtastic_info" | sed -n '/Module preferences: {/,$p' | sed '1s/.*/{/; /^[[:space:]]*$/q')" |
|
||||
jq -r 'to_entries[] | select(.value | type == "object") | .key as $block | .value | to_entries[] | "\($block)_\(.key)=\(.value)"'
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ "$1" == *"all"* ]] || [[ "$1" == *"channels"* ]]; then
|
||||
# channels
|
||||
while read index line; do
|
||||
channel_type=$(echo "$line" | awk '{print $3}')
|
||||
psk_type=$(echo "$line" | grep -o 'psk=[^ ]*' | cut -d= -f2)
|
||||
eval "channel${index}_type='$channel_type'"
|
||||
[[ "$1" != *"quiet"* ]] && echo "channel${index}_type:$channel_type"
|
||||
eval "channel${index}_psk_type='$psk_type'"
|
||||
[[ "$1" != *"quiet"* ]] && echo "channel${index}_psk_type:$psk_type"
|
||||
|
||||
# get the json portion of the channel listing
|
||||
while IFS=":" read -r key value; do
|
||||
eval "$key='$value'"
|
||||
[[ "$1" != *"quiet"* ]] && echo "$key:$value"
|
||||
done < <(
|
||||
echo "$(echo "$line" | sed 's/.*\({.*\)/\1/')" | jq -r 'to_entries | .[] | "channel'${index}'_\(.key):\(.value)"'
|
||||
)
|
||||
done < <(
|
||||
echo "$meshtastic_info" | awk '/Channels:/ {f=1; next} f && NF {print} f && !NF {exit}' | nl -v 0
|
||||
)
|
||||
|
||||
eval "url_primary_channel='$(echo "$meshtastic_info" | sed -n 's/^Primary channel URL: //p')'"
|
||||
[[ "$1" != *"quiet"* ]] && echo "url_primary_channel:$url_primary_channel"
|
||||
eval "url_all_channels='$(echo "$meshtastic_info" | sed -n 's/^Complete URL (includes all channels): //p')'"
|
||||
[[ "$1" != *"quiet"* ]] && echo "url_all_channels:$url_all_channels"
|
||||
fi
|
||||
}
|
||||
|
||||
# Parse options
|
||||
while getopts ":higkl:q:uU:rR:aA:cpo:sM:Stwuxm" opt; do
|
||||
while getopts ":hiC:gkl:q:uU:rR:aA:cpo:sM:Stwuxm" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
;;
|
||||
i) # Option -i (Get important node info)
|
||||
declare -a output_array
|
||||
output=$(meshtastic --host --info)
|
||||
get_meshtastic_settings quiet,nodeinfo,settings
|
||||
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)"
|
||||
Version:$metadata_firmwareVersion
|
||||
Node name:$myInfo_owner
|
||||
NodeID:$nodeinfo_user_id
|
||||
Nodenum:$myInfo_myNodeNum
|
||||
TX enabled:$lora_txEnabled
|
||||
Use preset:$lora_usePreset
|
||||
Preset:$lora_modemPreset
|
||||
Bandwidth:$lora_bandwidth
|
||||
Spread factor:$lora_spreadFactor
|
||||
Coding rate:$lora_codingRate
|
||||
Role:$device_role
|
||||
Freq offset:$lora_frequencyOffset
|
||||
Region:$lora_region
|
||||
Hop limit:$lora_hopLimit
|
||||
Freq slot:$lora_channelNum
|
||||
Override freq:$lora_overrideFrequency
|
||||
Public key:$security_publicKey
|
||||
Nodes in db:$metadata_nodedbCount"
|
||||
|
||||
;;
|
||||
C) # Option -C (Complete node config)
|
||||
get_meshtastic_settings $OPTARG
|
||||
;;
|
||||
g) # Option -g (get config URL)
|
||||
url=$(meshtastic --host --qr-all | grep -oP '(?<=Complete URL \(includes all channels\): )https://[^ ]+') #add look for errors
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ export LANG=C.UTF-8
|
|||
|
||||
title="Meshtastic LoRa Settings"
|
||||
args=$@
|
||||
|
||||
send_settings() {
|
||||
if [ -n "$command" ]; then
|
||||
set -o pipefail
|
||||
|
|
@ -126,9 +125,9 @@ lora_settings_actions() {
|
|||
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)
|
||||
while IFS=':' read -r key value; do
|
||||
eval "${key}=\"${value}\"" # Create a variable with the key name and assign it the value
|
||||
done < <(sudo femto-meshtasticd-config.sh -C settings)
|
||||
|
||||
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")
|
||||
|
|
@ -143,7 +142,7 @@ 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 "$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 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "$lora_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: ${lora_region})" 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
|
||||
|
|
@ -155,7 +154,7 @@ lora_settings_actions() {
|
|||
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 "${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 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "${lora_usePreset^}" --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: ${lora_usePreset:-unknown})" 0 0 0 \
|
||||
"True" "(default)" "" \
|
||||
"False" "" "" \
|
||||
" " "" "" \
|
||||
|
|
@ -184,7 +183,7 @@ 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 "$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 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "${$lora_modemPreset^}" --item-help --menu "The default preset will provide a strong mixture of speed and range, for most users.\n\nPreset? (current: ${lora_modemPreset:-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
|
||||
|
|
@ -199,7 +198,7 @@ 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 $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 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --item-help --default-item $lora_bandwidth --menu "Width of the frequency \"band\" used around the calculated center frequency. Only used if modem preset is disabled.\n\nBandwidth? (current: ${lora_bandwidth:-unknown})" 0 0 0 \
|
||||
0 "(default, automatic)" "" \
|
||||
31 "" "" \
|
||||
62 "" "" \
|
||||
|
|
@ -217,7 +216,7 @@ lora_settings_actions() {
|
|||
|
||||
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 $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 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --item-help --default-item $lora_spreadFactor --menu "Indicates the number of chirps per symbol. Only used if modem preset is disabled.\n\nSpread factor? (current: ${lora_spreadFactor:-unknown})" 0 0 0 \
|
||||
0 "(default, automatic)" "" \
|
||||
7 "" "" \
|
||||
8 "" "" \
|
||||
|
|
@ -236,7 +235,7 @@ lora_settings_actions() {
|
|||
|
||||
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 $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 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --item-help --default-item $lora_codingRate --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: ${lora_codingRate:-unknown})" 0 0 0 \
|
||||
0 "(default, automatic)" "" \
|
||||
5 "" "" \
|
||||
6 "" "" \
|
||||
|
|
@ -254,7 +253,7 @@ lora_settings_actions() {
|
|||
|
||||
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 $freq_offset 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 ${lora_frequencyOffset:-unknown} 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
|
||||
|
|
@ -265,7 +264,7 @@ lora_settings_actions() {
|
|||
|
||||
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 $hop_limit 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 ${lora_hopLimit:-unknown} 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
|
||||
|
|
@ -277,7 +276,7 @@ lora_settings_actions() {
|
|||
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 "${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 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "${lora_txEnabled^}" --item-help --menu "Enables/disables the radio chip. Useful for hot-swapping antennas.\n\nEnable TX? (current: ${lora_txEnabled:-unknown})" 0 0 0 \
|
||||
"True" "(default)" "" \
|
||||
"False" "" "" \
|
||||
" " "" "" \
|
||||
|
|
@ -300,8 +299,8 @@ 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 ${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
|
||||
TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 ${lora_txPower:-unknown} 3>&1 1>&2 2>&3)
|
||||
[[ -z $input || $input =~ ^([12]?[0-9]|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
|
||||
|
|
@ -311,7 +310,7 @@ TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 ${tx_power:-0} 3>&1 1>&2 2>
|
|||
|
||||
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 $freq_slot 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 ${lora_channelNum:-unknown} 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
|
||||
|
|
@ -322,7 +321,7 @@ TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 ${tx_power:-0} 3>&1 1>&2 2>
|
|||
|
||||
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 "$(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 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "$(echo "${lora_overrideDutyCycle:-False}" | sed 's/^./\U&/')" --item-help --menu "May have legal ramifications.\n\nOverride duty cycle? (current: ${lora_overrideDutyCycle:-unknown})" 0 0 0 \
|
||||
"True" "" "" \
|
||||
"False" "(default)" "" \
|
||||
" " "" "" \
|
||||
|
|
@ -336,7 +335,7 @@ TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 ${tx_power:-0} 3>&1 1>&2 2>
|
|||
|
||||
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 "$(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 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "$(echo "${lora_sx126xRxBoostedGain:-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: ${lora_sx126xRxBoostedGain:-unknown})" 0 0 0 \
|
||||
"True" "(default)" "" \
|
||||
"False" "" "" \
|
||||
" " "" "" \
|
||||
|
|
@ -350,7 +349,7 @@ TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 ${tx_power:-0} 3>&1 1>&2 2>
|
|||
|
||||
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 ${override_freq:-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 ${lora_overrideFrequency:-unknown} 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,7 +361,7 @@ TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 ${tx_power:-0} 3>&1 1>&2 2>
|
|||
|
||||
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 "$(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 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "$(echo "${lora_ignoreMqtt:-unknown}" | 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: ${lora_ignoreMqtt:-unknown})" 0 0 0 \
|
||||
"True" "" "" \
|
||||
"False" "(default)" "" \
|
||||
" " "" "" \
|
||||
|
|
@ -376,7 +375,7 @@ TX power in dBm. Must be 0-30 (0 for automatic)" 0 0 ${tx_power:-0} 3>&1 1>&2 2>
|
|||
|
||||
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 "$(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 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "$([[ "$1" == "wizard" ]] && echo "Skip" || echo "Cancel")" --default-item "$(echo "${lora_configOkToMqtt:-unknown}" | sed 's/^./\U&/')" --item-help --menu "Indicates that the user approves their packets to be uplinked to MQTT brokers.\n\nOK to MQTT? (current: ${lora_configOkToMqtt:-unknown})" 0 0 0 \
|
||||
"True" "" "" \
|
||||
"False" "(default)" "" \
|
||||
" " "" "" \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue