From 7cffd9ba7083468816a63d3485c70e1a698dcda3 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 14 May 2025 15:31:28 -0500 Subject: [PATCH] Added new map report opt-in for compliance and limit map report (and default) to one hour (#6813) * Added new map report opt-in for compliance and limit map report (and default) to one hour * Trunk --- src/mesh/Default.h | 1 + src/mesh/NodeDB.cpp | 5 +++++ src/modules/AdminModule.cpp | 2 +- src/mqtt/MQTT.cpp | 4 +++- src/mqtt/MQTT.h | 4 ++-- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/mesh/Default.h b/src/mesh/Default.h index bc2aa785f..208f992c8 100644 --- a/src/mesh/Default.h +++ b/src/mesh/Default.h @@ -21,6 +21,7 @@ #define default_neighbor_info_broadcast_secs 6 * 60 * 60 #define min_node_info_broadcast_secs 60 * 60 // No regular broadcasts of more than once an hour #define min_neighbor_info_broadcast_secs 4 * 60 * 60 +#define default_map_publish_interval_secs 60 * 60 #define default_mqtt_address "mqtt.meshtastic.org" #define default_mqtt_username "meshdev" diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 48d22c65d..4b1a6d64d 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -328,6 +328,11 @@ NodeDB::NodeDB() moduleConfig.telemetry.health_update_interval = Default::getConfiguredOrMinimumValue( moduleConfig.telemetry.health_update_interval, min_default_telemetry_interval_secs); } + if (moduleConfig.mqtt.has_map_report_settings && + moduleConfig.mqtt.map_report_settings.publish_interval_secs < default_map_publish_interval_secs) { + moduleConfig.mqtt.map_report_settings.publish_interval_secs = default_map_publish_interval_secs; + } + // Ensure that the neighbor info update interval is coerced to the minimum moduleConfig.neighbor_info.update_interval = Default::getConfiguredOrMinimumValue(moduleConfig.neighbor_info.update_interval, min_neighbor_info_broadcast_secs); diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 0fac15b15..3ff4fa74d 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -504,7 +504,7 @@ void AdminModule::handleSetOwner(const meshtastic_User &o) sendWarning(licensedModeMessage); } } - if (owner.has_is_unmessagable != o.has_is_unmessagable || + if (owner.has_is_unmessagable != o.has_is_unmessagable || (o.has_is_unmessagable && owner.is_unmessagable != o.is_unmessagable)) { changed = 1; owner.has_is_unmessagable = o.has_is_unmessagable || o.has_is_unmessagable; diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 3776f59f5..713077272 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -769,7 +769,8 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp_encrypted, const meshtastic_Me void MQTT::perhapsReportToMap() { - if (!moduleConfig.mqtt.map_reporting_enabled || !(moduleConfig.mqtt.proxy_to_client_enabled || isConnectedDirectly())) + if (!moduleConfig.mqtt.map_reporting_enabled || !moduleConfig.mqtt.map_report_settings.should_report_location || + !(moduleConfig.mqtt.proxy_to_client_enabled || isConnectedDirectly())) return; if (Throttle::isWithinTimespanMs(last_report_to_map, map_publish_interval_msecs)) @@ -801,6 +802,7 @@ void MQTT::perhapsReportToMap() mapReport.region = config.lora.region; mapReport.modem_preset = config.lora.modem_preset; mapReport.has_default_channel = channels.hasDefaultChannel(); + mapReport.has_opted_report_location = true; // Set position with precision (same as in PositionModule) if (map_position_precision < 32 && map_position_precision > 0) { diff --git a/src/mqtt/MQTT.h b/src/mqtt/MQTT.h index 2b11f479d..7d5715602 100644 --- a/src/mqtt/MQTT.h +++ b/src/mqtt/MQTT.h @@ -1,5 +1,6 @@ #pragma once +#include "Default.h" #include "configuration.h" #include "concurrency/OSThread.h" @@ -105,8 +106,7 @@ class MQTT : private concurrency::OSThread std::string mapTopic = "/2/map/"; // For protobuf-encoded MapReport messages // For map reporting (only applies when enabled) - const uint32_t default_map_position_precision = 14; // defaults to max. offset of ~1459m - const uint32_t default_map_publish_interval_secs = 60 * 15; // defaults to 15 minutes + const uint32_t default_map_position_precision = 14; // defaults to max. offset of ~1459m uint32_t last_report_to_map = 0; uint32_t map_position_precision = default_map_position_precision; uint32_t map_publish_interval_msecs = default_map_publish_interval_secs * 1000;