diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp index 9d89c4b5..3943819f 100644 --- a/core/LocAdapterBase.cpp +++ b/core/LocAdapterBase.cpp @@ -153,7 +153,8 @@ bool LocAdapterBase:: DEFAULT_IMPL(false) void LocAdapterBase:: - reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& /*measurementsNotify*/) + reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& /*measurements*/, + int /*msInWeek*/) DEFAULT_IMPL() bool LocAdapterBase:: diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h index 5c471fd5..e7beca83 100644 --- a/core/LocAdapterBase.h +++ b/core/LocAdapterBase.h @@ -150,7 +150,8 @@ public: virtual bool requestNiNotifyEvent(const GnssNiNotification ¬ify, const void* data); inline virtual bool isInSession() { return false; } ContextBase* getContext() const { return mContext; } - virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurementsNotify); + virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurements, + int msInWeek); virtual bool reportWwanZppFix(LocGpsLocation &zppLoc); }; diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 6cc00b13..303d03a4 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -401,10 +401,11 @@ void* LocApiBase :: getSibling() LocApiProxyBase* LocApiBase :: getLocApiProxy() DEFAULT_IMPL(NULL) -void LocApiBase::reportGnssMeasurementData(GnssMeasurementsNotification& measurementsNotify) +void LocApiBase::reportGnssMeasurementData(GnssMeasurementsNotification& measurements, + int msInWeek) { // loop through adapters, and deliver to all adapters. - TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementDataEvent(measurementsNotify)); + TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementDataEvent(measurements, msInWeek)); } enum loc_api_adapter_err LocApiBase:: diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 86610e72..f2fcd9d0 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -131,7 +131,7 @@ public: void reportDataCallClosed(); void requestNiNotify(GnssNiNotification ¬ify, const void* data); void saveSupportedMsgList(uint64_t supportedMsgList); - void reportGnssMeasurementData(GnssMeasurementsNotification& measurementsNotify); + void reportGnssMeasurementData(GnssMeasurementsNotification& measurements, int msInWeek); void saveSupportedFeatureList(uint8_t *featureList); void reportWwanZppFix(LocGpsLocation &zppLoc); diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 677a020d..ef3657d5 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -818,6 +818,10 @@ GnssAdapter::gnssDeleteAidingDataCommand(GnssAidingData& data) LocationError err = LOCATION_ERROR_SUCCESS; err = mApi.deleteAidingData(mData); mAdapter.reportResponse(err, mSessionId); + SystemStatus* s = LocDualContext::getSystemStatus(); + if ((nullptr != s) && (mData.deleteAll)) { + s->setDefaultReport(); + } } }; @@ -2289,32 +2293,38 @@ GnssAdapter::requestNiNotify(const GnssNiNotification& notify, const void* data) } void -GnssAdapter::reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurementsNotify) +GnssAdapter::reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurements, + int msInWeek) { LOC_LOGD("%s]: ", __func__); struct MsgReportGnssMeasurementData : public LocMsg { GnssAdapter& mAdapter; - const GnssMeasurementsNotification mMeasurementsNotify; + GnssMeasurementsNotification mMeasurementsNotify; inline MsgReportGnssMeasurementData(GnssAdapter& adapter, - const GnssMeasurementsNotification& measurementsNotify) : - LocMsg(), - mAdapter(adapter), - mMeasurementsNotify(measurementsNotify) {} + const GnssMeasurementsNotification& measurements, + int msInWeek) : + LocMsg(), + mAdapter(adapter), + mMeasurementsNotify(measurements) { + if (-1 != msInWeek) { + getAgcInformation(mMeasurementsNotify, msInWeek); + } + } inline virtual void proc() const { mAdapter.reportGnssMeasurementData(mMeasurementsNotify); } }; - sendMsg(new MsgReportGnssMeasurementData(*this, measurementsNotify)); + sendMsg(new MsgReportGnssMeasurementData(*this, measurements, msInWeek)); } void -GnssAdapter::reportGnssMeasurementData(const GnssMeasurementsNotification& measurementsNotify) +GnssAdapter::reportGnssMeasurementData(const GnssMeasurementsNotification& measurements) { for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { if (nullptr != it->second.gnssMeasurementsCb) { - it->second.gnssMeasurementsCb(measurementsNotify); + it->second.gnssMeasurementsCb(measurements); } } } @@ -2921,3 +2931,58 @@ bool GnssAdapter::getDebugReport(GnssDebugReport& r) return true; } +/* get AGC information from system status and fill it */ +void +GnssAdapter::getAgcInformation(GnssMeasurementsNotification& measurements, int msInWeek) +{ + SystemStatus* systemstatus = LocDualContext::getSystemStatus(); + + if (nullptr != systemstatus) { + SystemStatusReports reports = {}; + systemstatus->getReport(reports, true); + + if ((!reports.mRfAndParams.empty()) && (!reports.mTimeAndClock.empty()) && + reports.mTimeAndClock.back().mTimeValid && + (abs(msInWeek - (int)reports.mTimeAndClock.back().mGpsTowMs) < 2000)) { + + for (size_t i = 0; i < measurements.count; i++) { + switch (measurements.measurements[i].svType) { + case GNSS_SV_TYPE_GPS: + measurements.measurements[i].agcLevelDb = + reports.mRfAndParams.back().mAgcGps; + measurements.measurements[i].flags |= + GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT; + break; + + case GNSS_SV_TYPE_GALILEO: + measurements.measurements[i].agcLevelDb = + reports.mRfAndParams.back().mAgcGal; + measurements.measurements[i].flags |= + GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT; + break; + + case GNSS_SV_TYPE_GLONASS: + measurements.measurements[i].agcLevelDb = + reports.mRfAndParams.back().mAgcGlo; + measurements.measurements[i].flags |= + GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT; + break; + + case GNSS_SV_TYPE_BEIDOU: + measurements.measurements[i].agcLevelDb = + reports.mRfAndParams.back().mAgcBds; + measurements.measurements[i].flags |= + GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT; + break; + + case GNSS_SV_TYPE_QZSS: + case GNSS_SV_TYPE_SBAS: + case GNSS_SV_TYPE_UNKNOWN: + default: + break; + } + } + } + } +} + diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 2db97589..6e12d7ca 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -217,7 +217,8 @@ public: virtual void reportSvEvent(const GnssSvNotification& svNotify, bool fromUlp=false); virtual void reportNmeaEvent(const char* nmea, size_t length, bool fromUlp=false); virtual bool requestNiNotifyEvent(const GnssNiNotification& notify, const void* data); - virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurementsNotify); + virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurements, + int msInWeek); virtual void reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet); virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial); @@ -235,10 +236,12 @@ public: void reportSv(GnssSvNotification& svNotify); void reportNmea(const char* nmea, size_t length); bool requestNiNotify(const GnssNiNotification& notify, const void* data); - void reportGnssMeasurementData(const GnssMeasurementsNotification& measurementsNotify); + void reportGnssMeasurementData(const GnssMeasurementsNotification& measurements); /*======== GNSSDEBUG ================================================================*/ bool getDebugReport(GnssDebugReport& report); + /* get AGC information from system status and fill it */ + static void getAgcInformation(GnssMeasurementsNotification& measurements, int msInWeek); /*==== CONVERSION ===================================================================*/ static uint32_t convertGpsLock(const GnssConfigGpsLock gpsLock);