From 767c1a2f544efd622b01c1ef15064432f74d0f24 Mon Sep 17 00:00:00 2001 From: Mikael Nousiainen Date: Tue, 8 Aug 2023 18:44:01 +0300 Subject: [PATCH] Add leap seconds to raw GPS time --- src/config.h | 3 +++ src/radio.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/config.h b/src/config.h index 339a7ad..ec4018c 100644 --- a/src/config.h +++ b/src/config.h @@ -57,6 +57,9 @@ // Threshold for time-synchronized modes regarding how far from scheduled transmission time the transmission is still allowed #define RADIO_TIME_SYNC_THRESHOLD_MS 2000 +// Number of leap seconds to add to the raw GPS time reported by the GPS chip (see https://timetoolsltd.com/gps/what-is-gps-time/ for more info) +#define GPS_TIME_LEAP_SECONDS 18 + // Enable this setting to require 3D fix (altitude required, enable for airborne use), otherwise 2D fix is enough #define GPS_REQUIRE_3D_FIX true diff --git a/src/radio.c b/src/radio.c index 877d5ed..f1c2277 100644 --- a/src/radio.c +++ b/src/radio.c @@ -712,7 +712,7 @@ bool radio_handle_time_sync() return false; } - uint32_t time_millis = gps.time_of_week_millis; + uint32_t time_millis = gps.time_of_week_millis + (GPS_TIME_LEAP_SECONDS * 1000); if (time_millis == radio_previous_time_sync_scheduled) { // The GPS chip has not provided an updated time yet for some reason