aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-13 12:01:01 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-13 12:09:10 -0800
commit6124842b0c4e8e52a72434f78b4b4177c6e2474b (patch)
tree4d475e58600c6c499632e05e6a53b734b99dcac3
parentfb06d2759311c04c78716be4325e4bc4fb3f04e3 (diff)
downloadsubsurface-6124842b0c4e8e52a72434f78b4b4177c6e2474b.tar.gz
Location service: only request a fix once every 5 minutes
This should prevent the device from draining battery like crazy. This is not the same as the interval at which we record fixes - getting a fix every 5 minutes gives us a better chance to notice when we moved the minimum distance. Also add some more comments to the code that does the actual handling of storing the data. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-mobile/gpslocation.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/qt-mobile/gpslocation.cpp b/qt-mobile/gpslocation.cpp
index 97602356f..7cba1a199 100644
--- a/qt-mobile/gpslocation.cpp
+++ b/qt-mobile/gpslocation.cpp
@@ -17,6 +17,7 @@ GpsLocation::GpsLocation(QObject *parent)
QString msg = QString("have position source %1").arg(gpsSource->sourceName());
connect(gpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo)));
connect(gpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
+ gpsSource->setUpdateInterval(5 * 60 * 1000); // 5 minutes so the device doesn't drain the battery
} else {
status("don't have GPS source");
}
@@ -38,6 +39,7 @@ void GpsLocation::serviceEnable(bool toggle)
}
}
+// these two need to become configurable
#define MINTIME 600
#define MINDIST 200
@@ -53,7 +55,8 @@ void GpsLocation::newPosition(QGeoPositionInfo pos)
lastCoord.setLongitude(geoSettings->value(QString("gpsFix%1_lon").arg(nr)).toInt() / 1000000.0);
time_t lastTime = geoSettings->value(QString("gpsFix%1_time").arg(nr)).toULongLong();
}
- // if we have no record stored or if at least 10 minutes have passed or we moved at least 200m
+ // if we have no record stored or if at least the configured minimum
+ // time has passed or we moved at least the configured minimum distance
if (!nr || pos.timestamp().toTime_t() > lastTime + MINTIME || lastCoord.distanceTo(pos.coordinate()) > MINDIST) {
geoSettings->setValue("count", nr + 1);
geoSettings->setValue(QString("gpsFix%1_time").arg(nr), pos.timestamp().toTime_t());