From 07a8972aea39dc271dd42ed4216195a3871d005c Mon Sep 17 00:00:00 2001 From: geeksville Date: Sat, 4 Apr 2020 18:47:41 -0700 Subject: [PATCH] NEO-6M gps with empty backup batteries give super invalid times --- src/GPS.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/GPS.cpp b/src/GPS.cpp index 3265b9ddf..5312d97a5 100644 --- a/src/GPS.cpp +++ b/src/GPS.cpp @@ -176,8 +176,10 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s tv.tv_usec = 0; // time.centisecond() * (10 / 1000); DEBUG_MSG("Got time from GPS month=%d, year=%d, unixtime=%ld\n", t.tm_mon, t.tm_year, tv.tv_sec); - - perhapsSetRTC(&tv); + if (t.tm_year < 0 || t.tm_year >= 300) + DEBUG_MSG("Ignoring invalid GPS time\n"); + else + perhapsSetRTC(&tv); } if ((fixtype >= 3 && fixtype <= 4) && ublox.getP()) // rd fixes only