summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/ContextBase.cpp13
-rw-r--r--core/ContextBase.h4
-rw-r--r--core/LocAdapterBase.cpp4
-rw-r--r--core/LocAdapterBase.h1
-rw-r--r--core/LocApiBase.cpp24
-rw-r--r--core/LocApiBase.h11
-rw-r--r--etc/gps.conf36
-rw-r--r--gnss/GnssAdapter.cpp82
-rw-r--r--gnss/GnssAdapter.h11
-rw-r--r--gnss/location_gnss.cpp8
-rw-r--r--location/location_interface.h15
11 files changed, 203 insertions, 6 deletions
diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp
index fa87c3e..3d55e1c 100644
--- a/core/ContextBase.cpp
+++ b/core/ContextBase.cpp
@@ -74,6 +74,10 @@ const loc_param_s_type ContextBase::mGps_conf_table[] =
{"MODEM_TYPE", &mGps_conf.MODEM_TYPE, NULL, 'n' },
{"MO_SUPL_HOST", &mGps_conf.MO_SUPL_HOST, NULL, 's' },
{"MO_SUPL_PORT", &mGps_conf.MO_SUPL_PORT, NULL, 'n' },
+ {"CONSTRAINED_TIME_UNCERTAINTY_ENABLED", &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED, NULL, 'n'},
+ {"CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD", &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD, NULL, 'f'},
+ {"CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET", &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET, NULL, 'n'},
+ {"POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED", &mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED, NULL, 'n'},
};
const loc_param_s_type ContextBase::mSap_conf_table[] =
@@ -156,6 +160,15 @@ void ContextBase::readConfig()
/* inject supl config to modem with config values from config.xml or gps.conf, default 1 */
mGps_conf.AGPS_CONFIG_INJECT = 1;
+ /* default configuration value of constrained time uncertainty mode:
+ feature disabled, time uncertainty threshold defined by modem,
+ and unlimited power budget */
+ mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED = 0;
+ mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD = 0.0;
+ mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET = 0;
+ /* default configuration value of position assisted clock estimator mode */
+ mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED = 0;
+
UTIL_READ_CONF(LOC_PATH_GPS_CONF, mGps_conf_table);
UTIL_READ_CONF(LOC_PATH_SAP_CONF, mSap_conf_table);
diff --git a/core/ContextBase.h b/core/ContextBase.h
index bdabf7b..8a3d300 100644
--- a/core/ContextBase.h
+++ b/core/ContextBase.h
@@ -67,6 +67,10 @@ typedef struct loc_gps_cfg_s
uint32_t MODEM_TYPE;
char MO_SUPL_HOST[LOC_MAX_PARAM_STRING];
uint32_t MO_SUPL_PORT;
+ uint32_t CONSTRAINED_TIME_UNCERTAINTY_ENABLED;
+ double CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD;
+ uint32_t CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET;
+ uint32_t POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED;
} loc_gps_cfg_s_type;
/* NOTE: the implementaiton of the parser casts number
diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp
index 8197f4d..5a16b17 100644
--- a/core/LocAdapterBase.cpp
+++ b/core/LocAdapterBase.cpp
@@ -175,4 +175,8 @@ bool LocAdapterBase::
requestOdcpiEvent(OdcpiRequestInfo& /*request*/)
DEFAULT_IMPL(false)
+bool LocAdapterBase::
+ reportGnssEngEnergyConsumedEvent(uint64_t /*energyConsumedSinceFirstBoot*/)
+DEFAULT_IMPL(false)
+
} // namespace loc_core
diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h
index 6b3e02f..abbf3d6 100644
--- a/core/LocAdapterBase.h
+++ b/core/LocAdapterBase.h
@@ -167,6 +167,7 @@ public:
virtual void reportGnssSvIdConfigEvent(const GnssSvIdConfig& config);
virtual void reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& config);
virtual bool requestOdcpiEvent(OdcpiRequestInfo& request);
+ virtual bool reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot);
};
} // namespace loc_core
diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp
index 7b52c82..99a089e 100644
--- a/core/LocApiBase.cpp
+++ b/core/LocApiBase.cpp
@@ -362,6 +362,13 @@ void LocApiBase::requestOdcpi(OdcpiRequestInfo& request)
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestOdcpiEvent(request));
}
+void LocApiBase::reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot)
+{
+ // loop through adapters, and deliver to the first handling adapter.
+ TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssEngEnergyConsumedEvent(
+ energyConsumedSinceFirstBoot));
+}
+
void LocApiBase::reportSv(GnssSvNotification& svNotify)
{
const char* constellationString[] = { "Unknown", "GPS", "SBAS", "GLONASS",
@@ -540,6 +547,10 @@ void LocApiBase::
DEFAULT_IMPL()
void LocApiBase::
+ injectPosition(const GnssLocationInfoNotification & /*locationInfo*/, bool /*onDemandCpi*/)
+DEFAULT_IMPL()
+
+void LocApiBase::
setTime(LocGpsUtcTime /*time*/, int64_t /*timeReference*/, int /*uncertainty*/)
DEFAULT_IMPL()
@@ -676,4 +687,17 @@ DEFAULT_IMPL()
void LocApiBase::resetConstellationControl()
DEFAULT_IMPL()
+LocationError LocApiBase::
+ setConstrainedTuncMode(bool /*enabled*/,
+ float /*tuncConstraint*/,
+ uint32_t /*energyBudget*/)
+DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
+
+LocationError LocApiBase::
+ setPositionAssistedClockEstimatorMode(bool /*enabled*/)
+DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
+
+LocationError LocApiBase::
+ getGnssEnergyConsumed()
+DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
} // namespace loc_core
diff --git a/core/LocApiBase.h b/core/LocApiBase.h
index e80e273..d4d337a 100644
--- a/core/LocApiBase.h
+++ b/core/LocApiBase.h
@@ -183,6 +183,7 @@ public:
void reportGnssSvIdConfig(const GnssSvIdConfig& config);
void reportGnssSvTypeConfig(const GnssSvTypeConfig& config);
void requestOdcpi(OdcpiRequestInfo& request);
+ void reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot);
// downward calls
// All below functions are to be defined by adapter specific modules:
@@ -198,6 +199,10 @@ public:
virtual void
injectPosition(double latitude, double longitude, float accuracy);
+
+ virtual void
+ injectPosition(const GnssLocationInfoNotification &locationInfo, bool onDemandCpi=false);
+
virtual void
injectPosition(const Location& location, bool onDemandCpi);
virtual void
@@ -281,6 +286,12 @@ public:
virtual void setConstellationControl(const GnssSvTypeConfig& config);
virtual void getConstellationControl();
virtual void resetConstellationControl();
+
+ virtual LocationError setConstrainedTuncMode(bool enabled,
+ float tuncConstraint,
+ uint32_t energyBudget);
+ virtual LocationError setPositionAssistedClockEstimatorMode(bool enabled);
+ virtual LocationError getGnssEnergyConsumed();
};
typedef LocApiBase* (getLocApi_t)(LOC_API_ADAPTER_EVENT_MASK_T exMask,
diff --git a/etc/gps.conf b/etc/gps.conf
index 0a06cb5..957b661 100644
--- a/etc/gps.conf
+++ b/etc/gps.conf
@@ -245,3 +245,39 @@ PROPAGATION_TIME_UNCERTAINTY = 1
# for the first modem in the list
MODEM_TYPE = 1
+##################################################
+# CONSTRAINED TIME UNCERTAINTY MODE
+##################################################
+# 0 : disabled (default)
+# 1 : enabled
+# This setting enables GPS engine to keep its time
+# uncertainty below the specified constraint
+#CONSTRAINED_TIME_UNCERTAINTY_ENABLED = 0
+
+# If constrained time uncertainty mode is enabled,
+# this setting specifies the time uncertainty
+# threshold that gps engine need to maintain.
+# In unit of milli-seconds.
+# Default is 0.0 meaning that modem default value
+# of time uncertainty threshold will be used.
+#CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD = 0.0
+
+# If constrained time uncertainty mode is enabled,
+# this setting specifies the power budget that
+# gps engine is allowed to spend to maintain the time
+# uncertainty.
+# Default is 0 meaning that GPS engine is not constained
+# by power budget and can spend as much power as needed.
+# In unit of 0.1 milli watt second.
+#CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET = 0
+
+##################################################
+# POSITION ASSISTED CLOCK ESTIMATOR
+##################################################
+# 0 : disabled (default)
+# 1 : enabled
+# This setting enables GPS engine to estimate clock
+# bias and drift when the signal from at least 1
+# SV is available and the UE’s position is known by
+# other position engines.
+#POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED = 0
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index 78f3940..04ac187 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -733,6 +733,14 @@ GnssAdapter::setConfigCommand()
}
adapter.mLocApi->setXtraVersionCheckSync(gpsConf.XTRA_VERSION_CHECK);
+
+ adapter.mLocApi->setConstrainedTuncMode(
+ gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED == 1,
+ (float)gpsConf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD,
+ gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET);
+ adapter.mLocApi->setPositionAssistedClockEstimatorMode(
+ gpsConf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED == 1);
+
if (sapConf.GYRO_BIAS_RANDOM_WALK_VALID ||
sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
@@ -2935,18 +2943,25 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation,
mGnssSvIdUsedInPosAvail = true;
mGnssSvIdUsedInPosition = locationExtended.gnss_sv_used_ids;
}
+
+ GnssLocationInfoNotification locationInfo = {};
+ convertLocationInfo(locationInfo, locationExtended);
+ convertLocation(locationInfo.location, ulpLocation, locationExtended, techMask);
+
for (auto it=mClientData.begin(); it != mClientData.end(); ++it) {
if (nullptr != it->second.gnssLocationInfoCb) {
- GnssLocationInfoNotification locationInfo = {};
- convertLocationInfo(locationInfo, locationExtended);
- convertLocation(locationInfo.location, ulpLocation, locationExtended, techMask);
it->second.gnssLocationInfoCb(locationInfo);
} else if (nullptr != it->second.trackingCb) {
- Location location = {};
- convertLocation(location, ulpLocation, locationExtended, techMask);
- it->second.trackingCb(location);
+ it->second.trackingCb(locationInfo.location);
}
}
+
+ // if engine hub is running and the fix is from sensor, e.g.: DRE,
+ // inject DRE fix to modem
+ if ((1 == ContextBase::mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED) &&
+ (true == initEngHubProxy()) && (LOC_POS_TECH_MASK_SENSORS & techMask)) {
+ mLocApi->injectPosition(locationInfo, false);
+ }
}
if (NMEA_PROVIDER_AP == ContextBase::mGps_conf.NMEA_PROVIDER && !mTrackingSessions.empty()) {
@@ -3542,6 +3557,35 @@ void GnssAdapter::odcpiTimerExpire()
}
}
+void
+GnssAdapter::invokeGnssEnergyConsumedCallback(uint64_t energyConsumedSinceFirstBoot) {
+ if (mGnssEnergyConsumedCb) {
+ mGnssEnergyConsumedCb(energyConsumedSinceFirstBoot);
+ mGnssEnergyConsumedCb = nullptr;
+ }
+}
+
+bool
+GnssAdapter::reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot){
+ LOC_LOGD("%s]: %" PRIu64 " ", __func__, energyConsumedSinceFirstBoot);
+
+ struct MsgReportGnssGnssEngEnergyConsumed : public LocMsg {
+ GnssAdapter& mAdapter;
+ uint64_t mGnssEnergyConsumedSinceFirstBoot;
+ inline MsgReportGnssGnssEngEnergyConsumed(GnssAdapter& adapter,
+ uint64_t energyConsumed) :
+ LocMsg(),
+ mAdapter(adapter),
+ mGnssEnergyConsumedSinceFirstBoot(energyConsumed) {}
+ inline virtual void proc() const {
+ mAdapter.invokeGnssEnergyConsumedCallback(mGnssEnergyConsumedSinceFirstBoot);
+ }
+ };
+
+ sendMsg(new MsgReportGnssGnssEngEnergyConsumed(*this, energyConsumedSinceFirstBoot));
+ return true;
+}
+
void GnssAdapter::initDefaultAgps() {
LOC_LOGD("%s]: ", __func__);
@@ -4190,6 +4234,32 @@ static void agpsCloseResultCb (bool isSuccess, AGpsExtType agpsType, void* userD
}
}
+void
+GnssAdapter::saveGnssEnergyConsumedCallback(GnssEnergyConsumedCallback energyConsumedCb) {
+ mGnssEnergyConsumedCb = energyConsumedCb;
+}
+
+void
+GnssAdapter::getGnssEnergyConsumedCommand(GnssEnergyConsumedCallback energyConsumedCb) {
+ struct MsgGetGnssEnergyConsumed : public LocMsg {
+ GnssAdapter& mAdapter;
+ LocApiBase& mApi;
+ GnssEnergyConsumedCallback mEnergyConsumedCb;
+ inline MsgGetGnssEnergyConsumed(GnssAdapter& adapter, LocApiBase& api,
+ GnssEnergyConsumedCallback energyConsumedCb) :
+ LocMsg(),
+ mAdapter(adapter),
+ mApi(api),
+ mEnergyConsumedCb(energyConsumedCb){}
+ inline virtual void proc() const {
+ mAdapter.saveGnssEnergyConsumedCallback(mEnergyConsumedCb);
+ mApi.getGnssEnergyConsumed();
+ }
+ };
+
+ sendMsg(new MsgGetGnssEnergyConsumed(*this, *mLocApi, energyConsumedCb));
+}
+
/* ==== Eng Hub Proxy ================================================================= */
/* ======== UTILITIES ================================================================= */
void
diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h
index 3f2afaa..b328884 100644
--- a/gnss/GnssAdapter.h
+++ b/gnss/GnssAdapter.h
@@ -124,6 +124,10 @@ namespace loc_core {
class SystemStatus;
}
+typedef std::function<void(
+ uint64_t gnssEnergyConsumedFromFirstBoot
+)> GnssEnergyConsumedCallback;
+
class GnssAdapter : public LocAdapterBase {
/* ==== Engine Hub ===================================================================== */
@@ -172,6 +176,9 @@ class GnssAdapter : public LocAdapterBase {
/* === Misc ===================================================================== */
BlockCPIInfo mBlockCPIInfo;
+ /* === Misc callback from QMI LOC API ============================================== */
+ GnssEnergyConsumedCallback mGnssEnergyConsumedCb;
+
/*==== CONVERSION ===================================================================*/
static void convertOptions(LocPosMode& out, const TrackingOptions& trackingOptions);
static void convertLocation(Location& out, const UlpLocation& ulpLocation,
@@ -295,6 +302,7 @@ public:
const char* apnName, int apnLen, AGpsBearerType bearerType);
void dataConnClosedCommand(AGpsExtType agpsType);
void dataConnFailedCommand(AGpsExtType agpsType);
+ void getGnssEnergyConsumedCommand(GnssEnergyConsumedCallback energyConsumedCb);
/* ========= ODCPI ===================================================================== */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
@@ -334,6 +342,7 @@ public:
virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial);
virtual void reportGnssSvIdConfigEvent(const GnssSvIdConfig& config);
virtual void reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& config);
+ virtual bool reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot);
virtual bool requestATL(int connHandle, LocAGpsType agps_type, LocApnTypeMask apn_type_mask);
virtual bool releaseATL(int connHandle);
@@ -354,6 +363,8 @@ public:
void reportGnssSvIdConfig(const GnssSvIdConfig& config);
void reportGnssSvTypeConfig(const GnssSvTypeConfig& config);
void requestOdcpi(const OdcpiRequestInfo& request);
+ void invokeGnssEnergyConsumedCallback(uint64_t energyConsumedSinceFirstBoot);
+ void saveGnssEnergyConsumedCallback(GnssEnergyConsumedCallback energyConsumedCb);
/*======== GNSSDEBUG ================================================================*/
bool getDebugReport(GnssDebugReport& report);
diff --git a/gnss/location_gnss.cpp b/gnss/location_gnss.cpp
index 800ea1b..5a7710a 100644
--- a/gnss/location_gnss.cpp
+++ b/gnss/location_gnss.cpp
@@ -66,6 +66,7 @@ static void agpsDataConnClosed(AGpsExtType agpsType);
static void agpsDataConnFailed(AGpsExtType agpsType);
static void getDebugReport(GnssDebugReport& report);
static void updateConnectionStatus(bool connected, int8_t type);
+static void getGnssEnergyConsumed(GnssEnergyConsumedCallback energyConsumedCb);
static void odcpiInit(const OdcpiRequestCallback& callback);
static void odcpiInject(const Location& location);
@@ -105,6 +106,7 @@ static const GnssInterface gGnssInterface = {
odcpiInit,
odcpiInject,
blockCPI,
+ getGnssEnergyConsumed
};
#ifndef DEBUG_X86
@@ -337,4 +339,10 @@ static void blockCPI(double latitude, double longitude, float accuracy,
gGnssAdapter->blockCPICommand(latitude, longitude, accuracy,
blockDurationMsec, latLonDiffThreshold);
}
+}
+
+static void getGnssEnergyConsumed(GnssEnergyConsumedCallback energyConsumedCb) {
+ if (NULL != gGnssAdapter) {
+ gGnssAdapter->getGnssEnergyConsumedCommand(energyConsumedCb);
+ }
} \ No newline at end of file
diff --git a/location/location_interface.h b/location/location_interface.h
index 359cb2b..e9e2fe8 100644
--- a/location/location_interface.h
+++ b/location/location_interface.h
@@ -32,6 +32,20 @@
#include <LocationAPI.h>
#include <gps_extended_c.h>
+/* Used for callback to deliver GNSS energy consumed */
+/** @fn
+ @brief Used by query API that retrieves energy consumed by
+ modem GNSS engine.
+
+ @param gnssEnergyConsumedFromFirstBoot:
+ Energy consumed by the GNSS engine since the first bootup
+ in units of 0.1 milli watt seconds.
+ A value of 0xffffffffffffffff indicates an invalid reading.
+*/
+typedef std::function<void(
+ uint64_t gnssEnergyConsumedFromFirstBoot
+)> GnssEnergyConsumedCallback;
+
struct GnssInterface {
size_t size;
void (*initialize)(void);
@@ -65,6 +79,7 @@ struct GnssInterface {
void (*odcpiInject)(const Location& location);
void (*blockCPI)(double latitude, double longitude, float accuracy,
int blockDurationMsec, double latLonDiffThreshold);
+ void (*getGnssEnergyConsumed)(GnssEnergyConsumedCallback energyConsumedCb);
};
struct FlpInterface {