From b538bd06d6f8a4f3a5f6fe8aa93b548bebcb64a2 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Thu, 2 Aug 2018 23:31:22 +1200 Subject: [PATCH] Fill metadata values even if the GPS fix isn't acquired. --- GpsTracker/Positions.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/GpsTracker/Positions.cpp b/GpsTracker/Positions.cpp index 81d2d52..f4ab051 100644 --- a/GpsTracker/Positions.cpp +++ b/GpsTracker/Positions.cpp @@ -57,19 +57,17 @@ namespace positions { NOTICE("acquire"); timestamp_t before; - + gps::powerOn(); before = rtc::getTime(); SIM808_GPS_STATUS gpsStatus = gps::acquireCurrentPosition(GPS_DEFAULT_TOTAL_TIMEOUT_MS); + uint16_t timeToFix = rtc::getTime() - before; SIM808ChargingStatus battery = hardware::sim808::device.getChargingState(); gps::powerOff(); + bool acquired = gpsStatus >= SIM808_GPS_STATUS::FIX; //prety useless wins 14 bytes on the hex size rather than return gpStatus >= ... NOTICE_FORMAT("acquire", "Status : %d", gpsStatus); - if (gpsStatus < SIM808_GPS_STATUS::FIX) return false; - - uint16_t timeToFix = rtc::getTime() - before; - metadata = { battery.level, battery.voltage, @@ -78,7 +76,7 @@ namespace positions { gpsStatus }; - return true; + return acquired; } void appendLast(const PositionEntryMetadata &metadata) { @@ -126,7 +124,7 @@ namespace positions { bool moveNext(uint16_t &index) { if (index == config::main::value.lastEntry) return false; - + if (index == details::maxEntryIndex) index = 0; //could use a modulo but easier to understand that way else index++;