diff --git a/src/location_service.cpp b/src/location_service.cpp index c279a44..1c9d7bf 100644 --- a/src/location_service.cpp +++ b/src/location_service.cpp @@ -104,6 +104,8 @@ bool LocationService::getFastLock() { } bool LocationService::configureGPS(LocationServiceConfiguration& config) { + enableHotStartOnWake_ = config.enableHotStartOnWake(); + bool ret = true; WITH_LOCK(*gps_) { @@ -121,6 +123,7 @@ bool LocationService::configureGPS(LocationServiceConfiguration& config) { _deviceConfig.imuToVRPY(), _deviceConfig.imuToVRPZ() ); + ret &= gps_->setAOPSettings(_deviceConfig.enableAssistNowAutonomous()); } return ret; } @@ -129,16 +132,20 @@ int LocationService::start(bool restart) { CHECK_TRUE(gps_, SYSTEM_ERROR_INVALID_STATE); if (restart && gps_->isOn()) { + if (enableHotStartOnWake_) { + CHECK_TRUE(gps_->saveOnShutdown(), SYSTEM_ERROR_INVALID_STATE); + } gps_->off(); } if (!gps_->isOn()) { auto ret = gps_->on(); if (ret) { + Log.error("Error %d when turning GNSS on", ret); return ret; } - - configureGPS(_deviceConfig); // TODO: Add error code return + Log.info("GNSS Start"); + CHECK_TRUE(configureGPS(_deviceConfig), SYSTEM_ERROR_INVALID_STATE); } return SYSTEM_ERROR_NONE; @@ -149,6 +156,10 @@ int LocationService::stop() { int ret = SYSTEM_ERROR_NONE; if (gps_->isOn()) { + Log.info("Turning GNSS off"); + if (enableHotStartOnWake_) { + CHECK_TRUE(gps_->saveOnShutdown(), SYSTEM_ERROR_INVALID_STATE); + } ret = gps_->off(); } diff --git a/src/location_service.h b/src/location_service.h index 9bafeaa..874ef17 100644 --- a/src/location_service.h +++ b/src/location_service.h @@ -129,6 +129,16 @@ struct LocationStatus { #define LOCATION_CONFIG_ENABLE_AUTO_IMU_ALIGNMENT (false) #endif +#ifndef LOCATION_CONFIG_ENABLE_HOT_START_ON_WAKE +// Enable or disable GNSS Hot Start on Wake, see LocationServiceConfiguration below +#define LOCATION_CONFIG_ENABLE_HOT_START_ON_WAKE (true) +#endif + +#ifndef LOCATION_CONFIG_ENABLE_ASSISTNOW_AUTONOMOUS +// Enable or disable uBlox AssistNow Autonomous setting, see LocationServiceConfiguration below +#define LOCATION_CONFIG_ENABLE_ASSISTNOW_AUTONOMOUS (true) +#endif + /** * @brief LocationServiceConfiguration class to configure the tracker device in application * @@ -146,7 +156,9 @@ class LocationServiceConfiguration { _imuYaw(LOCATION_CONFIG_IMU_ORIENTATION_YAW), _imuPitch(LOCATION_CONFIG_IMU_ORIENTATION_PITCH), _imuRoll(LOCATION_CONFIG_IMU_ORIENTATION_ROLL), - _enableIMUAutoAlignment(LOCATION_CONFIG_ENABLE_AUTO_IMU_ALIGNMENT) { + _enableIMUAutoAlignment(LOCATION_CONFIG_ENABLE_AUTO_IMU_ALIGNMENT) , + _enableHotStartOnWake(LOCATION_CONFIG_ENABLE_HOT_START_ON_WAKE), + _enableAssistNowAutonomous(LOCATION_CONFIG_ENABLE_ASSISTNOW_AUTONOMOUS) { } /** @@ -179,7 +191,7 @@ class LocationServiceConfiguration { /** * @brief Enable or disable Untethered Dead Reckoning * - * @param enable Enable or disable Untethered Dead Reckoning + * @@param[in] enable Enable or disable Untethered Dead Reckoning * @return LocationServiceConfiguration& */ LocationServiceConfiguration& enableUDR(bool enable) { @@ -200,7 +212,7 @@ class LocationServiceConfiguration { /** * @brief Set the Dynamic Model used for Untethered Dead Reckoning * - * @param model Untethered Dead Reckoning model + * @@param[in] model Untethered Dead Reckoning model * @return LocationServiceConfiguration& */ LocationServiceConfiguration& udrModel(ubx_dynamic_model_t model) { @@ -220,7 +232,7 @@ class LocationServiceConfiguration { /** * @brief Enable or disable automatic IMU alignment process * - * @param enable Enable or disable Untethered Dead Reckoning + * @@param[in] enable Enable or disable Untethered Dead Reckoning * @return LocationServiceConfiguration& */ LocationServiceConfiguration& enableIMUAutoAlignment(bool enable) { @@ -388,6 +400,44 @@ class LocationServiceConfiguration { return _imuVRPZ; } + /** + * @brief Return if "Hot Start on Wake" is enabled + * + * @return Is "Hot Start on Wake" enabled? + */ + bool enableHotStartOnWake() const { + return _enableHotStartOnWake; + } + + /** + * @brief Set GNSS "Hot Start on Wake" enable + * + * @return LocationServiceConfiguration& object + */ + LocationServiceConfiguration& enableHotStartOnWake(bool enable) { + _enableHotStartOnWake = enable; + return *this; + } + + /** + * @brief Return if "AssistNow Autonomous" is enabled + * + * @return Is "AssistNow Autonomous" enabled? + */ + bool enableAssistNowAutonomous() const { + return _enableAssistNowAutonomous; + } + + /** + * @brief Set GNSS "AssistNow Autonomous" enable + * + * @return LocationServiceConfiguration& object + */ + LocationServiceConfiguration& enableAssistNowAutonomous(bool enable) { + _enableAssistNowAutonomous = enable; + return *this; + } + LocationServiceConfiguration& operator=(const LocationServiceConfiguration& rhs) { if (this == &rhs) { return *this; @@ -402,6 +452,8 @@ class LocationServiceConfiguration { this->_imuVRPX = rhs._imuVRPX; this->_imuVRPY = rhs._imuVRPY; this->_imuVRPZ = rhs._imuVRPZ; + this->_enableHotStartOnWake = rhs._enableHotStartOnWake; + this->_enableAssistNowAutonomous = rhs._enableAssistNowAutonomous; return *this; } @@ -418,11 +470,8 @@ class LocationServiceConfiguration { double _imuYaw, _imuPitch, _imuRoll; bool _enableIMUAutoAlignment; int16_t _imuVRPX, _imuVRPY, _imuVRPZ; - - // TODO: enable 2D only fix? - // TODO: Assist Now Autonomous configuration - // TODO: Assist Now Online/Offline configuration - // TODO: HDOP max default? + bool _enableHotStartOnWake; + bool _enableAssistNowAutonomous; }; /** @@ -587,8 +636,6 @@ class LocationService { return gps_->is_active(); }; - // TODO: Getters and setters for config object — need to support config service - private: LocationService(); @@ -638,4 +685,5 @@ class LocationService { PointThreshold pointThreshold_; bool pointThresholdConfigured_; bool fastGnssLock_; + bool enableHotStartOnWake_; }; diff --git a/src/tracker.cpp b/src/tracker.cpp index 507fc8b..eeb3dfb 100644 --- a/src/tracker.cpp +++ b/src/tracker.cpp @@ -601,7 +601,6 @@ int Tracker::init() // Register our own configuration settings registerConfig(); - // TODO: Pass in a LocationServiceConfig object here ret = locationService.begin(_deviceConfig.locationServiceConfig()); if (ret) { diff --git a/src/tracker_location.cpp b/src/tracker_location.cpp index db94356..5d0829b 100644 --- a/src/tracker_location.cpp +++ b/src/tracker_location.cpp @@ -615,6 +615,7 @@ void TrackerLocation::onWake(TrackerSleepContext context) { if (result.networkNeeded) { enableNetwork(); // GNSS power state handled elsewhere + // TODO: Need to support GNSS Warm Start when unit has been off for more than 4 hours Log.trace("%s needs to start the network", __FUNCTION__); } else if (_geofenceConfig.interval && _pendingGeofence) {