kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
refactor: remove ClientProxy MQTT `status` topic
ref: https://github.com/meshtastic/firmware/pull/4305pull/1158/head
rodzic
fc2559f5f5
commit
9f4f919fe1
|
@ -2,7 +2,6 @@ package com.geeksville.mesh.repository.network
|
|||
|
||||
import com.geeksville.mesh.MeshProtos.MqttClientProxyMessage
|
||||
import com.geeksville.mesh.android.Logging
|
||||
import com.geeksville.mesh.model.DeviceVersion
|
||||
import com.geeksville.mesh.model.subscribeList
|
||||
import com.geeksville.mesh.mqttClientProxyMessage
|
||||
import com.geeksville.mesh.repository.datastore.RadioConfigRepository
|
||||
|
@ -41,7 +40,6 @@ class MQTTRepository @Inject constructor(
|
|||
*/
|
||||
private const val DEFAULT_QOS = 1
|
||||
private const val DEFAULT_TOPIC_ROOT = "msh"
|
||||
private const val STAT_TOPIC_LEVEL = "/2/stat/"
|
||||
private const val DEFAULT_TOPIC_LEVEL = "/2/e/"
|
||||
private const val JSON_TOPIC_LEVEL = "/2/json/"
|
||||
private const val DEFAULT_SERVER_ADDRESS = "mqtt.meshtastic.org"
|
||||
|
@ -68,12 +66,6 @@ class MQTTRepository @Inject constructor(
|
|||
sslContext.init(null, arrayOf<TrustManager>(TrustAllX509TrustManager()), SecureRandom())
|
||||
|
||||
val rootTopic = mqttConfig.root.ifEmpty { DEFAULT_TOPIC_ROOT }
|
||||
val statTopic = "$rootTopic$STAT_TOPIC_LEVEL$ownerId"
|
||||
|
||||
// TODO remove after MeshService.minDeviceVersion >= 2.3.0
|
||||
val myNodeInfo = radioConfigRepository.myNodeInfo.first()
|
||||
val curVer = DeviceVersion(myNodeInfo?.firmwareVersion.orEmpty())
|
||||
val defaultTopic = if (curVer < DeviceVersion("2.3.0")) "/2/c/" else DEFAULT_TOPIC_LEVEL
|
||||
|
||||
val connectOptions = MqttConnectOptions().apply {
|
||||
userName = mqttConfig.username
|
||||
|
@ -82,7 +74,6 @@ class MQTTRepository @Inject constructor(
|
|||
if (mqttConfig.tlsEnabled) {
|
||||
socketFactory = sslContext.socketFactory
|
||||
}
|
||||
setWill(statTopic, "offline".encodeToByteArray(), DEFAULT_QOS, true)
|
||||
}
|
||||
|
||||
val bufferOptions = DisconnectedBufferOptions().apply {
|
||||
|
@ -96,11 +87,9 @@ class MQTTRepository @Inject constructor(
|
|||
override fun connectComplete(reconnect: Boolean, serverURI: String) {
|
||||
info("MQTT connectComplete: $serverURI reconnect: $reconnect ")
|
||||
channelSet.subscribeList.forEach { globalId ->
|
||||
subscribe("$rootTopic$defaultTopic$globalId/#")
|
||||
// subscribe("$rootTopic$DEFAULT_TOPIC_LEVEL$globalId/#")
|
||||
subscribe("$rootTopic$DEFAULT_TOPIC_LEVEL$globalId/#")
|
||||
if (mqttConfig.jsonEnabled) subscribe("$rootTopic$JSON_TOPIC_LEVEL$globalId/#")
|
||||
}
|
||||
// publish(statTopic, "online".encodeToByteArray(), DEFAULT_QOS, true)
|
||||
}
|
||||
|
||||
override fun connectionLost(cause: Throwable) {
|
||||
|
|
Ładowanie…
Reference in New Issue