summaryrefslogtreecommitdiff
path: root/gnss
diff options
context:
space:
mode:
Diffstat (limited to 'gnss')
-rw-r--r--gnss/Agps.cpp16
-rw-r--r--gnss/Agps.h15
-rw-r--r--gnss/GnssAdapter.cpp171
-rw-r--r--gnss/GnssAdapter.h7
4 files changed, 147 insertions, 62 deletions
diff --git a/gnss/Agps.cpp b/gnss/Agps.cpp
index 7931d0c..9255f88 100644
--- a/gnss/Agps.cpp
+++ b/gnss/Agps.cpp
@@ -304,7 +304,7 @@ void AgpsStateMachine::requestOrReleaseDataConn(bool request){
nifRequest.status = LOC_GPS_RELEASE_AGPS_DATA_CONN;
}
- mAgpsManager->mFrameworkStatusV4Cb(nifRequest);
+ mFrameworkStatusV4Cb(nifRequest);
}
void AgpsStateMachine::notifyAllSubscribers(
@@ -511,7 +511,7 @@ void AgpsStateMachine::dropAllSubscribers(){
/* CREATE AGPS STATE MACHINES
* Must be invoked in Msg Handler context */
-void AgpsManager::createAgpsStateMachines() {
+void AgpsManager::createAgpsStateMachines(const AgpsCbInfo& cbInfo) {
LOC_LOGD("AgpsManager::createAgpsStateMachines");
@@ -519,13 +519,16 @@ void AgpsManager::createAgpsStateMachines() {
((loc_core::ContextBase::mGps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSA) ||
(loc_core::ContextBase::mGps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSB));
- if (NULL == mInternetNif) {
+ if (NULL == mInternetNif && (cbInfo.atlType & AGPS_ATL_TYPE_WWAN)) {
mInternetNif = new AgpsStateMachine(this, LOC_AGPS_TYPE_WWAN_ANY);
+ mInternetNif->registerFrameworkStatusCallback((AgnssStatusIpV4Cb)cbInfo.statusV4Cb);
LOC_LOGD("Internet NIF: %p", mInternetNif);
}
if (agpsCapable) {
- if (NULL == mAgnssNif) {
+ if (NULL == mAgnssNif && (cbInfo.atlType & AGPS_ATL_TYPE_SUPL) &&
+ (cbInfo.atlType & AGPS_ATL_TYPE_SUPL_ES)) {
mAgnssNif = new AgpsStateMachine(this, LOC_AGPS_TYPE_SUPL);
+ mAgnssNif->registerFrameworkStatusCallback((AgnssStatusIpV4Cb)cbInfo.statusV4Cb);
LOC_LOGD("AGNSS NIF: %p", mAgnssNif);
}
}
@@ -544,6 +547,11 @@ AgpsStateMachine* AgpsManager::getAgpsStateMachine(AGpsExtType agpsType) {
LOC_LOGE("NULL AGNSS NIF !");
}
return mAgnssNif;
+ case LOC_AGPS_TYPE_WWAN_ANY:
+ if (mInternetNif == NULL) {
+ LOC_LOGE("NULL Internet NIF !");
+ }
+ return mInternetNif;
default:
return mInternetNif;
}
diff --git a/gnss/Agps.h b/gnss/Agps.h
index 829cbd5..d559377 100644
--- a/gnss/Agps.h
+++ b/gnss/Agps.h
@@ -137,6 +137,7 @@ protected:
/* Current state for this state machine */
AgpsState mState;
+ AgnssStatusIpV4Cb mFrameworkStatusV4Cb;
private:
/* AGPS Type for this state machine
LOC_AGPS_TYPE_ANY 0
@@ -154,6 +155,7 @@ private:
public:
/* CONSTRUCTOR */
AgpsStateMachine(AgpsManager* agpsManager, AGpsExtType agpsType):
+ mFrameworkStatusV4Cb(NULL),
mAgpsManager(agpsManager), mSubscriberList(),
mCurrentSubscriber(NULL), mState(AGPS_STATE_RELEASED),
mAgpsType(agpsType), mAPN(NULL), mAPNLen(0),
@@ -175,6 +177,10 @@ public:
inline void setCurrentSubscriber(AgpsSubscriber* subscriber)
{ mCurrentSubscriber = subscriber; }
+ inline void registerFrameworkStatusCallback(AgnssStatusIpV4Cb frameworkStatusV4Cb) {
+ mFrameworkStatusV4Cb = frameworkStatusV4Cb;
+ }
+
/* Fetch subscriber with specified handle */
AgpsSubscriber* getSubscriber(int connHandle);
@@ -234,7 +240,6 @@ class AgpsManager {
public:
/* CONSTRUCTOR */
AgpsManager():
- mFrameworkStatusV4Cb(NULL),
mAtlOpenStatusCb(), mAtlCloseStatusCb(),
mAgnssNif(NULL), mInternetNif(NULL)/*, mDsNif(NULL)*/ {}
@@ -246,12 +251,11 @@ public:
mAtlCloseStatusCb = atlCloseStatusCb;
}
- inline void registerFrameworkStatusCallback(AgnssStatusIpV4Cb frameworkStatusV4Cb) {
- mFrameworkStatusV4Cb = frameworkStatusV4Cb;
- }
+ /* Check if AGPS client is registered */
+ inline bool isRegistered() { return nullptr != mAgnssNif || nullptr != mInternetNif; }
/* Create all AGPS state machines */
- void createAgpsStateMachines();
+ void createAgpsStateMachines(const AgpsCbInfo& cbInfo);
/* Process incoming ATL requests */
void requestATL(int connHandle, AGpsExtType agpsType, LocApnTypeMask apnTypeMask);
@@ -266,7 +270,6 @@ public:
void handleModemSSR();
protected:
- AgnssStatusIpV4Cb mFrameworkStatusV4Cb;
AgpsAtlOpenStatusCb mAtlOpenStatusCb;
AgpsAtlCloseStatusCb mAtlCloseStatusCb;
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index f3b459c..ad86606 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -80,7 +80,6 @@ GnssAdapter::GnssAdapter() :
mGnssSvTypeConfigCb(nullptr),
mNiData(),
mAgpsManager(),
- mAgpsCbInfo(),
mOdcpiRequestCb(nullptr),
mOdcpiRequestActive(false),
mOdcpiTimer(this),
@@ -485,6 +484,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;
+ }
}
@@ -722,8 +731,6 @@ GnssAdapter::setConfig()
//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
@@ -756,10 +763,17 @@ GnssAdapter::setConfig()
gnssConfigRequested.aGlonassPositionProtocolMask =
gpsConf.A_GLONASS_POS_PROTOCOL_SELECT;
}
- gnssConfigRequested.lppeControlPlaneMask =
- mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY);
- gnssConfigRequested.lppeUserPlaneMask =
- mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY);
+ if (gpsConf.LPPE_CP_TECHNOLOGY) {
+ gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT;
+ gnssConfigRequested.lppeControlPlaneMask =
+ mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY);
+ }
+
+ if (gpsConf.LPPE_UP_TECHNOLOGY) {
+ gnssConfigRequested.flags |= GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT;
+ gnssConfigRequested.lppeUserPlaneMask =
+ mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY);
+ }
gnssConfigRequested.blacklistedSvIds.assign(mBlacklistedSvIds.begin(),
mBlacklistedSvIds.end());
mLocApi->sendMsg(new LocApiMsg(
@@ -2079,10 +2093,9 @@ GnssAdapter::updateClientsEventMask()
mask);
}
- if (mAgpsCbInfo.statusV4Cb != NULL) {
+ if (mAgpsManager.isRegistered()) {
mask |= LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST;
}
-
// Add ODCPI handling
if (nullptr != mOdcpiRequestCb) {
mask |= LOC_API_ADAPTER_BIT_REQUEST_WIFI;
@@ -3052,32 +3065,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 {
@@ -3134,6 +3138,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,
@@ -3188,9 +3221,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);
}
@@ -3239,6 +3283,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)
{
@@ -4112,27 +4198,17 @@ void GnssAdapter::initDefaultAgpsCommand() {
/* INIT LOC AGPS MANAGER */
void GnssAdapter::initAgps(const AgpsCbInfo& cbInfo) {
- LOC_LOGD("%s]: mAgpsCbInfo.cbPriority - %d; cbInfo.cbPriority - %d",
- __func__, mAgpsCbInfo.cbPriority, cbInfo.cbPriority)
+ LOC_LOGD("%s]:cbInfo.atlType - %d", __func__, cbInfo.atlType);
if (!((ContextBase::mGps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSB) ||
(ContextBase::mGps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSA))) {
return;
}
- if (mAgpsCbInfo.cbPriority > cbInfo.cbPriority) {
- return;
- } else {
- mAgpsCbInfo = cbInfo;
-
- mAgpsManager.registerFrameworkStatusCallback((AgnssStatusIpV4Cb)cbInfo.statusV4Cb);
-
- mAgpsManager.createAgpsStateMachines();
-
- /* Register for AGPS event mask */
- updateEvtMask(LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST,
- LOC_REGISTRATION_MASK_ENABLED);
- }
+ mAgpsManager.createAgpsStateMachines(cbInfo);
+ /* Register for AGPS event mask */
+ updateEvtMask(LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST,
+ LOC_REGISTRATION_MASK_ENABLED);
}
void GnssAdapter::initAgpsCommand(const AgpsCbInfo& cbInfo){
@@ -4921,15 +4997,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..3ccdd96 100644
--- a/gnss/GnssAdapter.h
+++ b/gnss/GnssAdapter.h
@@ -163,7 +163,6 @@ class GnssAdapter : public LocAdapterBase {
/* ==== AGPS =========================================================================== */
// This must be initialized via initAgps()
AgpsManager mAgpsManager;
- AgpsCbInfo mAgpsCbInfo;
void initAgps(const AgpsCbInfo& cbInfo);
/* ==== NFW =========================================================================== */
@@ -351,9 +350,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 +387,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);