From d674aaaa29f519a8385ec788d07a181b15d94d0f Mon Sep 17 00:00:00 2001 From: geeksville Date: Wed, 22 Jul 2020 10:23:56 -0700 Subject: [PATCH] sometimes save config fails on ublox, don't cause a reboot for that --- src/error.h | 2 +- src/gps/UBloxGPS.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/error.h b/src/error.h index 6adcc0ec..6a2bae24 100644 --- a/src/error.h +++ b/src/error.h @@ -3,7 +3,7 @@ #include /// Error codes for critical error -enum CriticalErrorCode { NoError, ErrTxWatchdog, ErrSleepEnterWait, ErrNoRadio, ErrUnspecified }; +enum CriticalErrorCode { NoError, ErrTxWatchdog, ErrSleepEnterWait, ErrNoRadio, ErrUnspecified, UBloxInitFailed }; /// Record an error that should be reported via analytics void recordCriticalError(CriticalErrorCode code, uint32_t address = 0); diff --git a/src/gps/UBloxGPS.cpp b/src/gps/UBloxGPS.cpp index b63241c3..0ed506f6 100644 --- a/src/gps/UBloxGPS.cpp +++ b/src/gps/UBloxGPS.cpp @@ -1,4 +1,5 @@ #include "UBloxGPS.h" +#include "error.h" #include "sleep.h" #include @@ -83,7 +84,8 @@ bool UBloxGPS::setup() assert(ok); } ok = ublox.saveConfiguration(3000); - assert(ok); + if (!ok) + recordCriticalError(UBloxInitFailed); // Don't halt the boot if saving the config fails, but do report the bug concurrency::PeriodicTask::setup(); // We don't start our periodic task unless we actually found the device @@ -150,7 +152,8 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s // bogus lat lon is reported as 0 or 0 (can be bogus just for one) // Also: apparently when the GPS is initially reporting lock it can output a bogus latitude > 90 deg! - hasValidLocation = (latitude != 0) && (longitude != 0) && (latitude <= 900000000 && latitude >= -900000000) && (numSatellites > 0); + hasValidLocation = + (latitude != 0) && (longitude != 0) && (latitude <= 900000000 && latitude >= -900000000) && (numSatellites > 0); // we only notify if position has changed due to a new fix if ((fixtype >= 3 && fixtype <= 4) && ublox.getP(maxWait)) // rd fixes only