Skip to content

Commit d1e7bd1

Browse files
authored
feat: prevent QR imports from overriding local TX power (#3845)
1 parent 7227957 commit d1e7bd1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

core/ui/src/main/kotlin/org/meshtastic/core/ui/qr/ScannedQrCodeDialog.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,16 @@ fun ScannedQrCodeDialog(
9595
val channelSet =
9696
remember(shouldReplace) {
9797
if (shouldReplace) {
98-
incoming.copy { loraConfig = loraConfig.copy { configOkToMqtt = channels.loraConfig.configOkToMqtt } }
98+
// When replacing, apply the incoming LoRa configuration but preserve certain
99+
// locally safe fields such as MQTT flags and TX power. This prevents QR codes
100+
// from unintentionally overriding device-specific power limits (e.g. E22 caps).
101+
incoming.copy {
102+
loraConfig =
103+
loraConfig.copy {
104+
configOkToMqtt = channels.loraConfig.configOkToMqtt
105+
txPower = channels.loraConfig.txPower
106+
}
107+
}
99108
} else {
100109
channels.copy {
101110
// To guarantee consistent ordering, using a LinkedHashSet which iterates through
@@ -158,9 +167,6 @@ fun ScannedQrCodeDialog(
158167
if (current.txEnabled != new.txEnabled) {
159168
changes.add("Transmit Enabled: ${current.txEnabled} -> ${new.txEnabled}")
160169
}
161-
if (current.txPower != new.txPower) {
162-
changes.add("Transmit Power: ${current.txPower}dBm -> ${new.txPower}dBm")
163-
}
164170
if (current.channelNum != new.channelNum) {
165171
changes.add("Channel Number: ${current.channelNum} -> ${new.channelNum}")
166172
}

0 commit comments

Comments
 (0)