From 4debcd5ccd59eae3741789ce77d4c77f0567b17b Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:35:17 +0100 Subject: [PATCH 1/3] Set default position precision of mapReport to 14 (#3456) --- src/mqtt/MQTT.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mqtt/MQTT.h b/src/mqtt/MQTT.h index dbc0c77b3e..41b1601e79 100644 --- a/src/mqtt/MQTT.h +++ b/src/mqtt/MQTT.h @@ -90,8 +90,8 @@ class MQTT : private concurrency::OSThread // For map reporting (only applies when enabled) uint32_t last_report_to_map = 0; - uint32_t map_position_precision = 32; // default to full precision - uint32_t map_publish_interval_secs = 60 * 15; // default to 15 minutes + uint32_t map_position_precision = 14; // defaults to max. offset of ~1459m + uint32_t map_publish_interval_secs = 60 * 15; // defaults to 15 minutes /** return true if we have a channel that wants uplink/downlink or map reporting is enabled */ From 0a7ddb7594d4a8c514ba29b592df3039079fb7cd Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:42:53 +0100 Subject: [PATCH 2/3] Let NeighborInfo Module ignore packets coming from MQTT (#3457) --- src/modules/NeighborInfoModule.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/NeighborInfoModule.h b/src/modules/NeighborInfoModule.h index df5c2c9489..820e2d0d45 100644 --- a/src/modules/NeighborInfoModule.h +++ b/src/modules/NeighborInfoModule.h @@ -75,8 +75,9 @@ class NeighborInfoModule : public ProtobufModule, priva /* Does our periodic broadcast */ int32_t runOnce() override; - // Override wantPacket to say we want to see all packets when enabled, not just those for our port number - virtual bool wantPacket(const meshtastic_MeshPacket *p) override { return enabled; } + /* Override wantPacket to say we want to see all packets when enabled, not just those for our port number. + Exception is when the packet came via MQTT */ + virtual bool wantPacket(const meshtastic_MeshPacket *p) override { return enabled && !p->via_mqtt; } /* These are for debugging only */ void printNeighborInfo(const char *header, const meshtastic_NeighborInfo *np); From 6dd337a651ffafd81f47a530a41ee23bfce286e1 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 21 Mar 2024 14:43:10 -0500 Subject: [PATCH 3/3] Clear local position on nodedb-reset (#3451) * Clear local position on nodedb-reset * NodeDB pointer now, yo --------- Co-authored-by: Jonathan Bennett --- src/mesh/NodeDB.cpp | 11 +++++++++++ src/mesh/NodeDB.h | 2 ++ src/modules/PositionModule.cpp | 14 ++------------ src/modules/PositionModule.h | 3 --- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 6db8fc50b0..80b46a4268 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -434,6 +434,7 @@ void NodeDB::resetNodes() { numMeshNodes = 1; std::fill(devicestate.node_db_lite.begin() + 1, devicestate.node_db_lite.end(), meshtastic_NodeInfoLite()); + clearLocalPosition(); saveDeviceStateToDisk(); if (neighborInfoModule && moduleConfig.neighbor_info.enabled) neighborInfoModule->resetNeighbors(); @@ -455,6 +456,16 @@ void NodeDB::removeNodeByNum(uint nodeNum) saveDeviceStateToDisk(); } +void NodeDB::clearLocalPosition() +{ + meshtastic_NodeInfoLite *node = getMeshNode(nodeDB->getNodeNum()); + node->position.latitude_i = 0; + node->position.longitude_i = 0; + node->position.altitude = 0; + node->position.time = 0; + setLocalPosition(meshtastic_Position_init_default); +} + void NodeDB::cleanupMeshDB() { int newPos = 0, removed = 0; diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 23870db745..4d24d72257 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -131,6 +131,8 @@ class NodeDB meshtastic_NodeInfoLite *getMeshNode(NodeNum n); size_t getNumMeshNodes() { return numMeshNodes; } + void clearLocalPosition(); + void setLocalPosition(meshtastic_Position position, bool timeOnly = false) { if (timeOnly) { diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 0bfc775da7..d22c6b6994 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -34,21 +34,11 @@ PositionModule::PositionModule() if ((config.device.role == meshtastic_Config_DeviceConfig_Role_TRACKER || config.device.role == meshtastic_Config_DeviceConfig_Role_TAK_TRACKER) && config.power.is_power_saving) { - clearPosition(); + LOG_DEBUG("Clearing position on startup for sleepy tracker (ー。ー) zzz\n"); + nodeDB->clearLocalPosition(); } } -void PositionModule::clearPosition() -{ - LOG_DEBUG("Clearing position on startup for sleepy tracker (ー。ー) zzz\n"); - meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeDB->getNodeNum()); - node->position.latitude_i = 0; - node->position.longitude_i = 0; - node->position.altitude = 0; - node->position.time = 0; - nodeDB->setLocalPosition(meshtastic_Position_init_default); -} - bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Position *pptr) { auto p = *pptr; diff --git a/src/modules/PositionModule.h b/src/modules/PositionModule.h index fddafef6f7..68171ab0eb 100644 --- a/src/modules/PositionModule.h +++ b/src/modules/PositionModule.h @@ -51,9 +51,6 @@ class PositionModule : public ProtobufModule, private concu struct SmartPosition getDistanceTraveledSinceLastSend(meshtastic_PositionLite currentPosition); meshtastic_MeshPacket *allocAtakPli(); uint32_t precision; - - /** Only used in power saving trackers for now */ - void clearPosition(); void sendLostAndFoundText(); };