forked from iarv/pyMC_Repeater
Enhance radio configuration script to handle LED pin settings and DIO3 TCXO flag updates
This commit is contained in:
@@ -170,8 +170,8 @@ title=$(cat /tmp/radio_title_$selected 2>/dev/null)
|
||||
|
||||
|
||||
# Convert frequency from MHz to Hz (handle decimal values)
|
||||
freq_hz=$(echo "$freq * 1000000" | bc -l | cut -d. -f1)
|
||||
bw_hz=$(echo "$bw * 1000" | bc -l | cut -d. -f1)
|
||||
freq_hz=$(echo "$freq * 1000000" | awk '{printf "%.0f", $1}')
|
||||
bw_hz=$(echo "$bw * 1000" | awk '{printf "%.0f", $1}')
|
||||
|
||||
|
||||
echo ""
|
||||
@@ -230,8 +230,26 @@ else
|
||||
[ -n "$irq_pin" ] && sed "${SED_OPTS[@]}" "s/^ irq_pin:.*/ irq_pin: $irq_pin/" "$CONFIG_FILE"
|
||||
[ -n "$txen_pin" ] && sed "${SED_OPTS[@]}" "s/^ txen_pin:.*/ txen_pin: $txen_pin/" "$CONFIG_FILE"
|
||||
[ -n "$rxen_pin" ] && sed "${SED_OPTS[@]}" "s/^ rxen_pin:.*/ rxen_pin: $rxen_pin/" "$CONFIG_FILE"
|
||||
[ -n "$txled_pin" ] && sed "${SED_OPTS[@]}" "s/^ txled_pin:.*/ txled_pin: $txled_pin/" "$CONFIG_FILE"
|
||||
[ -n "$rxled_pin" ] && sed "${SED_OPTS[@]}" "s/^ rxled_pin:.*/ rxled_pin: $rxled_pin/" "$CONFIG_FILE"
|
||||
|
||||
# Handle LED pins - add if missing, update if present
|
||||
if [ -n "$txled_pin" ]; then
|
||||
if grep -q "^ txled_pin:" "$CONFIG_FILE"; then
|
||||
sed "${SED_OPTS[@]}" "s/^ txled_pin:.*/ txled_pin: $txled_pin/" "$CONFIG_FILE"
|
||||
else
|
||||
# Add txled_pin after rxen_pin
|
||||
sed "${SED_OPTS[@]}" "/^ rxen_pin:.*/a\\ txled_pin: $txled_pin" "$CONFIG_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$rxled_pin" ]; then
|
||||
if grep -q "^ rxled_pin:" "$CONFIG_FILE"; then
|
||||
sed "${SED_OPTS[@]}" "s/^ rxled_pin:.*/ rxled_pin: $rxled_pin/" "$CONFIG_FILE"
|
||||
else
|
||||
# Add rxled_pin after txled_pin
|
||||
sed "${SED_OPTS[@]}" "/^ txled_pin:.*/a\\ rxled_pin: $rxled_pin" "$CONFIG_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -n "$tx_power" ] && sed "${SED_OPTS[@]}" "s/^ tx_power:.*/ tx_power: $tx_power/" "$CONFIG_FILE"
|
||||
[ -n "$preamble_length" ] && sed "${SED_OPTS[@]}" "s/^ preamble_length:.*/ preamble_length: $preamble_length/" "$CONFIG_FILE"
|
||||
|
||||
@@ -244,9 +262,27 @@ else
|
||||
|
||||
# Update use_dio3_tcxo flag
|
||||
if [ "$use_dio3_tcxo" == "true" ]; then
|
||||
sed "${SED_OPTS[@]}" "s/^ use_dio3_tcxo:.*/ use_dio3_tcxo: true/" "$CONFIG_FILE"
|
||||
if grep -q "^ use_dio3_tcxo:" "$CONFIG_FILE"; then
|
||||
sed "${SED_OPTS[@]}" "s/^ use_dio3_tcxo:.*/ use_dio3_tcxo: true/" "$CONFIG_FILE"
|
||||
else
|
||||
# Add use_dio3_tcxo after rxled_pin (or rxen_pin if no LED pins)
|
||||
if grep -q "^ rxled_pin:" "$CONFIG_FILE"; then
|
||||
sed "${SED_OPTS[@]}" "/^ rxled_pin:.*/a\\ use_dio3_tcxo: true" "$CONFIG_FILE"
|
||||
else
|
||||
sed "${SED_OPTS[@]}" "/^ rxen_pin:.*/a\\ use_dio3_tcxo: true" "$CONFIG_FILE"
|
||||
fi
|
||||
fi
|
||||
elif [ "$use_dio3_tcxo" == "false" ]; then
|
||||
sed "${SED_OPTS[@]}" "s/^ use_dio3_tcxo:.*/ use_dio3_tcxo: false/" "$CONFIG_FILE"
|
||||
if grep -q "^ use_dio3_tcxo:" "$CONFIG_FILE"; then
|
||||
sed "${SED_OPTS[@]}" "s/^ use_dio3_tcxo:.*/ use_dio3_tcxo: false/" "$CONFIG_FILE"
|
||||
else
|
||||
# Add use_dio3_tcxo after rxled_pin (or rxen_pin if no LED pins)
|
||||
if grep -q "^ rxled_pin:" "$CONFIG_FILE"; then
|
||||
sed "${SED_OPTS[@]}" "/^ rxled_pin:.*/a\\ use_dio3_tcxo: false" "$CONFIG_FILE"
|
||||
else
|
||||
sed "${SED_OPTS[@]}" "/^ rxen_pin:.*/a\\ use_dio3_tcxo: false" "$CONFIG_FILE"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user