diff --git a/core/EngineHubProxyBase.h b/core/EngineHubProxyBase.h index 7b9f3ae8..4e259ba7 100644 --- a/core/EngineHubProxyBase.h +++ b/core/EngineHubProxyBase.h @@ -92,10 +92,13 @@ typedef std::function + bool fromUlp, + bool fromEngineHub)> GnssAdapterReportPositionEventCb; -typedef std::function +typedef std::function GnssAdapterReportSvEventCb; // potential parameters: message queue: MsgTask * msgTask; diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp index bf2be1c1..5531fa2d 100644 --- a/core/LocAdapterBase.cpp +++ b/core/LocAdapterBase.cpp @@ -79,7 +79,7 @@ void LocAdapterBase:: const GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask loc_technology_mask, - bool /*fromUlp*/) { + bool /*fromUlp*/, bool /*fromEngineHub*/) { if (mLocAdapterProxyBase != NULL) { mLocAdapterProxyBase->reportPositionEvent((UlpLocation&)location, (GpsLocationExtended&)locationExtended, @@ -91,7 +91,8 @@ void LocAdapterBase:: } void LocAdapterBase:: - reportSvEvent(const GnssSvNotification& /*svNotify*/, bool /*fromUlp*/) + reportSvEvent(const GnssSvNotification& /*svNotify*/, + bool /*fromUlp*/, bool /*fromEngineHub*/) DEFAULT_IMPL() void LocAdapterBase:: diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h index 7fd4c5b5..64537fea 100644 --- a/core/LocAdapterBase.h +++ b/core/LocAdapterBase.h @@ -131,8 +131,10 @@ public: const GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask loc_technology_mask, - bool fromUlp=false); - virtual void reportSvEvent(const GnssSvNotification& svNotify, bool fromUlp=false); + bool fromUlp=false, + bool fromEngineHub=false); + virtual void reportSvEvent(const GnssSvNotification& svNotify, + bool fromUlp=false, bool fromEngineHub=false); virtual void reportNmeaEvent(const char* nmea, size_t length, bool fromUlp=false); virtual void reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet); virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial); diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 91c88d6b..8bddb7b0 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -1289,6 +1289,7 @@ GnssAdapter::updateClientsEventMask() (true == initEngHubProxy())) { mask |= LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT; mask |= LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT; + mask |= LOC_API_ADAPTER_BIT_PARSED_UNPROPAGATED_POSITION_REPORT; LOC_LOGD("%s]: Auto usecase, Enable MEAS/POLY - mask 0x%x", __func__, mask); } @@ -2205,22 +2206,43 @@ GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation, const GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask techMask, - bool fromUlp) + bool fromUlp, + bool fromEngineHub) { LOC_LOGD("%s]: fromUlp %u status %u", __func__, fromUlp, status); // if this event is called from QMI LOC API, then try to call into ULP and return if successfull // if the position is called from ULP or engine hub, then send it out directly - if (!fromUlp) { - // report QMI position to engine hub, and engine hub will be - // distributing it to the registered plugins + if (!fromUlp && !fromEngineHub) { + // report QMI position (both propagated and unpropagated) to engine hub, + // and engine hub will be distributing it to the registered plugins mEngHubProxy->gnssReportPosition(ulpLocation, locationExtended, status); + + if (true == ulpLocation.unpropagatedPosition) { + return; + } + + // only send propagated position report to ulp if (mUlpProxy->reportPosition(ulpLocation, locationExtended, status, techMask)) { return; } + + // engine hub is loaded, do not report qmi position to client as + // final position report should come from engine hub + if (true == initEngHubProxy()){ + return; + } + } else if ((true == fromUlp) && (true == initEngHubProxy())) { + LOC_LOGV("%s]: drop ULP GNSS fix as engine hub is loaded", __func__); + return; } + // for all other cases: + // case 1: fix is from ULP and engine hub is not loaded, queue the msg + // case 2: fix is from engine hub, queue the msg + // when message is queued, the position can be dispatched to requesting client + struct MsgReportPosition : public LocMsg { GnssAdapter& mAdapter; const UlpLocation mUlpLocation; @@ -2321,18 +2343,28 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation, void GnssAdapter::reportSvEvent(const GnssSvNotification& svNotify, - bool fromUlp) + bool fromUlp, + bool fromEngineHub) { LOC_LOGD("%s]: fromUlp %u", __func__, fromUlp); // if this event is not called from ULP, then try to call into ULP and return if successfull - if (!fromUlp) { + if (!fromUlp && !fromEngineHub) { // report QMI SV report to eng hub mEngHubProxy->gnssReportSv(svNotify); if (mUlpProxy->reportSv(svNotify)) { return; } + + // engine hub is loaded, do not report sv to client + // as sv report should come from engine hub + if (true == initEngHubProxy()){ + return; + } + } else if ((true == fromUlp) && (true == initEngHubProxy())) { + LOC_LOGV("%s]: drop ULP GNSS SV event as engine hub is loaded", __func__); + return; } struct MsgReportSv : public LocMsg { @@ -3445,15 +3477,17 @@ GnssAdapter::initEngHubProxy() { const GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask techMask, - bool fromUlp) { + bool fromUlp, + bool fromEngineHub) { // report from engine hub on behalf of PPE will be treated as fromUlp - reportPositionEvent(ulpLocation, locationExtended, status, techMask, fromUlp); + reportPositionEvent(ulpLocation, locationExtended, status, + techMask, fromUlp, fromEngineHub); }; // callback function for engine hub to report back sv event GnssAdapterReportSvEventCb reportSvEventCb = - [this](const GnssSvNotification& svNotify, bool fromUlp) { - reportSvEvent(svNotify, fromUlp); + [this](const GnssSvNotification& svNotify, bool fromUlp, bool fromEngineHub) { + reportSvEvent(svNotify, fromUlp, fromEngineHub); }; getEngHubProxyFn* getter = (getEngHubProxyFn*) dlsym(handle, "getEngHubProxy"); diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 8d639fe8..80d67618 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -240,8 +240,11 @@ public: const GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask techMask, - bool fromUlp=false); - virtual void reportSvEvent(const GnssSvNotification& svNotify, bool fromUlp=false); + bool fromUlp=false, + bool fromEngineHub=false); + virtual void reportSvEvent(const GnssSvNotification& svNotify, + bool fromUlp=false, + bool fromEngineHub=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& measurements, diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 1a54278e..b7b1c09c 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -128,6 +128,7 @@ typedef struct { /* Provider indicator for HYBRID or GPS */ uint16_t position_source; LocPosTechMask tech_mask; + bool unpropagatedPosition; } UlpLocation; typedef struct { @@ -769,6 +770,7 @@ enum loc_api_adapter_event_index { LOC_API_ADAPTER_REQUEST_POSITION_INJECTION, // Position injection request LOC_API_ADAPTER_BATCH_STATUS, // batch status LOC_API_ADAPTER_FDCL_SERVICE_REQ, // FDCL service request + LOC_API_ADAPTER_REPORT_UNPROPAGATED_POSITION, // Unpropagated Position report LOC_API_ADAPTER_EVENT_MAX }; @@ -805,7 +807,7 @@ enum loc_api_adapter_event_index { #define LOC_API_ADAPTER_BIT_POSITION_INJECTION_REQUEST (1<