From d1e7bd1ad50af33e1b48ecd9e11ca99c7fba80de Mon Sep 17 00:00:00 2001 From: Mac DeCourcy <49794076+mdecourcy@users.noreply.github.com> Date: Fri, 28 Nov 2025 12:45:09 -0800 Subject: [PATCH] feat: prevent QR imports from overriding local TX power (#3845) --- .../meshtastic/core/ui/qr/ScannedQrCodeDialog.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/ui/src/main/kotlin/org/meshtastic/core/ui/qr/ScannedQrCodeDialog.kt b/core/ui/src/main/kotlin/org/meshtastic/core/ui/qr/ScannedQrCodeDialog.kt index 84c5f56ab..ae715e339 100644 --- a/core/ui/src/main/kotlin/org/meshtastic/core/ui/qr/ScannedQrCodeDialog.kt +++ b/core/ui/src/main/kotlin/org/meshtastic/core/ui/qr/ScannedQrCodeDialog.kt @@ -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}") }