summaryrefslogtreecommitdiff
path: root/gnss
diff options
context:
space:
mode:
Diffstat (limited to 'gnss')
-rw-r--r--gnss/GnssAdapter.cpp130
-rw-r--r--gnss/GnssAdapter.h6
2 files changed, 109 insertions, 27 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index 47e5527..5e47569 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -485,6 +485,16 @@ GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out,
out.flags |= GNSS_LOCATION_INFO_CALIBRATION_STATUS_BIT;
out.calibrationStatus = locationExtended.calibrationStatus;
}
+
+ if (GPS_LOCATION_EXTENDED_HAS_OUTPUT_ENG_TYPE & locationExtended.flags) {
+ out.flags |= GNSS_LOCATION_INFO_OUTPUT_ENG_TYPE_BIT;
+ out.locOutputEngType = locationExtended.locOutputEngType;
+ }
+
+ if (GPS_LOCATION_EXTENDED_HAS_OUTPUT_ENG_MASK & locationExtended.flags) {
+ out.flags |= GNSS_LOCATION_INFO_OUTPUT_ENG_MASK_BIT;
+ out.locOutputEngMask = locationExtended.locOutputEngMask;
+ }
}
@@ -3051,32 +3061,23 @@ GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation,
const GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask techMask,
- bool fromEngineHub,
GnssDataNotification* pDataNotify,
int msInWeek)
{
- // if this event is called from QMI LOC API, then send report to engine hub
+ // this position is from QMI LOC API, then send report to engine hub
// if sending is successful, we return as we will wait for final report from engine hub
// if the position is called from engine hub, then send it out directly
- if (!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;
- }
+ if (true == initEngHubProxy()){
+ mEngHubProxy->gnssReportPosition(ulpLocation, locationExtended, status);
+ 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;
- }
+ if (true == ulpLocation.unpropagatedPosition) {
+ return;
}
- // for all other cases:
- // case 1: fix is from engine hub, queue the msg
- // case 2: fix is not from engine hub, e.g. from QMI, and it is not an
+ // Fix is from QMI, and it is not an
// unpropagated position and engine hub is not loaded, queue the msg
// when message is queued, the position can be dispatched to requesting client
struct MsgReportPosition : public LocMsg {
@@ -3133,6 +3134,35 @@ GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation,
pDataNotify, msInWeek));
}
+void
+GnssAdapter::reportEnginePositionsEvent(unsigned int count,
+ EngineLocationInfo* locationArr)
+{
+ struct MsgReportEnginePositions : public LocMsg {
+ GnssAdapter& mAdapter;
+ unsigned int mCount;
+ EngineLocationInfo mEngLocInfo[LOC_OUTPUT_ENGINE_COUNT];
+ inline MsgReportEnginePositions(GnssAdapter& adapter,
+ unsigned int count,
+ EngineLocationInfo* locationArr) :
+ LocMsg(),
+ mAdapter(adapter),
+ mCount(count) {
+ if (mCount > LOC_OUTPUT_ENGINE_COUNT) {
+ mCount = LOC_OUTPUT_ENGINE_COUNT;
+ }
+ if (mCount > 0) {
+ memcpy(mEngLocInfo, locationArr, sizeof(EngineLocationInfo)*mCount);
+ }
+ }
+ inline virtual void proc() const {
+ mAdapter.reportEnginePositions(mCount, mEngLocInfo);
+ }
+ };
+
+ sendMsg(new MsgReportEnginePositions(*this, count, locationArr));
+}
+
bool
GnssAdapter::needReportForGnssClient(const UlpLocation& ulpLocation,
enum loc_sess_status status,
@@ -3187,9 +3217,20 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation,
for (auto it=mClientData.begin(); it != mClientData.end(); ++it) {
if ((reportToFlpClient && isFlpClient(it->second)) ||
- (reportToGnssClient && !isFlpClient(it->second))) {
+ (reportToGnssClient && !isFlpClient(it->second))) {
if (nullptr != it->second.gnssLocationInfoCb) {
it->second.gnssLocationInfoCb(locationInfo);
+ } else if ((nullptr != it->second.engineLocationsInfoCb) &&
+ (false == initEngHubProxy())) {
+ // if engine hub is disabled, this is SPE fix from modem
+ // we need to mark one copy marked as fused and one copy marked as PPE
+ // and dispatch it to the engineLocationsInfoCb
+ GnssLocationInfoNotification engLocationsInfo[2];
+ engLocationsInfo[0] = locationInfo;
+ engLocationsInfo[0].locOutputEngType = LOC_OUTPUT_ENGINE_FUSED;
+ engLocationsInfo[0].flags |= GNSS_LOCATION_INFO_OUTPUT_ENG_TYPE_BIT;
+ engLocationsInfo[1] = locationInfo;
+ it->second.engineLocationsInfoCb(2, engLocationsInfo);
} else if (nullptr != it->second.trackingCb) {
it->second.trackingCb(locationInfo.location);
}
@@ -3238,6 +3279,48 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation,
}
void
+GnssAdapter::reportEnginePositions(unsigned int count,
+ const EngineLocationInfo* locationArr)
+{
+ bool needReportEnginePositions = false;
+ for (auto it=mClientData.begin(); it != mClientData.end(); ++it) {
+ if (nullptr != it->second.engineLocationsInfoCb) {
+ needReportEnginePositions = true;
+ break;
+ }
+ }
+
+ GnssLocationInfoNotification locationInfo[LOC_OUTPUT_ENGINE_COUNT] = {};
+ for (unsigned int i = 0; i < count; i++) {
+ const EngineLocationInfo* engLocation = (locationArr+i);
+ // if it is fused/default location, call reportPosition maintain legacy behavior
+ if ((GPS_LOCATION_EXTENDED_HAS_OUTPUT_ENG_TYPE & engLocation->locationExtended.flags) &&
+ (LOC_OUTPUT_ENGINE_FUSED == engLocation->locationExtended.locOutputEngType)) {
+ reportPosition(engLocation->location,
+ engLocation->locationExtended,
+ engLocation->sessionStatus,
+ engLocation->location.tech_mask);
+ }
+
+ if (needReportEnginePositions) {
+ convertLocationInfo(locationInfo[i], engLocation->locationExtended);
+ convertLocation(locationInfo[i].location,
+ engLocation->location,
+ engLocation->locationExtended,
+ engLocation->location.tech_mask);
+ }
+ }
+
+ if (needReportEnginePositions) {
+ for (auto it=mClientData.begin(); it != mClientData.end(); ++it) {
+ if (nullptr != it->second.engineLocationsInfoCb) {
+ it->second.engineLocationsInfoCb(count, locationInfo);
+ }
+ }
+ }
+}
+
+void
GnssAdapter::reportSvEvent(const GnssSvNotification& svNotify,
bool fromEngineHub)
{
@@ -4920,15 +5003,10 @@ GnssAdapter::initEngHubProxy() {
// prepare the callback functions
// callback function for engine hub to report back position event
- GnssAdapterReportPositionEventCb reportPositionEventCb =
- [this](const UlpLocation& ulpLocation,
- const GpsLocationExtended& locationExtended,
- enum loc_sess_status status,
- LocPosTechMask techMask,
- bool fromEngineHub) {
+ GnssAdapterReportEnginePositionsEventCb reportPositionEventCb =
+ [this](int count, EngineLocationInfo* locationArr) {
// report from engine hub on behalf of PPE will be treated as fromUlp
- reportPositionEvent(ulpLocation, locationExtended, status,
- techMask, fromEngineHub);
+ reportEnginePositionsEvent(count, locationArr);
};
// callback function for engine hub to report back sv event
diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h
index b84c365..752adca 100644
--- a/gnss/GnssAdapter.h
+++ b/gnss/GnssAdapter.h
@@ -351,9 +351,11 @@ public:
const GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask techMask,
- bool fromEngineHub = false,
GnssDataNotification* pDataNotify = nullptr,
int msInWeek = -1);
+ virtual void reportEnginePositionsEvent(unsigned int count,
+ EngineLocationInfo* locationArr);
+
virtual void reportSvEvent(const GnssSvNotification& svNotify,
bool fromEngineHub=false);
virtual void reportNmeaEvent(const char* nmea, size_t length);
@@ -386,6 +388,8 @@ public:
const GpsLocationExtended &locationExtended,
enum loc_sess_status status,
LocPosTechMask techMask);
+ void reportEnginePositions(unsigned int count,
+ const EngineLocationInfo* locationArr);
void reportSv(GnssSvNotification& svNotify);
void reportNmea(const char* nmea, size_t length);
void reportData(GnssDataNotification& dataNotify);