From ee461842ec5257a7697a4464f33aa3f5f2db7e3e Mon Sep 17 00:00:00 2001 From: nagumii Date: Tue, 18 Feb 2025 21:16:33 +0200 Subject: [PATCH] Revamp settings ingest --- .../usr/local/bin/femto-config | 4 +- .../usr/local/bin/femto-meshtasticd-config.sh | 153 +++++++++++++++--- .../bin/femto-meshtasticd-lora-dialogs.sh | 41 +++-- 3 files changed, 154 insertions(+), 44 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index 0188acf..bcfde72 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -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 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh index 6b24d72..70a0dac 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh @@ -8,6 +8,7 @@ help=$(cat <&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)" "" \ " " "" "" \