From 225c47ede3ac069e2690fd3f5d9038fdea04a035 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 16 Jul 2025 19:17:45 -0500 Subject: [PATCH] Factory reset RTC --- src/gps/GPS.cpp | 7 +++++++ src/gps/cas.h | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 3a6b19f64..9f7a7ebbf 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1539,6 +1539,13 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s if (perhapsSetRTC(RTCQualityGPS, t) == RTCSetResultInvalidTime) { // Clear the GPS buffer if we got an invalid time clearBuffer(); + // Clear the RTC from the L76K, L76B, and clones + if (IS_ONE_OF(gnssModel, GNSS_MODEL_MTK_L76B, GNSS_MODEL_MTK)) { + // Clear the RTC from the L76 and MTK GPS modules + LOG_DEBUG("Clearing RTC from L76K/L76B"); + int msglen = makeCASPacket(0x06, 0x02, sizeof(_message_CAS_CFG_RST_FACTORY), _message_CAS_CFG_RST_FACTORY); + _serial_gps->write(_message_CAS_CFG_RST_FACTORY, msglen); + } } return true; } else diff --git a/src/gps/cas.h b/src/gps/cas.h index 725fd07b3..cd8ef0eba 100644 --- a/src/gps/cas.h +++ b/src/gps/cas.h @@ -27,6 +27,13 @@ static const uint8_t _message_CAS_CFG_RST_FACTORY[] = { 0x03 // Startup Mode: Factory }; +// Clear RTC data +static const uint8_t _message_CAS_CFG_RST_RTC[] = { + 0x00, 0x01, // NavBbrMask: Clear RTC data + 0x01, // Reset Mode: Controlled Software reset + 0x00 // Reserved +}; + // CFG_RATE (0x06, 0x01) // 1HZ update rate, this should always be the case after // factory reset but update it regardless