feat: prevent QR imports from overriding local TX power (#3845)

This commit is contained in:
Mac DeCourcy
2025-11-28 12:45:09 -08:00
committed by GitHub
parent 7227957f0a
commit d1e7bd1ad5

View File

@@ -95,7 +95,16 @@ fun ScannedQrCodeDialog(
val channelSet =
remember(shouldReplace) {
if (shouldReplace) {
incoming.copy { loraConfig = loraConfig.copy { configOkToMqtt = channels.loraConfig.configOkToMqtt } }
// When replacing, apply the incoming LoRa configuration but preserve certain
// locally safe fields such as MQTT flags and TX power. This prevents QR codes
// from unintentionally overriding device-specific power limits (e.g. E22 caps).
incoming.copy {
loraConfig =
loraConfig.copy {
configOkToMqtt = channels.loraConfig.configOkToMqtt
txPower = channels.loraConfig.txPower
}
}
} else {
channels.copy {
// To guarantee consistent ordering, using a LinkedHashSet which iterates through
@@ -158,9 +167,6 @@ fun ScannedQrCodeDialog(
if (current.txEnabled != new.txEnabled) {
changes.add("Transmit Enabled: ${current.txEnabled} -> ${new.txEnabled}")
}
if (current.txPower != new.txPower) {
changes.add("Transmit Power: ${current.txPower}dBm -> ${new.txPower}dBm")
}
if (current.channelNum != new.channelNum) {
changes.add("Channel Number: ${current.channelNum} -> ${new.channelNum}")
}