diff --git a/arch/stm32/stm32.ini b/arch/stm32/stm32.ini
index ffbc516805..050dbf7f0f 100644
--- a/arch/stm32/stm32.ini
+++ b/arch/stm32/stm32.ini
@@ -12,6 +12,7 @@ build_flags =
-flto
-Isrc/platform/stm32wl -g
-DMESHTASTIC_MINIMIZE_BUILD
+ -DMESHTASTIC_EXCLUDE_GPS
-DDEBUG_MUTE
; -DVECT_TAB_OFFSET=0x08000000
-DconfigUSE_CMSIS_RTOS_V2=1
@@ -21,7 +22,7 @@ build_flags =
-fdata-sections
build_src_filter =
- ${arduino_base.build_src_filter} - - - - - - - - - - - - -
+ ${arduino_base.build_src_filter} - - - - - - - - - - - - - -
board_upload.offset_address = 0x08000000
upload_protocol = stlink
diff --git a/src/gps/RTC.cpp b/src/gps/RTC.cpp
index 710baca985..0700386723 100644
--- a/src/gps/RTC.cpp
+++ b/src/gps/RTC.cpp
@@ -6,6 +6,7 @@
#include
static RTCQuality currentQuality = RTCQualityNone;
+uint32_t lastSetFromPhoneNtpOrGps = 0;
RTCQuality getRTCQuality()
{
@@ -121,6 +122,9 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpdate)
if (shouldSet) {
currentQuality = q;
lastSetMsec = now;
+ if (currentQuality >= RTCQualityNTP) {
+ lastSetFromPhoneNtpOrGps = now;
+ }
// This delta value works on all platforms
timeStartMsec = now;
diff --git a/src/gps/RTC.h b/src/gps/RTC.h
index d31e85433c..caa48dc06c 100644
--- a/src/gps/RTC.h
+++ b/src/gps/RTC.h
@@ -24,6 +24,8 @@ enum RTCQuality {
RTCQuality getRTCQuality();
+extern uint32_t lastSetFromPhoneNtpOrGps;
+
/// If we haven't yet set our RTC this boot, set it from a GPS derived time
bool perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpdate = false);
bool perhapsSetRTC(RTCQuality q, struct tm &t);
diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp
index 5da9180490..1618ba3ed5 100644
--- a/src/modules/PositionModule.cpp
+++ b/src/modules/PositionModule.cpp
@@ -90,7 +90,6 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
// will always be an equivalent or lesser RTCQuality (RTCQualityNTP or RTCQualityNet).
force = true;
#endif
-
// Set from phone RTC Quality to RTCQualityNTP since it should be approximately so
trySetRtc(p, isLocal, force);
}
@@ -126,14 +125,26 @@ void PositionModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtastic
void PositionModule::trySetRtc(meshtastic_Position p, bool isLocal, bool forceUpdate)
{
+ if (hasQualityTimesource() && !isLocal) {
+ LOG_DEBUG("Ignoring time from mesh because we have a GPS, RTC, or Phone/NTP time source in the past day\n");
+ return;
+ }
struct timeval tv;
uint32_t secs = p.time;
tv.tv_sec = secs;
tv.tv_usec = 0;
+
perhapsSetRTC(isLocal ? RTCQualityNTP : RTCQualityFromNet, &tv, forceUpdate);
}
+bool PositionModule::hasQualityTimesource()
+{
+ bool setFromPhoneOrNtpToday = (millis() - lastSetFromPhoneNtpOrGps) <= (SEC_PER_DAY * 1000UL);
+ bool hasGpsOrRtc = (gps && gps->isConnected()) || (rtc_found.address != ScanI2C::ADDRESS_NONE.address);
+ return hasGpsOrRtc || setFromPhoneOrNtpToday;
+}
+
meshtastic_MeshPacket *PositionModule::allocReply()
{
if (precision == 0) {
diff --git a/src/modules/PositionModule.h b/src/modules/PositionModule.h
index a5277aff69..c4ef665011 100644
--- a/src/modules/PositionModule.h
+++ b/src/modules/PositionModule.h
@@ -60,6 +60,7 @@ class PositionModule : public ProtobufModule, private concu
void trySetRtc(meshtastic_Position p, bool isLocal, bool forceUpdate = false);
uint32_t precision;
void sendLostAndFoundText();
+ bool hasQualityTimesource();
const uint32_t minimumTimeThreshold =
Default::getConfiguredOrDefaultMsScaled(config.position.broadcast_smart_minimum_interval_secs, 30, numOnlineNodes);
diff --git a/variants/rak2560/platformio.ini b/variants/rak2560/platformio.ini
index 96c1bfa92b..93c7acf717 100644
--- a/variants/rak2560/platformio.ini
+++ b/variants/rak2560/platformio.ini
@@ -6,6 +6,7 @@ board_check = true
build_flags = ${nrf52840_base.build_flags} -Ivariants/rak2560 -D RAK_4631
-L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard"
-DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
+ -DMESHTASTIC_EXCLUDE_GPS=1
-DHAS_RAKPROT=1 ; Define if RAk OneWireSerial is used (disables GPS)
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak2560> + + +
lib_deps =
diff --git a/variants/rak2560/variant.h b/variants/rak2560/variant.h
index 0c1c9aed90..8e5d905531 100644
--- a/variants/rak2560/variant.h
+++ b/variants/rak2560/variant.h
@@ -227,7 +227,7 @@ SO GPIO 39/TXEN MAY NOT BE DEFINED FOR SUCCESSFUL OPERATION OF THE SX1262 - TG
// #define GPS_TX_PIN PIN_SERIAL2_TX
// #define PIN_GPS_EN PIN_3V3_EN
// Disable GPS
-#define MESHTASTIC_EXCLUDE_GPS 1
+// #define MESHTASTIC_EXCLUDE_GPS 1
// Define pin to enable GPS toggle (set GPIO to LOW) via user button triple press
// RAK12002 RTC Module