diff --git a/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift b/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift index 435e162b..cf21d92e 100644 --- a/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift +++ b/Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift @@ -46,7 +46,12 @@ class MqttClientProxyManager { let root = node.mqttConfig?.root?.count ?? 0 > 0 ? node.mqttConfig?.root : "msh" let prefix = root! topic = prefix + "/2/e" + "/#" - connect(host: host, port: port, useSsl: useSsl, username: username, password: password, topic: topic) + // Require opt in to map report terms to connect + if node.mqttConfig?.mapReportingEnabled ?? false && UserDefaults.mapReportingOptIn || !(node.mqttConfig?.mapReportingEnabled ?? false) { + connect(host: host, port: port, useSsl: useSsl, username: username, password: password, topic: topic) + } else { + delegate?.onMqttError(message: "MQTT Map Reporting Terms need to be accepted.") + } } } func connect(host: String, port: Int, useSsl: Bool, username: String?, password: String?, topic: String?) { diff --git a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift index 61c2292b..217205cd 100644 --- a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift @@ -31,8 +31,7 @@ struct MQTTConfig: View { @State var defaultTopic = "msh/US" @State var nearbyTopics = [String]() @State var mapReportingEnabled = false - @State var mapReportingOptIn = false - //@AppStorage("mapReportingOptIn") private var mapReportingOptIn: Bool = false + @AppStorage("mapReportingOptIn") private var mapReportingOptIn: Bool = false @State var mapPublishIntervalSecs = 3600 @State var mapPositionPrecision: Double = 14.0 @@ -267,7 +266,7 @@ struct MQTTConfig: View { mqtt.encryptionEnabled = self.encryptionEnabled mqtt.jsonEnabled = self.jsonEnabled mqtt.tlsEnabled = self.tlsEnabled - mqtt.mapReportingEnabled = (self.mapReportingEnabled && self.mapReportingOptIn) + mqtt.mapReportingEnabled = self.mapReportingEnabled mqtt.mapReportSettings.positionPrecision = UInt32(self.mapPositionPrecision) mqtt.mapReportSettings.publishIntervalSecs = UInt32(self.mapPublishIntervalSecs) let adminMessageId = bleManager.saveMQTTConfig(config: mqtt, fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)