瀏覽代碼

Fill metadata values even if the GPS fix isn't acquired.

tags/v1.2.0
Bertrand Lemasle 6 年之前
父節點
當前提交
b538bd06d6
共有 1 個檔案被更改,包括 5 行新增7 行删除
  1. +5
    -7
      GpsTracker/Positions.cpp

+ 5
- 7
GpsTracker/Positions.cpp 查看文件

@@ -57,19 +57,17 @@ namespace positions {
NOTICE("acquire"); NOTICE("acquire");


timestamp_t before; timestamp_t before;
gps::powerOn(); gps::powerOn();
before = rtc::getTime(); before = rtc::getTime();
SIM808_GPS_STATUS gpsStatus = gps::acquireCurrentPosition(GPS_DEFAULT_TOTAL_TIMEOUT_MS); SIM808_GPS_STATUS gpsStatus = gps::acquireCurrentPosition(GPS_DEFAULT_TOTAL_TIMEOUT_MS);
uint16_t timeToFix = rtc::getTime() - before;
SIM808ChargingStatus battery = hardware::sim808::device.getChargingState(); SIM808ChargingStatus battery = hardware::sim808::device.getChargingState();
gps::powerOff(); 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); NOTICE_FORMAT("acquire", "Status : %d", gpsStatus);


if (gpsStatus < SIM808_GPS_STATUS::FIX) return false;

uint16_t timeToFix = rtc::getTime() - before;

metadata = { metadata = {
battery.level, battery.level,
battery.voltage, battery.voltage,
@@ -78,7 +76,7 @@ namespace positions {
gpsStatus gpsStatus
}; };


return true;
return acquired;
} }


void appendLast(const PositionEntryMetadata &metadata) { void appendLast(const PositionEntryMetadata &metadata) {
@@ -126,7 +124,7 @@ namespace positions {


bool moveNext(uint16_t &index) { bool moveNext(uint16_t &index) {
if (index == config::main::value.lastEntry) return false; if (index == config::main::value.lastEntry) return false;
if (index == details::maxEntryIndex) index = 0; //could use a modulo but easier to understand that way if (index == details::maxEntryIndex) index = 0; //could use a modulo but easier to understand that way
else index++; else index++;




Loading…
取消
儲存