Skip to content

Commit

Permalink
Add Fast TTFF
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan-Kouba authored and eberseth committed Sep 27, 2022
1 parent e03d1dc commit 7bc9258
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 14 deletions.
15 changes: 13 additions & 2 deletions src/location_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ bool LocationService::getFastLock() {
}

bool LocationService::configureGPS(LocationServiceConfiguration& config) {
enableHotStartOnWake_ = config.enableHotStartOnWake();

bool ret = true;

WITH_LOCK(*gps_) {
Expand All @@ -121,6 +123,7 @@ bool LocationService::configureGPS(LocationServiceConfiguration& config) {
_deviceConfig.imuToVRPY(),
_deviceConfig.imuToVRPZ()
);
ret &= gps_->setAOPSettings(_deviceConfig.enableAssistNowAutonomous());
}
return ret;
}
Expand All @@ -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;
Expand All @@ -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();
}

Expand Down
70 changes: 59 additions & 11 deletions src/location_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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) {
}

/**
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
};

/**
Expand Down Expand Up @@ -587,8 +636,6 @@ class LocationService {
return gps_->is_active();
};

// TODO: Getters and setters for config object — need to support config service

private:

LocationService();
Expand Down Expand Up @@ -638,4 +685,5 @@ class LocationService {
PointThreshold pointThreshold_;
bool pointThresholdConfigured_;
bool fastGnssLock_;
bool enableHotStartOnWake_;
};
1 change: 0 additions & 1 deletion src/tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions src/tracker_location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7bc9258

Please sign in to comment.