diff options
Diffstat (limited to 'gnss')
-rw-r--r-- | gnss/GnssAdapter.cpp | 368 | ||||
-rw-r--r-- | gnss/GnssAdapter.h | 15 |
2 files changed, 207 insertions, 176 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 026c1ee..f3b459c 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -73,7 +73,7 @@ GnssAdapter::GnssAdapter() : mGnssSvIdUsedInPosition(), mGnssSvIdUsedInPosAvail(false), mControlCallbacks(), - mPowerVoteId(0), + mAfwControlId(0), mNmeaMask(0), mGnssSvIdConfig(), mGnssSvTypeConfig(), @@ -97,7 +97,8 @@ GnssAdapter::GnssAdapter() : mPowerStateCb(nullptr), mIsE911Session(NULL), mGnssMbSvIdUsedInPosition{}, - mGnssMbSvIdUsedInPosAvail(false) + mGnssMbSvIdUsedInPosAvail(false), + mSupportNfwControl(true) { LOC_LOGD("%s]: Constructor %p", __func__, this); mLocPositionMode.mode = LOC_POSITION_MODE_INVALID; @@ -666,154 +667,161 @@ GnssAdapter::setSuplHostServer(const char* server, int port, LocServerType type) } if (LOC_AGPS_SUPL_SERVER != type && LOC_AGPS_MO_SUPL_SERVER != 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) { - url.assign(serverUrl); - - if (LOC_AGPS_SUPL_SERVER == type) { - strlcpy(ContextBase::mGps_conf.SUPL_HOST, server, LOC_MAX_PARAM_STRING); - ContextBase::mGps_conf.SUPL_PORT = port; + } else if (length >= 0) { + if (LOC_AGPS_SUPL_SERVER == type) { + getServerUrl().assign(serverUrl); + strlcpy(ContextBase::mGps_conf.SUPL_HOST, server, LOC_MAX_PARAM_STRING); + ContextBase::mGps_conf.SUPL_PORT = port; + } else { + if (strncasecmp(getMoServerUrl().c_str(), serverUrl, sizeof(serverUrl)) != 0) { + getMoServerUrl().assign(serverUrl); } - - LOC_LOGv("serverUrl=%s length=%d type=%d", serverUrl, length, 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; + // 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; + } } - mAdapter.mNmeaMask= mask; - - std::string oldServerUrl = mAdapter.getServerUrl(); - 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, 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); - } )); } - }; + } - sendMsg(new MsgSetConfig(*this, *mLocApi)); -} + 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); -std::vector<LocationError> GnssAdapter::gnssUpdateConfig(const std::string& oldServerUrl, - const std::string& oldMoServerUrl, const GnssConfig& gnssConfigRequested, + // 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; + /* Here we process an SSR. We need to set the GPS_LOCK to the proper values, as follows: + 1. Q behavior. This is identified by mSupportNfwControl being 1. In this case + ContextBase::mGps_conf.GPS_LOCK is a "state", meaning it should reflect the + NV value. Therefore we will set the NV to ContextBase::mGps_conf.GPS_LOCK + 2. P behavior. This is identified by mSupportNfwControl being 0. In this case + ContextBase::mGps_conf.GPS_LOCK is a "configuration", meaning it should hold + the "mask" for NI. There are two subcases: + a. Location enabled in GUI (1 == getAfwControlId()). We need to set + the NV to GNSS_CONFIG_GPS_LOCK_NONE (both MO and NI enabled) + b. Location disabled in GUI (0 == getAfwControlId()). We need to set + the NV to ContextBase::mGps_conf.GPS_LOCK (the "mask", which is SIM-card + specific) + */ + if (mSupportNfwControl || (0 == getAfwControlId())) { + gnssConfigRequested.gpsLock = gpsConf.GPS_LOCK; + } else { + gnssConfigRequested.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE; + } + + 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); + } )); + +} + +std::vector<LocationError> GnssAdapter::gnssUpdateConfig(const std::string& oldMoServerUrl, + const GnssConfig& gnssConfigRequested, const GnssConfig& gnssConfigNeedEngineUpdate, size_t count) { loc_gps_cfg_s gpsConf = ContextBase::mGps_conf; size_t index = 0; @@ -846,13 +854,10 @@ 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 (0 != oldServerUrl.compare(serverUrl)) { - - err = mLocApi->setServerSync( - serverUrl.c_str(), serverUrlLen, LOC_AGPS_SUPL_SERVER); - if (index < count) { - errsList[index] = err; - } + err = mLocApi->setServerSync( + serverUrl.c_str(), serverUrlLen, LOC_AGPS_SUPL_SERVER); + if (index < count) { + errsList[index] = err; } if (0 != oldMoServerUrl.compare(moServerUrl)) { LocationError locErr = @@ -1070,7 +1075,6 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) size_t countOfConfigs = mCount; GnssConfig gnssConfigRequested = mConfig; GnssConfig gnssConfigNeedEngineUpdate = mConfig; - std::string oldServerUrl = mAdapter.getServerUrl(); std::vector<uint32_t> sessionIds; sessionIds.assign(mIds, mIds + mCount); @@ -1079,11 +1083,33 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { GnssConfigGpsLock newGpsLock = gnssConfigRequested.gpsLock; - if (GNSS_CONFIG_GPS_LOCK_NONE == newGpsLock) { - newGpsLock = GNSS_CONFIG_GPS_LOCK_MO; - } - gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT); + + newGpsLock |= GNSS_CONFIG_GPS_LOCK_MO; ContextBase::mGps_conf.GPS_LOCK = newGpsLock; + /* If we get here it means that the changes in the framework to request for + 'P' behavior were made, and therefore we need to "behave" as in 'P' + However, we need to determine if enableCommand function has already been + called, since it could get called before this function.*/ + if (0 != mAdapter.getAfwControlId()) { + /* enableCommand function has already been called since getAfwControlId + returns non zero. Now there are two possible cases: + 1. This is the first time this function is called + (mSupportNfwControl is true). We need to behave as in 'P', but + for the first time, meaning MO was enabled, but NI was not, so + we need to unlock NI + 2. This is not the first time this function is called, meaning we + are already behaving as in 'P'. No need to update the configuration + in this case (return to 'P' code) */ + if (mAdapter.mSupportNfwControl) { + // case 1 above + newGpsLock = GNSS_CONFIG_GPS_LOCK_NONE; + } else { + // case 2 above + gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT); + } + } + gnssConfigRequested.gpsLock = newGpsLock; + mAdapter.mSupportNfwControl = false; index++; } if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { @@ -1163,11 +1189,9 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) mApi.sendMsg(new LocApiMsg( [&adapter, gnssConfigRequested, gnssConfigNeedEngineUpdate, - countOfConfigs, configCollectiveResponse, errs, oldServerUrl] () { - std::string serverUrl = adapter.getServerUrl(); - int serverUrlLen = serverUrl.length(); - std::vector<LocationError> errsList = adapter.gnssUpdateConfig(oldServerUrl, - "", gnssConfigRequested, gnssConfigNeedEngineUpdate, countOfConfigs); + countOfConfigs, configCollectiveResponse, errs] () { + std::vector<LocationError> errsList = adapter.gnssUpdateConfig("", + gnssConfigRequested, gnssConfigNeedEngineUpdate, countOfConfigs); configCollectiveResponse->returnToSender(errsList); })); @@ -2087,6 +2111,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(); @@ -2098,7 +2124,6 @@ GnssAdapter::handleEngineUpEvent() }; readConfigCommand(); - setConfigCommand(); sendMsg(new MsgHandleEngineUpEvent(*this)); } @@ -2942,18 +2967,20 @@ GnssAdapter::enableCommand(LocationTechnologyType techType) mTechType(techType) {} inline virtual void proc() const { LocationError err = LOCATION_ERROR_SUCCESS; - uint32_t powerVoteId = mAdapter.getAfwControlId(); + uint32_t afwControlId = mAdapter.getAfwControlId(); if (mTechType != LOCATION_TECHNOLOGY_TYPE_GNSS) { err = LOCATION_ERROR_INVALID_PARAMETER; - } else if (powerVoteId > 0) { + } else if (afwControlId > 0) { err = LOCATION_ERROR_ALREADY_STARTED; } else { mContext.modemPowerVote(true); mAdapter.setAfwControlId(mSessionId); GnssConfigGpsLock gpsLock = GNSS_CONFIG_GPS_LOCK_NONE; - ContextBase::mGps_conf.GPS_LOCK &= GNSS_CONFIG_GPS_LOCK_NI; - gpsLock = ContextBase::mGps_conf.GPS_LOCK; + if (mAdapter.mSupportNfwControl) { + 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); })); @@ -2993,21 +3020,22 @@ GnssAdapter::disableCommand(uint32_t id) mSessionId(sessionId) {} inline virtual void proc() const { LocationError err = LOCATION_ERROR_SUCCESS; - uint32_t powerVoteId = mAdapter.getAfwControlId(); - if (powerVoteId != mSessionId) { + uint32_t afwControlId = mAdapter.getAfwControlId(); + if (afwControlId != mSessionId) { err = LOCATION_ERROR_ID_UNKNOWN; } else { mContext.modemPowerVote(false); mAdapter.setAfwControlId(0); - /* We need to disable MO (AFW) */ - ContextBase::mGps_conf.GPS_LOCK |= GNSS_CONFIG_GPS_LOCK_MO; + if (mAdapter.mSupportNfwControl) { + /* 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.sendMsg(new LocApiMsg([&mApi = mApi, gpsLock]() { mApi.setGpsLockSync(gpsLock); })); - mAdapter.mXtraObserver.updateLockStatus( - ContextBase::mGps_conf.GPS_LOCK); + mAdapter.mXtraObserver.updateLockStatus(gpsLock); } mAdapter.reportResponse(err, mSessionId); } @@ -4791,11 +4819,11 @@ GnssAdapter::getGnssEnergyConsumedCommand(GnssEnergyConsumedCallback energyConsu void GnssAdapter::nfwControlCommand(bool enable) { - struct MsgenableNfwLocationAccess : public LocMsg { + struct MsgControlNfwLocationAccess : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; bool mEnable; - inline MsgenableNfwLocationAccess(GnssAdapter& adapter, LocApiBase& api, + inline MsgControlNfwLocationAccess(GnssAdapter& adapter, LocApiBase& api, bool enable) : LocMsg(), mAdapter(adapter), @@ -4817,7 +4845,11 @@ GnssAdapter::nfwControlCommand(bool enable) { } }; - sendMsg(new MsgenableNfwLocationAccess(*this, *mLocApi, enable)); + if (mSupportNfwControl) { + sendMsg(new MsgControlNfwLocationAccess(*this, *mLocApi, enable)); + } else { + LOC_LOGw("NFW control is not supported, do not use this for NFW"); + } } /* ==== Eng Hub Proxy ================================================================= */ diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index a44e68c..b84c365 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -150,11 +150,12 @@ class GnssAdapter : public LocAdapterBase { /* ==== CONTROL ======================================================================== */ LocationControlCallbacks mControlCallbacks; - uint32_t mPowerVoteId; + uint32_t mAfwControlId; uint32_t mNmeaMask; GnssSvIdConfig mGnssSvIdConfig; GnssSvTypeConfig mGnssSvTypeConfig; GnssSvTypeConfigCallback mGnssSvTypeConfigCb; + bool mSupportNfwControl; /* ==== NI ============================================================================= */ NiData mNiData; @@ -281,7 +282,6 @@ public: void disableCommand(uint32_t id); void setControlCallbacksCommand(LocationControlCallbacks& controlCallbacks); void readConfigCommand(); - void setConfigCommand(); void requestUlpCommand(); void initEngHubProxyCommand(); uint32_t* gnssUpdateConfigCommand(GnssConfig config); @@ -289,8 +289,8 @@ public: uint32_t gnssDeleteAidingDataCommand(GnssAidingData& data); void deleteAidingData(const GnssAidingData &data, uint32_t sessionId); void gnssUpdateXtraThrottleCommand(const bool enabled); - std::vector<LocationError> gnssUpdateConfig(const std::string& oldServerUrl, - const std::string& oldMoServerUrl, const GnssConfig& gnssConfigRequested, + std::vector<LocationError> gnssUpdateConfig(const std::string& oldMoServerUrl, + const GnssConfig& gnssConfigRequested, const GnssConfig& gnssConfigNeedEngineUpdate, size_t count = 0); /* ==== GNSS SV TYPE CONFIG ============================================================ */ @@ -313,6 +313,7 @@ public: { mGnssSvTypeConfigCb = callback; } inline GnssSvTypeConfigCallback gnssGetSvTypeConfigCallback() { return mGnssSvTypeConfigCb; } + void setConfig(); /* ========= AGPS ====================================================================== */ /* ======== COMMANDS ====(Called from Client Thread)==================================== */ @@ -337,10 +338,8 @@ public: LocationControlCallbacks& getControlCallbacks() { return mControlCallbacks; } void setControlCallbacks(const LocationControlCallbacks& controlCallbacks) { mControlCallbacks = controlCallbacks; } - void setAfwControlId(uint32_t id) { mPowerVoteId = id; } - uint32_t getAfwControlId() { return mPowerVoteId; } - void setPowerVoteId(uint32_t id) { mPowerVoteId = id; } - uint32_t getPowerVoteId() { return mPowerVoteId; } + void setAfwControlId(uint32_t id) { mAfwControlId = id; } + uint32_t getAfwControlId() { return mAfwControlId; } virtual bool isInSession() { return !mTimeBasedTrackingSessions.empty(); } void initDefaultAgps(); bool initEngHubProxy(); |