fix(mqtt): remove noop mqtt to allow the mqtt proxy to work on the desktop builds (#7400)

Co-authored-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
Tha_14andJames Rich authored and GitHub committed 2026-09-28 13:28:22 +00:00
1 parent 355c528acc
commit 12ce21eb69
6 files changed
+14 -45

No files matched your search

@@ -1159,8 +1159,8 @@
<string name="mqtt_probe_tcp_failure">Cannot reach broker (TCP)</string>
<string name="mqtt_probe_timeout">Timed out after %1$d ms</string>
<string name="mqtt_probe_tls_failure">TLS handshake failed: %1$s</string>
<string name="mqtt_proxy_local">MQTT proxy on this phone</string>
<string name="mqtt_proxy_local_summary">This phone relays MQTT traffic for the connected device. Turn off to cut the relay immediately without changing the device's MQTT setting — useful when MQTT traffic is overwhelming the connection. Turn back on to resume relaying.</string>
<string name="mqtt_proxy_local">MQTT proxy in this app</string>
<string name="mqtt_proxy_local_summary">This app relays MQTT traffic for the connected device. Turn off to cut the relay immediately without changing the device's MQTT setting, which helps when MQTT traffic is overwhelming the connection. Turn back on to resume relaying.</string>
<string name="mqtt_status_connected">Connected</string>
<string name="mqtt_status_connecting">Connecting…</string>
<string name="mqtt_status_disconnected">Disconnected</string>
@@ -1785,7 +1785,7 @@
<string name="time">Time</string>
<string name="timeout">Timeout</string>
<string name="timestamp">Timestamp</string>
<string name="tls_enabled_public_broker_summary">When this phone relays MQTT it always connects to mqtt.meshtastic.org over TLS. This setting applies when the radio reaches the broker over its own Wi-Fi or Ethernet.</string>
<string name="tls_enabled_public_broker_summary">When this app relays MQTT it always connects to mqtt.meshtastic.org over TLS. This setting applies when the radio reaches the broker over its own Wi-Fi or Ethernet.</string>
<string name="toggle_my_position">Toggle my position</string>
<string name="trace_route">Trace Route</string>
<!-- TRACEROUTE -->
@@ -18,7 +18,6 @@ package org.meshtastic.desktop.di
import org.koin.core.annotation.Module
import org.koin.core.annotation.Single
import org.meshtastic.core.network.repository.MQTTRepository
import org.meshtastic.core.repository.AppWidgetUpdater
import org.meshtastic.core.repository.LocationRepository
import org.meshtastic.core.repository.MeshLocationManager
@@ -27,7 +26,6 @@ import org.meshtastic.core.repository.PlatformAnalytics
import org.meshtastic.desktop.stub.NoopAppWidgetUpdater
import org.meshtastic.desktop.stub.NoopCompassHeadingProvider
import org.meshtastic.desktop.stub.NoopLocationRepository
import org.meshtastic.desktop.stub.NoopMQTTRepository
import org.meshtastic.desktop.stub.NoopMagneticFieldProvider
import org.meshtastic.desktop.stub.NoopMeshLocationManager
import org.meshtastic.desktop.stub.NoopMeshWorkerManager
@@ -39,8 +37,7 @@ import org.meshtastic.feature.node.compass.PhoneLocationProvider
/**
* Stubs for interfaces whose only real implementation needs Android APIs — WorkManager, widgets, location, sensors and
* analytics. [MQTTRepository] is the exception: it has a working `commonMain` implementation, and this binding
* deliberately shadows it because desktop does not run the MQTT bridge.
* analytics.
*/
@Module
class DesktopStubsModule {
@@ -55,8 +52,6 @@ class DesktopStubsModule {
@Single fun locationRepository(): LocationRepository = NoopLocationRepository()
@Single fun mqttRepository(): MQTTRepository = NoopMQTTRepository()
@Single fun compassHeadingProvider(): CompassHeadingProvider = NoopCompassHeadingProvider()
@Single fun phoneLocationProvider(): PhoneLocationProvider = NoopPhoneLocationProvider()
@@ -31,7 +31,6 @@ import org.meshtastic.core.model.ConnectionState
import org.meshtastic.core.model.DeviceType
import org.meshtastic.core.model.InterfaceId
import org.meshtastic.core.model.MeshActivity
import org.meshtastic.core.network.repository.MQTTRepository
import org.meshtastic.core.repository.AppWidgetUpdater
import org.meshtastic.core.repository.DataPair
import org.meshtastic.core.repository.Location
@@ -45,9 +44,6 @@ import org.meshtastic.core.repository.RadioSessionContext
import org.meshtastic.core.repository.RadioSessionLease
import org.meshtastic.core.repository.ReceivedRadioFrame
import org.meshtastic.core.repository.TransportDisconnectReason
import org.meshtastic.mqtt.MqttException
import org.meshtastic.proto.MqttClientProxyMessage
import org.meshtastic.mqtt.ConnectionState as MqttConnectionState
import org.meshtastic.proto.Position as ProtoPosition
/**
@@ -173,19 +169,3 @@ class NoopLocationRepository : LocationRepository {
}
// endregion
// region Network Stubs (MQTT — not yet available on Desktop)
class NoopMQTTRepository : MQTTRepository {
override fun disconnect() {}
override val proxyMessageFlow: Flow<MqttClientProxyMessage> = emptyFlow()
override fun publish(topic: String, data: ByteArray, retained: Boolean) {}
override val connectionState = MutableStateFlow<MqttConnectionState>(MqttConnectionState.Disconnected.Idle)
override val subscriptionRefusal = MutableStateFlow<MqttException.SubscriptionRefused?>(null)
}
// endregion
@@ -26,8 +26,6 @@ import org.koin.plugin.module.dsl.koinApplication
import org.koin.test.verify.verify
import org.meshtastic.core.ble.BleLogFormat
import org.meshtastic.core.ble.BleLogLevel
import org.meshtastic.core.network.repository.MQTTRepository
import org.meshtastic.desktop.stub.NoopMQTTRepository
import org.meshtastic.feature.docs.translation.DocTranslationService
import org.meshtastic.feature.docs.translation.NoOpDocTranslator
import org.meshtastic.feature.messaging.translation.MessageTranslationService
@@ -67,12 +65,10 @@ class DesktopKoinTest {
@Test
fun `desktop bindings win over the shared graph`() {
// @Configuration modules load before the ones listed in @KoinApplication, and Koin is last-wins, so which
// binding survives is ordering-dependent. MQTTRepository is the live case: core:network commonMain declares
// MQTTRepositoryImpl, and desktop must shadow it. verify() only checks definitions exist, never who won.
// binding survives is ordering-dependent. verify() only checks definitions exist, never who won.
val app = koinApplication<DesktopKoinApp>()
try {
val koin = app.koin
assertIs<NoopMQTTRepository>(koin.get<MQTTRepository>())
assertIs<NoOpMessageTranslator>(koin.get<MessageTranslationService>())
assertIs<NoOpDocTranslator>(koin.get<DocTranslationService>())
} finally {
+7 -9
View File
@@ -48,13 +48,13 @@ A gateway node with internet access (Wi-Fi or Ethernet) publishes mesh messages
| **JSON output enabled** | Also publish and consume the `/2/json/` topic. Deprecated in the protobuf schema, but still the only toggle for this behavior — and the app's own proxy honors it | Disabled |
| **TLS enabled** | Secure connection to broker | Disabled |
| **Map reporting** | Report position to public map | Disabled |
| **Proxy to client enabled** | Relay MQTT through the connected phone | Disabled |
| **Proxy to client enabled** | Relay MQTT through the connected app | Disabled |
### Connection Status and Test Connection
The top of the MQTT settings screen shows the status of the relay this phone runs —
The top of the MQTT settings screen shows the status of the relay this app runs:
**Connected**, **Connecting**, **Reconnecting**, **Disconnected**, or **Inactive**. It reads
**Inactive** whenever the phone is not relaying, which includes the normal case of a radio
**Inactive** whenever the app is not relaying, which includes the normal case of a radio
reaching the broker over its own Wi-Fi or Ethernet. The radio's own connection to the broker is
not reported here.
@@ -62,19 +62,17 @@ not reported here.
distinguishes the failure modes: the hostname not resolving, the TCP connection being refused,
TLS failing, the attempt timing out, or the broker rejecting your credentials with a reason.
### MQTT Proxy on This Phone
### MQTT Proxy in This App
If your radio has no internet access of its own, it can use the connected phone as its MQTT gateway: enable **MQTT** and **Proxy to client enabled** in the module config, and the app relays MQTT traffic between the radio and the broker over your phone's internet connection.
If your radio has no internet access of its own, it can use the app as its MQTT gateway: enable **MQTT** and **Proxy to client enabled** in the module config, and the app relays MQTT traffic between the radio and the broker over your phone's or computer's internet connection.
> ℹ️ **Note:** The proxy relay is mobile-only. On the Desktop app the MQTT settings are present, but no relay runs behind them.
The **MQTT proxy on this phone** toggle at the top of the MQTT settings screen shows whether this relay is running and lets you cut it off (or restart it) immediately — without editing and re-saving the radio's MQTT configuration.
The **MQTT proxy in this app** toggle at the top of the MQTT settings screen shows whether this relay is running and lets you cut it off (or restart it) immediately, without editing and re-saving the radio's MQTT configuration.
### Default Meshtastic Broker
The community maintains a public broker at `mqtt.meshtastic.org`. This is intended for general use and testing.
When this phone relays MQTT for the radio, connections to that broker always use TLS on port 8883 even if **TLS enabled** is off — that upgrade is the app's own, and the switch says so. A radio that reaches the broker over its own Wi-Fi or Ethernet forces nothing: it uses **TLS enabled** as stored, so turn it on yourself or the radio connects in the clear on port 1883. For any other broker the toggle decides in both cases (port 8883 with TLS, 1883 without).
When this app relays MQTT for the radio, connections to that broker always use TLS on port 8883 even if **TLS enabled** is off. That upgrade is the app's own, and the switch says so. A radio that reaches the broker over its own Wi-Fi or Ethernet forces nothing: it uses **TLS enabled** as stored, so turn it on yourself or the radio connects in the clear on port 1883. For any other broker the toggle decides in both cases (port 8883 with TLS, 1883 without).
> 🔒 **Privacy:** Messages on the public broker are readable by anyone subscribed. Always use channel encryption for private communications.
+2 -2
View File
@@ -46,8 +46,8 @@ Bridges mesh messages to and from an MQTT broker for internet connectivity. This
| JSON output enabled | Publish and consume MQTT messages as JSON. Marked deprecated in the protobuf schema, but it is still the only toggle for this behavior and the firmware still honors it |
| TLS enabled | Use secure connection |
| Root topic | Base MQTT topic path |
| Proxy to client enabled | Let a connected phone carry the node's MQTT traffic, instead of the node reaching the broker itself |
| MQTT proxy on this phone | The phone-side half of **Proxy to client enabled**: whether this phone acts as that relay. See [MQTT](mqtt) |
| Proxy to client enabled | Let the connected app carry the node's MQTT traffic, instead of the node reaching the broker itself |
| MQTT proxy in this app | The app-side half of **Proxy to client enabled**: whether this app acts as that relay. See [MQTT](mqtt) |
| Map reporting | Publish position to the public map — see the Map reporting group that follows |
Turning **Map reporting** on reveals a consent card headed *Consent to Share Unencrypted Node Data