diff options
Diffstat (limited to 'gnss/GnssAdapter.cpp')
-rw-r--r-- | gnss/GnssAdapter.cpp | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index d3792b9..cff0298 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -137,7 +137,8 @@ GnssAdapter::GnssAdapter() : mLastDeleteAidingDataTime(0), mDgnssState(0), mSendNmeaConsent(false), - mDgnssLastNmeaBootTimeMilli(0) + mDgnssLastNmeaBootTimeMilli(0), + mNativeAgpsHandler(mSystemStatus->getOsObserver(), *this) { LOC_LOGD("%s]: Constructor %p", __func__, this); mLocPositionMode.mode = LOC_POSITION_MODE_INVALID; @@ -356,7 +357,8 @@ uint16_t GnssAdapter::getNumSvUsed(uint64_t svUsedIdsMask, void GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out, - const GpsLocationExtended& locationExtended) + const GpsLocationExtended& locationExtended, + enum loc_sess_status status) { out.size = sizeof(GnssLocationInfoNotification); if (GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL & locationExtended.flags) { @@ -665,6 +667,9 @@ GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out, out.flags |= GNSS_LOCATION_INFO_ALTITUDE_ASSUMED_BIT; out.altitudeAssumed = locationExtended.altitudeAssumed; } + + out.flags |= GNSS_LOCATION_INFO_SESSION_STATUS_BIT; + out.sessionStatus = status; } inline uint32_t @@ -2602,6 +2607,7 @@ GnssAdapter::restartSessions(bool modemSSR) // inform engine hub that GNSS session is about to start mEngHubProxy->gnssSetFixMode(mLocPositionMode); mEngHubProxy->gnssStartFix(); + checkUpdateDgnssNtrip(false); } checkAndRestartSPESession(); @@ -2634,6 +2640,10 @@ GnssAdapter::suspendSessions() // inform engine hub that GNSS session has stopped mEngHubProxy->gnssStopFix(); mLocApi->stopFix(nullptr); + if (isDgnssNmeaRequired()) { + mDgnssState &= ~DGNSS_STATE_NO_NMEA_PENDING; + } + stopDgnssNtrip(); mSPEAlreadyRunningAtHighestInterval = false; } } @@ -2830,7 +2840,6 @@ GnssAdapter::saveTrackingSession(LocationAPI* client, uint32_t sessionId, mTimeBasedTrackingSessions[key] = options; } reportPowerStateIfChanged(); - checkUpdateDgnssNtrip(false); } void @@ -2847,16 +2856,8 @@ GnssAdapter::eraseTrackingSession(LocationAPI* client, uint32_t sessionId) } } reportPowerStateIfChanged(); - - if (mSendNmeaConsent && mStartDgnssNtripParams.ntripParams.requiresNmeaLocation) { - LOC_LOGd("requiresNmeaLocation"); - mDgnssState &= ~DGNSS_STATE_NO_NMEA_PENDING; - mStartDgnssNtripParams.nmea.clear(); - } - stopDgnssNtrip(); } - bool GnssAdapter::setLocPositionMode(const LocPosMode& mode) { if (!mLocPositionMode.equals(mode)) { mLocPositionMode = mode; @@ -3074,6 +3075,8 @@ GnssAdapter::startTimeBasedTracking(LocationAPI* client, uint32_t sessionId, [this, client, sessionId] (LocationError err) { if (LOCATION_ERROR_SUCCESS != err) { eraseTrackingSession(client, sessionId); + } else { + checkUpdateDgnssNtrip(false); } reportResponse(client, err, sessionId); @@ -3415,6 +3418,11 @@ GnssAdapter::stopTracking(LocationAPI* client, uint32_t id) reportResponse(client, err, id); })); + if (isDgnssNmeaRequired()) { + mDgnssState &= ~DGNSS_STATE_NO_NMEA_PENDING; + } + stopDgnssNtrip(); + mSPEAlreadyRunningAtHighestInterval = false; } @@ -3954,7 +3962,7 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation, if (reportToGnssClient || reportToFlpClient) { GnssLocationInfoNotification locationInfo = {}; - convertLocationInfo(locationInfo, locationExtended); + convertLocationInfo(locationInfo, locationExtended, status); convertLocation(locationInfo.location, ulpLocation, locationExtended); logLatencyInfo(); for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { @@ -4084,7 +4092,8 @@ GnssAdapter::reportEnginePositions(unsigned int count, } if (needReportEnginePositions) { - convertLocationInfo(locationInfo[i], engLocation->locationExtended); + convertLocationInfo(locationInfo[i], engLocation->locationExtended, + engLocation->sessionStatus); convertLocation(locationInfo[i].location, engLocation->location, engLocation->locationExtended); @@ -5027,23 +5036,20 @@ GnssAdapter::reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstB void GnssAdapter::initDefaultAgps() { LOC_LOGD("%s]: ", __func__); - void *handle = nullptr; - if ((handle = dlopen("libloc_net_iface.so", RTLD_NOW)) == nullptr) { - LOC_LOGD("%s]: libloc_net_iface.so not found !", __func__); - return; - } - LocAgpsGetAgpsCbInfo getAgpsCbInfo = (LocAgpsGetAgpsCbInfo) - dlsym(handle, "LocNetIfaceAgps_getAgpsCbInfo"); - if (getAgpsCbInfo == nullptr) { - LOC_LOGE("%s]: Failed to get method LocNetIfaceAgps_getStatusCb", __func__); - dlclose(handle); - return; + LocAgpsGetAgpsCbInfo getAgpsCbInfo = + (LocAgpsGetAgpsCbInfo)dlGetSymFromLib(handle, "libloc_net_iface.so", + "LocNetIfaceAgps_getAgpsCbInfo"); + // Below step is to make sure we init nativeAgpsHandler + // for Android platforms only + AgpsCbInfo cbInfo = {}; + if (nullptr != getAgpsCbInfo) { + cbInfo = getAgpsCbInfo(agpsOpenResultCb, agpsCloseResultCb, this); + } else { + cbInfo = mNativeAgpsHandler.getAgpsCbInfo(); } - AgpsCbInfo& cbInfo = getAgpsCbInfo(agpsOpenResultCb, agpsCloseResultCb, this); - if (cbInfo.statusV4Cb == nullptr) { LOC_LOGE("%s]: statusV4Cb is nullptr!", __func__); dlclose(handle); @@ -6780,9 +6786,6 @@ void GnssAdapter::enablePPENtripStreamCommand(const GnssNtripConnectionParams& p } void GnssAdapter::handleEnablePPENtrip(const GnssNtripConnectionParams& params) { - - LOC_LOGd("isInSession %d mDgnssState 0x%x", isInSession(), mDgnssState); - LOC_LOGd("%d %s %d %s %s %s %d mSendNmeaConsent %d", params.useSSL, params.hostNameOrIp.data(), params.port, params.mountPoint.data(), params.username.data(), params.password.data(), @@ -6796,7 +6799,8 @@ void GnssAdapter::handleEnablePPENtrip(const GnssNtripConnectionParams& params) 0 == pNtripParams->mountPoint.compare(params.mountPoint) && 0 == pNtripParams->username.compare(params.username) && 0 == pNtripParams->password.compare(params.password) && - params.requiresNmeaLocation == params.requiresNmeaLocation) { + pNtripParams->requiresNmeaLocation == params.requiresNmeaLocation && + mDgnssState & DGNSS_STATE_ENABLE_NTRIP_COMMAND) { LOC_LOGd("received same Ntrip param"); return; } @@ -6831,13 +6835,14 @@ void GnssAdapter::disablePPENtripStreamCommand() { } void GnssAdapter::handleDisablePPENtrip() { - mStartDgnssNtripParams.clear(); mDgnssState &= ~DGNSS_STATE_ENABLE_NTRIP_COMMAND; mDgnssState |= DGNSS_STATE_NO_NMEA_PENDING; stopDgnssNtrip(); } void GnssAdapter::checkUpdateDgnssNtrip(bool isLocationValid) { + LOC_LOGd("isInSession %d mDgnssState 0x%x isLocationValid %d", + isInSession(), mDgnssState, isLocationValid); if (isInSession()) { uint64_t curBootTime = getBootTimeMilliSec(); if (mDgnssState == (DGNSS_STATE_ENABLE_NTRIP_COMMAND | DGNSS_STATE_NO_NMEA_PENDING)) { @@ -6856,12 +6861,11 @@ void GnssAdapter::checkUpdateDgnssNtrip(bool isLocationValid) { } void GnssAdapter::stopDgnssNtrip() { + LOC_LOGd("isInSession %d mDgnssState 0x%x", isInSession(), mDgnssState); + mStartDgnssNtripParams.nmea.clear(); if (mDgnssState & DGNSS_STATE_NTRIP_SESSION_STARTED) { mDgnssState &= ~DGNSS_STATE_NTRIP_SESSION_STARTED; mXtraObserver.stopDgnssSource(); - } else { - LOC_LOGd("isInSession %d mDgnssState 0x%x", - isInSession(), mDgnssState); } } |