feat(mqtt): add phone-local MQTT proxy cutoff control#5823
Conversation
📄 Docs staleness check — advisoryThis PR modifies user-facing UI source files but does not update any page under
Changed source files: What to check:
New page checklist (if adding a new doc page):
If this PR does not require a doc update (e.g., internal refactor, bug fix, test change), add the
|
🖼️ Preview staleness check — advisoryThis PR modifies UI composables but does not update any
Changed UI files: What to check:
Adding previews checklist:
If this PR does not require preview updates (e.g., logic-only change, non-visual refactor), add the |
5227b2e to
3d66abc
Compare
Adds a "MQTT proxy on this phone" switch to the MQTT settings screen that stops/starts the phone-side MQTT proxy directly via MqttManager, without the slow read-modify-write-readback round-trip on the device's MQTT config. On nRF devices (where the phone is the MQTT proxy) a root-topic firehose can saturate the BLE link and MCU; this lets the user cut it immediately. - Expose MqttManager.proxyActive: StateFlow<Boolean> (phone-side lifecycle). - RadioConfigViewModel.setMqttProxyActive() stops/(re)starts the proxy using the device's current MQTT config, issuing no device config writes. - Switch is gated so off->on is only offered when the device config permits proxying, while staying live whenever the proxy is running. Fixes #5800 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
3d66abc to
6cda11e
Compare
When a device is set to the root topic, MQTT traffic can saturate the BLE link and the MCU on nRF devices — where the phone acts as the MQTT proxy — leaving the device unresponsive to phone requests. This adds a phone-local control that cuts the proxy firehose immediately, without the slow read-modify-write-readback cycle on the device's MQTT config.
Resolves #5800
🌟 New Features
MqttManagerand issues no device config reads or writes — so recovery is instant even when the BLE link is congested.🛠️ Refactoring & Architecture
MqttManagernow exposesproxyActive: StateFlow<Boolean>reflecting the phone-side proxy lifecycle (backed by the existing internal state inMqttManagerImpl, renamed to_proxyActive).RadioConfigViewModelsurfacesmqttProxyActiveand addssetMqttProxyActive(active), which callsMqttManager.stop()/startProxy(...)directly. On re-enable it reads the device's current (already-loaded) MQTT config rather than fetching it, and never writes config back.mqtt.enabled && proxy_to_client_enabled), while staying live whenever the proxy is actually running so it can always be turned off.Testing Performed
Added unit tests in
RadioConfigViewModelTest:setMqttProxyActive false stops the proxy without touching device config— verifiesMqttManager.stop()is called and nosetModuleConfigwrite is issued.setMqttProxyActive true restarts proxy using current device module config— verifiesstartProxy(true, true)from the loaded config, with no config write.setMqttProxyActive true is a no-op start when device MQTT is disabled— verifies it delegates with both flagsfalse(the manager's own guard then does nothing).Full baseline verification run locally and green:
spotlessApply spotlessCheck detekt assembleDebug test allTests kmpSmokeCompile.