diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index 47194cba..e7ee8bf1 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -42,6 +42,10 @@ namespace loc_core { loc_gps_cfg_s_type ContextBase::mGps_conf {}; loc_sap_cfg_s_type ContextBase::mSap_conf {}; +bool ContextBase::sIsEngineCapabilitiesKnown = false; +uint64_t ContextBase::sSupportedMsgMask = 0; +bool ContextBase::sGnssMeasurementSupported = false; +uint8_t ContextBase::sFeaturesSupported[MAX_FEATURE_LENGTH]; const loc_param_s_type ContextBase::mGps_conf_table[] = { @@ -215,7 +219,7 @@ LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask) // Check the target if (TARGET_NO_GNSS != loc_get_target()){ - if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask, this))) { + if (NULL == (locApi = mLBSProxy->getLocApi(exMask, this))) { void *handle = NULL; //try to see if LocApiV02 is present if ((handle = dlopen("libloc_api_v02.so", RTLD_NOW)) != NULL) { @@ -224,7 +228,7 @@ LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask) if (getter != NULL) { LOC_LOGD("%s:%d]: getter is not NULL for LocApiV02", __func__, __LINE__); - locApi = (*getter)(mMsgTask, exMask, this); + locApi = (*getter)(exMask, this); } } // only RPC is the option now @@ -237,7 +241,7 @@ LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask) if (NULL != getter) { LOC_LOGD("%s:%d]: getter is not NULL in RPC", __func__, __LINE__); - locApi = (*getter)(mMsgTask, exMask, this); + locApi = (*getter)(exMask, this); } } } @@ -247,7 +251,7 @@ LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask) // locApi could still be NULL at this time // we would then create a dummy one if (NULL == locApi) { - locApi = new LocApiBase(mMsgTask, exMask, this); + locApi = new LocApiBase(exMask, this); } return locApi; @@ -263,4 +267,33 @@ ContextBase::ContextBase(const MsgTask* msgTask, { } +void ContextBase::setEngineCapabilities(uint64_t supportedMsgMask, + uint8_t *featureList, bool gnssMeasurementSupported) { + + if (ContextBase::sIsEngineCapabilitiesKnown == false) { + ContextBase::sSupportedMsgMask = supportedMsgMask; + ContextBase::sGnssMeasurementSupported = gnssMeasurementSupported; + if (featureList != NULL) { + memcpy((void *)ContextBase::sFeaturesSupported, + (void *)featureList, sizeof(ContextBase::sFeaturesSupported)); + } + + ContextBase::sIsEngineCapabilitiesKnown = true; + } +} + + +bool ContextBase::isFeatureSupported(uint8_t featureVal) +{ + uint8_t arrayIndex = featureVal >> 3; + uint8_t bitPos = featureVal & 7; + + if (arrayIndex >= MAX_FEATURE_LENGTH) return false; + return ((ContextBase::sFeaturesSupported[arrayIndex] >> bitPos ) & 0x1); +} + +bool ContextBase::gnssConstellationConfig() { + return sGnssMeasurementSupported; +} + } diff --git a/core/ContextBase.h b/core/ContextBase.h index dc64b6ab..e7edb296 100644 --- a/core/ContextBase.h +++ b/core/ContextBase.h @@ -116,6 +116,7 @@ protected: const MsgTask* mMsgTask; LocApiBase* mLocApi; LocApiProxyBase *mLocApiProxy; + public: ContextBase(const MsgTask* msgTask, LOC_API_ADAPTER_EVENT_MASK_T exMask, @@ -140,12 +141,111 @@ public: static loc_gps_cfg_s_type mGps_conf; static loc_sap_cfg_s_type mSap_conf; + static bool sIsEngineCapabilitiesKnown; + static uint64_t sSupportedMsgMask; + static uint8_t sFeaturesSupported[MAX_FEATURE_LENGTH]; + static bool sGnssMeasurementSupported; void readConfig(); static uint32_t getCarrierCapabilities(); + void setEngineCapabilities(uint64_t supportedMsgMask, + uint8_t *featureList, bool gnssMeasurementSupported); + + static inline bool isEngineCapabilitiesKnown() { + return sIsEngineCapabilitiesKnown; + } + + static inline bool isMessageSupported(LocCheckingMessagesID msgID) { + + // confirm if msgID is not larger than the number of bits in + // mSupportedMsg + if ((uint64_t)msgID > (sizeof(sSupportedMsgMask) << 3)) { + return false; + } else { + uint32_t messageChecker = 1 << msgID; + return (messageChecker & sSupportedMsgMask) == messageChecker; + } + } + + /* + Check if a feature is supported + */ + static bool isFeatureSupported(uint8_t featureVal); + + /* + Check if gnss measurement is supported + */ + static bool gnssConstellationConfig(); }; +struct LocApiResponse: LocMsg { + private: + ContextBase& mContext; + std::function mProcImpl; + inline virtual void proc() const { + mProcImpl(mLocationError); + } + protected: + LocationError mLocationError; + public: + inline LocApiResponse(ContextBase& context, + std::function procImpl ) : + mContext(context), mProcImpl(procImpl) {} + + void returnToSender(const LocationError err) { + mLocationError = err; + mContext.sendMsg(this); + } +}; + +struct LocApiCollectiveResponse: LocMsg { + private: + ContextBase& mContext; + std::function errs)> mProcImpl; + inline virtual void proc() const { + mProcImpl(mLocationErrors); + } + protected: + std::vector mLocationErrors; + public: + inline LocApiCollectiveResponse(ContextBase& context, + std::function errs)> procImpl ) : + mContext(context), mProcImpl(procImpl) {} + inline virtual ~LocApiCollectiveResponse() { + } + + void returnToSender(std::vector& errs) { + mLocationErrors = errs; + mContext.sendMsg(this); + } +}; + + +template +struct LocApiResponseData: LocMsg { + private: + ContextBase& mContext; + std::function mProcImpl; + inline virtual void proc() const { + mProcImpl(mLocationError, mData); + } + protected: + LocationError mLocationError; + DATA mData; + public: + inline LocApiResponseData(ContextBase& context, + std::function procImpl ) : + mContext(context), mProcImpl(procImpl) {} + + void returnToSender(const LocationError err, const DATA data) { + mLocationError = err; + mData = data; + mContext.sendMsg(this); + } +}; + + } // namespace loc_core #endif //__LOC_CONTEXT_BASE__ diff --git a/core/LBSProxyBase.h b/core/LBSProxyBase.h index 94ddd0fb..bf786a35 100644 --- a/core/LBSProxyBase.h +++ b/core/LBSProxyBase.h @@ -29,7 +29,6 @@ #ifndef IZAT_PROXY_BASE_H #define IZAT_PROXY_BASE_H #include -#include namespace loc_core { @@ -40,11 +39,9 @@ class ContextBase; class LBSProxyBase { friend class ContextBase; inline virtual LocApiBase* - getLocApi(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T exMask, + getLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask, ContextBase* context) const { - (void)msgTask; (void)exMask; (void)context; return NULL; diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp index f3c999c2..bf2be1c1 100644 --- a/core/LocAdapterBase.cpp +++ b/core/LocAdapterBase.cpp @@ -161,4 +161,10 @@ bool LocAdapterBase:: reportWwanZppFix(LocGpsLocation &/*zppLoc*/) DEFAULT_IMPL(false) +bool LocAdapterBase:: + reportZppBestAvailableFix(LocGpsLocation& /*zppLoc*/, + GpsLocationExtended& /*location_extended*/, LocPosTechMask /*tech_mask*/) +DEFAULT_IMPL(false) + + } // namespace loc_core diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h index e7beca83..7fd4c5b5 100644 --- a/core/LocAdapterBase.h +++ b/core/LocAdapterBase.h @@ -107,7 +107,7 @@ public: } inline bool isFeatureSupported(uint8_t featureVal) { - return mLocApi->isFeatureSupported(featureVal); + return ContextBase::isFeatureSupported(featureVal); } uint32_t generateSessionId(); @@ -153,6 +153,8 @@ public: virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurements, int msInWeek); virtual bool reportWwanZppFix(LocGpsLocation &zppLoc); + virtual bool reportZppBestAvailableFix(LocGpsLocation &zppLoc, + GpsLocationExtended &location_extended, LocPosTechMask tech_mask); }; } // namespace loc_core diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 8aef94b3..8981e8b8 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -126,14 +126,36 @@ struct LocOpenMsg : public LocMsg { } }; -LocApiBase::LocApiBase(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T excludedMask, +struct LocCloseMsg : public LocMsg { + LocApiBase* mLocApi; + inline LocCloseMsg(LocApiBase* locApi) : + LocMsg(), mLocApi(locApi) + { + locallog(); + } + inline virtual void proc() const { + mLocApi->close(); + } + inline void locallog() const { + LOC_LOGV("%s]: LocCloseMsg"); + } + inline virtual void log() const { + locallog(); + } +}; + +MsgTask* LocApiBase::mMsgTask; + +LocApiBase::LocApiBase(LOC_API_ADAPTER_EVENT_MASK_T excludedMask, ContextBase* context) : - mMsgTask(msgTask), mContext(context), mSupportedMsg(0), + mContext(context), mMask(0), mExcludedMask(excludedMask) { memset(mLocAdapters, 0, sizeof(mLocAdapters)); - memset(mFeaturesSupported, 0, sizeof(mFeaturesSupported)); + + if (nullptr == mMsgTask) { + mMsgTask = new MsgTask("LocApiMsgTask", false); + } } LOC_API_ADAPTER_EVENT_MASK_T LocApiBase::getEvtMask() @@ -197,7 +219,7 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter) // if we have an empty list of adapters if (0 == i) { - close(); + mMsgTask->sendMsg(new LocCloseMsg(this)); } else { // else we need to remove the bit mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask())); @@ -208,14 +230,11 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter) void LocApiBase::updateEvtMask() { - open(getEvtMask()); + mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask())); } void LocApiBase::handleEngineUpEvent() { - // This will take care of renegotiating the loc handle - mMsgTask->sendMsg(new LocSsrMsg(this)); - LocDualContext::injectFeatureConfig(mContext); // loop through adapters, and deliver to all adapters. @@ -223,7 +242,9 @@ void LocApiBase::handleEngineUpEvent() } void LocApiBase::handleEngineDownEvent() -{ +{ // This will take care of renegotiating the loc handle + sendMsg(new LocSsrMsg(this)); + // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineDownEvent()); } @@ -239,7 +260,7 @@ void LocApiBase::reportPosition(UlpLocation& location, "timestamp: %" PRId64 "\n" "Session status: %d\n Technology mask: %u\n " "SV used in fix (gps/glo/bds/gal/qzss) : \ - (%" PRIx64 "/%" PRIx64 "/%" PRIx64 "/%" PRIx64 "/%" PRIx64 ")", + (0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 ")", location.gpsLocation.flags, location.position_source, location.gpsLocation.latitude, location.gpsLocation.longitude, location.gpsLocation.altitude, location.gpsLocation.speed, @@ -263,6 +284,15 @@ void LocApiBase::reportWwanZppFix(LocGpsLocation &zppLoc) TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportWwanZppFix(zppLoc)); } +void LocApiBase::reportZppBestAvailableFix(LocGpsLocation &zppLoc, + GpsLocationExtended &location_extended, LocPosTechMask tech_mask) +{ + // loop through adapters, and deliver to the first handling adapter. + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportZppBestAvailableFix(zppLoc, + location_extended, tech_mask)); +} + + void LocApiBase::reportSv(GnssSvNotification& svNotify) { const char* constellationString[] = { "Unknown", "GPS", "SBAS", "GLONASS", @@ -384,16 +414,6 @@ void LocApiBase::requestNiNotify(GnssNiNotification ¬ify, const void* data) TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotifyEvent(notify, data)); } -void LocApiBase::saveSupportedMsgList(uint64_t supportedMsgList) -{ - mSupportedMsg = supportedMsgList; -} - -void LocApiBase::saveSupportedFeatureList(uint8_t *featureList) -{ - memcpy((void *)mFeaturesSupported, (void *)featureList, sizeof(mFeaturesSupported)); -} - void* LocApiBase :: getSibling() DEFAULT_IMPL(NULL) @@ -415,86 +435,72 @@ enum loc_api_adapter_err LocApiBase:: close() DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) -enum loc_api_adapter_err LocApiBase:: - startFix(const LocPosMode& /*posMode*/) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +void LocApiBase::startFix(const LocPosMode& /*posMode*/, LocApiResponse* /*adapterResponse*/) +DEFAULT_IMPL() -enum loc_api_adapter_err LocApiBase:: - stopFix() -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +void LocApiBase::stopFix(LocApiResponse* /*adapterResponse*/) +DEFAULT_IMPL() -LocationError LocApiBase:: - deleteAidingData(const GnssAidingData& /*data*/) -DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) +void LocApiBase:: + deleteAidingData(const GnssAidingData& /*data*/, LocApiResponse* /*adapterResponse*/) +DEFAULT_IMPL() -enum loc_api_adapter_err LocApiBase:: - enableData(int /*enable*/) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - setAPN(char* /*apn*/, int /*len*/) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: +void LocApiBase:: injectPosition(double /*latitude*/, double /*longitude*/, float /*accuracy*/) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +DEFAULT_IMPL() -enum loc_api_adapter_err LocApiBase:: +void LocApiBase:: setTime(LocGpsUtcTime /*time*/, int64_t /*timeReference*/, int /*uncertainty*/) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +DEFAULT_IMPL() enum loc_api_adapter_err LocApiBase:: setXtraData(char* /*data*/, int /*length*/) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) -enum loc_api_adapter_err LocApiBase:: - requestXtraServer() -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - atlOpenStatus(int /*handle*/, int /*is_succ*/, char* /*apn*/, +void LocApiBase:: + atlOpenStatus(int /*handle*/, int /*is_succ*/, char* /*apn*/, uint32_t /*apnLen*/, AGpsBearerType /*bear*/, LocAGpsType /*agpsType*/) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +DEFAULT_IMPL() -enum loc_api_adapter_err LocApiBase:: +void LocApiBase:: atlCloseStatus(int /*handle*/, int /*is_succ*/) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +DEFAULT_IMPL() -enum loc_api_adapter_err LocApiBase:: +void LocApiBase:: setPositionMode(const LocPosMode& /*posMode*/) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +DEFAULT_IMPL() LocationError LocApiBase:: - setServer(const char* /*url*/, int /*len*/) + setServerSync(const char* /*url*/, int /*len*/) DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) LocationError LocApiBase:: - setServer(unsigned int /*ip*/, int /*port*/, LocServerType /*type*/) + setServerSync(unsigned int /*ip*/, int /*port*/, LocServerType /*type*/) DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) -LocationError LocApiBase:: +void LocApiBase:: informNiResponse(GnssNiResponse /*userResponse*/, const void* /*passThroughData*/) -DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) +DEFAULT_IMPL() LocationError LocApiBase:: - setSUPLVersion(GnssConfigSuplVersion /*version*/) + setSUPLVersionSync(GnssConfigSuplVersion /*version*/) DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) enum loc_api_adapter_err LocApiBase:: - setNMEATypes (uint32_t /*typesMask*/) + setNMEATypesSync (uint32_t /*typesMask*/) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) LocationError LocApiBase:: - setLPPConfig(GnssConfigLppProfile /*profile*/) + setLPPConfigSync(GnssConfigLppProfile /*profile*/) DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) enum loc_api_adapter_err LocApiBase:: - setSensorControlConfig(int /*sensorUsage*/, + setSensorControlConfigSync(int /*sensorUsage*/, int /*sensorProvider*/) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: - setSensorProperties(bool /*gyroBiasVarianceRandomWalk_valid*/, + setSensorPropertiesSync(bool /*gyroBiasVarianceRandomWalk_valid*/, float /*gyroBiasVarianceRandomWalk*/, bool /*accelBiasVarianceRandomWalk_valid*/, float /*accelBiasVarianceRandomWalk*/, @@ -507,7 +513,7 @@ enum loc_api_adapter_err LocApiBase:: DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: - setSensorPerfControlConfig(int /*controlMode*/, + setSensorPerfControlConfigSync(int /*controlMode*/, int /*accelSamplesPerBatch*/, int /*accelBatchesPerSec*/, int /*gyroSamplesPerBatch*/, @@ -520,37 +526,36 @@ enum loc_api_adapter_err LocApiBase:: DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) LocationError LocApiBase:: - setAGLONASSProtocol(GnssConfigAGlonassPositionProtocolMask /*aGlonassProtocol*/) + setAGLONASSProtocolSync(GnssConfigAGlonassPositionProtocolMask /*aGlonassProtocol*/) DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) LocationError LocApiBase:: - setLPPeProtocolCp(GnssConfigLppeControlPlaneMask /*lppeCP*/) + setLPPeProtocolCpSync(GnssConfigLppeControlPlaneMask /*lppeCP*/) DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) LocationError LocApiBase:: - setLPPeProtocolUp(GnssConfigLppeUserPlaneMask /*lppeUP*/) + setLPPeProtocolUpSync(GnssConfigLppeUserPlaneMask /*lppeUP*/) DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) +GnssConfigSuplVersion LocApiBase::convertSuplVersion(const uint32_t /*suplVersion*/) +DEFAULT_IMPL(GNSS_CONFIG_SUPL_VERSION_1_0_0) + +GnssConfigLppProfile LocApiBase::convertLppProfile(const uint32_t /*lppProfile*/) +DEFAULT_IMPL(GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE) + +GnssConfigLppeControlPlaneMask LocApiBase::convertLppeCp(const uint32_t /*lppeControlPlaneMask*/) +DEFAULT_IMPL(0) + +GnssConfigLppeUserPlaneMask LocApiBase::convertLppeUp(const uint32_t /*lppeUserPlaneMask*/) +DEFAULT_IMPL(0) + enum loc_api_adapter_err LocApiBase:: getWwanZppFix() DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) -enum loc_api_adapter_err LocApiBase:: - getBestAvailableZppFix(LocGpsLocation& zppLoc) -{ - memset(&zppLoc, 0, sizeof(zppLoc)); - DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) -} - -enum loc_api_adapter_err LocApiBase:: - getBestAvailableZppFix(LocGpsLocation & zppLoc, GpsLocationExtended & locationExtended, - LocPosTechMask & tech_mask) -{ - memset(&zppLoc, 0, sizeof(zppLoc)); - memset(&tech_mask, 0, sizeof(tech_mask)); - memset(&locationExtended, 0, sizeof (locationExtended)); - DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) -} +void LocApiBase:: + getBestAvailableZppFix() +DEFAULT_IMPL() int LocApiBase:: initDataServiceClient(bool /*isDueToSsr*/) @@ -573,7 +578,7 @@ void LocApiBase:: DEFAULT_IMPL() LocationError LocApiBase:: - setGpsLock(GnssConfigGpsLock /*lock*/) + setGpsLockSync(GnssConfigGpsLock /*lock*/) DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) void LocApiBase:: @@ -587,21 +592,7 @@ int LocApiBase:: DEFAULT_IMPL(-1) LocationError LocApiBase:: - setXtraVersionCheck(uint32_t /*check*/) + setXtraVersionCheckSync(uint32_t /*check*/) DEFAULT_IMPL(LOCATION_ERROR_SUCCESS) -bool LocApiBase:: - gnssConstellationConfig() -DEFAULT_IMPL(false) - -bool LocApiBase:: - isFeatureSupported(uint8_t featureVal) -{ - uint8_t arrayIndex = featureVal >> 3; - uint8_t bitPos = featureVal & 7; - - if (arrayIndex >= MAX_FEATURE_LENGTH) return false; - return ((mFeaturesSupported[arrayIndex] >> bitPos ) & 0x1); -} - } // namespace loc_core diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 25d95b2a..f0b1f592 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -37,7 +37,9 @@ #include namespace loc_core { + class ContextBase; +struct LocApiResponse; int hexcode(char *hexstring, int string_size, const char *data, int data_size); @@ -66,6 +68,28 @@ class LocAdapterBase; struct LocSsrMsg; struct LocOpenMsg; +typedef struct +{ + uint32_t accumulatedDistance; + uint32_t numOfBatchedPositions; +} LocApiBatchData; + +typedef struct +{ + uint32_t hwId; +} LocApiGeofenceData; + +struct LocApiMsg: LocMsg { + private: + std::function mProcImpl; + inline virtual void proc() const { + mProcImpl(); + } + public: + inline LocApiMsg(std::function procImpl ) : + mProcImpl(procImpl) {} +}; + class LocApiProxyBase { public: inline LocApiProxyBase() {} @@ -78,22 +102,21 @@ class LocApiBase { //LocOpenMsg calls open() which makes it necessary to declare //it as a friend friend struct LocOpenMsg; + friend struct LocCloseMsg; friend class ContextBase; - const MsgTask* mMsgTask; - ContextBase *mContext; + static MsgTask* mMsgTask; LocAdapterBase* mLocAdapters[MAX_ADAPTERS]; - uint64_t mSupportedMsg; - uint8_t mFeaturesSupported[MAX_FEATURE_LENGTH]; + protected: + ContextBase *mContext; virtual enum loc_api_adapter_err open(LOC_API_ADAPTER_EVENT_MASK_T mask); virtual enum loc_api_adapter_err close(); LOC_API_ADAPTER_EVENT_MASK_T getEvtMask(); LOC_API_ADAPTER_EVENT_MASK_T mMask; - LocApiBase(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T excludedMask, + LocApiBase(LOC_API_ADAPTER_EVENT_MASK_T excludedMask, ContextBase* context = NULL); inline virtual ~LocApiBase() { close(); } bool isInSession(); @@ -130,10 +153,10 @@ public: void reportDataCallOpened(); void reportDataCallClosed(); void requestNiNotify(GnssNiNotification ¬ify, const void* data); - void saveSupportedMsgList(uint64_t supportedMsgList); void reportGnssMeasurementData(GnssMeasurementsNotification& measurements, int msInWeek); - void saveSupportedFeatureList(uint8_t *featureList); void reportWwanZppFix(LocGpsLocation &zppLoc); + void reportZppBestAvailableFix(LocGpsLocation &zppLoc, GpsLocationExtended &location_extended, + LocPosTechMask tech_mask); // downward calls // All below functions are to be defined by adapter specific modules: @@ -141,45 +164,43 @@ public: virtual void* getSibling(); virtual LocApiProxyBase* getLocApiProxy(); - virtual enum loc_api_adapter_err - startFix(const LocPosMode& posMode); - virtual enum loc_api_adapter_err - stopFix(); - virtual LocationError - deleteAidingData(const GnssAidingData& data); - virtual enum loc_api_adapter_err - enableData(int enable); - virtual enum loc_api_adapter_err - setAPN(char* apn, int len); - virtual enum loc_api_adapter_err + virtual void startFix(const LocPosMode& fixCriteria, LocApiResponse* adapterResponse); + virtual void + stopFix(LocApiResponse* adapterResponse); + virtual void + deleteAidingData(const GnssAidingData& data, LocApiResponse* adapterResponse); + + virtual void injectPosition(double latitude, double longitude, float accuracy); - virtual enum loc_api_adapter_err + virtual void setTime(LocGpsUtcTime time, int64_t timeReference, int uncertainty); + + // // TODO:: called from izatapipds virtual enum loc_api_adapter_err setXtraData(char* data, int length); - virtual enum loc_api_adapter_err - requestXtraServer(); - virtual enum loc_api_adapter_err - atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, LocAGpsType agpsType); - virtual enum loc_api_adapter_err + + virtual void + atlOpenStatus(int handle, int is_succ, char* apn, uint32_t apnLen, + AGpsBearerType bear, LocAGpsType agpsType); + virtual void atlCloseStatus(int handle, int is_succ); - virtual enum loc_api_adapter_err + virtual void setPositionMode(const LocPosMode& posMode); virtual LocationError - setServer(const char* url, int len); + setServerSync(const char* url, int len); virtual LocationError - setServer(unsigned int ip, int port, + setServerSync(unsigned int ip, int port, LocServerType type); - virtual LocationError + virtual void informNiResponse(GnssNiResponse userResponse, const void* passThroughData); - virtual LocationError setSUPLVersion(GnssConfigSuplVersion version); + virtual LocationError setSUPLVersionSync(GnssConfigSuplVersion version); virtual enum loc_api_adapter_err - setNMEATypes (uint32_t typesMask); - virtual LocationError setLPPConfig(GnssConfigLppProfile profile); + setNMEATypesSync(uint32_t typesMask); + virtual LocationError setLPPConfigSync(GnssConfigLppProfile profile); virtual enum loc_api_adapter_err - setSensorControlConfig(int sensorUsage, int sensorProvider); + setSensorControlConfigSync(int sensorUsage, int sensorProvider); virtual enum loc_api_adapter_err - setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, + setSensorPropertiesSync(bool gyroBiasVarianceRandomWalk_valid, float gyroBiasVarianceRandomWalk, bool accelBiasVarianceRandomWalk_valid, float accelBiasVarianceRandomWalk, @@ -190,7 +211,7 @@ public: bool velocityBiasVarianceRandomWalk_valid, float velocityBiasVarianceRandomWalk); virtual enum loc_api_adapter_err - setSensorPerfControlConfig(int controlMode, + setSensorPerfControlConfigSync(int controlMode, int accelSamplesPerBatch, int accelBatchesPerSec, int gyroSamplesPerBatch, @@ -201,16 +222,18 @@ public: int gyroBatchesPerSecHigh, int algorithmConfig); virtual LocationError - setAGLONASSProtocol(GnssConfigAGlonassPositionProtocolMask aGlonassProtocol); - virtual LocationError setLPPeProtocolCp(GnssConfigLppeControlPlaneMask lppeCP); - virtual LocationError setLPPeProtocolUp(GnssConfigLppeUserPlaneMask lppeUP); + setAGLONASSProtocolSync(GnssConfigAGlonassPositionProtocolMask aGlonassProtocol); + virtual LocationError setLPPeProtocolCpSync(GnssConfigLppeControlPlaneMask lppeCP); + virtual LocationError setLPPeProtocolUpSync(GnssConfigLppeUserPlaneMask lppeUP); + virtual GnssConfigSuplVersion convertSuplVersion(const uint32_t suplVersion); + virtual GnssConfigLppProfile convertLppProfile(const uint32_t lppProfile); + virtual GnssConfigLppeControlPlaneMask convertLppeCp(const uint32_t lppeControlPlaneMask); + virtual GnssConfigLppeUserPlaneMask convertLppeUp(const uint32_t lppeUserPlaneMask); + virtual enum loc_api_adapter_err getWwanZppFix(); - virtual enum loc_api_adapter_err - getBestAvailableZppFix(LocGpsLocation & zppLoc); - virtual enum loc_api_adapter_err - getBestAvailableZppFix(LocGpsLocation & zppLoc, GpsLocationExtended & locationExtended, - LocPosTechMask & tech_mask); + virtual void + getBestAvailableZppFix(); virtual int initDataServiceClient(bool isDueToSsr); virtual int openAndStartDataCall(); virtual void stopDataCall(); @@ -223,21 +246,11 @@ public: (void)inSession; } - inline bool isMessageSupported (LocCheckingMessagesID msgID) const { - // confirm if msgID is not larger than the number of bits in - // mSupportedMsg - if ((uint64_t)msgID > (sizeof(mSupportedMsg) << 3)) { - return false; - } else { - uint32_t messageChecker = 1 << msgID; - return (messageChecker & mSupportedMsg) == messageChecker; - } - } void updateEvtMask(); - virtual LocationError setGpsLock(GnssConfigGpsLock lock); + virtual LocationError setGpsLockSync(GnssConfigGpsLock lock); /* Returns Current value of GPS Lock on success @@ -245,20 +258,11 @@ public: */ virtual int getGpsLock(void); - virtual LocationError setXtraVersionCheck(uint32_t check); - /* - Check if the modem support the service - */ - virtual bool gnssConstellationConfig(); + virtual LocationError setXtraVersionCheckSync(uint32_t check); - /* - Check if a feature is supported - */ - bool isFeatureSupported(uint8_t featureVal); }; -typedef LocApiBase* (getLocApi_t)(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T exMask, +typedef LocApiBase* (getLocApi_t)(LOC_API_ADAPTER_EVENT_MASK_T exMask, ContextBase *context); } // namespace loc_core diff --git a/gnss/Agps.cpp b/gnss/Agps.cpp index 6ce0c345..d6a75aba 100644 --- a/gnss/Agps.cpp +++ b/gnss/Agps.cpp @@ -360,13 +360,13 @@ void AgpsStateMachine::notifyEventToSubscriber( case AGPS_EVENT_GRANTED: mAgpsManager->mAtlOpenStatusCb( - subscriberToNotify->mConnHandle, 1, getAPN(), + subscriberToNotify->mConnHandle, 1, getAPN(), getAPNLen(), getBearer(), mAgpsType); break; case AGPS_EVENT_DENIED: mAgpsManager->mAtlOpenStatusCb( - subscriberToNotify->mConnHandle, 0, getAPN(), + subscriberToNotify->mConnHandle, 0, getAPN(), getAPNLen(), getBearer(), mAgpsType); break; @@ -661,7 +661,7 @@ void DSStateMachine::notifyEventToSubscriber( case AGPS_EVENT_GRANTED: mAgpsManager->mAtlOpenStatusCb( - subscriberToNotify->mConnHandle, 1, NULL, + subscriberToNotify->mConnHandle, 1, NULL, 0, AGPS_APN_BEARER_INVALID, LOC_AGPS_TYPE_SUPL_ES); break; @@ -778,7 +778,7 @@ void AgpsManager::requestATL(int connHandle, AGpsExtType agpsType){ LOC_LOGE("No AGPS State Machine for agpsType: %d", agpsType); mAtlOpenStatusCb( - connHandle, 0, NULL, AGPS_APN_BEARER_INVALID, agpsType); + connHandle, 0, NULL, 0, AGPS_APN_BEARER_INVALID, agpsType); return; } diff --git a/gnss/Agps.h b/gnss/Agps.h index 703a4750..f9a54f84 100644 --- a/gnss/Agps.h +++ b/gnss/Agps.h @@ -40,7 +40,7 @@ /* ATL callback function pointers * Passed in by Adapter to AgpsManager */ typedef std::function AgpsAtlOpenStatusCb; typedef std::function AgpsAtlCloseStatusCb; @@ -169,6 +169,7 @@ public: /* Getter/Setter methods */ void setAPN(char* apn, unsigned int len); inline char* getAPN() const { return (char*)mAPN; } + inline uint32_t getAPNLen() const { return mAPNLen; } inline void setBearer(AGpsBearerType bearer) { mBearer = bearer; } inline AGpsBearerType getBearer() const { return mBearer; } inline AGpsExtType getType() const { return mAgpsType; } diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index f996ebee..91c88d6b 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -92,11 +92,11 @@ GnssAdapter::GnssAdapter() : /* Set ATL open/close callbacks */ AgpsAtlOpenStatusCb atlOpenStatusCb = - [this](int handle, int isSuccess, char* apn, + [this](int handle, int isSuccess, char* apn, uint32_t apnLen, AGpsBearerType bearerType, AGpsExtType agpsType) { mLocApi->atlOpenStatus( - handle, isSuccess, apn, bearerType, agpsType); + handle, isSuccess, apn, apnLen, bearerType, agpsType); }; AgpsAtlCloseStatusCb atlCloseStatusCb = [this](int handle, int isSuccess) { @@ -146,7 +146,7 @@ GnssAdapter::GnssAdapter() : dsClientCloseDataCallFn, dsClientReleaseFn, sendMsgFn); readConfigCommand(); - setConfigCommand(); + requestUlpCommand(); initDefaultAgpsCommand(); initEngHubProxyCommand(); } @@ -415,20 +415,6 @@ GnssAdapter::convertSuplVersion(const GnssConfigSuplVersion suplVersion) } } -inline GnssConfigSuplVersion -GnssAdapter::convertSuplVersion(const uint32_t suplVersion) -{ - switch (suplVersion) { - case 0x00020000: - return GNSS_CONFIG_SUPL_VERSION_2_0_0; - case 0x00020002: - return GNSS_CONFIG_SUPL_VERSION_2_0_2; - case 0x00010000: - default: - return GNSS_CONFIG_SUPL_VERSION_1_0_0; - } -} - inline uint32_t GnssAdapter::convertLppProfile(const GnssConfigLppProfile lppProfile) { @@ -445,22 +431,6 @@ GnssAdapter::convertLppProfile(const GnssConfigLppProfile lppProfile) } } -inline GnssConfigLppProfile -GnssAdapter::convertLppProfile(const uint32_t lppProfile) -{ - switch (lppProfile) { - case 1: - return GNSS_CONFIG_LPP_PROFILE_USER_PLANE; - case 2: - return GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE; - case 3: - return GNSS_CONFIG_LPP_PROFILE_USER_PLANE_AND_CONTROL_PLANE; - case 0: - default: - return GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE; - } -} - uint32_t GnssAdapter::convertLppeCp(const GnssConfigLppeControlPlaneMask lppeControlPlaneMask) { @@ -480,26 +450,6 @@ GnssAdapter::convertLppeCp(const GnssConfigLppeControlPlaneMask lppeControlPlane return mask; } -GnssConfigLppeControlPlaneMask -GnssAdapter::convertLppeCp(const uint32_t lppeControlPlaneMask) -{ - GnssConfigLppeControlPlaneMask mask = 0; - if ((1<<0) & lppeControlPlaneMask) { - mask |= GNSS_CONFIG_LPPE_CONTROL_PLANE_DBH_BIT; - } - if ((1<<1) & lppeControlPlaneMask) { - mask |= GNSS_CONFIG_LPPE_CONTROL_PLANE_WLAN_AP_MEASUREMENTS_BIT; - } - if ((1<<2) & lppeControlPlaneMask) { - mask |= GNSS_CONFIG_LPPE_CONTROL_PLANE_SRN_AP_MEASUREMENTS_BIT; - } - if ((1<<3) & lppeControlPlaneMask) { - mask |= GNSS_CONFIG_LPPE_CONTROL_PLANE_SENSOR_BARO_MEASUREMENTS_BIT; - } - return mask; -} - - uint32_t GnssAdapter::convertLppeUp(const GnssConfigLppeUserPlaneMask lppeUserPlaneMask) { @@ -519,25 +469,6 @@ GnssAdapter::convertLppeUp(const GnssConfigLppeUserPlaneMask lppeUserPlaneMask) return mask; } -GnssConfigLppeUserPlaneMask -GnssAdapter::convertLppeUp(const uint32_t lppeUserPlaneMask) -{ - GnssConfigLppeUserPlaneMask mask = 0; - if ((1<<0) & lppeUserPlaneMask) { - mask |= GNSS_CONFIG_LPPE_USER_PLANE_DBH_BIT; - } - if ((1<<1) & lppeUserPlaneMask) { - mask |= GNSS_CONFIG_LPPE_USER_PLANE_WLAN_AP_MEASUREMENTS_BIT; - } - if ((1<<2) & lppeUserPlaneMask) { - mask |= GNSS_CONFIG_LPPE_USER_PLANE_SRN_AP_MEASUREMENTS_BIT; - } - if ((1<<3) & lppeUserPlaneMask) { - mask |= GNSS_CONFIG_LPPE_USER_PLANE_SENSOR_BARO_MEASUREMENTS_BIT; - } - return mask; -} - uint32_t GnssAdapter::convertAGloProt(const GnssConfigAGlonassPositionProtocolMask aGloPositionProtocolMask) { @@ -594,27 +525,6 @@ GnssAdapter::convertSuplMode(const GnssConfigSuplModeMask suplModeMask) return mask; } -bool -GnssAdapter::resolveInAddress(const char* hostAddress, struct in_addr* inAddress) -{ - bool ret = true; - - struct hostent* hp; - hp = gethostbyname(hostAddress); - if (hp != NULL) { /* DNS OK */ - memcpy(inAddress, hp->h_addr_list[0], hp->h_length); - } else { - /* Try IP representation */ - if (inet_aton(hostAddress, inAddress) == 0) { - /* IP not valid */ - LOC_LOGE("%s]: DNS query on '%s' failed", __func__, hostAddress); - ret = false; - } - } - - return ret; -} - void GnssAdapter::readConfigCommand() { @@ -640,17 +550,37 @@ GnssAdapter::readConfigCommand() } } -LocationError +void +GnssAdapter::requestUlpCommand() +{ + LOC_LOGD("%s]: ", __func__); + + struct MsgRequestUlp : public LocMsg { + GnssAdapter* mAdapter; + ContextBase& mContext; + inline MsgRequestUlp(GnssAdapter* adapter, + ContextBase& context) : + LocMsg(), + mAdapter(adapter), + mContext(context) {} + inline virtual void proc() const { + mContext.requestUlp((LocAdapterBase*)mAdapter, mContext.getCarrierCapabilities()); + } + }; + + if (mContext != NULL) { + sendMsg(new MsgRequestUlp(this, *mContext)); + } +} + +void GnssAdapter::setSuplHostServer(const char* server, int port) { - LocationError locErr = LOCATION_ERROR_SUCCESS; if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) { char serverUrl[MAX_URL_LEN] = {}; int32_t length = -1; const char noHost[] = "NONE"; - locErr = LOCATION_ERROR_INVALID_PARAMETER; - if ((NULL == server) || (server[0] == 0) || (strncasecmp(noHost, server, sizeof(noHost)) == 0)) { serverUrl[0] = NULL; @@ -662,14 +592,8 @@ GnssAdapter::setSuplHostServer(const char* server, int port) if (length >= 0 && strncasecmp(getServerUrl().c_str(), serverUrl, sizeof(serverUrl)) != 0) { setServerUrl(serverUrl); - locErr = mLocApi->setServer(serverUrl, length); - if (locErr != LOCATION_ERROR_SUCCESS) { - LOC_LOGE("%s]:Error while setting SUPL_HOST server:%s", - __func__, serverUrl); - } } } - return locErr; } void @@ -680,68 +604,105 @@ GnssAdapter::setConfigCommand() struct MsgSetConfig : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; - inline MsgSetConfig(GnssAdapter& adapter, - LocApiBase& api) : + inline MsgSetConfig(GnssAdapter& adapter, LocApiBase& api) : LocMsg(), mAdapter(adapter), mApi(api) {} inline virtual void proc() const { - if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) { - mApi.setSUPLVersion(mAdapter.convertSuplVersion(ContextBase::mGps_conf.SUPL_VER)); - mApi.setLPPConfig(mAdapter.convertLppProfile(ContextBase::mGps_conf.LPP_PROFILE)); - mApi.setAGLONASSProtocol(ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT); - } - mAdapter.setSuplHostServer(ContextBase::mGps_conf.SUPL_HOST, - ContextBase::mGps_conf.SUPL_PORT); - mApi.setSensorControlConfig(ContextBase::mSap_conf.SENSOR_USAGE, - ContextBase::mSap_conf.SENSOR_PROVIDER); - mApi.setLPPeProtocolCp( - mAdapter.convertLppeCp(ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY)); - mApi.setLPPeProtocolUp( - mAdapter.convertLppeUp(ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY)); // set nmea mask type uint32_t mask = 0; if (NMEA_PROVIDER_MP == ContextBase::mGps_conf.NMEA_PROVIDER) { mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK; } - if (mApi.isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) { + if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) { mask |= LOC_NMEA_MASK_DEBUG_V02; } - if (mask != 0) { - mApi.setNMEATypes(mask); - } mAdapter.mNmeaMask= mask; - mApi.setXtraVersionCheck(ContextBase::mGps_conf.XTRA_VERSION_CHECK); - if (ContextBase::mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID || - ContextBase::mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID || - ContextBase::mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || - ContextBase::mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || - ContextBase::mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) { - mApi.setSensorProperties( - ContextBase::mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID, - ContextBase::mSap_conf.GYRO_BIAS_RANDOM_WALK, - ContextBase::mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - ContextBase::mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, - ContextBase::mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - ContextBase::mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, - ContextBase::mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - ContextBase::mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, - ContextBase::mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - ContextBase::mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY); - } - mApi.setSensorPerfControlConfig( - ContextBase::mSap_conf.SENSOR_CONTROL_MODE, - ContextBase::mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, - ContextBase::mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC, - ContextBase::mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH, - ContextBase::mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC, - ContextBase::mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, - ContextBase::mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, - ContextBase::mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, - ContextBase::mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, - ContextBase::mSap_conf.SENSOR_ALGORITHM_CONFIG_MASK); + std::string oldServerUrl = mAdapter.getServerUrl(); + mAdapter.setSuplHostServer(ContextBase::mGps_conf.SUPL_HOST, + ContextBase::mGps_conf.SUPL_PORT); + + // inject the configurations into modem + GnssAdapter& adapter = mAdapter; + loc_gps_cfg_s gpsConf = ContextBase::mGps_conf; + loc_sap_cfg_s_type sapConf = ContextBase::mSap_conf; + + mApi.sendMsg(new LocApiMsg( + [&adapter, gpsConf, sapConf, oldServerUrl] () { + + std::string serverUrl = adapter.getServerUrl(); + int serverUrlLen = serverUrl.length(); + + if (gpsConf.AGPS_CONFIG_INJECT) { + adapter.mLocApi->setSUPLVersionSync( + adapter.mLocApi->convertSuplVersion(gpsConf.SUPL_VER)); + adapter.mLocApi->setLPPConfigSync( + adapter.mLocApi->convertLppProfile(gpsConf.LPP_PROFILE)); + adapter.mLocApi->setAGLONASSProtocolSync( + gpsConf.A_GLONASS_POS_PROTOCOL_SELECT); + } + + if ((serverUrlLen !=0) && (oldServerUrl.compare(serverUrl) != 0)) { + LocationError locErr = + adapter.mLocApi->setServerSync(serverUrl.c_str(), serverUrlLen); + if (locErr != LOCATION_ERROR_SUCCESS) { + LOC_LOGE("%s]:Error while setting SUPL_HOST server:%s", + __func__, serverUrl.c_str()); + } + } + + adapter.mLocApi->setSensorControlConfigSync(sapConf.SENSOR_USAGE, + sapConf.SENSOR_PROVIDER); + adapter.mLocApi->setLPPeProtocolCpSync( + adapter.mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY)); + adapter.mLocApi->setLPPeProtocolUpSync( + adapter.mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY)); + + // set nmea mask type + uint32_t mask = 0; + if (NMEA_PROVIDER_MP == gpsConf.NMEA_PROVIDER) { + mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK; + } + if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) { + mask |= LOC_NMEA_MASK_DEBUG_V02; + } + + if (mask != 0) { + adapter.mLocApi->setNMEATypesSync(mask); + } + + adapter.mLocApi->setXtraVersionCheckSync(gpsConf.XTRA_VERSION_CHECK); + if (sapConf.GYRO_BIAS_RANDOM_WALK_VALID || + sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID || + sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || + sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || + sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) { + adapter.mLocApi->setSensorPropertiesSync( + sapConf.GYRO_BIAS_RANDOM_WALK_VALID, + sapConf.GYRO_BIAS_RANDOM_WALK, + sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, + sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, + sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, + sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY); + } + adapter.mLocApi->setSensorPerfControlConfigSync( + sapConf.SENSOR_CONTROL_MODE, + sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH, + sapConf.SENSOR_ACCEL_BATCHES_PER_SEC, + sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH, + sapConf.SENSOR_GYRO_BATCHES_PER_SEC, + sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, + sapConf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, + sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, + sapConf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, + sapConf.SENSOR_ALGORITHM_CONFIG_MASK); + } )); } }; @@ -783,8 +744,8 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) GnssAdapter& mAdapter; LocApiBase& mApi; GnssConfig mConfig; - uint32_t* mIds; size_t mCount; + uint32_t* mIds; inline MsgGnssUpdateConfig(GnssAdapter& adapter, LocApiBase& api, GnssConfig config, @@ -794,163 +755,260 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) mAdapter(adapter), mApi(api), mConfig(config), - mIds(ids), - mCount(count) {} + mCount(count), + mIds(ids) {} inline virtual ~MsgGnssUpdateConfig() { - delete[] mIds; + delete [] mIds; } + inline virtual void proc() const { - LocationError* errs = new LocationError[mCount]; - LocationError err = LOCATION_ERROR_SUCCESS; - uint32_t index = 0; - if (errs == nullptr) { - LOC_LOGE("%s] new allocation failed, fatal error.", __func__); - return; - } + GnssAdapter& adapter = mAdapter; + size_t countOfConfigs = mCount; + GnssConfig gnssConfigRequested = mConfig; + GnssConfig gnssConfigNeedEngineUpdate = mConfig; + std::string oldServerUrl = mAdapter.getServerUrl(); - if (mConfig.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { - uint32_t newGpsLock = mAdapter.convertGpsLock(mConfig.gpsLock); + std::vector sessionIds; + sessionIds.assign(mIds, mIds + mCount); + std::vector errs(mCount, LOCATION_ERROR_SUCCESS); + int index = 0; + + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { + index++; + uint32_t newGpsLock = mAdapter.convertGpsLock(gnssConfigRequested.gpsLock); ContextBase::mGps_conf.GPS_LOCK = newGpsLock; - if (0 == mAdapter.getPowerVoteId()) { - err = mApi.setGpsLock(mConfig.gpsLock); - } - if (index < mCount) { - errs[index++] = err; + if (0 != mAdapter.getPowerVoteId()) { + gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT); } } - if (mConfig.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { - uint32_t newSuplVersion = mAdapter.convertSuplVersion(mConfig.suplVersion); + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { + index++; + uint32_t newSuplVersion = + mAdapter.convertSuplVersion(gnssConfigRequested.suplVersion); if (newSuplVersion != ContextBase::mGps_conf.SUPL_VER && ContextBase::mGps_conf.AGPS_CONFIG_INJECT) { ContextBase::mGps_conf.SUPL_VER = newSuplVersion; - err = mApi.setSUPLVersion(mConfig.suplVersion); } else { - err = LOCATION_ERROR_SUCCESS; - } - if (index < mCount) { - errs[index++] = err; + gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT); } } - if (mConfig.flags & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) { + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) { + index++; if (GNSS_ASSISTANCE_TYPE_SUPL == mConfig.assistanceServer.type) { - err = mAdapter.setSuplHostServer(mConfig.assistanceServer.hostName, - mConfig.assistanceServer.port); - } else if (GNSS_ASSISTANCE_TYPE_C2K == mConfig.assistanceServer.type) { - if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) { - struct in_addr addr; - if (!mAdapter.resolveInAddress(mConfig.assistanceServer.hostName, - &addr)) { - LOC_LOGE("%s]: hostName %s cannot be resolved", - __func__, mConfig.assistanceServer.hostName); - err = LOCATION_ERROR_INVALID_PARAMETER; - } else { - unsigned int ip = htonl(addr.s_addr); - err = mApi.setServer(ip, mConfig.assistanceServer.port, - LOC_AGPS_CDMA_PDE_SERVER); - } - } else { - err = LOCATION_ERROR_SUCCESS; - } - } else { + mAdapter.setSuplHostServer(mConfig.assistanceServer.hostName, + mConfig.assistanceServer.port); + } else if (GNSS_ASSISTANCE_TYPE_C2K != mConfig.assistanceServer.type) { LOC_LOGE("%s]: Not a valid gnss assistance type %u", - __func__, mConfig.assistanceServer.type); - err = LOCATION_ERROR_INVALID_PARAMETER; - } - if (index < mCount) { - errs[index++] = err; + __func__, mConfig.assistanceServer.type); + errs.at(index) = LOCATION_ERROR_INVALID_PARAMETER; + gnssConfigNeedEngineUpdate.flags &= + ~(GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT); } } - if (mConfig.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) { - uint32_t newLppProfile = mAdapter.convertLppProfile(mConfig.lppProfile); + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) { + index++; + uint32_t newLppProfile = mAdapter.convertLppProfile(gnssConfigRequested.lppProfile); if (newLppProfile != ContextBase::mGps_conf.LPP_PROFILE && ContextBase::mGps_conf.AGPS_CONFIG_INJECT) { ContextBase::mGps_conf.LPP_PROFILE = newLppProfile; - err = mApi.setLPPConfig(mConfig.lppProfile); } else { - err = LOCATION_ERROR_SUCCESS; - } - if (index < mCount) { - errs[index++] = err; + gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT); } } - if (mConfig.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) { + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) { + index++; uint32_t newLppeControlPlaneMask = - mAdapter.convertLppeCp(mConfig.lppeControlPlaneMask); + mAdapter.convertLppeCp(gnssConfigRequested.lppeControlPlaneMask); if (newLppeControlPlaneMask != ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY) { ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY = newLppeControlPlaneMask; - err = mApi.setLPPeProtocolCp(mConfig.lppeControlPlaneMask); } else { - err = LOCATION_ERROR_SUCCESS; - } - if (index < mCount) { - errs[index++] = err; + gnssConfigNeedEngineUpdate.flags &= + ~(GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT); } } - if (mConfig.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) { + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) { + index++; uint32_t newLppeUserPlaneMask = - mAdapter.convertLppeUp(mConfig.lppeUserPlaneMask); + mAdapter.convertLppeUp(gnssConfigRequested.lppeUserPlaneMask); if (newLppeUserPlaneMask != ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY) { ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY = newLppeUserPlaneMask; - err = mApi.setLPPeProtocolUp(mConfig.lppeUserPlaneMask); } else { - err = LOCATION_ERROR_SUCCESS; - } - if (index < mCount) { - errs[index++] = err; + gnssConfigNeedEngineUpdate.flags &= + ~(GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT); } } - if (mConfig.flags & GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) { + if (gnssConfigRequested.flags & + GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) { + index++; uint32_t newAGloProtMask = - mAdapter.convertAGloProt(mConfig.aGlonassPositionProtocolMask); + mAdapter.convertAGloProt(gnssConfigRequested.aGlonassPositionProtocolMask); if (newAGloProtMask != ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT && ContextBase::mGps_conf.AGPS_CONFIG_INJECT) { ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT = newAGloProtMask; - err = mApi.setAGLONASSProtocol(mConfig.aGlonassPositionProtocolMask); } else { - err = LOCATION_ERROR_SUCCESS; + gnssConfigNeedEngineUpdate.flags &= + ~(GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT); } - if (index < mCount) { - errs[index++] = err; - } - } - if (mConfig.flags & GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT) { - uint32_t newEP4ES = mAdapter.convertEP4ES(mConfig.emergencyPdnForEmergencySupl); + } + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT) { + index++; + uint32_t newEP4ES = mAdapter.convertEP4ES( + gnssConfigRequested.emergencyPdnForEmergencySupl); if (newEP4ES != ContextBase::mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL) { ContextBase::mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = newEP4ES; } - err = LOCATION_ERROR_SUCCESS; - if (index < mCount) { - errs[index++] = err; - } - } - if (mConfig.flags & GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT) { - uint32_t newSuplEs = mAdapter.convertSuplEs(mConfig.suplEmergencyServices); + } + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT) { + index++; + uint32_t newSuplEs = mAdapter.convertSuplEs( + gnssConfigRequested.suplEmergencyServices); if (newSuplEs != ContextBase::mGps_conf.SUPL_ES) { ContextBase::mGps_conf.SUPL_ES = newSuplEs; } - err = LOCATION_ERROR_SUCCESS; - if (index < mCount) { - errs[index++] = err; - } - } - if (mConfig.flags & GNSS_CONFIG_FLAGS_SUPL_MODE_BIT) { - uint32_t newSuplMode = mAdapter.convertSuplMode(mConfig.suplModeMask); + } + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_MODE_BIT) { + index++; + uint32_t newSuplMode = mAdapter.convertSuplMode(gnssConfigRequested.suplModeMask); if (newSuplMode != ContextBase::mGps_conf.SUPL_MODE) { ContextBase::mGps_conf.SUPL_MODE = newSuplMode; mAdapter.getUlpProxy()->setCapabilities( ContextBase::getCarrierCapabilities()); mAdapter.broadcastCapabilities(mAdapter.getCapabilities()); } - err = LOCATION_ERROR_SUCCESS; - if (index < mCount) { - errs[index++] = err; - } } - mAdapter.reportResponse(index, errs, mIds); - delete[] errs; + LocApiCollectiveResponse *configCollectiveResponse = new LocApiCollectiveResponse( + *adapter.getContext(), + [&adapter, sessionIds, countOfConfigs] (std::vector errs) { + + std::vector ids(sessionIds); + adapter.reportResponse(countOfConfigs, errs.data(), ids.data()); + }); + + mApi.sendMsg(new LocApiMsg( + [&adapter, gnssConfigRequested, gnssConfigNeedEngineUpdate, + countOfConfigs, configCollectiveResponse, errs, oldServerUrl] () { + + size_t index = 0; + LocationError err = LOCATION_ERROR_SUCCESS; + std::vector errsList(errs); + + std::string serverUrl = adapter.getServerUrl(); + int serverUrlLen = serverUrl.length(); + + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { + if (gnssConfigNeedEngineUpdate.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { + err = adapter.mLocApi->setGpsLockSync(gnssConfigRequested.gpsLock); + if (index < countOfConfigs) { + errsList[index] = err; + } + } + } + if (gnssConfigRequested.flags & + GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) { + index++; + if (gnssConfigNeedEngineUpdate.flags & + GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) { + if (gnssConfigNeedEngineUpdate.assistanceServer.type == + GNSS_ASSISTANCE_TYPE_SUPL) { + if ((serverUrlLen != 0) && (oldServerUrl.compare(serverUrl) !=0)) { + err = adapter.mLocApi->setServerSync( + serverUrl.c_str(), serverUrlLen); + errsList[index] = err; + } + } else if (gnssConfigNeedEngineUpdate.assistanceServer.type == + GNSS_ASSISTANCE_TYPE_C2K) { + struct in_addr addr; + struct hostent* hp; + bool resolveAddrSuccess = true; + + hp = gethostbyname( + gnssConfigNeedEngineUpdate.assistanceServer.hostName); + if (hp != NULL) { /* DNS OK */ + memcpy(&addr, hp->h_addr_list[0], hp->h_length); + } else { + /* Try IP representation */ + if (inet_aton( + gnssConfigNeedEngineUpdate.assistanceServer.hostName, + &addr) == 0) { + /* IP not valid */ + LOC_LOGE("%s]: hostname '%s' cannot be resolved ", + __func__, + gnssConfigNeedEngineUpdate.assistanceServer.hostName); + errsList[index] = LOCATION_ERROR_INVALID_PARAMETER; + } else { + resolveAddrSuccess = false; + } + } + + if (resolveAddrSuccess) { + unsigned int ip = htonl(addr.s_addr); + err = adapter.mLocApi->setServerSync(ip, + gnssConfigNeedEngineUpdate.assistanceServer.port, + LOC_AGPS_CDMA_PDE_SERVER); + errsList[index] = err; + } + } + } + } + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { + index++; + if (gnssConfigNeedEngineUpdate.flags & + GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { + err = adapter.mLocApi->setSUPLVersionSync(gnssConfigRequested.suplVersion); + if (index < countOfConfigs) { + errsList[index] = err; + } + } + } + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) { + index++; + if (gnssConfigNeedEngineUpdate.flags & + GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) { + err = adapter.mLocApi->setLPPConfigSync(gnssConfigRequested.lppProfile); + if (index < countOfConfigs) { + errsList[index] = err; + } + } + } + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) { + index++; + if (gnssConfigNeedEngineUpdate.flags & + GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) { + err = adapter.mLocApi->setLPPeProtocolCpSync( + gnssConfigRequested.lppeControlPlaneMask); + if (index < countOfConfigs) { + errsList[index] = err; + } + } + } + if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) { + index++; + if (gnssConfigNeedEngineUpdate.flags & + GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) { + err = adapter.mLocApi->setLPPeProtocolUpSync( + gnssConfigRequested.lppeUserPlaneMask); + if (index < countOfConfigs) { + errsList[index] = err; + } + } + } + if (gnssConfigRequested.flags & + GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) { + index++; + if (gnssConfigNeedEngineUpdate.flags & + GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) { + err = adapter.mLocApi->setAGLONASSProtocolSync( + gnssConfigRequested.aGlonassPositionProtocolMask); + if (index < countOfConfigs) { + errsList[index] = err; + } + } + } + configCollectiveResponse->returnToSender(errsList); + })); } }; @@ -963,6 +1021,13 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) return ids; } +void GnssAdapter::deleteAidingData(const GnssAidingData &data, uint32_t sessionId) { + mLocApi->deleteAidingData(data, new LocApiResponse(*getContext(), + [this, sessionId] (LocationError err) { + reportResponse(err, sessionId); + })); +} + uint32_t GnssAdapter::gnssDeleteAidingDataCommand(GnssAidingData& data) { @@ -971,22 +1036,18 @@ GnssAdapter::gnssDeleteAidingDataCommand(GnssAidingData& data) struct MsgDeleteAidingData : public LocMsg { GnssAdapter& mAdapter; - LocApiBase& mApi; uint32_t mSessionId; GnssAidingData mData; inline MsgDeleteAidingData(GnssAdapter& adapter, - LocApiBase& api, uint32_t sessionId, GnssAidingData& data) : LocMsg(), mAdapter(adapter), - mApi(api), mSessionId(sessionId), mData(data) {} inline virtual void proc() const { - LocationError err = LOCATION_ERROR_SUCCESS; - err = mApi.deleteAidingData(mData); - mAdapter.reportResponse(err, mSessionId); + mAdapter.deleteAidingData(mData, mSessionId); + SystemStatus* s = mAdapter.getSystemStatus(); if ((nullptr != s) && (mData.deleteAll)) { s->setDefaultGnssEngineStates(); @@ -995,7 +1056,7 @@ GnssAdapter::gnssDeleteAidingDataCommand(GnssAidingData& data) } }; - sendMsg(new MsgDeleteAidingData(*this, *mLocApi, sessionId, data)); + sendMsg(new MsgDeleteAidingData(*this, sessionId, data)); return sessionId; } @@ -1187,11 +1248,9 @@ GnssAdapter::stopClientSessions(LocationAPI* client) LOC_LOGD("%s]: client %p", __func__, client); for (auto it = mTrackingSessions.begin(); it != mTrackingSessions.end();) { if (client == it->first.client) { - LocationError err = stopTrackingMultiplex(it->first.client, it->first.id); - if (LOCATION_ERROR_SUCCESS == err) { - it = mTrackingSessions.erase(it); - continue; - } + stopTrackingMultiplex(it->first.client, it->first.id); + it = mTrackingSessions.erase(it); + continue; } ++it; // increment only when not erasing an iterator } @@ -1244,18 +1303,23 @@ GnssAdapter::updateClientsEventMask() void GnssAdapter::handleEngineUpEvent() { - struct MsgRestartSessions : public LocMsg { + LOC_LOGD("%s]: ", __func__); + + struct MsgHandleEngineUpEvent : public LocMsg { GnssAdapter& mAdapter; - inline MsgRestartSessions(GnssAdapter& adapter) : + inline MsgHandleEngineUpEvent(GnssAdapter& adapter) : LocMsg(), mAdapter(adapter) {} virtual void proc() const { + mAdapter.broadcastCapabilities(mAdapter.getCapabilities()); + // restart sessions mAdapter.restartSessions(); } }; + readConfigCommand(); setConfigCommand(); - sendMsg(new MsgRestartSessions(*this)); + sendMsg(new MsgHandleEngineUpEvent(*this)); } void @@ -1279,11 +1343,9 @@ GnssAdapter::restartSessions() LocPosMode locPosMode = {}; convertOptions(locPosMode, smallestIntervalOptions); - // inform engine hub of the fix mode and start session - mEngHubProxy->gnssSetFixMode(locPosMode); - mEngHubProxy->gnssStartFix(); - - mLocApi->startFix(locPosMode); + mLocApi->startFix(locPosMode, new LocApiResponse(*getContext(), + [] (LocationError err) {} + )); } void @@ -1306,12 +1368,14 @@ GnssAdapter::requestCapabilitiesCommand(LocationAPI* client) return; } - LocationCapabilitiesMask mask = mAdapter.getCapabilities(); - callbacks.capabilitiesCb(mask); + LocationCapabilitiesMask mask = mAdapter.getCapabilities(); + callbacks.capabilitiesCb(mask); } }; - sendMsg(new MsgRequestCapabilities(*this, client)); + if (ContextBase::isEngineCapabilitiesKnown()) { + sendMsg(new MsgRequestCapabilities(*this, client)); + } } LocationCapabilitiesMask @@ -1329,22 +1393,20 @@ GnssAdapter::getCapabilities() if (LOC_GPS_CAPABILITY_MSA & carrierCapabilities) { mask |= LOCATION_CAPABILITIES_GNSS_MSA_BIT; } - if (mLocApi == nullptr) - return mask; - if (mLocApi->isMessageSupported(LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_LOCATION_BATCHING)) { + if (ContextBase::isMessageSupported(LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_LOCATION_BATCHING)) { mask |= LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT | LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT; } - if (mLocApi->isMessageSupported(LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_TRACKING)) { + if (ContextBase::isMessageSupported(LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_TRACKING)) { mask |= LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT; } - if (mLocApi->isMessageSupported(LOC_API_ADAPTER_MESSAGE_OUTDOOR_TRIP_BATCHING)) { + if (ContextBase::isMessageSupported(LOC_API_ADAPTER_MESSAGE_OUTDOOR_TRIP_BATCHING)) { mask |= LOCATION_CAPABILITIES_OUTDOOR_TRIP_BATCHING_BIT; } - if (mLocApi->gnssConstellationConfig()) { + if (ContextBase::gnssConstellationConfig()) { mask |= LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT; } - if (mLocApi->isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) { + if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) { mask |= LOCATION_CAPABILITIES_DEBUG_NMEA_BIT; } return mask; @@ -1353,9 +1415,9 @@ GnssAdapter::getCapabilities() void GnssAdapter::broadcastCapabilities(LocationCapabilitiesMask mask) { - for (auto it = mClientData.begin(); it != mClientData.end(); ++it) { - if (nullptr != it->second.capabilitiesCb) { - it->second.capabilitiesCb(mask); + for (auto clientData : mClientData) { + if (nullptr != clientData.second.capabilitiesCb) { + clientData.second.capabilitiesCb(mask); } } } @@ -1443,8 +1505,7 @@ GnssAdapter::reportResponse(LocationAPI* client, LocationError err, uint32_t ses LOC_LOGD("%s]: client %p id %u err %u", __func__, client, sessionId, err); auto it = mClientData.find(client); - if (it != mClientData.end() && - it->second.responseCb != nullptr) { + if (it != mClientData.end() && it->second.responseCb != nullptr) { it->second.responseCb(err, sessionId); } else { LOC_LOGW("%s]: client %p id %u not found in data", __func__, client, sessionId); @@ -1522,12 +1583,14 @@ GnssAdapter::startTrackingCommand(LocationAPI* client, LocationOptions& options) err = LOCATION_ERROR_INVALID_PARAMETER; } else { // Api doesn't support multiple clients for time based tracking, so mutiplex - err = mAdapter.startTrackingMultiplex(mOptions); - if (LOCATION_ERROR_SUCCESS == err) { - mAdapter.saveTrackingSession(mClient, mSessionId, mOptions); + bool reportToClientWithNoWait = + mAdapter.startTrackingMultiplex(mClient, mSessionId, mOptions); + mAdapter.saveTrackingSession(mClient, mSessionId, mOptions); + + if (reportToClientWithNoWait) { + mAdapter.reportResponse(mClient, LOCATION_ERROR_SUCCESS, mSessionId); } } - mAdapter.reportResponse(mClient, err, mSessionId); } }; @@ -1536,13 +1599,14 @@ GnssAdapter::startTrackingCommand(LocationAPI* client, LocationOptions& options) } -LocationError -GnssAdapter::startTrackingMultiplex(const LocationOptions& options) +bool +GnssAdapter::startTrackingMultiplex(LocationAPI* client, uint32_t sessionId, + const LocationOptions& options) { - LocationError err = LOCATION_ERROR_SUCCESS; + bool reportToClientWithNoWait = true; if (mTrackingSessions.empty()) { - err = startTracking(options); + reportToClientWithNoWait = startTracking(client, sessionId, options); } else { // get the LocationOptions that has the smallest interval, which should be the active one LocationOptions smallestIntervalOptions = {}; // size is zero until set for the first time @@ -1555,17 +1619,19 @@ GnssAdapter::startTrackingMultiplex(const LocationOptions& options) // if new session's minInterval is smaller than any in other sessions if (options.minInterval < smallestIntervalOptions.minInterval) { // restart time based tracking with new options - err = startTracking(options); + reportToClientWithNoWait = startTracking(client, sessionId, options); } } - return err; + return reportToClientWithNoWait; } -LocationError -GnssAdapter::startTracking(const LocationOptions& options) +bool +GnssAdapter::startTracking(LocationAPI* client, uint32_t sessionId, + const LocationOptions& options) { - LocationError err = LOCATION_ERROR_SUCCESS; + bool reportToClientWithNoWait = true; + LocPosMode locPosMode = {}; convertOptions(locPosMode, options); if (!mUlpProxy->sendFixMode(locPosMode)) { @@ -1576,17 +1642,56 @@ GnssAdapter::startTracking(const LocationOptions& options) mEngHubProxy->gnssSetFixMode(locPosMode); mEngHubProxy->gnssStartFix(); - loc_api_adapter_err apiErr = mLocApi->startFix(locPosMode); - if (LOC_API_ADAPTER_ERR_SUCCESS == apiErr) { - err = LOCATION_ERROR_SUCCESS; - } else { - err = LOCATION_ERROR_GENERAL_FAILURE; - } + mLocApi->startFix(locPosMode, new LocApiResponse(*getContext(), + [this, client, sessionId] (LocationError err) { + if (LOCATION_ERROR_SUCCESS != err) { + eraseTrackingSession(client, sessionId); + } + + reportResponse(client, err, sessionId); + } + )); + + reportToClientWithNoWait = false; } - return err; + return reportToClientWithNoWait; } +bool +GnssAdapter::updateTracking(LocationAPI* client, uint32_t sessionId, + const LocationOptions& updatedOptions, const LocationOptions& oldOptions) +{ + bool reportToClientWithNoWait = true; + + LocPosMode locPosMode = {}; + convertOptions(locPosMode, updatedOptions); + if (!mUlpProxy->sendFixMode(locPosMode)) { + // do nothing + } + if (!mUlpProxy->sendStartFix()) { + // inform engine hub that GNSS session is about to start + mEngHubProxy->gnssSetFixMode(locPosMode); + mEngHubProxy->gnssStartFix(); + + mLocApi->startFix(locPosMode, new LocApiResponse(*getContext(), + [this, client, sessionId, oldOptions] (LocationError err) { + if (LOCATION_ERROR_SUCCESS != err) { + // restore the old LocationOptions + saveTrackingSession(client, sessionId, oldOptions); + } + + reportResponse(client, err, sessionId); + } + )); + + reportToClientWithNoWait = false; + } + + return reportToClientWithNoWait; +} + + void GnssAdapter::setPositionModeCommand(LocPosMode& locPosMode) { @@ -1640,8 +1745,11 @@ GnssAdapter::startTrackingCommand() // inform engine hub of the fix mode and start session mAdapter.mEngHubProxy->gnssSetFixMode(ulpPositionMode); mAdapter.mEngHubProxy->gnssStartFix(); - if (!mAdapter.isInSession()) { - mApi.startFix(ulpPositionMode); + if (!mAdapter.isInSession()) { + LocPosMode& ulpPositionMode = mAdapter.getUlpPositionMode(); + mApi.startFix(ulpPositionMode, new LocApiResponse(*mAdapter.getContext(), + [] (LocationError err) {} + )); } } }; @@ -1680,12 +1788,14 @@ GnssAdapter::updateTrackingOptionsCommand(LocationAPI* client, uint32_t id, err = LOCATION_ERROR_INVALID_PARAMETER; } else { // Api doesn't support multiple clients for time based tracking, so mutiplex - err = mAdapter.updateTrackingMultiplex(mClient, mSessionId, mOptions); - if (LOCATION_ERROR_SUCCESS == err) { - mAdapter.saveTrackingSession(mClient, mSessionId, mOptions); + bool reportToClientWithNoWait = + mAdapter.updateTrackingMultiplex(mClient, mSessionId, mOptions); + mAdapter.saveTrackingSession(mClient, mSessionId, mOptions); + + if (reportToClientWithNoWait) { + mAdapter.reportResponse(mClient, err, mSessionId); } } - mAdapter.reportResponse(mClient, err, mSessionId); } // we do not reportResponse for the case where there is no existing tracking session // for the client and id being used, since updateTrackingCommand can be sent to both @@ -1696,19 +1806,21 @@ GnssAdapter::updateTrackingOptionsCommand(LocationAPI* client, uint32_t id, sendMsg(new MsgUpdateTracking(*this, *mLocApi, client, id, options)); } -LocationError +bool GnssAdapter::updateTrackingMultiplex(LocationAPI* client, uint32_t id, const LocationOptions& options) { - LocationError err = LOCATION_ERROR_SUCCESS; + bool reportToClientWithNoWait = true; + + LocationSessionKey key(client, id); + // get the session we are updating + auto it = mTrackingSessions.find(key); + // cache the clients existing LocationOptions + LocationOptions oldOptions = it->second; if (1 == mTrackingSessions.size()) { - err = startTracking(options); + reportToClientWithNoWait = updateTracking(client, id, options, oldOptions); } else { - LocationSessionKey key(client, id); - - // get the session we are updating - auto it = mTrackingSessions.find(key); if (it != mTrackingSessions.end()) { // find the smallest interval, other than the session we are updating LocationOptions smallestIntervalOptions = {}; // size is 0 until set for the first time @@ -1723,16 +1835,17 @@ GnssAdapter::updateTrackingMultiplex(LocationAPI* client, uint32_t id, // if session we are updating has smaller interval then next smallest if (options.minInterval < smallestIntervalOptions.minInterval) { // restart time based tracking with the newly updated interval - err = startTracking(options); + reportToClientWithNoWait = updateTracking(client, id, options, oldOptions); // else if the session we are updating used to be the smallest } else if (it->second.minInterval < smallestIntervalOptions.minInterval) { // restart time based tracking with the next smallest - err = startTracking(smallestIntervalOptions); + reportToClientWithNoWait = updateTracking( + client, id, smallestIntervalOptions, oldOptions); } } } - return err; + return reportToClientWithNoWait; } void @@ -1756,31 +1869,31 @@ GnssAdapter::stopTrackingCommand(LocationAPI* client, uint32_t id) mSessionId(sessionId) {} inline virtual void proc() const { if (mAdapter.isTrackingSession(mClient, mSessionId)) { - LocationError err = LOCATION_ERROR_SUCCESS; // Api doesn't support multiple clients for time based tracking, so mutiplex - err = mAdapter.stopTrackingMultiplex(mClient, mSessionId); - if (LOCATION_ERROR_SUCCESS == err) { - mAdapter.eraseTrackingSession(mClient, mSessionId); + bool reportToClientWithNoWait = + mAdapter.stopTrackingMultiplex(mClient, mSessionId); + mAdapter.eraseTrackingSession(mClient, mSessionId); + + if (reportToClientWithNoWait) { + mAdapter.reportResponse(mClient, LOCATION_ERROR_SUCCESS, mSessionId); } - mAdapter.reportResponse(mClient, err, mSessionId); } // we do not reportResponse for the case where there is no existing tracking session // for the client and id being used, since stopTrackingCommand can be sent to both // GnssAdapter & FlpAdapter by LocationAPI and we want to avoid incorrect error response - } }; sendMsg(new MsgStopTracking(*this, *mLocApi, client, id)); } -LocationError +bool GnssAdapter::stopTrackingMultiplex(LocationAPI* client, uint32_t id) { - LocationError err = LOCATION_ERROR_SUCCESS; + bool reportToClientWithNoWait = true; if (1 == mTrackingSessions.size()) { - err = stopTracking(); + reportToClientWithNoWait = stopTracking(client, id); } else { LocationSessionKey key(client, id); @@ -1800,31 +1913,32 @@ GnssAdapter::stopTrackingMultiplex(LocationAPI* client, uint32_t id) // if session we are stopping has smaller interval then next smallest if (it->second.minInterval < smallestIntervalOptions.minInterval) { // restart time based tracking with next smallest interval - err = startTracking(smallestIntervalOptions); + reportToClientWithNoWait = startTracking(client, id, smallestIntervalOptions); } } } - return err; + return reportToClientWithNoWait; } -LocationError -GnssAdapter::stopTracking() +bool +GnssAdapter::stopTracking(LocationAPI* client, uint32_t id) { - LocationError err = LOCATION_ERROR_SUCCESS; + bool reportToClientWithNoWait = true; + if (!mUlpProxy->sendStopFix()) { // inform engine hub that GNSS session has stopped mEngHubProxy->gnssStopFix(); - loc_api_adapter_err apiErr = mLocApi->stopFix(); - if (LOC_API_ADAPTER_ERR_SUCCESS == apiErr) { - err = LOCATION_ERROR_SUCCESS; - } else { - err = LOCATION_ERROR_GENERAL_FAILURE; - } + mLocApi->stopFix(new LocApiResponse(*getContext(), + [this, client, id] (LocationError err) { + reportResponse(client, err, id); + })); + + reportToClientWithNoWait = false; } - return err; + return reportToClientWithNoWait; } void @@ -1849,7 +1963,9 @@ GnssAdapter::stopTrackingCommand() mLocPosMode.mode = LOC_POSITION_MODE_INVALID; mAdapter.setUlpPositionMode(mLocPosMode); // don't need to multiplex because ULP will do that for us if it is present - mApi.stopFix(); + mApi.stopFix(new LocApiResponse(*mAdapter.getContext(), + [] (LocationError /* err*/) {} + )); } }; @@ -1870,24 +1986,12 @@ GnssAdapter::getZppCommand() mAdapter(adapter), mApi(api) {} inline virtual void proc() const { - UlpLocation location = {}; - LocPosTechMask techMask = LOC_POS_TECH_MASK_DEFAULT; - GpsLocationExtended locationExtended = {}; - locationExtended.size = sizeof(locationExtended); - - mApi.getBestAvailableZppFix(location.gpsLocation, locationExtended, - techMask); - //Mark the location source as from ZPP - location.gpsLocation.flags |= LOCATION_HAS_SOURCE_INFO; - location.position_source = ULP_LOCATION_IS_FROM_ZPP; - - mAdapter.getUlpProxy()->reportPosition(location, - locationExtended, - LOC_SESS_SUCCESS, - techMask); + mApi.getBestAvailableZppFix(); } }; + // TODO: we could avoid this extra context switch, as getBestAvailableZppFix + // will return asynchronously anyways. sendMsg(new MsgGetZpp(*this, *mLocApi)); } @@ -1971,28 +2075,28 @@ GnssAdapter::gnssNiResponseCommand(GnssNiResponse response, void* rawRequest) LOC_LOGD("%s]: response %u", __func__, response); struct MsgGnssNiResponse : public LocMsg { + GnssAdapter& mAdapter; LocApiBase& mApi; const GnssNiResponse mResponse; const void* mPayload; - inline MsgGnssNiResponse(LocApiBase& api, + inline MsgGnssNiResponse(GnssAdapter& adapter, + LocApiBase& api, const GnssNiResponse response, const void* rawRequest) : LocMsg(), + mAdapter(adapter), mApi(api), mResponse(response), mPayload(rawRequest) {} inline virtual ~MsgGnssNiResponse() { - // this is a bit weird since mPayload is not - // allocated by this class. But there is no better way. - // mPayload actually won't be NULL here. - free((void*)mPayload); } inline virtual void proc() const { + const void *rawPayload = mPayload; mApi.informNiResponse(mResponse, mPayload); } }; - sendMsg(new MsgGnssNiResponse(*mLocApi, response, rawRequest)); + sendMsg(new MsgGnssNiResponse(*this, *mLocApi, response, rawRequest)); } @@ -2029,7 +2133,11 @@ GnssAdapter::enableCommand(LocationTechnologyType techType) } else { mContext.modemPowerVote(true); mAdapter.setPowerVoteId(mSessionId); - mApi.setGpsLock(GNSS_CONFIG_GPS_LOCK_NONE); + + mApi.sendMsg(new LocApiMsg([&mApi = mApi] () { + mApi.setGpsLockSync(GNSS_CONFIG_GPS_LOCK_NONE); + })); + mAdapter.mXtraObserver.updateLockStatus( mAdapter.convertGpsLock(GNSS_CONFIG_GPS_LOCK_NONE)); } @@ -2073,7 +2181,12 @@ GnssAdapter::disableCommand(uint32_t id) } else { mContext.modemPowerVote(false); mAdapter.setPowerVoteId(0); - mApi.setGpsLock(mAdapter.convertGpsLock(ContextBase::mGps_conf.GPS_LOCK)); + + GnssConfigGpsLock gpsLock = + mAdapter.convertGpsLock(ContextBase::mGps_conf.GPS_LOCK); + mApi.sendMsg(new LocApiMsg([&mApi = mApi,gpsLock] () { + mApi.setGpsLockSync(gpsLock); + })); mAdapter.mXtraObserver.updateLockStatus( mAdapter.convertGpsLock(ContextBase::mGps_conf.GPS_LOCK)); } @@ -2810,6 +2923,41 @@ bool GnssAdapter::reportDataCallClosed(){ return true; } +bool GnssAdapter::reportZppBestAvailableFix(LocGpsLocation &zppLoc, + GpsLocationExtended &location_extended, LocPosTechMask tech_mask) { + + struct MsgReportZpp : public LocMsg { + GnssAdapter& mAdapter; + UlpLocation mUlpLocation; + GpsLocationExtended mGpsLocationExtended; + LocPosTechMask mPosTechMask; + + inline MsgReportZpp(GnssAdapter& adapter, + LocGpsLocation &zppLoc, GpsLocationExtended &location_extended, + LocPosTechMask tech_mask) : + LocMsg(), + mAdapter(adapter), + mGpsLocationExtended(location_extended), + mPosTechMask(tech_mask) { + mUlpLocation = {}; + memcpy(&mUlpLocation.gpsLocation, &zppLoc, sizeof(LocGpsLocation)); + + //Mark the location source as from ZPP + mUlpLocation.gpsLocation.flags |= LOCATION_HAS_SOURCE_INFO; + mUlpLocation.position_source = ULP_LOCATION_IS_FROM_ZPP; + } + inline virtual void proc() const { + mAdapter.getUlpProxy()->reportPosition(mUlpLocation, + mGpsLocationExtended, + LOC_SESS_SUCCESS, + mPosTechMask); + } + }; + + sendMsg(new MsgReportZpp(*this, zppLoc, location_extended, tech_mask)); + return true; +} + void GnssAdapter::dataConnOpenCommand( AGpsExtType agpsType, const char* apnName, int apnLen, AGpsBearerType bearerType){ diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index c1e17545..8d639fe8 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -157,7 +157,7 @@ public: LocationCallbacks getClientCallbacks(LocationAPI* client); LocationCapabilitiesMask getCapabilities(); void broadcastCapabilities(LocationCapabilitiesMask); - LocationError setSuplHostServer(const char* server, int port); + void setSuplHostServer(const char* server, int port); /* ==== TRACKING ======================================================================= */ /* ======== COMMANDS ====(Called from Client Thread)==================================== */ @@ -180,12 +180,16 @@ public: void eraseTrackingSession(LocationAPI* client, uint32_t sessionId); bool setUlpPositionMode(const LocPosMode& mode); LocPosMode& getUlpPositionMode() { return mUlpPositionMode; } - LocationError startTrackingMultiplex(const LocationOptions& options); - LocationError startTracking(const LocationOptions& options); - LocationError stopTrackingMultiplex(LocationAPI* client, uint32_t id); - LocationError stopTracking(); - LocationError updateTrackingMultiplex(LocationAPI* client, uint32_t id, + bool startTrackingMultiplex(LocationAPI* client, uint32_t sessionId, + const LocationOptions& options); + bool startTracking(LocationAPI* client, uint32_t sessionId, + const LocationOptions& options); + bool stopTrackingMultiplex(LocationAPI* client, uint32_t id); + bool stopTracking(LocationAPI* client, uint32_t id); + bool updateTrackingMultiplex(LocationAPI* client, uint32_t id, const LocationOptions& options); + bool updateTracking(LocationAPI* client, uint32_t sessionId, + const LocationOptions& updatedOptions, const LocationOptions& oldOptions); /* ==== NI ============================================================================= */ /* ======== COMMANDS ====(Called from Client Thread)==================================== */ @@ -203,9 +207,11 @@ public: void setControlCallbacksCommand(LocationControlCallbacks& controlCallbacks); void readConfigCommand(); void setConfigCommand(); + void requestUlpCommand(); void initEngHubProxyCommand(); uint32_t* gnssUpdateConfigCommand(GnssConfig config); uint32_t gnssDeleteAidingDataCommand(GnssAidingData& data); + void deleteAidingData(const GnssAidingData &data, uint32_t sessionId); void gnssUpdateXtraThrottleCommand(const bool enabled); void initDefaultAgpsCommand(); @@ -224,7 +230,6 @@ public: { mControlCallbacks = controlCallbacks; } void setPowerVoteId(uint32_t id) { mPowerVoteId = id; } uint32_t getPowerVoteId() { return mPowerVoteId; } - bool resolveInAddress(const char* hostAddress, struct in_addr* inAddress); virtual bool isInSession() { return !mTrackingSessions.empty(); } void initDefaultAgps(); bool initEngHubProxy(); @@ -249,6 +254,8 @@ public: virtual bool requestSuplES(int connHandle); virtual bool reportDataCallOpened(); virtual bool reportDataCallClosed(); + virtual bool reportZppBestAvailableFix(LocGpsLocation &zppLoc, + GpsLocationExtended &location_extended, LocPosTechMask tech_mask); /* ======== UTILITIES ================================================================= */ bool needReport(const UlpLocation& ulpLocation, @@ -276,15 +283,11 @@ public: static uint32_t convertGpsLock(const GnssConfigGpsLock gpsLock); static GnssConfigGpsLock convertGpsLock(const uint32_t gpsLock); static uint32_t convertSuplVersion(const GnssConfigSuplVersion suplVersion); - static GnssConfigSuplVersion convertSuplVersion(const uint32_t suplVersion); static uint32_t convertLppProfile(const GnssConfigLppProfile lppProfile); - static GnssConfigLppProfile convertLppProfile(const uint32_t lppProfile); static uint32_t convertEP4ES(const GnssConfigEmergencyPdnForEmergencySupl); static uint32_t convertSuplEs(const GnssConfigSuplEmergencyServices suplEmergencyServices); static uint32_t convertLppeCp(const GnssConfigLppeControlPlaneMask lppeControlPlaneMask); - static GnssConfigLppeControlPlaneMask convertLppeCp(const uint32_t lppeControlPlaneMask); static uint32_t convertLppeUp(const GnssConfigLppeUserPlaneMask lppeUserPlaneMask); - static GnssConfigLppeUserPlaneMask convertLppeUp(const uint32_t lppeUserPlaneMask); static uint32_t convertAGloProt(const GnssConfigAGlonassPositionProtocolMask); static uint32_t convertSuplMode(const GnssConfigSuplModeMask suplModeMask); static void convertSatelliteInfo(std::vector& out, diff --git a/gnss/Makefile.am b/gnss/Makefile.am index 7ee60892..db20c15a 100644 --- a/gnss/Makefile.am +++ b/gnss/Makefile.am @@ -7,7 +7,7 @@ AM_CFLAGS = \ -I../utils \ -I$(WORKSPACE)/hardware/qcom/gps/core/data-items \ -I../location \ - -std=c++11 + -std=c++1y libgnss_la_SOURCES = \ location_gnss.cpp \