summaryrefslogtreecommitdiff
path: root/gnss/GnssAdapter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gnss/GnssAdapter.cpp')
-rw-r--r--gnss/GnssAdapter.cpp249
1 files changed, 127 insertions, 122 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index 7253efe..5eb7b91 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -475,6 +475,16 @@ GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out,
out.flags |= GNSS_LOCATION_INFO_TIME_UNC_BIT;
out.timeUncMs = locationExtended.timeUncMs;
}
+
+ if (GPS_LOCATION_EXTENDED_HAS_CALIBRATION_CONFIDENCE & locationExtended.flags) {
+ out.flags |= GNSS_LOCATION_INFO_CALIBRATION_CONFIDENCE_BIT;
+ out.calibrationConfidence = locationExtended.calibrationConfidence;
+ }
+
+ if (GPS_LOCATION_EXTENDED_HAS_CALIBRATION_STATUS & locationExtended.flags) {
+ out.flags |= GNSS_LOCATION_INFO_CALIBRATION_STATUS_BIT;
+ out.calibrationStatus = locationExtended.calibrationStatus;
+ }
}
@@ -659,7 +669,7 @@ GnssAdapter::setSuplHostServer(const char* server, int port, LocServerType type)
LOC_LOGe("Invalid type=%d", type);
} else {
string& url = (LOC_AGPS_SUPL_SERVER == type) ? getServerUrl() : getMoServerUrl();
- if (length > 0 && strncasecmp(url.c_str(), serverUrl, sizeof(serverUrl)) != 0) {
+ if (length >= 0 && strncasecmp(url.c_str(), serverUrl, sizeof(serverUrl)) != 0) {
url.assign(serverUrl);
if (LOC_AGPS_SUPL_SERVER == type) {
@@ -714,90 +724,88 @@ GnssAdapter::setConfigCommand()
loc_gps_cfg_s gpsConf = ContextBase::mGps_conf;
loc_sap_cfg_s_type sapConf = ContextBase::mSap_conf;
- mApi.sendMsg(new LocApiMsg(
- [&adapter, gpsConf, sapConf, oldServerUrl, oldMoServerUrl] () {
- //cache the injected configuration with GnssConfigRequested struct
- GnssConfig gnssConfigRequested = {};
- gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT |
- GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT |
- GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT |
- GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
- gnssConfigRequested.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE;
- if (0 == adapter.getAfwControlId() || NULL != adapter.mNfwCb) {
- gnssConfigRequested.gpsLock = gpsConf.GPS_LOCK;
- }
-
- if (gpsConf.AGPS_CONFIG_INJECT) {
- gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT |
- GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT |
- GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT |
- GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
- gnssConfigRequested.suplVersion =
- adapter.mLocApi->convertSuplVersion(gpsConf.SUPL_VER);
- gnssConfigRequested.lppProfile =
- adapter.mLocApi->convertLppProfile(gpsConf.LPP_PROFILE);
- gnssConfigRequested.aGlonassPositionProtocolMask =
- gpsConf.A_GLONASS_POS_PROTOCOL_SELECT;
- }
- gnssConfigRequested.lppeControlPlaneMask =
- adapter.mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY);
- gnssConfigRequested.lppeUserPlaneMask =
- adapter.mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY);
- gnssConfigRequested.blacklistedSvIds.assign(adapter.mBlacklistedSvIds.begin(),
- adapter.mBlacklistedSvIds.end());
- adapter.gnssUpdateConfig(oldServerUrl, oldMoServerUrl, gnssConfigRequested,
- gnssConfigRequested);
-
- // set nmea mask type
- uint32_t mask = 0;
- if (NMEA_PROVIDER_MP == gpsConf.NMEA_PROVIDER) {
- mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK;
- }
- if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) {
- mask |= LOC_NMEA_MASK_DEBUG_V02;
- }
-
- if (mask != 0) {
- adapter.mLocApi->setNMEATypesSync(mask);
- }
-
- 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 ||
- sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
- sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) {
- adapter.mLocApi->setSensorPropertiesSync(
- sapConf.GYRO_BIAS_RANDOM_WALK_VALID,
- sapConf.GYRO_BIAS_RANDOM_WALK,
- sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
- sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY,
- sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
- sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY,
- sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
- sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY,
- sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
- sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY);
- }
- adapter.mLocApi->setSensorPerfControlConfigSync(
- sapConf.SENSOR_CONTROL_MODE,
- sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH,
- sapConf.SENSOR_ACCEL_BATCHES_PER_SEC,
- sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH,
- sapConf.SENSOR_GYRO_BATCHES_PER_SEC,
- sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH,
- sapConf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH,
- sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH,
- sapConf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH,
- sapConf.SENSOR_ALGORITHM_CONFIG_MASK);
+ //cache the injected configuration with GnssConfigRequested struct
+ GnssConfig gnssConfigRequested = {};
+ gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT |
+ GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT |
+ GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT |
+ GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
+ gnssConfigRequested.gpsLock = gpsConf.GPS_LOCK;
+
+ if (gpsConf.AGPS_CONFIG_INJECT) {
+ gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT |
+ GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT |
+ GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT |
+ GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
+ gnssConfigRequested.suplVersion =
+ adapter.mLocApi->convertSuplVersion(gpsConf.SUPL_VER);
+ gnssConfigRequested.lppProfile =
+ adapter.mLocApi->convertLppProfile(gpsConf.LPP_PROFILE);
+ gnssConfigRequested.aGlonassPositionProtocolMask =
+ gpsConf.A_GLONASS_POS_PROTOCOL_SELECT;
+ }
+ gnssConfigRequested.lppeControlPlaneMask =
+ adapter.mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY);
+ gnssConfigRequested.lppeUserPlaneMask =
+ adapter.mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY);
+ gnssConfigRequested.blacklistedSvIds.assign(adapter.mBlacklistedSvIds.begin(),
+ adapter.mBlacklistedSvIds.end());
+ mApi.sendMsg(new LocApiMsg(
+ [&adapter, gpsConf, sapConf, oldServerUrl,
+ oldMoServerUrl, gnssConfigRequested] () {
+ adapter.gnssUpdateConfig(oldServerUrl, oldMoServerUrl, gnssConfigRequested,
+ gnssConfigRequested);
+
+ // set nmea mask type
+ uint32_t mask = 0;
+ if (NMEA_PROVIDER_MP == gpsConf.NMEA_PROVIDER) {
+ mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK;
+ }
+ if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) {
+ mask |= LOC_NMEA_MASK_DEBUG_V02;
+ }
+
+ if (mask != 0) {
+ adapter.mLocApi->setNMEATypesSync(mask);
+ }
+
+ 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 ||
+ sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
+ sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) {
+ adapter.mLocApi->setSensorPropertiesSync(
+ sapConf.GYRO_BIAS_RANDOM_WALK_VALID,
+ sapConf.GYRO_BIAS_RANDOM_WALK,
+ sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
+ sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY,
+ sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
+ sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY,
+ sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
+ sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY,
+ sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
+ sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY);
+ }
+ adapter.mLocApi->setSensorPerfControlConfigSync(
+ sapConf.SENSOR_CONTROL_MODE,
+ sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH,
+ sapConf.SENSOR_ACCEL_BATCHES_PER_SEC,
+ sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH,
+ sapConf.SENSOR_GYRO_BATCHES_PER_SEC,
+ sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH,
+ sapConf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH,
+ sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH,
+ sapConf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH,
+ sapConf.SENSOR_ALGORITHM_CONFIG_MASK);
} ));
}
};
@@ -839,7 +847,7 @@ std::vector<LocationError> GnssAdapter::gnssUpdateConfig(const std::string& oldS
GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
if (gnssConfigNeedEngineUpdate.assistanceServer.type ==
GNSS_ASSISTANCE_TYPE_SUPL) {
- if ((serverUrlLen != 0) && (oldServerUrl.compare(serverUrl) !=0)) {
+ if (0 != oldServerUrl.compare(serverUrl)) {
err = mLocApi->setServerSync(
serverUrl.c_str(), serverUrlLen, LOC_AGPS_SUPL_SERVER);
@@ -847,7 +855,7 @@ std::vector<LocationError> GnssAdapter::gnssUpdateConfig(const std::string& oldS
errsList[index] = err;
}
}
- if ((moServerUrlLen != 0) && (oldMoServerUrl.compare(moServerUrl) != 0)) {
+ if (0 != oldMoServerUrl.compare(moServerUrl)) {
LocationError locErr =
mLocApi->setServerSync(moServerUrl.c_str(),
moServerUrlLen,
@@ -1074,10 +1082,7 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config)
if (GNSS_CONFIG_GPS_LOCK_NONE == newGpsLock) {
newGpsLock = GNSS_CONFIG_GPS_LOCK_MO;
}
- if (newGpsLock == ContextBase::mGps_conf.GPS_LOCK ||
- 0 != mAdapter.getAfwControlId()) {
- gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT);
- }
+ gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT);
ContextBase::mGps_conf.GPS_LOCK = newGpsLock;
index++;
}
@@ -1635,9 +1640,10 @@ GnssAdapter::gnssSvTypeConfigUpdate(const GnssSvTypeConfig& config)
void
GnssAdapter::gnssSvTypeConfigUpdate(bool sendReset)
{
- LOC_LOGd("constellations blacklisted 0x%" PRIx64 ", enabled 0x%" PRIx64 ", sendReset %d",
- mGnssSvTypeConfig.blacklistedSvTypesMask, mGnssSvTypeConfig.enabledSvTypesMask,
- sendReset);
+ LOC_LOGd("size %" PRIu32" constellations blacklisted 0x%" PRIx64 ", enabled 0x%" PRIx64
+ ", sendReset %d",
+ mGnssSvTypeConfig.size, mGnssSvTypeConfig.blacklistedSvTypesMask,
+ mGnssSvTypeConfig.enabledSvTypesMask, sendReset);
if (mGnssSvTypeConfig.size == sizeof(mGnssSvTypeConfig)) {
@@ -1673,8 +1679,6 @@ GnssAdapter::gnssSvTypeConfigUpdate(bool sendReset)
svTypeConfig.enabledSvTypesMask = mGnssSvTypeConfig.enabledSvTypesMask;
mLocApi->setConstellationControl(svTypeConfig);
}
- } else {
- LOC_LOGE("Invalid GnssSvTypeConfig size");
}
}
@@ -2976,10 +2980,8 @@ GnssAdapter::enableCommand(LocationTechnologyType techType)
mAdapter.setAfwControlId(mSessionId);
GnssConfigGpsLock gpsLock = GNSS_CONFIG_GPS_LOCK_NONE;
- if (NULL != mAdapter.mNfwCb) {
- ContextBase::mGps_conf.GPS_LOCK &= GNSS_CONFIG_GPS_LOCK_NI;
- gpsLock = ContextBase::mGps_conf.GPS_LOCK;
- }
+ ContextBase::mGps_conf.GPS_LOCK &= GNSS_CONFIG_GPS_LOCK_NI;
+ gpsLock = ContextBase::mGps_conf.GPS_LOCK;
mApi.sendMsg(new LocApiMsg([&mApi = mApi, gpsLock]() {
mApi.setGpsLockSync(gpsLock);
}));
@@ -3026,10 +3028,8 @@ GnssAdapter::disableCommand(uint32_t id)
mContext.modemPowerVote(false);
mAdapter.setAfwControlId(0);
- if (NULL != mAdapter.mNfwCb) {
- /* We need to disable MO (AFW) */
- ContextBase::mGps_conf.GPS_LOCK |= GNSS_CONFIG_GPS_LOCK_MO;
- }
+ /* We need to disable MO (AFW) */
+ ContextBase::mGps_conf.GPS_LOCK |= GNSS_CONFIG_GPS_LOCK_MO;
GnssConfigGpsLock gpsLock = ContextBase::mGps_conf.GPS_LOCK;
mApi.sendMsg(new LocApiMsg([&mApi = mApi,gpsLock] () {
mApi.setGpsLockSync(gpsLock);
@@ -3332,6 +3332,9 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify)
case GNSS_SIGNAL_BEIDOU_B2AI:
svUsedIdMask = mGnssMbSvIdUsedInPosition.bds_b2ai_sv_used_ids_mask;
break;
+ case GNSS_SIGNAL_BEIDOU_B2AQ:
+ svUsedIdMask = mGnssMbSvIdUsedInPosition.bds_b2aq_sv_used_ids_mask;
+ break;
}
} else {
svUsedIdMask = mGnssSvIdUsedInPosition.bds_sv_used_ids_mask;
@@ -3779,26 +3782,28 @@ GnssAdapter::reportGnssMeasurementsEvent(const GnssMeasurements& gnssMeasurement
{
LOC_LOGD("%s]: msInWeek=%d", __func__, msInWeek);
- struct MsgReportGnssMeasurementData : public LocMsg {
- GnssAdapter& mAdapter;
- GnssMeasurements mGnssMeasurements;
- GnssMeasurementsNotification mMeasurementsNotify;
- inline MsgReportGnssMeasurementData(GnssAdapter& adapter,
- const GnssMeasurements& gnssMeasurements,
- int msInWeek) :
- LocMsg(),
- mAdapter(adapter),
- mMeasurementsNotify(gnssMeasurements.gnssMeasNotification) {
- if (-1 != msInWeek) {
- mAdapter.getAgcInformation(mMeasurementsNotify, msInWeek);
+ if (0 != gnssMeasurements.gnssMeasNotification.count) {
+ struct MsgReportGnssMeasurementData : public LocMsg {
+ GnssAdapter& mAdapter;
+ GnssMeasurements mGnssMeasurements;
+ GnssMeasurementsNotification mMeasurementsNotify;
+ inline MsgReportGnssMeasurementData(GnssAdapter& adapter,
+ const GnssMeasurements& gnssMeasurements,
+ int msInWeek) :
+ LocMsg(),
+ mAdapter(adapter),
+ mMeasurementsNotify(gnssMeasurements.gnssMeasNotification) {
+ if (-1 != msInWeek) {
+ mAdapter.getAgcInformation(mMeasurementsNotify, msInWeek);
+ }
}
- }
- inline virtual void proc() const {
- mAdapter.reportGnssMeasurementData(mMeasurementsNotify);
- }
- };
+ inline virtual void proc() const {
+ mAdapter.reportGnssMeasurementData(mMeasurementsNotify);
+ }
+ };
- sendMsg(new MsgReportGnssMeasurementData(*this, gnssMeasurements, msInWeek));
+ sendMsg(new MsgReportGnssMeasurementData(*this, gnssMeasurements, msInWeek));
+ }
mEngHubProxy->gnssReportSvMeasurement(gnssMeasurements.gnssSvMeasurementSet);
}