Fix potential NMEA event registration issue
The NMEA event may not be registered because of a race condition. Change-Id: Icc04039f0b3a3bc34101b667778881323edf9131 CRs-fixed: 2493919
This commit is contained in:
parent
eb3b1419e3
commit
fc6f5be4f8
2 changed files with 116 additions and 120 deletions
|
@ -681,130 +681,125 @@ GnssAdapter::setSuplHostServer(const char* server, int port, LocServerType type)
|
|||
}
|
||||
|
||||
void
|
||||
GnssAdapter::setConfigCommand()
|
||||
GnssAdapter::setConfig()
|
||||
{
|
||||
LOC_LOGD("%s]: ", __func__);
|
||||
|
||||
struct MsgSetConfig : public LocMsg {
|
||||
GnssAdapter& mAdapter;
|
||||
LocApiBase& mApi;
|
||||
inline MsgSetConfig(GnssAdapter& adapter, LocApiBase& api) :
|
||||
LocMsg(),
|
||||
mAdapter(adapter),
|
||||
mApi(api) {}
|
||||
inline virtual void proc() const {
|
||||
if (!mAdapter.isEngineCapabilitiesKnown()) {
|
||||
mAdapter.mPendingMsgs.push_back(new MsgSetConfig(*this));
|
||||
return;
|
||||
// set nmea mask type
|
||||
uint32_t mask = 0;
|
||||
if (NMEA_PROVIDER_MP == ContextBase::mGps_conf.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 (mNmeaMask != mask) {
|
||||
mNmeaMask = mask;
|
||||
if (mNmeaMask) {
|
||||
for (auto it=mClientData.begin(); it != mClientData.end(); ++it) {
|
||||
if ((it->second.gnssNmeaCb != nullptr)) {
|
||||
updateEvtMask(LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT,
|
||||
LOC_REGISTRATION_MASK_ENABLED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// set nmea mask type
|
||||
uint32_t mask = 0;
|
||||
if (NMEA_PROVIDER_MP == ContextBase::mGps_conf.NMEA_PROVIDER) {
|
||||
mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK;
|
||||
}
|
||||
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) {
|
||||
mask |= LOC_NMEA_MASK_DEBUG_V02;
|
||||
}
|
||||
mAdapter.mNmeaMask= mask;
|
||||
|
||||
std::string oldMoServerUrl = mAdapter.getMoServerUrl();
|
||||
mAdapter.setSuplHostServer(ContextBase::mGps_conf.SUPL_HOST,
|
||||
ContextBase::mGps_conf.SUPL_PORT,
|
||||
LOC_AGPS_SUPL_SERVER);
|
||||
mAdapter.setSuplHostServer(ContextBase::mGps_conf.MO_SUPL_HOST,
|
||||
ContextBase::mGps_conf.MO_SUPL_PORT,
|
||||
LOC_AGPS_MO_SUPL_SERVER);
|
||||
|
||||
// inject the configurations into modem
|
||||
GnssAdapter& adapter = mAdapter;
|
||||
loc_gps_cfg_s gpsConf = ContextBase::mGps_conf;
|
||||
loc_sap_cfg_s_type sapConf = ContextBase::mSap_conf;
|
||||
|
||||
//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, oldMoServerUrl, gnssConfigRequested] () {
|
||||
adapter.gnssUpdateConfig(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);
|
||||
} ));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
std::string oldMoServerUrl = getMoServerUrl();
|
||||
setSuplHostServer(ContextBase::mGps_conf.SUPL_HOST,
|
||||
ContextBase::mGps_conf.SUPL_PORT,
|
||||
LOC_AGPS_SUPL_SERVER);
|
||||
setSuplHostServer(ContextBase::mGps_conf.MO_SUPL_HOST,
|
||||
ContextBase::mGps_conf.MO_SUPL_PORT,
|
||||
LOC_AGPS_MO_SUPL_SERVER);
|
||||
|
||||
// inject the configurations into modem
|
||||
loc_gps_cfg_s gpsConf = ContextBase::mGps_conf;
|
||||
loc_sap_cfg_s_type sapConf = ContextBase::mSap_conf;
|
||||
|
||||
//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 =
|
||||
mLocApi->convertSuplVersion(gpsConf.SUPL_VER);
|
||||
gnssConfigRequested.lppProfile =
|
||||
mLocApi->convertLppProfile(gpsConf.LPP_PROFILE);
|
||||
gnssConfigRequested.aGlonassPositionProtocolMask =
|
||||
gpsConf.A_GLONASS_POS_PROTOCOL_SELECT;
|
||||
}
|
||||
gnssConfigRequested.lppeControlPlaneMask =
|
||||
mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY);
|
||||
gnssConfigRequested.lppeUserPlaneMask =
|
||||
mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY);
|
||||
gnssConfigRequested.blacklistedSvIds.assign(mBlacklistedSvIds.begin(),
|
||||
mBlacklistedSvIds.end());
|
||||
mLocApi->sendMsg(new LocApiMsg(
|
||||
[this, gpsConf, sapConf, oldMoServerUrl, gnssConfigRequested] () {
|
||||
gnssUpdateConfig(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) {
|
||||
mLocApi->setNMEATypesSync(mask);
|
||||
}
|
||||
|
||||
mLocApi->setXtraVersionCheckSync(gpsConf.XTRA_VERSION_CHECK);
|
||||
|
||||
mLocApi->setConstrainedTuncMode(
|
||||
gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED == 1,
|
||||
(float)gpsConf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD,
|
||||
gpsConf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET);
|
||||
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 ) {
|
||||
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);
|
||||
}
|
||||
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);
|
||||
} ));
|
||||
|
||||
sendMsg(new MsgSetConfig(*this, *mLocApi));
|
||||
}
|
||||
|
||||
std::vector<LocationError> GnssAdapter::gnssUpdateConfig(const std::string& oldMoServerUrl,
|
||||
|
@ -2075,6 +2070,8 @@ GnssAdapter::handleEngineUpEvent()
|
|||
virtual void proc() const {
|
||||
mAdapter.setEngineCapabilitiesKnown(true);
|
||||
mAdapter.broadcastCapabilities(mAdapter.getCapabilities());
|
||||
// must be called only after capabilities are known
|
||||
mAdapter.setConfig();
|
||||
mAdapter.restartSessions();
|
||||
mAdapter.gnssSvIdConfigUpdate();
|
||||
mAdapter.gnssSvTypeConfigUpdate();
|
||||
|
@ -2086,7 +2083,6 @@ GnssAdapter::handleEngineUpEvent()
|
|||
};
|
||||
|
||||
readConfigCommand();
|
||||
setConfigCommand();
|
||||
sendMsg(new MsgHandleEngineUpEvent(*this));
|
||||
}
|
||||
|
||||
|
|
|
@ -281,7 +281,6 @@ public:
|
|||
void disableCommand(uint32_t id);
|
||||
void setControlCallbacksCommand(LocationControlCallbacks& controlCallbacks);
|
||||
void readConfigCommand();
|
||||
void setConfigCommand();
|
||||
void requestUlpCommand();
|
||||
void initEngHubProxyCommand();
|
||||
uint32_t* gnssUpdateConfigCommand(GnssConfig config);
|
||||
|
@ -313,6 +312,7 @@ public:
|
|||
{ mGnssSvTypeConfigCb = callback; }
|
||||
inline GnssSvTypeConfigCallback gnssGetSvTypeConfigCallback()
|
||||
{ return mGnssSvTypeConfigCb; }
|
||||
void setConfig();
|
||||
|
||||
/* ========= AGPS ====================================================================== */
|
||||
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
|
||||
|
|
Loading…
Reference in a new issue