From bf84d18b9b3965694777617e94128bc18776588d Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 30 Aug 2024 18:06:13 -0500 Subject: [PATCH 1/2] Ignore (from)Net time on positions with an unknown or fixed location source --- src/modules/PositionModule.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 2a0c95a9b4..8cfba9b203 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -129,6 +129,10 @@ void PositionModule::trySetRtc(meshtastic_Position p, bool isLocal, bool forceUp LOG_DEBUG("Ignoring time from mesh because we have a GPS, RTC, or Phone/NTP time source in the past day\n"); return; } + if (!isLocal && p.location_source < meshtastic_Position_LocSource_LOC_INTERNAL) { + LOG_DEBUG("Ignoring time from mesh because it has a unknown or manual source\n"); + return; + } struct timeval tv; uint32_t secs = p.time; @@ -191,6 +195,10 @@ meshtastic_MeshPacket *PositionModule::allocReply() p.has_longitude_i = true; p.time = getValidTime(RTCQualityNTP) > 0 ? getValidTime(RTCQualityNTP) : localPosition.time; + if (config.position.fixed_position) { + p.location_source = meshtastic_Position_LocSource_LOC_MANUAL; + } + if (pos_flags & meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE) { if (pos_flags & meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE_MSL) { p.altitude = localPosition.altitude; From 30dd06c64761ce65442c69796a079910c178f1b9 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 30 Aug 2024 18:23:25 -0500 Subject: [PATCH 2/2] Dunk a trunk --- src/modules/PositionModule.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 8cfba9b203..7c08835bc0 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -130,7 +130,7 @@ void PositionModule::trySetRtc(meshtastic_Position p, bool isLocal, bool forceUp return; } if (!isLocal && p.location_source < meshtastic_Position_LocSource_LOC_INTERNAL) { - LOG_DEBUG("Ignoring time from mesh because it has a unknown or manual source\n"); + LOG_DEBUG("Ignoring time from mesh because it has a unknown or manual source\n"); return; } struct timeval tv; @@ -198,7 +198,7 @@ meshtastic_MeshPacket *PositionModule::allocReply() if (config.position.fixed_position) { p.location_source = meshtastic_Position_LocSource_LOC_MANUAL; } - + if (pos_flags & meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE) { if (pos_flags & meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE_MSL) { p.altitude = localPosition.altitude;