From 5b2f22434981dfa456c5a64f7fd105d7ee7df2ba Mon Sep 17 00:00:00 2001 From: Bhavna Sharma Date: Mon, 29 Jan 2018 14:32:06 +0530 Subject: [PATCH 01/19] GPS: integrate GNSS engine hub with Gnss Adapter Integrate GNSS engine hub with Gnss Adapter using dynamically loadable .so file. Change-Id: I0420a17628db96447c01b8821e54782f7d992aec CRs-fixed: 2165862 --- core/EngineHubProxyBase.h | 109 +++++++++++++++++++++++++ core/Makefile.am | 1 + gnss/GnssAdapter.cpp | 164 ++++++++++++++++++++++++++++++++++++-- gnss/GnssAdapter.h | 9 ++- 4 files changed, 275 insertions(+), 8 deletions(-) create mode 100644 core/EngineHubProxyBase.h diff --git a/core/EngineHubProxyBase.h b/core/EngineHubProxyBase.h new file mode 100644 index 00000000..c17b2c29 --- /dev/null +++ b/core/EngineHubProxyBase.h @@ -0,0 +1,109 @@ +/* Copyright (c) 2018, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef ENGINE_HUB_PROXY_BASE_H +#define ENGINE_HUB_PROXY_BASE_H + +namespace loc_core { + +class EngineHubProxyBase { +public: + inline EngineHubProxyBase() { + } + inline virtual ~EngineHubProxyBase() {} + + // gnss session related functions + inline virtual bool gnssStartFix() { + LOC_LOGD("%s]: empty called ", __func__); + return false; + } + + inline virtual bool gnssStopFix() { + return false; + } + + inline virtual bool gnssSetFixMode(const LocPosMode ¶ms) { + (void) params; + return false; + } + + inline virtual bool gnssDeleteAidingData(const GnssAidingData &aidingData) { + (void) aidingData; + return false; + } + + // GNSS reports + inline virtual bool gnssReportPosition(const UlpLocation &location, + const GpsLocationExtended &locationExtended, + enum loc_sess_status status) { + (void) location; + (void) locationExtended; + (void) status; + return false; + } + + inline virtual bool gnssReportSv(const GnssSvNotification& svNotify) { + (void) svNotify; + return false; + } + + inline virtual bool gnssReportSvMeasurement(const GnssSvMeasurementSet& svMeasurementSet) { + (void) svMeasurementSet; + return false; + } + + inline virtual bool gnssReportSvPolynomial(const GnssSvPolynomial& svPolynomial) { + (void) svPolynomial; + return false; + } + + inline virtual bool gnssReportNmea(const char* nmea) { + (void) nmea; + return false; + } +}; + +typedef std::function + GnssAdapterReportPositionEventCb; + +typedef std::function + GnssAdapterReportSvEventCb; + +// potential parameters: message queue: MsgTask * msgTask; +// callback function to report back dr and ppe position and sv report +typedef EngineHubProxyBase* (getEngHubProxyFn)(const MsgTask * msgTask, + GnssAdapterReportPositionEventCb positionEventCb, + GnssAdapterReportSvEventCb svEventCb); + +} // namespace loc_core + +#endif // ENGINE_HUB_PROXY_BASE_H diff --git a/core/Makefile.am b/core/Makefile.am index dc540e9c..78ae76b0 100644 --- a/core/Makefile.am +++ b/core/Makefile.am @@ -20,6 +20,7 @@ libloc_core_la_h_sources = \ UlpProxyBase.h \ loc_core_log.h \ LocAdapterProxyBase.h \ + EngineHubProxyBase.h \ data-items/DataItemId.h \ data-items/IDataItemCore.h \ data-items/DataItemConcreteTypesBase.h \ diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index db4696f5..098c8aa0 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -47,6 +47,7 @@ #include #define RAD2DEG (180.0 / M_PI) +#define PROCESS_NAME_ENGINE_SERVICE "engine-service" using namespace loc_core; @@ -65,6 +66,7 @@ GnssAdapter::GnssAdapter() : LocDualContext::mLocationHalName, false)), mUlpProxy(new UlpProxyBase()), + mEngHubProxy(new EngineHubProxyBase()), mUlpPositionMode(), mGnssSvIdUsedInPosition(), mGnssSvIdUsedInPosAvail(false), @@ -146,6 +148,7 @@ GnssAdapter::GnssAdapter() : readConfigCommand(); setConfigCommand(); initDefaultAgpsCommand(); + initEngHubProxyCommand(); } void @@ -936,6 +939,7 @@ GnssAdapter::gnssDeleteAidingDataCommand(GnssAidingData& data) if ((nullptr != s) && (mData.deleteAll)) { s->setDefaultGnssEngineStates(); } + mAdapter.mEngHubProxy->gnssDeleteAidingData(mData); } }; @@ -1166,9 +1170,12 @@ GnssAdapter::updateClientsEventMask() /* ** For Automotive use cases we need to enable MEASUREMENT and POLY - ** when QDR is enabled + ** when QDR is enabled (e.g.: either enabled via conf file or + ** engine hub is loaded successfully). + ** Note: this need to be called from msg queue thread. */ - if(1 == ContextBase::mGps_conf.EXTERNAL_DR_ENABLED) { + if((1 == ContextBase::mGps_conf.EXTERNAL_DR_ENABLED) || + (true == initEngHubProxy())) { mask |= LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT; mask |= LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT; @@ -1219,6 +1226,11 @@ 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); } @@ -1508,6 +1520,10 @@ GnssAdapter::startTracking(const LocationOptions& options) // do nothing } if (!mUlpProxy->sendStartFix()) { + // inform engine hub that GNSS session is about to start + mEngHubProxy->gnssSetFixMode(locPosMode); + mEngHubProxy->gnssStartFix(); + loc_api_adapter_err apiErr = mLocApi->startFix(locPosMode); if (LOC_API_ADAPTER_ERR_SUCCESS == apiErr) { err = LOCATION_ERROR_SUCCESS; @@ -1539,6 +1555,7 @@ GnssAdapter::setPositionModeCommand(LocPosMode& locPosMode) inline virtual void proc() const { // saves the mode in adapter to be used when startTrackingCommand is called from ULP if (mAdapter.setUlpPositionMode(mLocPosMode)) { + mAdapter.mEngHubProxy->gnssSetFixMode(mLocPosMode); mApi.setPositionMode(mLocPosMode); } } @@ -1563,8 +1580,15 @@ GnssAdapter::startTrackingCommand() inline virtual void proc() const { // we get this call from ULP, so just call LocApi without multiplexing because // ulp would be doing the multiplexing for us if it is present - if (!mAdapter.isInSession()) { - LocPosMode& ulpPositionMode = mAdapter.getUlpPositionMode(); + LocPosMode& ulpPositionMode = mAdapter.getUlpPositionMode(); + + // TBD: once CR 2165853 is fixed, move below codes + // to inside condition of if (!mAdapter.isInSession()) + // + // inform engine hub of the fix mode and start session + mAdapter.mEngHubProxy->gnssSetFixMode(ulpPositionMode); + mAdapter.mEngHubProxy->gnssStartFix(); + if (!mAdapter.isInSession()) { mApi.startFix(ulpPositionMode); } } @@ -1737,6 +1761,9 @@ GnssAdapter::stopTracking() { LocationError err = LOCATION_ERROR_SUCCESS; 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; @@ -1762,6 +1789,9 @@ GnssAdapter::stopTrackingCommand() mAdapter(adapter), mApi(api) {} inline virtual void proc() const { + // inform engine hub that GNSS session has stopped + mAdapter.mEngHubProxy->gnssStopFix(); + // clear the position mode LocPosMode mLocPosMode = {}; mLocPosMode.mode = LOC_POSITION_MODE_INVALID; @@ -2014,8 +2044,12 @@ GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation, { LOC_LOGD("%s]: fromUlp %u status %u", __func__, fromUlp, status); - // if this event is not called from ULP, then try to call into ULP and return if successfull + // if this event is called from QMI LOC API, then try to call into ULP and return if successfull + // if the position is called from ULP or engine hub, then send it out directly if (!fromUlp) { + // report QMI position to engine hub, and engine hub will be + // distributing it to the registered plugins + mEngHubProxy->gnssReportPosition(ulpLocation, locationExtended, status); if (mUlpProxy->reportPosition(ulpLocation, locationExtended, status, techMask)) { return; @@ -2137,6 +2171,9 @@ GnssAdapter::reportSvEvent(const GnssSvNotification& svNotify, // if this event is not called from ULP, then try to call into ULP and return if successfull if (!fromUlp) { + // report QMI SV report to eng hub + mEngHubProxy->gnssReportSv(svNotify); + if (mUlpProxy->reportSv(svNotify)) { return; } @@ -2231,6 +2268,7 @@ GnssAdapter::reportNmeaEvent(const char* nmea, size_t length, bool fromUlp) { // if this event is not called from ULP, then try to call into ULP and return if successfull if (!fromUlp && !loc_nmea_is_debug(nmea, length)) { + mEngHubProxy->gnssReportNmea(nmea); if (mUlpProxy->reportNmea(nmea, length)) { return; } @@ -2501,6 +2539,7 @@ GnssAdapter::reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet) // We send SvMeasurementSet to AmtProxy/ULPProxy to be forwarded as necessary. mUlpProxy->reportSvMeasurement(svMeasurementSet); + mEngHubProxy->gnssReportSvMeasurement(svMeasurementSet); } void @@ -2510,6 +2549,8 @@ GnssAdapter::reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial) // We send SvMeasurementSet to AmtProxy/ULPProxy to be forwarded as necessary. mUlpProxy->reportSvPolynomial(svPolynomial); + + mEngHubProxy->gnssReportSvPolynomial(svPolynomial); } void GnssAdapter::initDefaultAgps() { @@ -3138,3 +3179,114 @@ static void agpsCloseResultCb (bool isSuccess, AGpsExtType agpsType, void* userD adapter->dataConnFailedCommand(agpsType); } } + +/* ==== Eng Hub Proxy ================================================================= */ +/* ======== UTILITIES ================================================================= */ +void +GnssAdapter::initEngHubProxyCommand() { + LOC_LOGD("%s]: ", __func__); + + struct MsgInitEngHubProxy : public LocMsg { + GnssAdapter* mAdapter; + inline MsgInitEngHubProxy(GnssAdapter* adapter) : + LocMsg(), + mAdapter(adapter) {} + inline virtual void proc() const { + mAdapter->initEngHubProxy(); + } + }; + + sendMsg(new MsgInitEngHubProxy(this)); +} + +bool +GnssAdapter::initEngHubProxy() { + static bool firstTime = true; + static bool engHubLoadSuccessful = false; + + const char *error = nullptr; + unsigned int processListLength = 0; + loc_process_info_s_type* processInfoList = nullptr; + + do { + // load eng hub only once + if (firstTime == false) { + break; + } + + int rc = loc_read_process_conf(LOC_PATH_IZAT_CONF, &processListLength, + &processInfoList); + if (rc != 0) { + LOC_LOGE("%s]: failed to parse conf file", __func__); + break; + } + + bool pluginDaemonEnabled = false; + // go over the conf table to see whether any plugin daemon is enabled + for (unsigned int i = 0; i < processListLength; i++) { + if ((strncmp(processInfoList[i].name[0], PROCESS_NAME_ENGINE_SERVICE, + strlen(PROCESS_NAME_ENGINE_SERVICE)) == 0) && + (processInfoList[i].proc_status == ENABLED)) { + pluginDaemonEnabled = true; + break; + } + } + + // no plugin daemon is enabled for this platform, no need to load eng hub .so + if (pluginDaemonEnabled == false) { + break; + } + + // load the engine hub .so, if the .so is not present + // all EngHubProxyBase calls will turn into no-op. + void *handle = nullptr; + if ((handle = dlopen("libloc_eng_hub.so", RTLD_NOW)) == nullptr) { + if ((error = dlerror()) != nullptr) { + LOC_LOGE("%s]: libloc_eng_hub.so not found %s !", __func__, error); + } + break; + } + + // 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 fromUlp) { + // report from engine hub on behalf of PPE will be treated as fromUlp + reportPositionEvent(ulpLocation, locationExtended, status, techMask, fromUlp); + }; + + // callback function for engine hub to report back sv event + GnssAdapterReportSvEventCb reportSvEventCb = + [this](const GnssSvNotification& svNotify, bool fromUlp) { + reportSvEvent(svNotify, fromUlp); + }; + + getEngHubProxyFn* getter = (getEngHubProxyFn*) dlsym(handle, "getEngHubProxy"); + if(getter != nullptr) { + EngineHubProxyBase* hubProxy = (*getter) (mMsgTask, reportPositionEventCb, + reportSvEventCb); + if (hubProxy != nullptr) { + mEngHubProxy = hubProxy; + engHubLoadSuccessful = true; + } + } + else { + LOC_LOGD("%s]: entered, did not find function", __func__); + } + } while (0); + + if (processInfoList != nullptr) { + free (processInfoList); + processInfoList = nullptr; + } + + LOC_LOGD("%s]: first time initialization %d, returned %d", + __func__, firstTime, engHubLoadSuccessful); + + firstTime = false; + return engHubLoadSuccessful; +} diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 99ce5c9a..cf871ba3 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -84,6 +85,9 @@ class GnssAdapter : public LocAdapterBase { /* ==== ULP ============================================================================ */ UlpProxyBase* mUlpProxy; + /* ==== Engine Hub ===================================================================== */ + EngineHubProxyBase* mEngHubProxy; + /* ==== CLIENT ========================================================================= */ typedef std::map ClientDataMap; ClientDataMap mClientData; @@ -198,6 +202,7 @@ public: void setControlCallbacksCommand(LocationControlCallbacks& controlCallbacks); void readConfigCommand(); void setConfigCommand(); + void initEngHubProxyCommand(); uint32_t* gnssUpdateConfigCommand(GnssConfig config); uint32_t gnssDeleteAidingDataCommand(GnssAidingData& data); void gnssUpdateXtraThrottleCommand(const bool enabled); @@ -221,6 +226,7 @@ public: bool resolveInAddress(const char* hostAddress, struct in_addr* inAddress); virtual bool isInSession() { return !mTrackingSessions.empty(); } void initDefaultAgps(); + bool initEngHubProxy(); /* ==== REPORTS ======================================================================== */ /* ======== EVENTS ====(Called from QMI/ULP Thread)===================================== */ @@ -286,7 +292,6 @@ public: void injectLocationCommand(double latitude, double longitude, float accuracy); void injectTimeCommand(int64_t time, int64_t timeReference, int32_t uncertainty); - }; #endif //GNSS_ADAPTER_H From 946f536641d97d7e17041290daf3f1d7daa7be93 Mon Sep 17 00:00:00 2001 From: Harikrishnan Hariharan Date: Fri, 2 Feb 2018 20:15:03 +0530 Subject: [PATCH 02/19] Fix compilation issues as a result of LE cleanup Change-Id: I1f7bb8c3bb4d912c7a743d5807dd7790f1973afd CRs-fixed: 2181265 --- gnss/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnss/Makefile.am b/gnss/Makefile.am index c818cae7..7ee60892 100644 --- a/gnss/Makefile.am +++ b/gnss/Makefile.am @@ -25,7 +25,7 @@ libgnss_la_LDFLAGS = -Wl,-z,defs -lpthread -shared -version-info 1:0:0 libgnss_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) endif -libgnss_la_LIBADD = -lstdc++ $(GPSUTILS_LIBS) $(LOCCORE_LIBS) +libgnss_la_LIBADD = -lstdc++ -ldl $(GPSUTILS_LIBS) $(LOCCORE_LIBS) #Create and Install libraries lib_LTLIBRARIES = libgnss.la From bb529c50e9a91f0bdb73d4a8a36e55155002a73e Mon Sep 17 00:00:00 2001 From: Saurabh Srivastava Date: Fri, 19 Jan 2018 17:32:08 +0530 Subject: [PATCH 03/19] Moving location sockets from /data to /dev Keeping sockets in /data/vendor/location prevents unmounting of /data partition after build load. CRs-Fixed: 2174503 Change-Id: Ib1b9f07bb25368ac7d1a32536e58c52dd2b2ad4e --- utils/gps_extended_c.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index afe47ccc..e29b2a84 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -1314,8 +1314,8 @@ typedef void (*LocAgpsOpenResultCb)(bool isSuccess, AGpsExtType agpsType, const typedef void (*LocAgpsCloseResultCb)(bool isSuccess, AGpsExtType agpsType, void* userDataPtr); /* Shared resources of LocIpc */ -#define LOC_IPC_HAL "/data/vendor/location/socket_hal" -#define LOC_IPC_XTRA "/data/vendor/location/xtra/socket_xtra" +#define LOC_IPC_HAL "/dev/socket/location/socket_hal" +#define LOC_IPC_XTRA "/dev/socket/location/xtra/socket_xtra" #ifdef __cplusplus } From af34b8d1ac48db485f78d832b4d263473d18dde9 Mon Sep 17 00:00:00 2001 From: Yingjie Wang Date: Wed, 10 Jan 2018 13:58:17 +0800 Subject: [PATCH 04/19] Enhance LocationAPI structs to hold full position Match the output of izat_remote_api clients with LocationAPI clients. Fill GnssLocationInfoNotification with missing fields from GpsLocationExtended and Location structure. And allow one single callback to report complete position info. Meanwhile, remove fields from UlpLocation that are no longer used. CRs-fixed: 2169738 Change-Id: Ib5bd3dd9c065c4b3d6cad32b23167546ad950d06 --- core/LocApiBase.cpp | 5 +- gnss/GnssAdapter.cpp | 101 ++++++++++++++------ gnss/GnssAdapter.h | 2 +- location/LocationAPI.h | 205 ++++++++++++++++++++++++++++++++++++++++- utils/gps_extended_c.h | 26 ------ 5 files changed, 279 insertions(+), 60 deletions(-) diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 95768425..8aef94b3 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -236,7 +236,7 @@ void LocApiBase::reportPosition(UlpLocation& location, // print the location info before delivering LOC_LOGD("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n " "altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n " - "timestamp: %" PRId64 "\n rawDataSize: %d\n rawData: %p\n " + "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 ")", @@ -244,8 +244,7 @@ void LocApiBase::reportPosition(UlpLocation& location, location.gpsLocation.latitude, location.gpsLocation.longitude, location.gpsLocation.altitude, location.gpsLocation.speed, location.gpsLocation.bearing, location.gpsLocation.accuracy, - location.gpsLocation.timestamp, location.rawDataSize, - location.rawData, status, loc_technology_mask, + location.gpsLocation.timestamp, status, loc_technology_mask, locationExtended.gnss_sv_used_ids.gps_sv_used_ids_mask, locationExtended.gnss_sv_used_ids.glo_sv_used_ids_mask, locationExtended.gnss_sv_used_ids.bds_sv_used_ids_mask, diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 098c8aa0..a57d1a40 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -190,32 +190,32 @@ GnssAdapter::convertOptions(LocPosMode& out, const LocationOptions& options) } void -GnssAdapter::convertLocation(Location& out, const LocGpsLocation& locGpsLocation, +GnssAdapter::convertLocation(Location& out, const UlpLocation& ulpLocation, const GpsLocationExtended& locationExtended, const LocPosTechMask techMask) { memset(&out, 0, sizeof(Location)); out.size = sizeof(Location); - if (LOC_GPS_LOCATION_HAS_LAT_LONG & locGpsLocation.flags) { + if (LOC_GPS_LOCATION_HAS_LAT_LONG & ulpLocation.gpsLocation.flags) { out.flags |= LOCATION_HAS_LAT_LONG_BIT; - out.latitude = locGpsLocation.latitude; - out.longitude = locGpsLocation.longitude; + out.latitude = ulpLocation.gpsLocation.latitude; + out.longitude = ulpLocation.gpsLocation.longitude; } - if (LOC_GPS_LOCATION_HAS_ALTITUDE & locGpsLocation.flags) { + if (LOC_GPS_LOCATION_HAS_ALTITUDE & ulpLocation.gpsLocation.flags) { out.flags |= LOCATION_HAS_ALTITUDE_BIT; - out.altitude = locGpsLocation.altitude; + out.altitude = ulpLocation.gpsLocation.altitude; } - if (LOC_GPS_LOCATION_HAS_SPEED & locGpsLocation.flags) { + if (LOC_GPS_LOCATION_HAS_SPEED & ulpLocation.gpsLocation.flags) { out.flags |= LOCATION_HAS_SPEED_BIT; - out.speed = locGpsLocation.speed; + out.speed = ulpLocation.gpsLocation.speed; } - if (LOC_GPS_LOCATION_HAS_BEARING & locGpsLocation.flags) { + if (LOC_GPS_LOCATION_HAS_BEARING & ulpLocation.gpsLocation.flags) { out.flags |= LOCATION_HAS_BEARING_BIT; - out.bearing = locGpsLocation.bearing; + out.bearing = ulpLocation.gpsLocation.bearing; } - if (LOC_GPS_LOCATION_HAS_ACCURACY & locGpsLocation.flags) { + if (LOC_GPS_LOCATION_HAS_ACCURACY & ulpLocation.gpsLocation.flags) { out.flags |= LOCATION_HAS_ACCURACY_BIT; - out.accuracy = locGpsLocation.accuracy; + out.accuracy = ulpLocation.gpsLocation.accuracy; } if (GPS_LOCATION_EXTENDED_HAS_VERT_UNC & locationExtended.flags) { out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT; @@ -229,7 +229,7 @@ GnssAdapter::convertLocation(Location& out, const LocGpsLocation& locGpsLocation out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT; out.bearingAccuracy = locationExtended.bearing_unc; } - out.timestamp = locGpsLocation.timestamp; + out.timestamp = ulpLocation.gpsLocation.timestamp; if (LOC_POS_TECH_MASK_SATELLITE & techMask) { out.techMask |= LOCATION_TECHNOLOGY_GNSS_BIT; } @@ -259,6 +259,11 @@ GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out, out.hdop = locationExtended.hdop; out.vdop = locationExtended.vdop; } + if (GPS_LOCATION_EXTENDED_HAS_EXT_DOP & locationExtended.flags) { + out.flags |= GNSS_LOCATION_INFO_EXT_DOP_BIT; + out.gdop = locationExtended.extDOP.GDOP; + out.tdop = locationExtended.extDOP.TDOP; + } if (GPS_LOCATION_EXTENDED_HAS_MAG_DEV & locationExtended.flags) { out.flags |= GNSS_LOCATION_INFO_MAGNETIC_DEVIATION_BIT; out.magneticDeviation = locationExtended.magneticDeviation; @@ -315,6 +320,53 @@ GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out, out.flags |= GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_AZIMUTH_BIT; out.horUncEllipseOrientAzimuth = locationExtended.horUncEllipseOrientAzimuth; } + if (GPS_LOCATION_EXTENDED_HAS_GNSS_SV_USED_DATA & locationExtended.flags) { + out.flags |= GNSS_LOCATION_INFO_GNSS_SV_USED_DATA_BIT; + out.svUsedInPosition.gpsSvUsedIdsMask = + locationExtended.gnss_sv_used_ids.gps_sv_used_ids_mask; + out.svUsedInPosition.gloSvUsedIdsMask = + locationExtended.gnss_sv_used_ids.glo_sv_used_ids_mask; + out.svUsedInPosition.galSvUsedIdsMask = + locationExtended.gnss_sv_used_ids.gal_sv_used_ids_mask; + out.svUsedInPosition.bdsSvUsedIdsMask = + locationExtended.gnss_sv_used_ids.bds_sv_used_ids_mask; + out.svUsedInPosition.qzssSvUsedIdsMask = + locationExtended.gnss_sv_used_ids.qzss_sv_used_ids_mask; + } + if (GPS_LOCATION_EXTENDED_HAS_NAV_SOLUTION_MASK & locationExtended.flags) { + out.flags |= GNSS_LOCATION_INFO_NAV_SOLUTION_MASK_BIT; + out.navSolutionMask = locationExtended.navSolutionMask; + } + if (GPS_LOCATION_EXTENDED_HAS_POS_TECH_MASK & locationExtended.flags) { + out.flags |= GPS_LOCATION_EXTENDED_HAS_POS_TECH_MASK; + out.posTechMask = locationExtended.tech_mask; + } + if (GPS_LOCATION_EXTENDED_HAS_POS_DYNAMICS_DATA & locationExtended.flags) { + out.flags |= GPS_LOCATION_EXTENDED_HAS_POS_DYNAMICS_DATA; + if (locationExtended.bodyFrameData.bodyFrameDatamask & + LOCATION_NAV_DATA_HAS_LONG_ACCEL_BIT) { + out.bodyFrameData.bodyFrameDataMask |= LOCATION_NAV_DATA_HAS_LONG_ACCEL_BIT; + } + if (locationExtended.bodyFrameData.bodyFrameDatamask & + LOCATION_NAV_DATA_HAS_LAT_ACCEL_BIT) { + out.bodyFrameData.bodyFrameDataMask |= LOCATION_NAV_DATA_HAS_LAT_ACCEL_BIT; + } + if (locationExtended.bodyFrameData.bodyFrameDatamask & + LOCATION_NAV_DATA_HAS_VERT_ACCEL_BIT) { + out.bodyFrameData.bodyFrameDataMask |= LOCATION_NAV_DATA_HAS_VERT_ACCEL_BIT; + } + if (locationExtended.bodyFrameData.bodyFrameDatamask & LOCATION_NAV_DATA_HAS_YAW_RATE_BIT) { + out.bodyFrameData.bodyFrameDataMask |= LOCATION_NAV_DATA_HAS_YAW_RATE_BIT; + } + if (locationExtended.bodyFrameData.bodyFrameDatamask & LOCATION_NAV_DATA_HAS_PITCH_BIT) { + out.bodyFrameData.bodyFrameDataMask |= LOCATION_NAV_DATA_HAS_PITCH_BIT; + } + out.bodyFrameData.longAccel = locationExtended.bodyFrameData.longAccel; + out.bodyFrameData.latAccel = locationExtended.bodyFrameData.latAccel; + out.bodyFrameData.vertAccel = locationExtended.bodyFrameData.vertAccel; + out.bodyFrameData.yawRate = locationExtended.bodyFrameData.yawRate; + out.bodyFrameData.pitch = locationExtended.bodyFrameData.pitch; + } } inline uint32_t @@ -1151,7 +1203,7 @@ GnssAdapter::updateClientsEventMask() { LOC_API_ADAPTER_EVENT_MASK_T mask = 0; for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { - if (it->second.trackingCb != nullptr) { + if (it->second.trackingCb != nullptr || it->second.gnssLocationInfoCb != nullptr) { mask |= LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT; } if (it->second.gnssNiCb != nullptr) { @@ -1340,7 +1392,7 @@ bool GnssAdapter::hasTrackingCallback(LocationAPI* client) { auto it = mClientData.find(client); - return (it != mClientData.end() && it->second.trackingCb); + return (it != mClientData.end() && (it->second.trackingCb || it->second.gnssLocationInfoCb)); } bool @@ -2126,15 +2178,15 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation, mGnssSvIdUsedInPosition = locationExtended.gnss_sv_used_ids; } for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { - if (nullptr != it->second.trackingCb) { - Location location = {}; - convertLocation(location, ulpLocation.gpsLocation, locationExtended, techMask); - it->second.trackingCb(location); - } if (nullptr != it->second.gnssLocationInfoCb) { GnssLocationInfoNotification locationInfo = {}; convertLocationInfo(locationInfo, locationExtended); + convertLocation(locationInfo.location, ulpLocation, locationExtended, techMask); it->second.gnssLocationInfoCb(locationInfo); + } else if (nullptr != it->second.trackingCb) { + Location location = {}; + convertLocation(location, ulpLocation, locationExtended, techMask); + it->second.trackingCb(location); } } } @@ -2152,15 +2204,6 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation, reportNmea(sentence.c_str(), sentence.length()); } } - - // Free the allocated memory for rawData - UlpLocation* gp = (UlpLocation*)&(ulpLocation); - if (gp != NULL && gp->rawData != NULL) - { - delete (char*)gp->rawData; - gp->rawData = NULL; - gp->rawDataSize = 0; - } } void diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index cf871ba3..e047f75b 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -119,7 +119,7 @@ class GnssAdapter : public LocAdapterBase { /*==== CONVERSION ===================================================================*/ static void convertOptions(LocPosMode& out, const LocationOptions& options); - static void convertLocation(Location& out, const LocGpsLocation& locGpsLocation, + static void convertLocation(Location& out, const UlpLocation& ulpLocation, const GpsLocationExtended& locationExtended, const LocPosTechMask techMask); static void convertLocationInfo(GnssLocationInfoNotification& out, diff --git a/location/LocationAPI.h b/location/LocationAPI.h index 530b1b08..ce478d23 100644 --- a/location/LocationAPI.h +++ b/location/LocationAPI.h @@ -88,6 +88,40 @@ typedef enum { LOCATION_RELIABILITY_HIGH, } LocationReliability; +typedef uint32_t GnssLocationNavSolutionMask; +typedef enum { + LOCATION_SBAS_CORRECTION_IONO_BIT = (1<<0), // SBAS ionospheric correction is used + LOCATION_SBAS_CORRECTION_FAST_BIT = (1<<1), // SBAS fast correction is used + LOCATION_SBAS_CORRECTION_LONG_BIT = (1<<2), // SBAS long-tem correction is used + LOCATION_SBAS_INTEGRITY_BIT = (1<<3), // SBAS integrity information is used + LOCATION_NAV_CORRECTION_DGNSS_BIT = (1<<4), // Position Report is DGNSS corrected + LOCATION_NAV_CORRECTION_RTK_BIT = (1<<5), // Position Report is RTK corrected + LOCATION_NAV_CORRECTION_PPP_BIT = (1<<6) // Position Report is PPP corrected +} GnssLocationNavSolutionBits; + +typedef uint32_t GnssLocationPosTechMask; +typedef enum { + LOCATION_POS_TECH_DEFAULT_BIT = 0, + LOCATION_POS_TECH_SATELLITE_BIT = (1<<0), + LOCATION_POS_TECH_CELLID_BIT = (1<<1), + LOCATION_POS_TECH_WIFI_BIT = (1<<2), + LOCATION_POS_TECH_SENSORS_BIT = (1<<3), + LOCATION_POS_TECH_REFERENCE_LOCATION_BIT = (1<<4), + LOCATION_POS_TECH_INJECTED_COARSE_POSITION_BIT = (1<<5), + LOCATION_POS_TECH_AFLT_BIT = (1<<6), + LOCATION_POS_TECH_HYBRID_BIT = (1<<7), + LOCATION_POS_TECH_PPE_BIT = (1<<8) +} GnssLocationPosTechBits; + +typedef uint32_t GnssLocationPosDataMask; +typedef enum { + LOCATION_NAV_DATA_HAS_LONG_ACCEL_BIT = (1<<0), // Navigation data has Forward Acceleration + LOCATION_NAV_DATA_HAS_LAT_ACCEL_BIT = (1<<1), // Navigation data has Sideward Acceleration + LOCATION_NAV_DATA_HAS_VERT_ACCEL_BIT = (1<<2), // Navigation data has Vertical Acceleration + LOCATION_NAV_DATA_HAS_YAW_RATE_BIT = (1<<3), // Navigation data has Heading Rate + LOCATION_NAV_DATA_HAS_PITCH_BIT = (1<<4) // Navigation data has Body pitch +} GnssLocationPosDataBits; + typedef uint32_t GnssLocationInfoFlagMask; typedef enum { GNSS_LOCATION_INFO_ALTITUDE_MEAN_SEA_LEVEL_BIT = (1<<0), // valid altitude mean sea level @@ -97,7 +131,14 @@ typedef enum { GNSS_LOCATION_INFO_VER_RELIABILITY_BIT = (1<<4), // valid vertical reliability GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MAJOR_BIT = (1<<5), // valid elipsode semi major GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MINOR_BIT = (1<<6), // valid elipsode semi minor - GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_AZIMUTH_BIT = (1<<7),// valid accuracy elipsode azimuth + GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_AZIMUTH_BIT = (1<<7), // valid accuracy elipsode azimuth + GNSS_LOCATION_INFO_GNSS_SV_USED_DATA_BIT = (1<<8), // valid gnss sv used in pos data + GNSS_LOCATION_INFO_NAV_SOLUTION_MASK_BIT = (1<<9), // valid navSolutionMask + GNSS_LOCATION_INFO_POS_TECH_MASK_BIT = (1<<10),// valid LocPosTechMask + GNSS_LOCATION_INFO_SV_SOURCE_INFO_BIT = (1<<11),// valid LocSvInfoSource + GNSS_LOCATION_INFO_POS_DYNAMICS_DATA_BIT = (1<<12),// valid position dynamics data + GNSS_LOCATION_INFO_GPS_TIME_BIT = (1<<13),// valid GPS Time + GNSS_LOCATION_INFO_EXT_DOP_BIT = (1<<14) // valid gdop, tdop } GnssLocationInfoFlagBits; typedef enum { @@ -411,6 +452,45 @@ typedef enum { GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT = (1<<4), } GnssAidingDataSvTypeBits; +typedef enum +{ + GNSS_LOC_SV_SYSTEM_GPS = 1, + /**< GPS satellite. */ + GNSS_LOC_SV_SYSTEM_GALILEO = 2, + /**< GALILEO satellite. */ + GNSS_LOC_SV_SYSTEM_SBAS = 3, + /**< SBAS satellite. */ + GNSS_LOC_SV_SYSTEM_COMPASS = 4, + /**< COMPASS satellite. */ + GNSS_LOC_SV_SYSTEM_GLONASS = 5, + /**< GLONASS satellite. */ + GNSS_LOC_SV_SYSTEM_BDS = 6, + /**< BDS satellite. */ + GNSS_LOC_SV_SYSTEM_QZSS = 7 + /**< QZSS satellite. */ +} Gnss_LocSvSystemEnumType; + +typedef uint32_t GnssSystemTimeStructTypeFlags; +typedef enum { + GNSS_SYSTEM_TIME_WEEK_VALID = (1 << 0), + GNSS_SYSTEM_TIME_WEEK_MS_VALID = (1 << 1), + GNSS_SYSTEM_CLK_TIME_BIAS_VALID = (1 << 2), + GNSS_SYSTEM_CLK_TIME_BIAS_UNC_VALID = (1 << 3), + GNSS_SYSTEM_REF_FCOUNT_VALID = (1 << 4), + GNSS_SYSTEM_NUM_CLOCK_RESETS_VALID = (1 << 5) +} GnssSystemTimeTypeBits; + +typedef uint32_t GnssGloTimeStructTypeFlags; +typedef enum { + GNSS_CLO_DAYS_VALID = (1 << 0), + GNSS_GLOS_MSEC_VALID = (1 << 1), + GNSS_GLO_CLK_TIME_BIAS_VALID = (1 << 2), + GNSS_GLO_CLK_TIME_BIAS_UNC_VALID = (1 << 3), + GNSS_GLO_REF_FCOUNT_VALID = (1 << 4), + GNSS_GLO_NUM_CLOCK_RESETS_VALID = (1 << 5), + GNSS_GLO_FOUR_YEAR_VALID = (1 << 6) +} GnssGloTimeTypeBits; + typedef struct { GnssAidingDataSvMask svMask; // bitwise OR of GnssAidingDataSvBits GnssAidingDataSvTypeMask svTypeMask; // bitwise OR of GnssAidingDataSvTypeBits @@ -499,6 +579,114 @@ typedef struct { LocationTechnologyType techType; // GNSS } GeofenceStatusNotification; +typedef struct { + uint64_t gpsSvUsedIdsMask; + uint64_t gloSvUsedIdsMask; + uint64_t galSvUsedIdsMask; + uint64_t bdsSvUsedIdsMask; + uint64_t qzssSvUsedIdsMask; +} GnssLocationSvUsedInPosition; + +/** @struct + Body Frame parameters +*/ +typedef struct { + GnssLocationPosDataMask bodyFrameDataMask; // Contains Body frame LocPosDataMask bits + float longAccel; // Forward Acceleration in body frame (m/s2) + float latAccel; // Sideward Acceleration in body frame (m/s2) + float vertAccel; // Vertical Acceleration in body frame (m/s2) + float yawRate; // Heading Rate (Radians/second) + float pitch; // Body pitch (Radians) +} GnssLocationPositionDynamics; + +typedef struct { + /** Validity mask for below fields */ + GnssSystemTimeStructTypeFlags validityMask; + /** Extended week number at reference tick. + Unit: Week. + Set to 65535 if week number is unknown. + For GPS: + Calculated from midnight, Jan. 6, 1980. + OTA decoded 10 bit GPS week is extended to map between: + [NV6264 to (NV6264 + 1023)]. + NV6264: Minimum GPS week number configuration. + Default value of NV6264: 1738 + For BDS: + Calculated from 00:00:00 on January 1, 2006 of Coordinated Universal Time (UTC). + For GAL: + Calculated from 00:00 UT on Sunday August 22, 1999 (midnight between August 21 and August 22). + */ + uint16_t systemWeek; + /** Time in to the current week at reference tick. + Unit: Millisecond. Range: 0 to 604799999. + Check for systemClkTimeUncMs before use */ + uint32_t systemMsec; + /** System clock time bias (sub-millisecond) + Units: Millisecond + Note: System time (TOW Millisecond) = systemMsec - systemClkTimeBias. + Check for systemClkTimeUncMs before use. */ + float systemClkTimeBias; + /** Single sided maximum time bias uncertainty + Units: Millisecond */ + float systemClkTimeUncMs; + /** FCount (free running HW timer) value. Don't use for relative time purpose + due to possible discontinuities. + Unit: Millisecond */ + uint32_t refFCount; + /** Number of clock resets/discontinuities detected, affecting the local hardware counter value. */ + uint32_t numClockResets; +} GnssSystemTimeStructType; + +typedef struct { + /** GLONASS day number in four years. Refer to GLONASS ICD. + Applicable only for GLONASS and shall be ignored for other constellations. + If unknown shall be set to 65535 */ + uint16_t gloDays; + /** Validity mask for below fields */ + GnssGloTimeStructTypeFlags validityMask; + /** GLONASS time of day in Millisecond. Refer to GLONASS ICD. + Units: Millisecond + Check for gloClkTimeUncMs before use */ + uint32_t gloMsec; + /** GLONASS clock time bias (sub-millisecond) + Units: Millisecond + Note: GLO time (TOD Millisecond) = gloMsec - gloClkTimeBias. + Check for gloClkTimeUncMs before use. */ + float gloClkTimeBias; + /** Single sided maximum time bias uncertainty + Units: Millisecond */ + float gloClkTimeUncMs; + /** FCount (free running HW timer) value. Don't use for relative time purpose + due to possible discontinuities. + Unit: Millisecond */ + uint32_t refFCount; + /** Number of clock resets/discontinuities detected, affecting the local hardware counter value. */ + uint32_t numClockResets; + /** GLONASS four year number from 1996. Refer to GLONASS ICD. + Applicable only for GLONASS and shall be ignored for other constellations. + If unknown shall be set to 255 */ + uint8_t gloFourYear; +} GnssGloTimeStructType; + +typedef union { + GnssSystemTimeStructType gpsSystemTime; + GnssSystemTimeStructType galSystemTime; + GnssSystemTimeStructType bdsSystemTime; + GnssSystemTimeStructType qzssSystemTime; + GnssGloTimeStructType gloSytemTime; +} SystemTimeStructUnion; + /** Time applicability of PVT report */ +typedef struct { + /** Specifies GNSS system time reported. Mandatory field */ + Gnss_LocSvSystemEnumType gnssSystemTimeSrc; + /** Reporting of GPS system time is recommended. + If GPS time is unknown & other satellite system time is known, + it should be reported. + Mandatory field + */ + SystemTimeStructUnion u; +} GnssSystemTime; + typedef struct { size_t size; // set to sizeof(GnssLocationInfo) GnssLocationInfoFlagMask flags; // bitwise OR of GnssLocationInfoBits for param validity @@ -506,12 +694,27 @@ typedef struct { float pdop; // position dilusion of precision float hdop; // horizontal dilusion of precision float vdop; // vertical dilusion of precision + float gdop; // geometric dilution of precision + float tdop; // time dilution of precision float magneticDeviation; // magnetic deviation LocationReliability horReliability; // horizontal reliability LocationReliability verReliability; // vertical reliability float horUncEllipseSemiMajor; // horizontal elliptical accuracy semi-major axis float horUncEllipseSemiMinor; // horizontal elliptical accuracy semi-minor axis float horUncEllipseOrientAzimuth; // horizontal elliptical accuracy azimuth + float northVelocity; // North Velocity.Unit: Meters/sec + float eastVelocity; // East Velocity + float upVelocity; + float northVelocityStdDeviation; + float eastVelocityStdDeviation; + float upVelocityStdDeviation; + GnssLocationSvUsedInPosition svUsedInPosition;// Gnss sv used in position data + GnssLocationNavSolutionMask navSolutionMask; // Nav solution mask to indicate sbas corrections + GnssLocationPosTechMask posTechMask; // Position technology used in computing this fix + GnssLocationPositionDynamics bodyFrameData; // Body Frame Dynamics: 4wayAcceleration and + // pitch set with validity + GnssSystemTime gnssSystemTime; // GNSS System Time + Location location; } GnssLocationInfoNotification; typedef struct { diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index e29b2a84..bd528d9e 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -127,13 +127,6 @@ typedef struct { /* Provider indicator for HYBRID or GPS */ uint16_t position_source; LocPosTechMask tech_mask; - /*allows HAL to pass additional information related to the location */ - int rawDataSize; /* in # of bytes */ - void * rawData; - bool is_indoor; - float floor_number; - char map_url[GPS_LOCATION_MAP_URL_SIZE]; - unsigned char map_index[GPS_LOCATION_MAP_INDEX_SIZE]; } UlpLocation; typedef struct { @@ -728,25 +721,6 @@ enum ulp_gnss_sv_poly_valid_flags{ #define ULP_GNSS_SV_POLY_BIT_VELO_COEFF (1< Date: Thu, 15 Feb 2018 18:49:42 -0800 Subject: [PATCH 05/19] fixing LE hy11 build define ALOGx for HY11 build, which doesn't have liblog Change-Id: I151d451997f71179e4c4bba3946d7fd52e1f345f CRs-Fixed: 2190714 --- utils/log_util.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/utils/log_util.h b/utils/log_util.h index 460d6e7e..2fc04e2c 100644 --- a/utils/log_util.h +++ b/utils/log_util.h @@ -39,13 +39,32 @@ #include #include #include +#include #include -#include #ifndef LOG_TAG #define LOG_TAG "GPS_UTILS" #endif /* LOG_TAG */ +// LE targets with no logcat support +#define TS_PRINTF(format, x...) \ +{ \ + struct timeval tv; \ + struct timezone tz; \ + int hh, mm, ss; \ + gettimeofday(&tv, &tz); \ + hh = tv.tv_sec/3600%24; \ + mm = (tv.tv_sec%3600)/60; \ + ss = tv.tv_sec%60; \ + fprintf(stdout,"%02d:%02d:%02d.%06ld]" format "\n", hh, mm, ss, tv.tv_usec, ##x); \ +} + +#define ALOGE(format, x...) TS_PRINTF("E/%s (%d): " format , LOG_TAG, getpid(), ##x) +#define ALOGW(format, x...) TS_PRINTF("W/%s (%d): " format , LOG_TAG, getpid(), ##x) +#define ALOGI(format, x...) TS_PRINTF("I/%s (%d): " format , LOG_TAG, getpid(), ##x) +#define ALOGD(format, x...) TS_PRINTF("D/%s (%d): " format , LOG_TAG, getpid(), ##x) +#define ALOGV(format, x...) TS_PRINTF("V/%s (%d): " format , LOG_TAG, getpid(), ##x) + #endif /* #if defined (USE_ANDROID_LOGGING) || defined (ANDROID) */ #ifdef __cplusplus From 453ea463522ef8a8f6f0a0e8233f16b5477d742e Mon Sep 17 00:00:00 2001 From: Naresh Munagala Date: Fri, 20 Oct 2017 15:26:33 +0530 Subject: [PATCH 06/19] configuration to ignore PPS pulse at start and after long outage First PPS pulse is impacting on AP time uncertanity in QDR. Made necessary changes to ignore first few PPS pulses at startup and after long gnss RF outage. These parameters are controlled through IGNORE_PPS_PULSE_COUNT and GNSS_OUTAGE_DURATION in gps.cof. Change-Id: I19c7495d281b70c393844d02ca83642c2314ab96 CRs-Fixed: 2132152 --- etc/gps.conf | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/etc/gps.conf b/etc/gps.conf index d30461e6..7653408d 100644 --- a/etc/gps.conf +++ b/etc/gps.conf @@ -185,6 +185,16 @@ DR_SYNC_ENABLED = 0 ##################################### PPS_DEVICENAME = /dev/pps0 +##################################### +# Ignore PPS at Startup and after long outage +##################################### +IGNORE_PPS_PULSE_COUNT = 1 + +##################################### +# Long GNSS RF outage in seconds +##################################### +GNSS_OUTAGE_DURATION = 10 + ##################################### # AP Clock Accuracy ##################################### From 85e65f8168d6f3e32d63e47b0298b747eeeba0e5 Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Tue, 13 Feb 2018 17:19:54 -0800 Subject: [PATCH 07/19] moving AGnssCbIface from static to class member mAGnssCbIface is a static C++ obj, which ctor may not get called at load time, but its memory block will only be 0'ed out. Change-Id: Ie275f916a01c5eb3bf0a7cfa71b19fe4e0d3e879 CRs-Fixed: 2190347 --- android/AGnss.cpp | 25 ++++++++++++++++++++----- android/AGnss.h | 6 ++++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/android/AGnss.cpp b/android/AGnss.cpp index 6213a083..3602e85d 100644 --- a/android/AGnss.cpp +++ b/android/AGnss.cpp @@ -30,12 +30,23 @@ namespace gnss { namespace V1_0 { namespace implementation { -sp AGnss::sAGnssCbIface = nullptr; +static AGnss* spAGnss = nullptr; AGnss::AGnss(Gnss* gnss) : mGnss(gnss) { + spAGnss = this; +} + +AGnss::~AGnss() { + spAGnss = nullptr; } void AGnss::agnssStatusIpV4Cb(AGnssExtStatusIpV4 status){ + if (nullptr != spAGnss) { + spAGnss->statusIpV4Cb(status); + } +} + +void AGnss::statusIpV4Cb(AGnssExtStatusIpV4 status) { IAGnssCallback::AGnssStatusIpV4 st = {}; switch (status.type) { @@ -72,9 +83,13 @@ void AGnss::agnssStatusIpV4Cb(AGnssExtStatusIpV4 status){ } st.ipV4Addr = status.ipV4Addr; - auto r = sAGnssCbIface->agnssStatusIpV4Cb(st); - if (!r.isOk()) { - LOC_LOGE("Error invoking AGNSS status cb %s", r.description().c_str()); + if (mAGnssCbIface != nullptr) { + auto r = mAGnssCbIface->agnssStatusIpV4Cb(st); + if (!r.isOk()) { + LOC_LOGw("Error invoking AGNSS status cb %s", r.description().c_str()); + } + } else { + LOC_LOGw("setCallback has not been called yet"); } } @@ -86,7 +101,7 @@ Return AGnss::setCallback(const sp& callback) { } // Save the interface - sAGnssCbIface = callback; + mAGnssCbIface = callback; AgpsCbInfo cbInfo = {}; cbInfo.statusV4Cb = (void*)agnssStatusIpV4Cb; diff --git a/android/AGnss.h b/android/AGnss.h index a3f4a87b..ead64169 100644 --- a/android/AGnss.h +++ b/android/AGnss.h @@ -43,7 +43,7 @@ struct Gnss; struct AGnss : public IAGnss { AGnss(Gnss* gnss); - ~AGnss() = default; + ~AGnss(); /* * Methods from ::android::hardware::gnss::V1_0::IAGnss interface follow. * These declarations were generated from IAGnss.hal. @@ -60,12 +60,14 @@ struct AGnss : public IAGnss { Return setServer(IAGnssCallback::AGnssType type, const hidl_string& hostname, int32_t port) override; + void statusIpV4Cb(AGnssExtStatusIpV4 status); + /* Data call setup callback passed down to GNSS HAL implementation */ static void agnssStatusIpV4Cb(AGnssExtStatusIpV4 status); private: Gnss* mGnss = nullptr; - static sp sAGnssCbIface; + sp mAGnssCbIface = nullptr; }; } // namespace implementation From 980d403c819d1053f8f19f00f077dcfbe9dd68a3 Mon Sep 17 00:00:00 2001 From: Saurabh Srivastava Date: Wed, 21 Feb 2018 16:04:28 +0530 Subject: [PATCH 08/19] KW Warning Fix Check file pointer before closing. Change-Id: Id9526f6eacf57e282dc0af35d72f571f950b0b0e CRs-Fixed: 2193268 --- utils/loc_cfg.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/loc_cfg.cpp b/utils/loc_cfg.cpp index fd38c8a9..884bb10d 100644 --- a/utils/loc_cfg.cpp +++ b/utils/loc_cfg.cpp @@ -1119,7 +1119,9 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p } err: - fclose(conf_fp); + if (conf_fp) { + fclose(conf_fp); + } if (ret != 0) { LOC_LOGE("%s:%d]: ret: %d", __func__, __LINE__, ret); if (child_proc) { From cd1e0726c8d5f37c3ddfbb5d608a036a4b203e8d Mon Sep 17 00:00:00 2001 From: Harikrishnan Hariharan Date: Thu, 22 Feb 2018 11:31:38 +0530 Subject: [PATCH 09/19] Reset MSA/MSB capabilities for APQ targets. - Capabilities MSA/MSB should be reset even if defined in gps.conf for APQ/QSC targets. Since WWAN modem will not be available, we need to trigger Standalone fixes only. If MSB capability is set,then default position mode is MSB. - Handle the new string "qcs" for baseband for Gen9 APQ targets. - Make sure that ContextBase::readConfig avoid repeat initialize for config reading. Change-Id: Ic0a1e57dd76a88bf4d037cd374ceded84cc0f904 CRs-Fixed: 2193207 --- core/ContextBase.cpp | 124 ++++++++++++++++++++++++------------------- utils/loc_target.cpp | 4 +- 2 files changed, 72 insertions(+), 56 deletions(-) diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index 35e65854..47194cba 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -92,65 +92,79 @@ const loc_param_s_type ContextBase::mSap_conf_table[] = void ContextBase::readConfig() { - /*Defaults for gps.conf*/ - mGps_conf.INTERMEDIATE_POS = 0; - mGps_conf.ACCURACY_THRES = 0; - mGps_conf.NMEA_PROVIDER = 0; - mGps_conf.GPS_LOCK = 0; - mGps_conf.SUPL_VER = 0x10000; - mGps_conf.SUPL_MODE = 0x1; - mGps_conf.SUPL_ES = 0; - mGps_conf.SUPL_HOST[0] = 0; - mGps_conf.SUPL_PORT = 0; - mGps_conf.CAPABILITIES = 0x7; - /* LTE Positioning Profile configuration is disable by default*/ - mGps_conf.LPP_PROFILE = 0; - /*By default no positioning protocol is selected on A-GLONASS system*/ - mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0; - /*XTRA version check is disabled by default*/ - mGps_conf.XTRA_VERSION_CHECK=0; - /*Use emergency PDN by default*/ - mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = 1; - /* By default no LPPe CP technology is enabled*/ - mGps_conf.LPPE_CP_TECHNOLOGY = 0; - /* By default no LPPe UP technology is enabled*/ - mGps_conf.LPPE_UP_TECHNOLOGY = 0; + static bool confReadDone = false; + if (!confReadDone) { + confReadDone = true; + /*Defaults for gps.conf*/ + mGps_conf.INTERMEDIATE_POS = 0; + mGps_conf.ACCURACY_THRES = 0; + mGps_conf.NMEA_PROVIDER = 0; + mGps_conf.GPS_LOCK = 0; + mGps_conf.SUPL_VER = 0x10000; + mGps_conf.SUPL_MODE = 0x1; + mGps_conf.SUPL_ES = 0; + mGps_conf.SUPL_HOST[0] = 0; + mGps_conf.SUPL_PORT = 0; + mGps_conf.CAPABILITIES = 0x7; + /* LTE Positioning Profile configuration is disable by default*/ + mGps_conf.LPP_PROFILE = 0; + /*By default no positioning protocol is selected on A-GLONASS system*/ + mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0; + /*XTRA version check is disabled by default*/ + mGps_conf.XTRA_VERSION_CHECK=0; + /*Use emergency PDN by default*/ + mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = 1; + /* By default no LPPe CP technology is enabled*/ + mGps_conf.LPPE_CP_TECHNOLOGY = 0; + /* By default no LPPe UP technology is enabled*/ + mGps_conf.LPPE_UP_TECHNOLOGY = 0; - /*Defaults for sap.conf*/ - mSap_conf.GYRO_BIAS_RANDOM_WALK = 0; - mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC = 2; - mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH = 5; - mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC = 2; - mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH = 5; - mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH = 4; - mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH = 25; - mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH = 4; - mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH = 25; - mSap_conf.SENSOR_CONTROL_MODE = 0; /* AUTO */ - mSap_conf.SENSOR_USAGE = 0; /* Enabled */ - mSap_conf.SENSOR_ALGORITHM_CONFIG_MASK = 0; /* INS Disabled = FALSE*/ - /* Values MUST be set by OEMs in configuration for sensor-assisted - navigation to work. There are NO default values */ - mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY = 0; - mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY = 0; - mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY = 0; - mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY = 0; - mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID = 0; - mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; - mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; - mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; - mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; - /* default provider is SSC */ - mSap_conf.SENSOR_PROVIDER = 1; + /*Defaults for sap.conf*/ + mSap_conf.GYRO_BIAS_RANDOM_WALK = 0; + mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC = 2; + mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH = 5; + mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC = 2; + mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH = 5; + mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH = 4; + mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH = 25; + mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH = 4; + mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH = 25; + mSap_conf.SENSOR_CONTROL_MODE = 0; /* AUTO */ + mSap_conf.SENSOR_USAGE = 0; /* Enabled */ + mSap_conf.SENSOR_ALGORITHM_CONFIG_MASK = 0; /* INS Disabled = FALSE*/ + /* Values MUST be set by OEMs in configuration for sensor-assisted + navigation to work. There are NO default values */ + mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY = 0; + mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY = 0; + mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY = 0; + mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY = 0; + mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID = 0; + mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; + mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; + mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; + mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; + /* default provider is SSC */ + mSap_conf.SENSOR_PROVIDER = 1; - /* None of the 10 slots for agps certificates are writable by default */ - mGps_conf.AGPS_CERT_WRITABLE_MASK = 0; + /* None of the 10 slots for agps certificates are writable by default */ + mGps_conf.AGPS_CERT_WRITABLE_MASK = 0; - /* inject supl config to modem with config values from config.xml or gps.conf, default 1 */ - mGps_conf.AGPS_CONFIG_INJECT = 1; + /* inject supl config to modem with config values from config.xml or gps.conf, default 1 */ + mGps_conf.AGPS_CONFIG_INJECT = 1; - UTIL_READ_CONF(LOC_PATH_GPS_CONF, mGps_conf_table); - UTIL_READ_CONF(LOC_PATH_SAP_CONF, mSap_conf_table); + UTIL_READ_CONF(LOC_PATH_GPS_CONF, mGps_conf_table); + UTIL_READ_CONF(LOC_PATH_SAP_CONF, mSap_conf_table); + + switch (getTargetGnssType(loc_get_target())) { + case GNSS_GSS: + case GNSS_AUTO: + // For APQ targets, MSA/MSB capabilities should be reset + mGps_conf.CAPABILITIES &= ~(LOC_GPS_CAPABILITY_MSA | LOC_GPS_CAPABILITY_MSB); + break; + default: + break; + } + } } uint32_t ContextBase::getCarrierCapabilities() { diff --git a/utils/loc_target.cpp b/utils/loc_target.cpp index d31f8874..dd6aa4fc 100644 --- a/utils/loc_target.cpp +++ b/utils/loc_target.cpp @@ -54,6 +54,7 @@ #define STR_MTP "MTP" #define STR_APQ "apq" #define STR_SDC "sdc" // alternative string for APQ targets +#define STR_QCS "qcs" // string for Gen9 APQ targets #define STR_MSM "msm" #define STR_SDM "sdm" // alternative string for MSM targets #define STR_APQ_NO_WGR "baseband_apq_nowgr" @@ -175,7 +176,8 @@ unsigned int loc_get_target(void) } if( !memcmp(baseband, STR_APQ, LENGTH(STR_APQ)) || - !memcmp(baseband, STR_SDC, LENGTH(STR_SDC)) ) { + !memcmp(baseband, STR_SDC, LENGTH(STR_SDC)) || + !memcmp(baseband, STR_QCS, LENGTH(STR_QCS)) ) { if( !memcmp(rd_id, MPQ8064_ID_1, LENGTH(MPQ8064_ID_1)) && IS_STR_END(rd_id[LENGTH(MPQ8064_ID_1)]) ) From c645cb167bfb81a8646da19457573b00534a6e7c Mon Sep 17 00:00:00 2001 From: Harikrishnan Hariharan Date: Tue, 13 Feb 2018 16:04:32 +0530 Subject: [PATCH 10/19] Define gps user and group id's for Android and LE. - Define gps user and group id's for Android and LE. - Update to use getgrnam for getting group id's. - Get group id's for child processes for LE also. Change-Id: I5365dbc1c51eb89ab66ba8652f3ed1c5dbea6eb4 CRs-Fixed: 2183710 --- pla/android/loc_pla.h | 4 ++++ pla/oe/loc_pla.h | 3 +++ utils/loc_cfg.cpp | 13 ++++++------- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pla/android/loc_pla.h b/pla/android/loc_pla.h index 9caae737..bedb079c 100644 --- a/pla/android/loc_pla.h +++ b/pla/android/loc_pla.h @@ -41,6 +41,10 @@ extern "C" { #include #include #include +#include + +#define UID_GPS (AID_GPS) +#define GID_GPS (AID_GPS) #define LOC_PATH_GPS_CONF_STR "/vendor/etc/gps.conf" #define LOC_PATH_IZAT_CONF_STR "/vendor/etc/izat.conf" diff --git a/pla/oe/loc_pla.h b/pla/oe/loc_pla.h index 3ca1964a..50b19c2f 100644 --- a/pla/oe/loc_pla.h +++ b/pla/oe/loc_pla.h @@ -51,6 +51,9 @@ extern "C" { #define strlcpy strncpy #endif +#define UID_GPS (1021) +#define GID_GPS (1021) + #define LOC_PATH_GPS_CONF_STR "/etc/gps.conf" #define LOC_PATH_IZAT_CONF_STR "/etc/izat.conf" #define LOC_PATH_FLP_CONF_STR "/etc/flp.conf" diff --git a/utils/loc_cfg.cpp b/utils/loc_cfg.cpp index 884bb10d..3e1922cc 100644 --- a/utils/loc_cfg.cpp +++ b/utils/loc_cfg.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -826,18 +826,17 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p child_proc[j].num_groups = 0; ngroups = loc_util_split_string(conf.group_list, split_strings, MAX_NUM_STRINGS, ' '); -#ifdef __ANDROID__ for(i=0; ipw_gid; + struct group* grp = getgrnam(split_strings[i]); + if (grp) { + child_proc[j].group_list[i] = grp->gr_gid; child_proc[j].num_groups++; LOC_LOGD("%s:%d]:Group %s = %d matches child_group: %d\n", __func__, __LINE__, split_strings[i], - pwd->pw_gid,child_proc[j].group_list[i]); + grp->gr_gid,child_proc[j].group_list[i]); } } -#endif + nstrings = loc_util_split_string(conf.platform_list, split_strings, MAX_NUM_STRINGS, ' '); if(strcmp("all", split_strings[0]) == 0) { if (nstrings == 1 || (nstrings == 2 && (strcmp("exclude", split_strings[1]) == 0))) { From 0fc49e84322b6cec0bf206ec1e6b57bcbfaa20c0 Mon Sep 17 00:00:00 2001 From: Katz Yamada Date: Wed, 28 Feb 2018 11:22:58 -0800 Subject: [PATCH 11/19] feat: Separate LocationAPI.h Separate LocationAPI.h into ILocationAPI.h for interface and LocationDataTypes.h for data structure definitions. CRs-Fixed: 2148023 Change-Id: I9f375a6057b22cf5bdd0b73a41ba1c010d9e0e4e --- location/ILocationAPI.h | 194 +++++++ location/LocationAPI.h | 979 +---------------------------------- location/LocationDataTypes.h | 967 ++++++++++++++++++++++++++++++++++ location/Makefile.am | 4 +- 4 files changed, 1187 insertions(+), 957 deletions(-) create mode 100644 location/ILocationAPI.h create mode 100644 location/LocationDataTypes.h diff --git a/location/ILocationAPI.h b/location/ILocationAPI.h new file mode 100644 index 00000000..ae695cf8 --- /dev/null +++ b/location/ILocationAPI.h @@ -0,0 +1,194 @@ +/* Copyright (c) 2018 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ILOCATIONAPI_H +#define ILOCATIONAPI_H + +#include "LocationDataTypes.h" + +class ILocationAPI +{ +public: + virtual ~ILocationAPI(){}; + + /** @brief Updates/changes the callbacks that will be called. + mandatory callbacks must be present for callbacks to be successfully updated + no return value */ + virtual void updateCallbacks(LocationCallbacks&) = 0; + + /* ================================== TRACKING ================================== */ + + /** @brief Starts a tracking session, which returns a session id that will be + used by the other tracking APIs and also in the responseCallback to match command + with response. locations are reported on the registered trackingCallback + periodically according to LocationOptions. + @return session id + responseCallback returns: + LOCATION_ERROR_SUCCESS if session was successfully started + LOCATION_ERROR_ALREADY_STARTED if a startTracking session is already in progress + LOCATION_ERROR_CALLBACK_MISSING if no trackingCallback was passed + LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameter is invalid */ + virtual uint32_t startTracking(LocationOptions&) = 0; + + /** @brief Stops a tracking session associated with id parameter. + responseCallback returns: + LOCATION_ERROR_SUCCESS if successful + LOCATION_ERROR_ID_UNKNOWN if id is not associated with a tracking session */ + virtual void stopTracking(uint32_t id) = 0; + + /** @brief Changes the LocationOptions of a tracking session associated with id. + responseCallback returns: + LOCATION_ERROR_SUCCESS if successful + LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameters are invalid + LOCATION_ERROR_ID_UNKNOWN if id is not associated with a tracking session */ + virtual void updateTrackingOptions(uint32_t id, LocationOptions&) = 0; + + /* ================================== BATCHING ================================== */ + + /** @brief starts a batching session, which returns a session id that will be + used by the other batching APIs and also in the responseCallback to match command + with response. locations are reported on the batchingCallback passed in createInstance + periodically according to LocationOptions. A batching session starts tracking on + the low power processor and delivers them in batches by the batchingCallback when + the batch is full or when getBatchedLocations is called. This allows for the processor + that calls this API to sleep when the low power processor can batch locations in the + backgroup and wake up the processor calling the API only when the batch is full, thus + saving power. + @return session id + responseCallback returns: + LOCATION_ERROR_SUCCESS if session was successful + LOCATION_ERROR_ALREADY_STARTED if a startBatching session is already in progress + LOCATION_ERROR_CALLBACK_MISSING if no batchingCallback + LOCATION_ERROR_INVALID_PARAMETER if a parameter is invalid + LOCATION_ERROR_NOT_SUPPORTED if batching is not supported */ + virtual uint32_t startBatching(LocationOptions&, BatchingOptions&) = 0; + + /** @brief Stops a batching session associated with id parameter. + responseCallback returns: + LOCATION_ERROR_SUCCESS if successful + LOCATION_ERROR_ID_UNKNOWN if id is not associated with batching session */ + virtual void stopBatching(uint32_t id) = 0; + + /** @brief Changes the LocationOptions of a batching session associated with id. + responseCallback returns: + LOCATION_ERROR_SUCCESS if successful + LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameters are invalid + LOCATION_ERROR_ID_UNKNOWN if id is not associated with a batching session */ + virtual void updateBatchingOptions(uint32_t id, LocationOptions&, BatchingOptions&) = 0; + + /** @brief Gets a number of locations that are currently stored/batched + on the low power processor, delivered by the batchingCallback passed in createInstance. + Location are then deleted from the batch stored on the low power processor. + responseCallback returns: + LOCATION_ERROR_SUCCESS if successful, will be followed by batchingCallback call + LOCATION_ERROR_CALLBACK_MISSING if no batchingCallback + LOCATION_ERROR_ID_UNKNOWN if id is not associated with a batching session */ + virtual void getBatchedLocations(uint32_t id, size_t count) = 0; + + /* ================================== GEOFENCE ================================== */ + + /** @brief Adds any number of geofences and returns an array of geofence ids that + will be used by the other geofence APIs and also in the collectiveResponseCallback to + match command with response. The geofenceBreachCallback will deliver the status of each + geofence according to the GeofenceOption for each. The geofence id array returned will + be valid until the collectiveResponseCallback is called and has returned. + @return id array + collectiveResponseCallback returns: + LOCATION_ERROR_SUCCESS if session was successful + LOCATION_ERROR_CALLBACK_MISSING if no geofenceBreachCallback + LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid + LOCATION_ERROR_NOT_SUPPORTED if geofence is not supported */ + virtual uint32_t* addGeofences(size_t count, GeofenceOption*, GeofenceInfo*) = 0; + + /** @brief Removes any number of geofences. Caller should delete ids array after + removeGeofences returneds. + collectiveResponseCallback returns: + LOCATION_ERROR_SUCCESS if successful + LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */ + virtual void removeGeofences(size_t count, uint32_t* ids) = 0; + + /** @brief Modifies any number of geofences. Caller should delete ids array after + modifyGeofences returns. + collectiveResponseCallback returns: + LOCATION_ERROR_SUCCESS if successful + LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session + LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid */ + virtual void modifyGeofences(size_t count, uint32_t* ids, GeofenceOption* options) = 0; + + /** @brief Pauses any number of geofences, which is similar to removeGeofences, + only that they can be resumed at any time. Caller should delete ids array after + pauseGeofences returns. + collectiveResponseCallback returns: + LOCATION_ERROR_SUCCESS if successful + LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */ + virtual void pauseGeofences(size_t count, uint32_t* ids) = 0; + + /** @brief Resumes any number of geofences that are currently paused. Caller should + delete ids array after resumeGeofences returns. + collectiveResponseCallback returns: + LOCATION_ERROR_SUCCESS if successful + LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */ + virtual void resumeGeofences(size_t count, uint32_t* ids) = 0; + + /* ================================== GNSS ====================================== */ + + /** @brief gnssNiResponse is called in response to a gnssNiCallback. + responseCallback returns: + LOCATION_ERROR_SUCCESS if session was successful + LOCATION_ERROR_INVALID_PARAMETER if any parameters in GnssNiResponse are invalid + LOCATION_ERROR_ID_UNKNOWN if id does not match a gnssNiCallback */ + virtual void gnssNiResponse(uint32_t id, GnssNiResponse response) = 0; +}; + +class ILocationControlAPI +{ +public: + virtual ~ILocationControlAPI(){}; + + /** @brief Updates the gnss specific configuration, which returns a session id array + with an id for each of the bits set in GnssConfig.flags, order from low bits to high bits. + The response for each config that is set will be returned in collectiveResponseCallback. + The session id array returned will be valid until the collectiveResponseCallback is called + and has returned. This effect is global for all clients of ILocationAPI. + collectiveResponseCallback returns: + LOCATION_ERROR_SUCCESS if session was successful + LOCATION_ERROR_INVALID_PARAMETER if any other parameters are invalid + LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason */ + virtual uint32_t* gnssUpdateConfig(GnssConfig config) = 0; + + /** @brief Delete specific gnss aiding data for testing, which returns a session id + that will be returned in responseCallback to match command with response. + Only allowed in userdebug builds. This effect is global for all clients of ILocationAPI. + responseCallback returns: + LOCATION_ERROR_SUCCESS if successful + LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid + LOCATION_ERROR_NOT_SUPPORTED if build is not userdebug */ + virtual uint32_t gnssDeleteAidingData(GnssAidingData& data) = 0; +}; + +#endif /* ILOCATIONAPI_H */ diff --git a/location/LocationAPI.h b/location/LocationAPI.h index ce478d23..ce38bc6b 100644 --- a/location/LocationAPI.h +++ b/location/LocationAPI.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2017 The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -26,945 +26,12 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LOCATION_H -#define LOCATION_H +#ifndef LOCATIONAPI_H +#define LOCATIONAPI_H -#include -#include -#include -#include +#include "ILocationAPI.h" -#define GNSS_NI_REQUESTOR_MAX 256 -#define GNSS_NI_MESSAGE_ID_MAX 2048 -#define GNSS_SV_MAX 64 -#define GNSS_MEASUREMENTS_MAX 64 -#define GNSS_UTC_TIME_OFFSET (3657) - -#define GNSS_BUGREPORT_GPS_MIN (1) -#define GNSS_BUGREPORT_SBAS_MIN (120) -#define GNSS_BUGREPORT_GLO_MIN (1) -#define GNSS_BUGREPORT_QZSS_MIN (193) -#define GNSS_BUGREPORT_BDS_MIN (1) -#define GNSS_BUGREPORT_GAL_MIN (1) - -typedef enum { - LOCATION_ERROR_SUCCESS = 0, - LOCATION_ERROR_GENERAL_FAILURE, - LOCATION_ERROR_CALLBACK_MISSING, - LOCATION_ERROR_INVALID_PARAMETER, - LOCATION_ERROR_ID_EXISTS, - LOCATION_ERROR_ID_UNKNOWN, - LOCATION_ERROR_ALREADY_STARTED, - LOCATION_ERROR_GEOFENCES_AT_MAX, - LOCATION_ERROR_NOT_SUPPORTED -} LocationError; - -// Flags to indicate which values are valid in a Location -typedef uint16_t LocationFlagsMask; -typedef enum { - LOCATION_HAS_LAT_LONG_BIT = (1<<0), // location has valid latitude and longitude - LOCATION_HAS_ALTITUDE_BIT = (1<<1), // location has valid altitude - LOCATION_HAS_SPEED_BIT = (1<<2), // location has valid speed - LOCATION_HAS_BEARING_BIT = (1<<3), // location has valid bearing - LOCATION_HAS_ACCURACY_BIT = (1<<4), // location has valid accuracy - LOCATION_HAS_VERTICAL_ACCURACY_BIT = (1<<5), // location has valid vertical accuracy - LOCATION_HAS_SPEED_ACCURACY_BIT = (1<<6), // location has valid speed accuracy - LOCATION_HAS_BEARING_ACCURACY_BIT = (1<<7), // location has valid bearing accuracy -} LocationFlagsBits; - -typedef uint16_t LocationTechnologyMask; -typedef enum { - LOCATION_TECHNOLOGY_GNSS_BIT = (1<<0), // location was calculated using GNSS - LOCATION_TECHNOLOGY_CELL_BIT = (1<<1), // location was calculated using Cell - LOCATION_TECHNOLOGY_WIFI_BIT = (1<<2), // location was calculated using WiFi - LOCATION_TECHNOLOGY_SENSORS_BIT = (1<<3), // location was calculated using Sensors -} LocationTechnologyBits; - -typedef enum { - LOCATION_RELIABILITY_NOT_SET = 0, - LOCATION_RELIABILITY_VERY_LOW, - LOCATION_RELIABILITY_LOW, - LOCATION_RELIABILITY_MEDIUM, - LOCATION_RELIABILITY_HIGH, -} LocationReliability; - -typedef uint32_t GnssLocationNavSolutionMask; -typedef enum { - LOCATION_SBAS_CORRECTION_IONO_BIT = (1<<0), // SBAS ionospheric correction is used - LOCATION_SBAS_CORRECTION_FAST_BIT = (1<<1), // SBAS fast correction is used - LOCATION_SBAS_CORRECTION_LONG_BIT = (1<<2), // SBAS long-tem correction is used - LOCATION_SBAS_INTEGRITY_BIT = (1<<3), // SBAS integrity information is used - LOCATION_NAV_CORRECTION_DGNSS_BIT = (1<<4), // Position Report is DGNSS corrected - LOCATION_NAV_CORRECTION_RTK_BIT = (1<<5), // Position Report is RTK corrected - LOCATION_NAV_CORRECTION_PPP_BIT = (1<<6) // Position Report is PPP corrected -} GnssLocationNavSolutionBits; - -typedef uint32_t GnssLocationPosTechMask; -typedef enum { - LOCATION_POS_TECH_DEFAULT_BIT = 0, - LOCATION_POS_TECH_SATELLITE_BIT = (1<<0), - LOCATION_POS_TECH_CELLID_BIT = (1<<1), - LOCATION_POS_TECH_WIFI_BIT = (1<<2), - LOCATION_POS_TECH_SENSORS_BIT = (1<<3), - LOCATION_POS_TECH_REFERENCE_LOCATION_BIT = (1<<4), - LOCATION_POS_TECH_INJECTED_COARSE_POSITION_BIT = (1<<5), - LOCATION_POS_TECH_AFLT_BIT = (1<<6), - LOCATION_POS_TECH_HYBRID_BIT = (1<<7), - LOCATION_POS_TECH_PPE_BIT = (1<<8) -} GnssLocationPosTechBits; - -typedef uint32_t GnssLocationPosDataMask; -typedef enum { - LOCATION_NAV_DATA_HAS_LONG_ACCEL_BIT = (1<<0), // Navigation data has Forward Acceleration - LOCATION_NAV_DATA_HAS_LAT_ACCEL_BIT = (1<<1), // Navigation data has Sideward Acceleration - LOCATION_NAV_DATA_HAS_VERT_ACCEL_BIT = (1<<2), // Navigation data has Vertical Acceleration - LOCATION_NAV_DATA_HAS_YAW_RATE_BIT = (1<<3), // Navigation data has Heading Rate - LOCATION_NAV_DATA_HAS_PITCH_BIT = (1<<4) // Navigation data has Body pitch -} GnssLocationPosDataBits; - -typedef uint32_t GnssLocationInfoFlagMask; -typedef enum { - GNSS_LOCATION_INFO_ALTITUDE_MEAN_SEA_LEVEL_BIT = (1<<0), // valid altitude mean sea level - GNSS_LOCATION_INFO_DOP_BIT = (1<<1), // valid pdop, hdop, and vdop - GNSS_LOCATION_INFO_MAGNETIC_DEVIATION_BIT = (1<<2), // valid magnetic deviation - GNSS_LOCATION_INFO_HOR_RELIABILITY_BIT = (1<<3), // valid horizontal reliability - GNSS_LOCATION_INFO_VER_RELIABILITY_BIT = (1<<4), // valid vertical reliability - GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MAJOR_BIT = (1<<5), // valid elipsode semi major - GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MINOR_BIT = (1<<6), // valid elipsode semi minor - GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_AZIMUTH_BIT = (1<<7), // valid accuracy elipsode azimuth - GNSS_LOCATION_INFO_GNSS_SV_USED_DATA_BIT = (1<<8), // valid gnss sv used in pos data - GNSS_LOCATION_INFO_NAV_SOLUTION_MASK_BIT = (1<<9), // valid navSolutionMask - GNSS_LOCATION_INFO_POS_TECH_MASK_BIT = (1<<10),// valid LocPosTechMask - GNSS_LOCATION_INFO_SV_SOURCE_INFO_BIT = (1<<11),// valid LocSvInfoSource - GNSS_LOCATION_INFO_POS_DYNAMICS_DATA_BIT = (1<<12),// valid position dynamics data - GNSS_LOCATION_INFO_GPS_TIME_BIT = (1<<13),// valid GPS Time - GNSS_LOCATION_INFO_EXT_DOP_BIT = (1<<14) // valid gdop, tdop -} GnssLocationInfoFlagBits; - -typedef enum { - GEOFENCE_BREACH_ENTER = 0, - GEOFENCE_BREACH_EXIT, - GEOFENCE_BREACH_DWELL_IN, - GEOFENCE_BREACH_DWELL_OUT, - GEOFENCE_BREACH_UNKNOWN, -} GeofenceBreachType; - -typedef uint16_t GeofenceBreachTypeMask; -typedef enum { - GEOFENCE_BREACH_ENTER_BIT = (1<<0), - GEOFENCE_BREACH_EXIT_BIT = (1<<1), - GEOFENCE_BREACH_DWELL_IN_BIT = (1<<2), - GEOFENCE_BREACH_DWELL_OUT_BIT = (1<<3), -} GeofenceBreachTypeBits; - -typedef enum { - GEOFENCE_STATUS_AVAILABILE_NO = 0, - GEOFENCE_STATUS_AVAILABILE_YES, -} GeofenceStatusAvailable; - -typedef uint32_t LocationCapabilitiesMask; -typedef enum { - // supports startTracking API with minInterval param - LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT = (1<<0), - // supports startBatching API with minInterval param - LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT = (1<<1), - // supports startTracking API with minDistance param - LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT = (1<<2), - // supports startBatching API with minDistance param - LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT = (1<<3), - // supports addGeofences API - LOCATION_CAPABILITIES_GEOFENCE_BIT = (1<<4), - // supports GnssMeasurementsCallback - LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT = (1<<5), - // supports startTracking/startBatching API with LocationOptions.mode of MSB (Ms Based) - LOCATION_CAPABILITIES_GNSS_MSB_BIT = (1<<6), - // supports startTracking/startBatching API with LocationOptions.mode of MSA (MS Assisted) - LOCATION_CAPABILITIES_GNSS_MSA_BIT = (1<<7), - // supports debug nmea sentences in the debugNmeaCallback - LOCATION_CAPABILITIES_DEBUG_NMEA_BIT = (1<<8), - // support outdoor trip batching - LOCATION_CAPABILITIES_OUTDOOR_TRIP_BATCHING_BIT = (1<<9) -} LocationCapabilitiesBits; - -typedef enum { - LOCATION_TECHNOLOGY_TYPE_GNSS = 0, -} LocationTechnologyType; - -// Configures how GPS is locked when GPS is disabled (through GnssDisable) -typedef enum { - GNSS_CONFIG_GPS_LOCK_NONE = 0, // gps is not locked when GPS is disabled (GnssDisable) - GNSS_CONFIG_GPS_LOCK_MO, // gps mobile originated (MO) is locked when GPS is disabled - GNSS_CONFIG_GPS_LOCK_NI, // gps network initiated (NI) is locked when GPS is disabled - GNSS_CONFIG_GPS_LOCK_MO_AND_NI,// gps MO and NI is locked when GPS is disabled -} GnssConfigGpsLock; - -// SUPL version -typedef enum { - GNSS_CONFIG_SUPL_VERSION_1_0_0 = 1, - GNSS_CONFIG_SUPL_VERSION_2_0_0, - GNSS_CONFIG_SUPL_VERSION_2_0_2, -} GnssConfigSuplVersion; - -// LTE Positioning Profile -typedef enum { - GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE = 0, // RRLP on LTE (Default) - GNSS_CONFIG_LPP_PROFILE_USER_PLANE, // LPP User Plane (UP) on LTE - GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE, // LPP_Control_Plane (CP) - GNSS_CONFIG_LPP_PROFILE_USER_PLANE_AND_CONTROL_PLANE, // Both LPP UP and CP -} GnssConfigLppProfile; - -// Technology for LPPe Control Plane -typedef uint16_t GnssConfigLppeControlPlaneMask; -typedef enum { - GNSS_CONFIG_LPPE_CONTROL_PLANE_DBH_BIT = (1<<0), // DBH - GNSS_CONFIG_LPPE_CONTROL_PLANE_WLAN_AP_MEASUREMENTS_BIT = (1<<1), // WLAN_AP_MEASUREMENTS - GNSS_CONFIG_LPPE_CONTROL_PLANE_SRN_AP_MEASUREMENTS_BIT = (1<<2), // SRN_AP_MEASUREMENTS - GNSS_CONFIG_LPPE_CONTROL_PLANE_SENSOR_BARO_MEASUREMENTS_BIT = (1<<3), - // SENSOR_BARO_MEASUREMENTS -} GnssConfigLppeControlPlaneBits; - -// Technology for LPPe User Plane -typedef uint16_t GnssConfigLppeUserPlaneMask; -typedef enum { - GNSS_CONFIG_LPPE_USER_PLANE_DBH_BIT = (1<<0), // DBH - GNSS_CONFIG_LPPE_USER_PLANE_WLAN_AP_MEASUREMENTS_BIT = (1<<1), // WLAN_AP_MEASUREMENTS - GNSS_CONFIG_LPPE_USER_PLANE_SRN_AP_MEASUREMENTS_BIT = (1<<2), // SRN_AP_MEASUREMENTS - GNSS_CONFIG_LPPE_USER_PLANE_SENSOR_BARO_MEASUREMENTS_BIT = (1<<3), - // SENSOR_BARO_MEASUREMENTS -} GnssConfigLppeUserPlaneBits; - -// Positioning Protocol on A-GLONASS system -typedef uint16_t GnssConfigAGlonassPositionProtocolMask; -typedef enum { - GNSS_CONFIG_RRC_CONTROL_PLANE_BIT = (1<<0), // RRC Control Plane - GNSS_CONFIG_RRLP_USER_PLANE_BIT = (1<<1), // RRLP User Plane - GNSS_CONFIG_LLP_USER_PLANE_BIT = (1<<2), // LPP User Plane - GNSS_CONFIG_LLP_CONTROL_PLANE_BIT = (1<<3), // LPP Control Plane -} GnssConfigAGlonassPositionProtocolBits; - -typedef enum { - GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_NO = 0, - GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_YES, -} GnssConfigEmergencyPdnForEmergencySupl; - -typedef enum { - GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO = 0, - GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_YES, -} GnssConfigSuplEmergencyServices; - -typedef uint16_t GnssConfigSuplModeMask; -typedef enum { - GNSS_CONFIG_SUPL_MODE_MSB_BIT = (1<<0), - GNSS_CONFIG_SUPL_MODE_MSA_BIT = (1<<1), -} GnssConfigSuplModeBits; - -typedef uint32_t GnssConfigFlagsMask; -typedef enum { - GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT = (1<<0), - GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT = (1<<1), - GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT = (1<<2), - GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT = (1<<3), - GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT = (1<<4), - GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT = (1<<5), - GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT = (1<<6), - GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT = (1<<7), - GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT = (1<<8), - GNSS_CONFIG_FLAGS_SUPL_MODE_BIT = (1<<9), -} GnssConfigFlagsBits; - -typedef enum { - GNSS_NI_ENCODING_TYPE_NONE = 0, - GNSS_NI_ENCODING_TYPE_GSM_DEFAULT, - GNSS_NI_ENCODING_TYPE_UTF8, - GNSS_NI_ENCODING_TYPE_UCS2, -} GnssNiEncodingType; - -typedef enum { - GNSS_NI_TYPE_VOICE = 0, - GNSS_NI_TYPE_SUPL, - GNSS_NI_TYPE_CONTROL_PLANE, - GNSS_NI_TYPE_EMERGENCY_SUPL -} GnssNiType; - -typedef uint16_t GnssNiOptionsMask; -typedef enum { - GNSS_NI_OPTIONS_NOTIFICATION_BIT = (1<<0), - GNSS_NI_OPTIONS_VERIFICATION_BIT = (1<<1), - GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT = (1<<2), -} GnssNiOptionsBits; - -typedef enum { - GNSS_NI_RESPONSE_ACCEPT = 1, - GNSS_NI_RESPONSE_DENY, - GNSS_NI_RESPONSE_NO_RESPONSE, - GNSS_NI_RESPONSE_IGNORE, -} GnssNiResponse; - -typedef enum { - GNSS_SV_TYPE_UNKNOWN = 0, - GNSS_SV_TYPE_GPS, - GNSS_SV_TYPE_SBAS, - GNSS_SV_TYPE_GLONASS, - GNSS_SV_TYPE_QZSS, - GNSS_SV_TYPE_BEIDOU, - GNSS_SV_TYPE_GALILEO, -} GnssSvType; - -typedef enum { - GNSS_EPH_TYPE_UNKNOWN = 0, - GNSS_EPH_TYPE_EPHEMERIS, - GNSS_EPH_TYPE_ALMANAC, -} GnssEphemerisType; - -typedef enum { - GNSS_EPH_SOURCE_UNKNOWN = 0, - GNSS_EPH_SOURCE_DEMODULATED, - GNSS_EPH_SOURCE_SUPL_PROVIDED, - GNSS_EPH_SOURCE_OTHER_SERVER_PROVIDED, - GNSS_EPH_SOURCE_LOCAL, -} GnssEphemerisSource; - -typedef enum { - GNSS_EPH_HEALTH_UNKNOWN = 0, - GNSS_EPH_HEALTH_GOOD, - GNSS_EPH_HEALTH_BAD, -} GnssEphemerisHealth; - -typedef uint16_t GnssSvOptionsMask; -typedef enum { - GNSS_SV_OPTIONS_HAS_EPHEMER_BIT = (1<<0), - GNSS_SV_OPTIONS_HAS_ALMANAC_BIT = (1<<1), - GNSS_SV_OPTIONS_USED_IN_FIX_BIT = (1<<2), -} GnssSvOptionsBits; - -typedef enum { - GNSS_ASSISTANCE_TYPE_SUPL = 0, - GNSS_ASSISTANCE_TYPE_C2K, -} GnssAssistanceType; - -typedef enum { - GNSS_SUPL_MODE_STANDALONE = 0, - GNSS_SUPL_MODE_MSB, - GNSS_SUPL_MODE_MSA, -} GnssSuplMode; - -typedef enum { - BATCHING_MODE_ROUTINE = 0, // positions are reported when batched positions memory is full - BATCHING_MODE_TRIP, // positions are reported when a certain distance is covered - BATCHING_MODE_NO_AUTO_REPORT // no report of positions automatically, instead queried on demand -} BatchingMode; - -typedef enum { - BATCHING_STATUS_TRIP_COMPLETED = 0, - BATCHING_STATUS_POSITION_AVAILABE, - BATCHING_STATUS_POSITION_UNAVAILABLE -} BatchingStatus; - -typedef uint16_t GnssMeasurementsAdrStateMask; -typedef enum { - GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_UNKNOWN = 0, - GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT = (1<<0), - GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT = (1<<1), - GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT = (1<<2), -} GnssMeasurementsAdrStateBits; - -typedef uint32_t GnssMeasurementsDataFlagsMask; -typedef enum { - GNSS_MEASUREMENTS_DATA_SV_ID_BIT = (1<<0), - GNSS_MEASUREMENTS_DATA_SV_TYPE_BIT = (1<<1), - GNSS_MEASUREMENTS_DATA_STATE_BIT = (1<<2), - GNSS_MEASUREMENTS_DATA_RECEIVED_SV_TIME_BIT = (1<<3), - GNSS_MEASUREMENTS_DATA_RECEIVED_SV_TIME_UNCERTAINTY_BIT = (1<<4), - GNSS_MEASUREMENTS_DATA_CARRIER_TO_NOISE_BIT = (1<<5), - GNSS_MEASUREMENTS_DATA_PSEUDORANGE_RATE_BIT = (1<<6), - GNSS_MEASUREMENTS_DATA_PSEUDORANGE_RATE_UNCERTAINTY_BIT = (1<<7), - GNSS_MEASUREMENTS_DATA_ADR_STATE_BIT = (1<<8), - GNSS_MEASUREMENTS_DATA_ADR_BIT = (1<<9), - GNSS_MEASUREMENTS_DATA_ADR_UNCERTAINTY_BIT = (1<<10), - GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT = (1<<11), - GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT = (1<<12), - GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT = (1<<13), - GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT = (1<<14), - GNSS_MEASUREMENTS_DATA_MULTIPATH_INDICATOR_BIT = (1<<15), - GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT = (1<<16), - GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT = (1<<17), -} GnssMeasurementsDataFlagsBits; - -typedef uint32_t GnssMeasurementsStateMask; -typedef enum { - GNSS_MEASUREMENTS_STATE_UNKNOWN_BIT = 0, - GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT = (1<<0), - GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT = (1<<1), - GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT = (1<<2), - GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT = (1<<3), - GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT = (1<<4), - GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT = (1<<5), - GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT = (1<<6), - GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT = (1<<7), - GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT = (1<<8), - GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT = (1<<9), - GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT = (1<<10), - GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT = (1<<11), - GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT = (1<<12), - GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT = (1<<13), -} GnssMeasurementsStateBits; - -typedef enum { - GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_UNKNOWN = 0, - GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_PRESENT, - GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_NOT_PRESENT, -} GnssMeasurementsMultipathIndicator; - -typedef uint32_t GnssMeasurementsClockFlagsMask; -typedef enum { - GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT = (1<<0), - GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_BIT = (1<<1), - GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT = (1<<2), - GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT = (1<<3), - GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT = (1<<4), - GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT = (1<<5), - GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_BIT = (1<<6), - GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_UNCERTAINTY_BIT = (1<<7), - GNSS_MEASUREMENTS_CLOCK_FLAGS_HW_CLOCK_DISCONTINUITY_COUNT_BIT = (1<<8), -} GnssMeasurementsClockFlagsBits; - -typedef uint32_t GnssAidingDataSvMask; -typedef enum { - GNSS_AIDING_DATA_SV_EPHEMERIS_BIT = (1<<0), // ephemeris - GNSS_AIDING_DATA_SV_ALMANAC_BIT = (1<<1), // almanac - GNSS_AIDING_DATA_SV_HEALTH_BIT = (1<<2), // health - GNSS_AIDING_DATA_SV_DIRECTION_BIT = (1<<3), // direction - GNSS_AIDING_DATA_SV_STEER_BIT = (1<<4), // steer - GNSS_AIDING_DATA_SV_ALMANAC_CORR_BIT = (1<<5), // almanac correction - GNSS_AIDING_DATA_SV_BLACKLIST_BIT = (1<<6), // blacklist SVs - GNSS_AIDING_DATA_SV_SA_DATA_BIT = (1<<7), // sensitivity assistance data - GNSS_AIDING_DATA_SV_NO_EXIST_BIT = (1<<8), // SV does not exist - GNSS_AIDING_DATA_SV_IONOSPHERE_BIT = (1<<9), // ionosphere correction - GNSS_AIDING_DATA_SV_TIME_BIT = (1<<10),// reset satellite time -} GnssAidingDataSvBits; - -typedef uint32_t GnssAidingDataSvTypeMask; -typedef enum { - GNSS_AIDING_DATA_SV_TYPE_GPS_BIT = (1<<0), - GNSS_AIDING_DATA_SV_TYPE_GLONASS_BIT = (1<<1), - GNSS_AIDING_DATA_SV_TYPE_QZSS_BIT = (1<<2), - GNSS_AIDING_DATA_SV_TYPE_BEIDOU_BIT = (1<<3), - GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT = (1<<4), -} GnssAidingDataSvTypeBits; - -typedef enum -{ - GNSS_LOC_SV_SYSTEM_GPS = 1, - /**< GPS satellite. */ - GNSS_LOC_SV_SYSTEM_GALILEO = 2, - /**< GALILEO satellite. */ - GNSS_LOC_SV_SYSTEM_SBAS = 3, - /**< SBAS satellite. */ - GNSS_LOC_SV_SYSTEM_COMPASS = 4, - /**< COMPASS satellite. */ - GNSS_LOC_SV_SYSTEM_GLONASS = 5, - /**< GLONASS satellite. */ - GNSS_LOC_SV_SYSTEM_BDS = 6, - /**< BDS satellite. */ - GNSS_LOC_SV_SYSTEM_QZSS = 7 - /**< QZSS satellite. */ -} Gnss_LocSvSystemEnumType; - -typedef uint32_t GnssSystemTimeStructTypeFlags; -typedef enum { - GNSS_SYSTEM_TIME_WEEK_VALID = (1 << 0), - GNSS_SYSTEM_TIME_WEEK_MS_VALID = (1 << 1), - GNSS_SYSTEM_CLK_TIME_BIAS_VALID = (1 << 2), - GNSS_SYSTEM_CLK_TIME_BIAS_UNC_VALID = (1 << 3), - GNSS_SYSTEM_REF_FCOUNT_VALID = (1 << 4), - GNSS_SYSTEM_NUM_CLOCK_RESETS_VALID = (1 << 5) -} GnssSystemTimeTypeBits; - -typedef uint32_t GnssGloTimeStructTypeFlags; -typedef enum { - GNSS_CLO_DAYS_VALID = (1 << 0), - GNSS_GLOS_MSEC_VALID = (1 << 1), - GNSS_GLO_CLK_TIME_BIAS_VALID = (1 << 2), - GNSS_GLO_CLK_TIME_BIAS_UNC_VALID = (1 << 3), - GNSS_GLO_REF_FCOUNT_VALID = (1 << 4), - GNSS_GLO_NUM_CLOCK_RESETS_VALID = (1 << 5), - GNSS_GLO_FOUR_YEAR_VALID = (1 << 6) -} GnssGloTimeTypeBits; - -typedef struct { - GnssAidingDataSvMask svMask; // bitwise OR of GnssAidingDataSvBits - GnssAidingDataSvTypeMask svTypeMask; // bitwise OR of GnssAidingDataSvTypeBits -} GnssAidingDataSv; - -typedef uint32_t GnssAidingDataCommonMask; -typedef enum { - GNSS_AIDING_DATA_COMMON_POSITION_BIT = (1<<0), // position estimate - GNSS_AIDING_DATA_COMMON_TIME_BIT = (1<<1), // reset all clock values - GNSS_AIDING_DATA_COMMON_UTC_BIT = (1<<2), // UTC estimate - GNSS_AIDING_DATA_COMMON_RTI_BIT = (1<<3), // RTI - GNSS_AIDING_DATA_COMMON_FREQ_BIAS_EST_BIT = (1<<4), // frequency bias estimate - GNSS_AIDING_DATA_COMMON_CELLDB_BIT = (1<<5), // all celldb info -} GnssAidingDataCommonBits; - -typedef struct { - GnssAidingDataCommonMask mask; // bitwise OR of GnssAidingDataCommonBits -} GnssAidingDataCommon; - -typedef struct { - bool deleteAll; // if true, delete all aiding data and ignore other params - GnssAidingDataSv sv; // SV specific aiding data - GnssAidingDataCommon common; // common aiding data -} GnssAidingData; - -typedef struct { - size_t size; // set to sizeof(Location) - LocationFlagsMask flags; // bitwise OR of LocationFlagsBits to mark which params are valid - uint64_t timestamp; // UTC timestamp for location fix, milliseconds since January 1, 1970 - double latitude; // in degrees - double longitude; // in degrees - double altitude; // in meters above the WGS 84 reference ellipsoid - float speed; // in meters per second - float bearing; // in degrees; range [0, 360) - float accuracy; // in meters - float verticalAccuracy; // in meters - float speedAccuracy; // in meters/second - float bearingAccuracy; // in degrees (0 to 359.999) - LocationTechnologyMask techMask; -} Location; - -typedef struct { - size_t size; // set to sizeof(LocationOptions) - uint32_t minInterval; // in milliseconds - uint32_t minDistance; // in meters. if minDistance > 0, gnssSvCallback/gnssNmeaCallback/ - // gnssMeasurementsCallback may not be called - GnssSuplMode mode; // Standalone/MS-Based/MS-Assisted -} LocationOptions; - -typedef struct { - size_t size; - BatchingMode batchingMode; -} BatchingOptions; - -typedef struct { - size_t size; - BatchingStatus batchingStatus; -} BatchingStatusInfo; - -typedef struct { - size_t size; // set to sizeof(GeofenceOption) - GeofenceBreachTypeMask breachTypeMask; // bitwise OR of GeofenceBreachTypeBits - uint32_t responsiveness; // in milliseconds - uint32_t dwellTime; // in seconds -} GeofenceOption; - -typedef struct { - size_t size; // set to sizeof(GeofenceInfo) - double latitude; // in degrees - double longitude; // in degrees - double radius; // in meters -} GeofenceInfo; - -typedef struct { - size_t size; // set to sizeof(GeofenceBreachNotification) - size_t count; // number of ids in array - uint32_t* ids; // array of ids that have breached - Location location; // location associated with breach - GeofenceBreachType type; // type of breach - uint64_t timestamp; // timestamp of breach -} GeofenceBreachNotification; - -typedef struct { - size_t size; // set to sizeof(GeofenceBreachNotification) - GeofenceStatusAvailable available; // GEOFENCE_STATUS_AVAILABILE_NO/_YES - LocationTechnologyType techType; // GNSS -} GeofenceStatusNotification; - -typedef struct { - uint64_t gpsSvUsedIdsMask; - uint64_t gloSvUsedIdsMask; - uint64_t galSvUsedIdsMask; - uint64_t bdsSvUsedIdsMask; - uint64_t qzssSvUsedIdsMask; -} GnssLocationSvUsedInPosition; - -/** @struct - Body Frame parameters -*/ -typedef struct { - GnssLocationPosDataMask bodyFrameDataMask; // Contains Body frame LocPosDataMask bits - float longAccel; // Forward Acceleration in body frame (m/s2) - float latAccel; // Sideward Acceleration in body frame (m/s2) - float vertAccel; // Vertical Acceleration in body frame (m/s2) - float yawRate; // Heading Rate (Radians/second) - float pitch; // Body pitch (Radians) -} GnssLocationPositionDynamics; - -typedef struct { - /** Validity mask for below fields */ - GnssSystemTimeStructTypeFlags validityMask; - /** Extended week number at reference tick. - Unit: Week. - Set to 65535 if week number is unknown. - For GPS: - Calculated from midnight, Jan. 6, 1980. - OTA decoded 10 bit GPS week is extended to map between: - [NV6264 to (NV6264 + 1023)]. - NV6264: Minimum GPS week number configuration. - Default value of NV6264: 1738 - For BDS: - Calculated from 00:00:00 on January 1, 2006 of Coordinated Universal Time (UTC). - For GAL: - Calculated from 00:00 UT on Sunday August 22, 1999 (midnight between August 21 and August 22). - */ - uint16_t systemWeek; - /** Time in to the current week at reference tick. - Unit: Millisecond. Range: 0 to 604799999. - Check for systemClkTimeUncMs before use */ - uint32_t systemMsec; - /** System clock time bias (sub-millisecond) - Units: Millisecond - Note: System time (TOW Millisecond) = systemMsec - systemClkTimeBias. - Check for systemClkTimeUncMs before use. */ - float systemClkTimeBias; - /** Single sided maximum time bias uncertainty - Units: Millisecond */ - float systemClkTimeUncMs; - /** FCount (free running HW timer) value. Don't use for relative time purpose - due to possible discontinuities. - Unit: Millisecond */ - uint32_t refFCount; - /** Number of clock resets/discontinuities detected, affecting the local hardware counter value. */ - uint32_t numClockResets; -} GnssSystemTimeStructType; - -typedef struct { - /** GLONASS day number in four years. Refer to GLONASS ICD. - Applicable only for GLONASS and shall be ignored for other constellations. - If unknown shall be set to 65535 */ - uint16_t gloDays; - /** Validity mask for below fields */ - GnssGloTimeStructTypeFlags validityMask; - /** GLONASS time of day in Millisecond. Refer to GLONASS ICD. - Units: Millisecond - Check for gloClkTimeUncMs before use */ - uint32_t gloMsec; - /** GLONASS clock time bias (sub-millisecond) - Units: Millisecond - Note: GLO time (TOD Millisecond) = gloMsec - gloClkTimeBias. - Check for gloClkTimeUncMs before use. */ - float gloClkTimeBias; - /** Single sided maximum time bias uncertainty - Units: Millisecond */ - float gloClkTimeUncMs; - /** FCount (free running HW timer) value. Don't use for relative time purpose - due to possible discontinuities. - Unit: Millisecond */ - uint32_t refFCount; - /** Number of clock resets/discontinuities detected, affecting the local hardware counter value. */ - uint32_t numClockResets; - /** GLONASS four year number from 1996. Refer to GLONASS ICD. - Applicable only for GLONASS and shall be ignored for other constellations. - If unknown shall be set to 255 */ - uint8_t gloFourYear; -} GnssGloTimeStructType; - -typedef union { - GnssSystemTimeStructType gpsSystemTime; - GnssSystemTimeStructType galSystemTime; - GnssSystemTimeStructType bdsSystemTime; - GnssSystemTimeStructType qzssSystemTime; - GnssGloTimeStructType gloSytemTime; -} SystemTimeStructUnion; - /** Time applicability of PVT report */ -typedef struct { - /** Specifies GNSS system time reported. Mandatory field */ - Gnss_LocSvSystemEnumType gnssSystemTimeSrc; - /** Reporting of GPS system time is recommended. - If GPS time is unknown & other satellite system time is known, - it should be reported. - Mandatory field - */ - SystemTimeStructUnion u; -} GnssSystemTime; - -typedef struct { - size_t size; // set to sizeof(GnssLocationInfo) - GnssLocationInfoFlagMask flags; // bitwise OR of GnssLocationInfoBits for param validity - float altitudeMeanSeaLevel; // altitude wrt mean sea level - float pdop; // position dilusion of precision - float hdop; // horizontal dilusion of precision - float vdop; // vertical dilusion of precision - float gdop; // geometric dilution of precision - float tdop; // time dilution of precision - float magneticDeviation; // magnetic deviation - LocationReliability horReliability; // horizontal reliability - LocationReliability verReliability; // vertical reliability - float horUncEllipseSemiMajor; // horizontal elliptical accuracy semi-major axis - float horUncEllipseSemiMinor; // horizontal elliptical accuracy semi-minor axis - float horUncEllipseOrientAzimuth; // horizontal elliptical accuracy azimuth - float northVelocity; // North Velocity.Unit: Meters/sec - float eastVelocity; // East Velocity - float upVelocity; - float northVelocityStdDeviation; - float eastVelocityStdDeviation; - float upVelocityStdDeviation; - GnssLocationSvUsedInPosition svUsedInPosition;// Gnss sv used in position data - GnssLocationNavSolutionMask navSolutionMask; // Nav solution mask to indicate sbas corrections - GnssLocationPosTechMask posTechMask; // Position technology used in computing this fix - GnssLocationPositionDynamics bodyFrameData; // Body Frame Dynamics: 4wayAcceleration and - // pitch set with validity - GnssSystemTime gnssSystemTime; // GNSS System Time - Location location; -} GnssLocationInfoNotification; - -typedef struct { - size_t size; // set to sizeof(GnssNiNotification) - GnssNiType type; // type of NI (Voice, SUPL, Control Plane) - GnssNiOptionsMask options; // bitwise OR of GnssNiOptionsBits - uint32_t timeout; // time (seconds) to wait for user input - GnssNiResponse timeoutResponse; // the response that should be sent when timeout expires - char requestor[GNSS_NI_REQUESTOR_MAX]; // the requestor that is making the request - GnssNiEncodingType requestorEncoding; // the encoding type for requestor - char message[GNSS_NI_MESSAGE_ID_MAX]; // the message to show user - GnssNiEncodingType messageEncoding; // the encoding type for message - char extras[GNSS_NI_MESSAGE_ID_MAX]; -} GnssNiNotification; - -typedef struct { - size_t size; // set to sizeof(GnssSv) - uint16_t svId; // Unique Identifier - GnssSvType type; // type of SV (GPS, SBAS, GLONASS, QZSS, BEIDOU, GALILEO) - float cN0Dbhz; // signal strength - float elevation; // elevation of SV (in degrees) - float azimuth; // azimuth of SV (in degrees) - GnssSvOptionsMask gnssSvOptionsMask; // Bitwise OR of GnssSvOptionsBits -} GnssSv; - -typedef struct { - size_t size; // set to sizeof(GnssConfigSetAssistanceServer) - GnssAssistanceType type; // SUPL or C2K - const char* hostName; // null terminated string - uint32_t port; // port of server -} GnssConfigSetAssistanceServer; - -typedef struct { - size_t size; // set to sizeof(GnssMeasurementsData) - GnssMeasurementsDataFlagsMask flags; // bitwise OR of GnssMeasurementsDataFlagsBits - int16_t svId; - GnssSvType svType; - double timeOffsetNs; - GnssMeasurementsStateMask stateMask; // bitwise OR of GnssMeasurementsStateBits - int64_t receivedSvTimeNs; - int64_t receivedSvTimeUncertaintyNs; - double carrierToNoiseDbHz; - double pseudorangeRateMps; - double pseudorangeRateUncertaintyMps; - GnssMeasurementsAdrStateMask adrStateMask; // bitwise OR of GnssMeasurementsAdrStateBits - double adrMeters; - double adrUncertaintyMeters; - float carrierFrequencyHz; - int64_t carrierCycles; - double carrierPhase; - double carrierPhaseUncertainty; - GnssMeasurementsMultipathIndicator multipathIndicator; - double signalToNoiseRatioDb; - double agcLevelDb; -} GnssMeasurementsData; - -typedef struct { - size_t size; // set to sizeof(GnssMeasurementsClock) - GnssMeasurementsClockFlagsMask flags; // bitwise OR of GnssMeasurementsClockFlagsBits - int16_t leapSecond; - int64_t timeNs; - double timeUncertaintyNs; - int64_t fullBiasNs; - double biasNs; - double biasUncertaintyNs; - double driftNsps; - double driftUncertaintyNsps; - uint32_t hwClockDiscontinuityCount; -} GnssMeasurementsClock; - -typedef struct { - size_t size; // set to sizeof(GnssSvNotification) - size_t count; // number of SVs in the GnssSv array - GnssSv gnssSvs[GNSS_SV_MAX]; // information on a number of SVs -} GnssSvNotification; - -typedef struct { - size_t size; // set to sizeof(GnssNmeaNotification) - uint64_t timestamp; // timestamp - const char* nmea; // nmea text - size_t length; // length of the nmea text -} GnssNmeaNotification; - -typedef struct { - size_t size; // set to sizeof(GnssMeasurementsNotification) - size_t count; // number of items in GnssMeasurements array - GnssMeasurementsData measurements[GNSS_MEASUREMENTS_MAX]; - GnssMeasurementsClock clock; // clock -} GnssMeasurementsNotification; - -typedef struct { - size_t size; // set to sizeof(GnssConfig) - GnssConfigFlagsMask flags; // bitwise OR of GnssConfigFlagsBits to mark which params are valid - GnssConfigGpsLock gpsLock; - GnssConfigSuplVersion suplVersion; - GnssConfigSetAssistanceServer assistanceServer; - GnssConfigLppProfile lppProfile; - GnssConfigLppeControlPlaneMask lppeControlPlaneMask; - GnssConfigLppeUserPlaneMask lppeUserPlaneMask; - GnssConfigAGlonassPositionProtocolMask aGlonassPositionProtocolMask; - GnssConfigEmergencyPdnForEmergencySupl emergencyPdnForEmergencySupl; - GnssConfigSuplEmergencyServices suplEmergencyServices; - GnssConfigSuplModeMask suplModeMask; //bitwise OR of GnssConfigSuplModeBits -} GnssConfig; - -typedef struct { - size_t size; // set to sizeof - bool mValid; - Location mLocation; - double verticalAccuracyMeters; - double speedAccuracyMetersPerSecond; - double bearingAccuracyDegrees; - timespec mUtcReported; -} GnssDebugLocation; - -typedef struct { - size_t size; // set to sizeof - bool mValid; - int64_t timeEstimate; - float timeUncertaintyNs; - float frequencyUncertaintyNsPerSec; -} GnssDebugTime; - -typedef struct { - size_t size; // set to sizeof - uint32_t svid; - GnssSvType constellation; - GnssEphemerisType mEphemerisType; - GnssEphemerisSource mEphemerisSource; - GnssEphemerisHealth mEphemerisHealth; - float ephemerisAgeSeconds; - bool serverPredictionIsAvailable; - float serverPredictionAgeSeconds; -} GnssDebugSatelliteInfo; - -typedef struct { - size_t size; // set to sizeof - GnssDebugLocation mLocation; - GnssDebugTime mTime; - std::vector mSatelliteInfo; -} GnssDebugReport; - -/* Provides the capabilities of the system - capabilities callback is called once soon after createInstance is called */ -typedef std::function capabilitiesCallback; - -/* Used by tracking, batching, and miscellanous APIs - responseCallback is called for every Tracking, Batching API, and Miscellanous API */ -typedef std::function responseCallback; - -/* Used by APIs that gets more than one LocationError in it's response - collectiveResponseCallback is called for every geofence API call. - ids array and LocationError array are only valid until collectiveResponseCallback returns. */ -typedef std::function collectiveResponseCallback; - -/* Used for startTracking API, optional can be NULL - trackingCallback is called when delivering a location in a tracking session - broadcasted to all clients, no matter if a session has started by client */ -typedef std::function trackingCallback; - -/* Used for startBatching API, optional can be NULL - batchingCallback is called when delivering locations in a batching session. - broadcasted to all clients, no matter if a session has started by client */ -typedef std::function batchingCallback; - -typedef std::function & listOfCompletedTrips -)> batchingStatusCallback; - -/* Gives GNSS Location information, optional can be NULL - gnssLocationInfoCallback is called only during a tracking session - broadcasted to all clients, no matter if a session has started by client */ -typedef std::function gnssLocationInfoCallback; - -/* Used for addGeofences API, optional can be NULL - geofenceBreachCallback is called when any number of geofences have a state change */ -typedef std::function geofenceBreachCallback; - -/* Used for addGeofences API, optional can be NULL - geofenceStatusCallback is called when any number of geofences have a status change */ -typedef std::function geofenceStatusCallback; - -/* Network Initiated request, optional can be NULL - This callback should be responded to by calling gnssNiResponse */ -typedef std::function gnssNiCallback; - -/* Gives GNSS SV information, optional can be NULL - gnssSvCallback is called only during a tracking session - broadcasted to all clients, no matter if a session has started by client */ -typedef std::function gnssSvCallback; - -/* Gives GNSS NMEA data, optional can be NULL - gnssNmeaCallback is called only during a tracking session - broadcasted to all clients, no matter if a session has started by client */ -typedef std::function gnssNmeaCallback; - -/* Gives GNSS Measurements information, optional can be NULL - gnssMeasurementsCallback is called only during a tracking session - broadcasted to all clients, no matter if a session has started by client */ -typedef std::function gnssMeasurementsCallback; - -typedef struct { - size_t size; // set to sizeof(LocationCallbacks) - capabilitiesCallback capabilitiesCb; // mandatory - responseCallback responseCb; // mandatory - collectiveResponseCallback collectiveResponseCb; // mandatory - trackingCallback trackingCb; // optional - batchingCallback batchingCb; // optional - geofenceBreachCallback geofenceBreachCb; // optional - geofenceStatusCallback geofenceStatusCb; // optional - gnssLocationInfoCallback gnssLocationInfoCb; // optional - gnssNiCallback gnssNiCb; // optional - gnssSvCallback gnssSvCb; // optional - gnssNmeaCallback gnssNmeaCb; // optional - gnssMeasurementsCallback gnssMeasurementsCb; // optional - batchingStatusCallback batchingStatusCb; // optional -} LocationCallbacks; - -class LocationAPI +class LocationAPI : public ILocationAPI { private: LocationAPI(); @@ -984,7 +51,7 @@ public: /* updates/changes the callbacks that will be called. mandatory callbacks must be present for callbacks to be successfully updated no return value */ - void updateCallbacks(LocationCallbacks&); + virtual void updateCallbacks(LocationCallbacks&) override; /* ================================== TRACKING ================================== */ @@ -997,20 +64,20 @@ public: LOCATION_ERROR_ALREADY_STARTED if a startTracking session is already in progress LOCATION_ERROR_CALLBACK_MISSING if no trackingCallback was passed in createInstance LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameter is invalid */ - uint32_t startTracking(LocationOptions&); // returns session id + virtual uint32_t startTracking(LocationOptions&) override; /* stopTracking stops a tracking session associated with id parameter. responseCallback returns: LOCATION_ERROR_SUCCESS if successful LOCATION_ERROR_ID_UNKNOWN if id is not associated with a tracking session */ - void stopTracking(uint32_t id); + virtual void stopTracking(uint32_t id) override; /* updateTrackingOptions changes the LocationOptions of a tracking session associated with id responseCallback returns: LOCATION_ERROR_SUCCESS if successful LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameters are invalid LOCATION_ERROR_ID_UNKNOWN if id is not associated with a tracking session */ - void updateTrackingOptions(uint32_t id, LocationOptions&); + virtual void updateTrackingOptions(uint32_t id, LocationOptions&) override; /* ================================== BATCHING ================================== */ @@ -1029,20 +96,20 @@ public: LOCATION_ERROR_CALLBACK_MISSING if no batchingCallback was passed in createInstance LOCATION_ERROR_INVALID_PARAMETER if a parameter is invalid LOCATION_ERROR_NOT_SUPPORTED if batching is not supported */ - uint32_t startBatching(LocationOptions&, BatchingOptions&); // returns session id + virtual uint32_t startBatching(LocationOptions&, BatchingOptions&) override; /* stopBatching stops a batching session associated with id parameter. responseCallback returns: LOCATION_ERROR_SUCCESS if successful LOCATION_ERROR_ID_UNKNOWN if id is not associated with batching session */ - void stopBatching(uint32_t id); + virtual void stopBatching(uint32_t id) override; /* updateBatchingOptions changes the LocationOptions of a batching session associated with id responseCallback returns: LOCATION_ERROR_SUCCESS if successful LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameters are invalid LOCATION_ERROR_ID_UNKNOWN if id is not associated with a batching session */ - void updateBatchingOptions(uint32_t id, LocationOptions&, BatchingOptions&); + virtual void updateBatchingOptions(uint32_t id, LocationOptions&, BatchingOptions&) override; /* getBatchedLocations gets a number of locations that are currently stored/batched on the low power processor, delivered by the batchingCallback passed in createInstance. @@ -1051,7 +118,7 @@ public: LOCATION_ERROR_SUCCESS if successful, will be followed by batchingCallback call LOCATION_ERROR_CALLBACK_MISSING if no batchingCallback was passed in createInstance LOCATION_ERROR_ID_UNKNOWN if id is not associated with a batching session */ - void getBatchedLocations(uint32_t id, size_t count); + virtual void getBatchedLocations(uint32_t id, size_t count) override; /* ================================== GEOFENCE ================================== */ @@ -1065,14 +132,14 @@ public: LOCATION_ERROR_CALLBACK_MISSING if no geofenceBreachCallback LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid LOCATION_ERROR_NOT_SUPPORTED if geofence is not supported */ - uint32_t* addGeofences(size_t count, GeofenceOption*, GeofenceInfo*); // returns id array + virtual uint32_t* addGeofences(size_t count, GeofenceOption*, GeofenceInfo*) override; /* removeGeofences removes any number of geofences. Caller should delete ids array after removeGeofences returneds. collectiveResponseCallback returns: LOCATION_ERROR_SUCCESS if successful LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */ - void removeGeofences(size_t count, uint32_t* ids); + virtual void removeGeofences(size_t count, uint32_t* ids) override; /* modifyGeofences modifies any number of geofences. Caller should delete ids array after modifyGeofences returns. @@ -1080,7 +147,7 @@ public: LOCATION_ERROR_SUCCESS if successful LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid */ - void modifyGeofences(size_t count, uint32_t* ids, GeofenceOption* options); + virtual void modifyGeofences(size_t count, uint32_t* ids, GeofenceOption* options) override; /* pauseGeofences pauses any number of geofences, which is similar to removeGeofences, only that they can be resumed at any time. Caller should delete ids array after @@ -1088,14 +155,14 @@ public: collectiveResponseCallback returns: LOCATION_ERROR_SUCCESS if successful LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */ - void pauseGeofences(size_t count, uint32_t* ids); + virtual void pauseGeofences(size_t count, uint32_t* ids) override; /* resumeGeofences resumes any number of geofences that are currently paused. Caller should delete ids array after resumeGeofences returns. collectiveResponseCallback returns: LOCATION_ERROR_SUCCESS if successful LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */ - void resumeGeofences(size_t count, uint32_t* ids); + virtual void resumeGeofences(size_t count, uint32_t* ids) override; /* ================================== GNSS ====================================== */ @@ -1104,7 +171,7 @@ public: LOCATION_ERROR_SUCCESS if session was successful LOCATION_ERROR_INVALID_PARAMETER if any parameters in GnssNiResponse are invalid LOCATION_ERROR_ID_UNKNOWN if id does not match a gnssNiCallback */ - void gnssNiResponse(uint32_t id, GnssNiResponse response); + virtual void gnssNiResponse(uint32_t id, GnssNiResponse response) override; }; typedef struct { @@ -1113,7 +180,7 @@ typedef struct { collectiveResponseCallback collectiveResponseCb; // mandatory } LocationControlCallbacks; -class LocationControlAPI +class LocationControlAPI : public ILocationControlAPI { private: LocationControlAPI(); @@ -1162,7 +229,7 @@ public: LOCATION_ERROR_SUCCESS if session was successful LOCATION_ERROR_INVALID_PARAMETER if any other parameters are invalid LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason */ - uint32_t* gnssUpdateConfig(GnssConfig config); + virtual uint32_t* gnssUpdateConfig(GnssConfig config) override; /* delete specific gnss aiding data for testing, which returns a session id that will be returned in responseCallback to match command with response. @@ -1171,7 +238,7 @@ public: LOCATION_ERROR_SUCCESS if successful LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid LOCATION_ERROR_NOT_SUPPORTED if build is not userdebug */ - uint32_t gnssDeleteAidingData(GnssAidingData& data); + virtual uint32_t gnssDeleteAidingData(GnssAidingData& data) override; }; -#endif /* LOCATION_H */ +#endif /* LOCATIONAPI_H */ diff --git a/location/LocationDataTypes.h b/location/LocationDataTypes.h new file mode 100644 index 00000000..d03a8b4d --- /dev/null +++ b/location/LocationDataTypes.h @@ -0,0 +1,967 @@ +/* Copyright (c) 2018 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef LOCATIONDATATYPES_H +#define LOCATIONDATATYPES_H + +#include +#include +#include +#include + +#define GNSS_NI_REQUESTOR_MAX (256) +#define GNSS_NI_MESSAGE_ID_MAX (2048) +#define GNSS_SV_MAX (64) +#define GNSS_MEASUREMENTS_MAX (64) +#define GNSS_UTC_TIME_OFFSET (3657) + +#define GNSS_BUGREPORT_GPS_MIN (1) +#define GNSS_BUGREPORT_SBAS_MIN (120) +#define GNSS_BUGREPORT_GLO_MIN (1) +#define GNSS_BUGREPORT_QZSS_MIN (193) +#define GNSS_BUGREPORT_BDS_MIN (1) +#define GNSS_BUGREPORT_GAL_MIN (1) + +typedef enum { + LOCATION_ERROR_SUCCESS = 0, + LOCATION_ERROR_GENERAL_FAILURE, + LOCATION_ERROR_CALLBACK_MISSING, + LOCATION_ERROR_INVALID_PARAMETER, + LOCATION_ERROR_ID_EXISTS, + LOCATION_ERROR_ID_UNKNOWN, + LOCATION_ERROR_ALREADY_STARTED, + LOCATION_ERROR_GEOFENCES_AT_MAX, + LOCATION_ERROR_NOT_SUPPORTED +} LocationError; + +// Flags to indicate which values are valid in a Location +typedef uint16_t LocationFlagsMask; +typedef enum { + LOCATION_HAS_LAT_LONG_BIT = (1<<0), // location has valid latitude and longitude + LOCATION_HAS_ALTITUDE_BIT = (1<<1), // location has valid altitude + LOCATION_HAS_SPEED_BIT = (1<<2), // location has valid speed + LOCATION_HAS_BEARING_BIT = (1<<3), // location has valid bearing + LOCATION_HAS_ACCURACY_BIT = (1<<4), // location has valid accuracy + LOCATION_HAS_VERTICAL_ACCURACY_BIT = (1<<5), // location has valid vertical accuracy + LOCATION_HAS_SPEED_ACCURACY_BIT = (1<<6), // location has valid speed accuracy + LOCATION_HAS_BEARING_ACCURACY_BIT = (1<<7), // location has valid bearing accuracy +} LocationFlagsBits; + +typedef uint16_t LocationTechnologyMask; +typedef enum { + LOCATION_TECHNOLOGY_GNSS_BIT = (1<<0), // location was calculated using GNSS + LOCATION_TECHNOLOGY_CELL_BIT = (1<<1), // location was calculated using Cell + LOCATION_TECHNOLOGY_WIFI_BIT = (1<<2), // location was calculated using WiFi + LOCATION_TECHNOLOGY_SENSORS_BIT = (1<<3), // location was calculated using Sensors +} LocationTechnologyBits; + +typedef enum { + LOCATION_RELIABILITY_NOT_SET = 0, + LOCATION_RELIABILITY_VERY_LOW, + LOCATION_RELIABILITY_LOW, + LOCATION_RELIABILITY_MEDIUM, + LOCATION_RELIABILITY_HIGH, +} LocationReliability; + +typedef uint32_t GnssLocationNavSolutionMask; +typedef enum { + LOCATION_SBAS_CORRECTION_IONO_BIT = (1<<0), // SBAS ionospheric correction is used + LOCATION_SBAS_CORRECTION_FAST_BIT = (1<<1), // SBAS fast correction is used + LOCATION_SBAS_CORRECTION_LONG_BIT = (1<<2), // SBAS long-tem correction is used + LOCATION_SBAS_INTEGRITY_BIT = (1<<3), // SBAS integrity information is used + LOCATION_NAV_CORRECTION_DGNSS_BIT = (1<<4), // Position Report is DGNSS corrected + LOCATION_NAV_CORRECTION_RTK_BIT = (1<<5), // Position Report is RTK corrected + LOCATION_NAV_CORRECTION_PPP_BIT = (1<<6) // Position Report is PPP corrected +} GnssLocationNavSolutionBits; + +typedef uint32_t GnssLocationPosTechMask; +typedef enum { + LOCATION_POS_TECH_DEFAULT_BIT = 0, + LOCATION_POS_TECH_SATELLITE_BIT = (1<<0), + LOCATION_POS_TECH_CELLID_BIT = (1<<1), + LOCATION_POS_TECH_WIFI_BIT = (1<<2), + LOCATION_POS_TECH_SENSORS_BIT = (1<<3), + LOCATION_POS_TECH_REFERENCE_LOCATION_BIT = (1<<4), + LOCATION_POS_TECH_INJECTED_COARSE_POSITION_BIT = (1<<5), + LOCATION_POS_TECH_AFLT_BIT = (1<<6), + LOCATION_POS_TECH_HYBRID_BIT = (1<<7), + LOCATION_POS_TECH_PPE_BIT = (1<<8) +} GnssLocationPosTechBits; + +typedef uint32_t GnssLocationPosDataMask; +typedef enum { + LOCATION_NAV_DATA_HAS_LONG_ACCEL_BIT = (1<<0), // Navigation data has Forward Acceleration + LOCATION_NAV_DATA_HAS_LAT_ACCEL_BIT = (1<<1), // Navigation data has Sideward Acceleration + LOCATION_NAV_DATA_HAS_VERT_ACCEL_BIT = (1<<2), // Navigation data has Vertical Acceleration + LOCATION_NAV_DATA_HAS_YAW_RATE_BIT = (1<<3), // Navigation data has Heading Rate + LOCATION_NAV_DATA_HAS_PITCH_BIT = (1<<4) // Navigation data has Body pitch +} GnssLocationPosDataBits; + +typedef uint32_t GnssLocationInfoFlagMask; +typedef enum { + GNSS_LOCATION_INFO_ALTITUDE_MEAN_SEA_LEVEL_BIT = (1<<0), // valid altitude mean sea level + GNSS_LOCATION_INFO_DOP_BIT = (1<<1), // valid pdop, hdop, and vdop + GNSS_LOCATION_INFO_MAGNETIC_DEVIATION_BIT = (1<<2), // valid magnetic deviation + GNSS_LOCATION_INFO_HOR_RELIABILITY_BIT = (1<<3), // valid horizontal reliability + GNSS_LOCATION_INFO_VER_RELIABILITY_BIT = (1<<4), // valid vertical reliability + GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MAJOR_BIT = (1<<5), // valid elipsode semi major + GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MINOR_BIT = (1<<6), // valid elipsode semi minor + GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_AZIMUTH_BIT = (1<<7), // valid accuracy elipsode azimuth + GNSS_LOCATION_INFO_GNSS_SV_USED_DATA_BIT = (1<<8), // valid gnss sv used in pos data + GNSS_LOCATION_INFO_NAV_SOLUTION_MASK_BIT = (1<<9), // valid navSolutionMask + GNSS_LOCATION_INFO_POS_TECH_MASK_BIT = (1<<10),// valid LocPosTechMask + GNSS_LOCATION_INFO_SV_SOURCE_INFO_BIT = (1<<11),// valid LocSvInfoSource + GNSS_LOCATION_INFO_POS_DYNAMICS_DATA_BIT = (1<<12),// valid position dynamics data + GNSS_LOCATION_INFO_GPS_TIME_BIT = (1<<13),// valid GPS Time + GNSS_LOCATION_INFO_EXT_DOP_BIT = (1<<14) // valid gdop, tdop +} GnssLocationInfoFlagBits; + +typedef enum { + GEOFENCE_BREACH_ENTER = 0, + GEOFENCE_BREACH_EXIT, + GEOFENCE_BREACH_DWELL_IN, + GEOFENCE_BREACH_DWELL_OUT, + GEOFENCE_BREACH_UNKNOWN, +} GeofenceBreachType; + +typedef uint16_t GeofenceBreachTypeMask; +typedef enum { + GEOFENCE_BREACH_ENTER_BIT = (1<<0), + GEOFENCE_BREACH_EXIT_BIT = (1<<1), + GEOFENCE_BREACH_DWELL_IN_BIT = (1<<2), + GEOFENCE_BREACH_DWELL_OUT_BIT = (1<<3), +} GeofenceBreachTypeBits; + +typedef enum { + GEOFENCE_STATUS_AVAILABILE_NO = 0, + GEOFENCE_STATUS_AVAILABILE_YES, +} GeofenceStatusAvailable; + +typedef uint32_t LocationCapabilitiesMask; +typedef enum { + // supports startTracking API with minInterval param + LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT = (1<<0), + // supports startBatching API with minInterval param + LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT = (1<<1), + // supports startTracking API with minDistance param + LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT = (1<<2), + // supports startBatching API with minDistance param + LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT = (1<<3), + // supports addGeofences API + LOCATION_CAPABILITIES_GEOFENCE_BIT = (1<<4), + // supports GnssMeasurementsCallback + LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT = (1<<5), + // supports startTracking/startBatching API with LocationOptions.mode of MSB (Ms Based) + LOCATION_CAPABILITIES_GNSS_MSB_BIT = (1<<6), + // supports startTracking/startBatching API with LocationOptions.mode of MSA (MS Assisted) + LOCATION_CAPABILITIES_GNSS_MSA_BIT = (1<<7), + // supports debug nmea sentences in the debugNmeaCallback + LOCATION_CAPABILITIES_DEBUG_NMEA_BIT = (1<<8), + // support outdoor trip batching + LOCATION_CAPABILITIES_OUTDOOR_TRIP_BATCHING_BIT = (1<<9) +} LocationCapabilitiesBits; + +typedef enum { + LOCATION_TECHNOLOGY_TYPE_GNSS = 0, +} LocationTechnologyType; + +// Configures how GPS is locked when GPS is disabled (through GnssDisable) +typedef enum { + GNSS_CONFIG_GPS_LOCK_NONE = 0, // gps is not locked when GPS is disabled (GnssDisable) + GNSS_CONFIG_GPS_LOCK_MO, // gps mobile originated (MO) is locked when GPS is disabled + GNSS_CONFIG_GPS_LOCK_NI, // gps network initiated (NI) is locked when GPS is disabled + GNSS_CONFIG_GPS_LOCK_MO_AND_NI,// gps MO and NI is locked when GPS is disabled +} GnssConfigGpsLock; + +// SUPL version +typedef enum { + GNSS_CONFIG_SUPL_VERSION_1_0_0 = 1, + GNSS_CONFIG_SUPL_VERSION_2_0_0, + GNSS_CONFIG_SUPL_VERSION_2_0_2, +} GnssConfigSuplVersion; + +// LTE Positioning Profile +typedef enum { + GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE = 0, // RRLP on LTE (Default) + GNSS_CONFIG_LPP_PROFILE_USER_PLANE, // LPP User Plane (UP) on LTE + GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE, // LPP_Control_Plane (CP) + GNSS_CONFIG_LPP_PROFILE_USER_PLANE_AND_CONTROL_PLANE, // Both LPP UP and CP +} GnssConfigLppProfile; + +// Technology for LPPe Control Plane +typedef uint16_t GnssConfigLppeControlPlaneMask; +typedef enum { + GNSS_CONFIG_LPPE_CONTROL_PLANE_DBH_BIT = (1<<0), // DBH + GNSS_CONFIG_LPPE_CONTROL_PLANE_WLAN_AP_MEASUREMENTS_BIT = (1<<1), // WLAN_AP_MEASUREMENTS + GNSS_CONFIG_LPPE_CONTROL_PLANE_SRN_AP_MEASUREMENTS_BIT = (1<<2), // SRN_AP_MEASUREMENTS + GNSS_CONFIG_LPPE_CONTROL_PLANE_SENSOR_BARO_MEASUREMENTS_BIT = (1<<3), + // SENSOR_BARO_MEASUREMENTS +} GnssConfigLppeControlPlaneBits; + +// Technology for LPPe User Plane +typedef uint16_t GnssConfigLppeUserPlaneMask; +typedef enum { + GNSS_CONFIG_LPPE_USER_PLANE_DBH_BIT = (1<<0), // DBH + GNSS_CONFIG_LPPE_USER_PLANE_WLAN_AP_MEASUREMENTS_BIT = (1<<1), // WLAN_AP_MEASUREMENTS + GNSS_CONFIG_LPPE_USER_PLANE_SRN_AP_MEASUREMENTS_BIT = (1<<2), // SRN_AP_MEASUREMENTS + GNSS_CONFIG_LPPE_USER_PLANE_SENSOR_BARO_MEASUREMENTS_BIT = (1<<3), + // SENSOR_BARO_MEASUREMENTS +} GnssConfigLppeUserPlaneBits; + +// Positioning Protocol on A-GLONASS system +typedef uint16_t GnssConfigAGlonassPositionProtocolMask; +typedef enum { + GNSS_CONFIG_RRC_CONTROL_PLANE_BIT = (1<<0), // RRC Control Plane + GNSS_CONFIG_RRLP_USER_PLANE_BIT = (1<<1), // RRLP User Plane + GNSS_CONFIG_LLP_USER_PLANE_BIT = (1<<2), // LPP User Plane + GNSS_CONFIG_LLP_CONTROL_PLANE_BIT = (1<<3), // LPP Control Plane +} GnssConfigAGlonassPositionProtocolBits; + +typedef enum { + GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_NO = 0, + GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_YES, +} GnssConfigEmergencyPdnForEmergencySupl; + +typedef enum { + GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO = 0, + GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_YES, +} GnssConfigSuplEmergencyServices; + +typedef uint16_t GnssConfigSuplModeMask; +typedef enum { + GNSS_CONFIG_SUPL_MODE_MSB_BIT = (1<<0), + GNSS_CONFIG_SUPL_MODE_MSA_BIT = (1<<1), +} GnssConfigSuplModeBits; + +typedef uint32_t GnssConfigFlagsMask; +typedef enum { + GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT = (1<<0), + GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT = (1<<1), + GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT = (1<<2), + GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT = (1<<3), + GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT = (1<<4), + GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT = (1<<5), + GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT = (1<<6), + GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT = (1<<7), + GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT = (1<<8), + GNSS_CONFIG_FLAGS_SUPL_MODE_BIT = (1<<9), +} GnssConfigFlagsBits; + +typedef enum { + GNSS_NI_ENCODING_TYPE_NONE = 0, + GNSS_NI_ENCODING_TYPE_GSM_DEFAULT, + GNSS_NI_ENCODING_TYPE_UTF8, + GNSS_NI_ENCODING_TYPE_UCS2, +} GnssNiEncodingType; + +typedef enum { + GNSS_NI_TYPE_VOICE = 0, + GNSS_NI_TYPE_SUPL, + GNSS_NI_TYPE_CONTROL_PLANE, + GNSS_NI_TYPE_EMERGENCY_SUPL +} GnssNiType; + +typedef uint16_t GnssNiOptionsMask; +typedef enum { + GNSS_NI_OPTIONS_NOTIFICATION_BIT = (1<<0), + GNSS_NI_OPTIONS_VERIFICATION_BIT = (1<<1), + GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT = (1<<2), +} GnssNiOptionsBits; + +typedef enum { + GNSS_NI_RESPONSE_ACCEPT = 1, + GNSS_NI_RESPONSE_DENY, + GNSS_NI_RESPONSE_NO_RESPONSE, + GNSS_NI_RESPONSE_IGNORE, +} GnssNiResponse; + +typedef enum { + GNSS_SV_TYPE_UNKNOWN = 0, + GNSS_SV_TYPE_GPS, + GNSS_SV_TYPE_SBAS, + GNSS_SV_TYPE_GLONASS, + GNSS_SV_TYPE_QZSS, + GNSS_SV_TYPE_BEIDOU, + GNSS_SV_TYPE_GALILEO, +} GnssSvType; + +typedef enum { + GNSS_EPH_TYPE_UNKNOWN = 0, + GNSS_EPH_TYPE_EPHEMERIS, + GNSS_EPH_TYPE_ALMANAC, +} GnssEphemerisType; + +typedef enum { + GNSS_EPH_SOURCE_UNKNOWN = 0, + GNSS_EPH_SOURCE_DEMODULATED, + GNSS_EPH_SOURCE_SUPL_PROVIDED, + GNSS_EPH_SOURCE_OTHER_SERVER_PROVIDED, + GNSS_EPH_SOURCE_LOCAL, +} GnssEphemerisSource; + +typedef enum { + GNSS_EPH_HEALTH_UNKNOWN = 0, + GNSS_EPH_HEALTH_GOOD, + GNSS_EPH_HEALTH_BAD, +} GnssEphemerisHealth; + +typedef uint16_t GnssSvOptionsMask; +typedef enum { + GNSS_SV_OPTIONS_HAS_EPHEMER_BIT = (1<<0), + GNSS_SV_OPTIONS_HAS_ALMANAC_BIT = (1<<1), + GNSS_SV_OPTIONS_USED_IN_FIX_BIT = (1<<2), +} GnssSvOptionsBits; + +typedef enum { + GNSS_ASSISTANCE_TYPE_SUPL = 0, + GNSS_ASSISTANCE_TYPE_C2K, +} GnssAssistanceType; + +typedef enum { + GNSS_SUPL_MODE_STANDALONE = 0, + GNSS_SUPL_MODE_MSB, + GNSS_SUPL_MODE_MSA, +} GnssSuplMode; + +typedef enum { + BATCHING_MODE_ROUTINE = 0, // positions are reported when batched positions memory is full + BATCHING_MODE_TRIP, // positions are reported when a certain distance is covered + BATCHING_MODE_NO_AUTO_REPORT // no report of positions automatically, instead queried on demand +} BatchingMode; + +typedef enum { + BATCHING_STATUS_TRIP_COMPLETED = 0, + BATCHING_STATUS_POSITION_AVAILABE, + BATCHING_STATUS_POSITION_UNAVAILABLE +} BatchingStatus; + +typedef uint16_t GnssMeasurementsAdrStateMask; +typedef enum { + GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_UNKNOWN = 0, + GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT = (1<<0), + GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT = (1<<1), + GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT = (1<<2), +} GnssMeasurementsAdrStateBits; + +typedef uint32_t GnssMeasurementsDataFlagsMask; +typedef enum { + GNSS_MEASUREMENTS_DATA_SV_ID_BIT = (1<<0), + GNSS_MEASUREMENTS_DATA_SV_TYPE_BIT = (1<<1), + GNSS_MEASUREMENTS_DATA_STATE_BIT = (1<<2), + GNSS_MEASUREMENTS_DATA_RECEIVED_SV_TIME_BIT = (1<<3), + GNSS_MEASUREMENTS_DATA_RECEIVED_SV_TIME_UNCERTAINTY_BIT = (1<<4), + GNSS_MEASUREMENTS_DATA_CARRIER_TO_NOISE_BIT = (1<<5), + GNSS_MEASUREMENTS_DATA_PSEUDORANGE_RATE_BIT = (1<<6), + GNSS_MEASUREMENTS_DATA_PSEUDORANGE_RATE_UNCERTAINTY_BIT = (1<<7), + GNSS_MEASUREMENTS_DATA_ADR_STATE_BIT = (1<<8), + GNSS_MEASUREMENTS_DATA_ADR_BIT = (1<<9), + GNSS_MEASUREMENTS_DATA_ADR_UNCERTAINTY_BIT = (1<<10), + GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT = (1<<11), + GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT = (1<<12), + GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT = (1<<13), + GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT = (1<<14), + GNSS_MEASUREMENTS_DATA_MULTIPATH_INDICATOR_BIT = (1<<15), + GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT = (1<<16), + GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT = (1<<17), +} GnssMeasurementsDataFlagsBits; + +typedef uint32_t GnssMeasurementsStateMask; +typedef enum { + GNSS_MEASUREMENTS_STATE_UNKNOWN_BIT = 0, + GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT = (1<<0), + GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT = (1<<1), + GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT = (1<<2), + GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT = (1<<3), + GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT = (1<<4), + GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT = (1<<5), + GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT = (1<<6), + GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT = (1<<7), + GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT = (1<<8), + GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT = (1<<9), + GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT = (1<<10), + GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT = (1<<11), + GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT = (1<<12), + GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT = (1<<13), +} GnssMeasurementsStateBits; + +typedef enum { + GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_UNKNOWN = 0, + GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_PRESENT, + GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_NOT_PRESENT, +} GnssMeasurementsMultipathIndicator; + +typedef uint32_t GnssMeasurementsClockFlagsMask; +typedef enum { + GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT = (1<<0), + GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_BIT = (1<<1), + GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT = (1<<2), + GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT = (1<<3), + GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT = (1<<4), + GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT = (1<<5), + GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_BIT = (1<<6), + GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_UNCERTAINTY_BIT = (1<<7), + GNSS_MEASUREMENTS_CLOCK_FLAGS_HW_CLOCK_DISCONTINUITY_COUNT_BIT = (1<<8), +} GnssMeasurementsClockFlagsBits; + +typedef uint32_t GnssAidingDataSvMask; +typedef enum { + GNSS_AIDING_DATA_SV_EPHEMERIS_BIT = (1<<0), // ephemeris + GNSS_AIDING_DATA_SV_ALMANAC_BIT = (1<<1), // almanac + GNSS_AIDING_DATA_SV_HEALTH_BIT = (1<<2), // health + GNSS_AIDING_DATA_SV_DIRECTION_BIT = (1<<3), // direction + GNSS_AIDING_DATA_SV_STEER_BIT = (1<<4), // steer + GNSS_AIDING_DATA_SV_ALMANAC_CORR_BIT = (1<<5), // almanac correction + GNSS_AIDING_DATA_SV_BLACKLIST_BIT = (1<<6), // blacklist SVs + GNSS_AIDING_DATA_SV_SA_DATA_BIT = (1<<7), // sensitivity assistance data + GNSS_AIDING_DATA_SV_NO_EXIST_BIT = (1<<8), // SV does not exist + GNSS_AIDING_DATA_SV_IONOSPHERE_BIT = (1<<9), // ionosphere correction + GNSS_AIDING_DATA_SV_TIME_BIT = (1<<10),// reset satellite time +} GnssAidingDataSvBits; + +typedef uint32_t GnssAidingDataSvTypeMask; +typedef enum { + GNSS_AIDING_DATA_SV_TYPE_GPS_BIT = (1<<0), + GNSS_AIDING_DATA_SV_TYPE_GLONASS_BIT = (1<<1), + GNSS_AIDING_DATA_SV_TYPE_QZSS_BIT = (1<<2), + GNSS_AIDING_DATA_SV_TYPE_BEIDOU_BIT = (1<<3), + GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT = (1<<4), +} GnssAidingDataSvTypeBits; + +typedef enum +{ + GNSS_LOC_SV_SYSTEM_GPS = 1, + /**< GPS satellite. */ + GNSS_LOC_SV_SYSTEM_GALILEO = 2, + /**< GALILEO satellite. */ + GNSS_LOC_SV_SYSTEM_SBAS = 3, + /**< SBAS satellite. */ + GNSS_LOC_SV_SYSTEM_COMPASS = 4, + /**< COMPASS satellite. */ + GNSS_LOC_SV_SYSTEM_GLONASS = 5, + /**< GLONASS satellite. */ + GNSS_LOC_SV_SYSTEM_BDS = 6, + /**< BDS satellite. */ + GNSS_LOC_SV_SYSTEM_QZSS = 7 + /**< QZSS satellite. */ +} Gnss_LocSvSystemEnumType; + +typedef uint32_t GnssSystemTimeStructTypeFlags; +typedef enum { + GNSS_SYSTEM_TIME_WEEK_VALID = (1 << 0), + GNSS_SYSTEM_TIME_WEEK_MS_VALID = (1 << 1), + GNSS_SYSTEM_CLK_TIME_BIAS_VALID = (1 << 2), + GNSS_SYSTEM_CLK_TIME_BIAS_UNC_VALID = (1 << 3), + GNSS_SYSTEM_REF_FCOUNT_VALID = (1 << 4), + GNSS_SYSTEM_NUM_CLOCK_RESETS_VALID = (1 << 5) +} GnssSystemTimeTypeBits; + +typedef uint32_t GnssGloTimeStructTypeFlags; +typedef enum { + GNSS_CLO_DAYS_VALID = (1 << 0), + GNSS_GLOS_MSEC_VALID = (1 << 1), + GNSS_GLO_CLK_TIME_BIAS_VALID = (1 << 2), + GNSS_GLO_CLK_TIME_BIAS_UNC_VALID = (1 << 3), + GNSS_GLO_REF_FCOUNT_VALID = (1 << 4), + GNSS_GLO_NUM_CLOCK_RESETS_VALID = (1 << 5), + GNSS_GLO_FOUR_YEAR_VALID = (1 << 6) +} GnssGloTimeTypeBits; + +typedef struct { + GnssAidingDataSvMask svMask; // bitwise OR of GnssAidingDataSvBits + GnssAidingDataSvTypeMask svTypeMask; // bitwise OR of GnssAidingDataSvTypeBits +} GnssAidingDataSv; + +typedef uint32_t GnssAidingDataCommonMask; +typedef enum { + GNSS_AIDING_DATA_COMMON_POSITION_BIT = (1<<0), // position estimate + GNSS_AIDING_DATA_COMMON_TIME_BIT = (1<<1), // reset all clock values + GNSS_AIDING_DATA_COMMON_UTC_BIT = (1<<2), // UTC estimate + GNSS_AIDING_DATA_COMMON_RTI_BIT = (1<<3), // RTI + GNSS_AIDING_DATA_COMMON_FREQ_BIAS_EST_BIT = (1<<4), // frequency bias estimate + GNSS_AIDING_DATA_COMMON_CELLDB_BIT = (1<<5), // all celldb info +} GnssAidingDataCommonBits; + +typedef struct { + GnssAidingDataCommonMask mask; // bitwise OR of GnssAidingDataCommonBits +} GnssAidingDataCommon; + +typedef struct { + bool deleteAll; // if true, delete all aiding data and ignore other params + GnssAidingDataSv sv; // SV specific aiding data + GnssAidingDataCommon common; // common aiding data +} GnssAidingData; + +typedef struct { + size_t size; // set to sizeof(Location) + LocationFlagsMask flags; // bitwise OR of LocationFlagsBits to mark which params are valid + uint64_t timestamp; // UTC timestamp for location fix, milliseconds since January 1, 1970 + double latitude; // in degrees + double longitude; // in degrees + double altitude; // in meters above the WGS 84 reference ellipsoid + float speed; // in meters per second + float bearing; // in degrees; range [0, 360) + float accuracy; // in meters + float verticalAccuracy; // in meters + float speedAccuracy; // in meters/second + float bearingAccuracy; // in degrees (0 to 359.999) + LocationTechnologyMask techMask; +} Location; + +typedef struct { + size_t size; // set to sizeof(LocationOptions) + uint32_t minInterval; // in milliseconds + uint32_t minDistance; // in meters. if minDistance > 0, gnssSvCallback/gnssNmeaCallback/ + // gnssMeasurementsCallback may not be called + GnssSuplMode mode; // Standalone/MS-Based/MS-Assisted +} LocationOptions; + +typedef struct { + size_t size; + BatchingMode batchingMode; +} BatchingOptions; + +typedef struct { + size_t size; + BatchingStatus batchingStatus; +} BatchingStatusInfo; + +typedef struct { + size_t size; // set to sizeof(GeofenceOption) + GeofenceBreachTypeMask breachTypeMask; // bitwise OR of GeofenceBreachTypeBits + uint32_t responsiveness; // in milliseconds + uint32_t dwellTime; // in seconds +} GeofenceOption; + +typedef struct { + size_t size; // set to sizeof(GeofenceInfo) + double latitude; // in degrees + double longitude; // in degrees + double radius; // in meters +} GeofenceInfo; + +typedef struct { + size_t size; // set to sizeof(GeofenceBreachNotification) + size_t count; // number of ids in array + uint32_t* ids; // array of ids that have breached + Location location; // location associated with breach + GeofenceBreachType type; // type of breach + uint64_t timestamp; // timestamp of breach +} GeofenceBreachNotification; + +typedef struct { + size_t size; // set to sizeof(GeofenceBreachNotification) + GeofenceStatusAvailable available; // GEOFENCE_STATUS_AVAILABILE_NO/_YES + LocationTechnologyType techType; // GNSS +} GeofenceStatusNotification; + +typedef struct { + uint64_t gpsSvUsedIdsMask; + uint64_t gloSvUsedIdsMask; + uint64_t galSvUsedIdsMask; + uint64_t bdsSvUsedIdsMask; + uint64_t qzssSvUsedIdsMask; +} GnssLocationSvUsedInPosition; + +/** @struct + Body Frame parameters +*/ +typedef struct { + GnssLocationPosDataMask bodyFrameDataMask; // Contains Body frame LocPosDataMask bits + float longAccel; // Forward Acceleration in body frame (m/s2) + float latAccel; // Sideward Acceleration in body frame (m/s2) + float vertAccel; // Vertical Acceleration in body frame (m/s2) + float yawRate; // Heading Rate (Radians/second) + float pitch; // Body pitch (Radians) +} GnssLocationPositionDynamics; + +typedef struct { + /** Validity mask for below fields */ + GnssSystemTimeStructTypeFlags validityMask; + /** Extended week number at reference tick. + Unit: Week. + Set to 65535 if week number is unknown. + For GPS: + Calculated from midnight, Jan. 6, 1980. + OTA decoded 10 bit GPS week is extended to map between: + [NV6264 to (NV6264 + 1023)]. + NV6264: Minimum GPS week number configuration. + Default value of NV6264: 1738 + For BDS: + Calculated from 00:00:00 on January 1, 2006 of Coordinated Universal Time (UTC). + For GAL: + Calculated from 00:00 UT on Sunday August 22, 1999 (midnight between August 21 and August 22). + */ + uint16_t systemWeek; + /** Time in to the current week at reference tick. + Unit: Millisecond. Range: 0 to 604799999. + Check for systemClkTimeUncMs before use */ + uint32_t systemMsec; + /** System clock time bias (sub-millisecond) + Units: Millisecond + Note: System time (TOW Millisecond) = systemMsec - systemClkTimeBias. + Check for systemClkTimeUncMs before use. */ + float systemClkTimeBias; + /** Single sided maximum time bias uncertainty + Units: Millisecond */ + float systemClkTimeUncMs; + /** FCount (free running HW timer) value. Don't use for relative time purpose + due to possible discontinuities. + Unit: Millisecond */ + uint32_t refFCount; + /** Number of clock resets/discontinuities detected, affecting the local hardware counter value. */ + uint32_t numClockResets; +} GnssSystemTimeStructType; + +typedef struct { + /** GLONASS day number in four years. Refer to GLONASS ICD. + Applicable only for GLONASS and shall be ignored for other constellations. + If unknown shall be set to 65535 */ + uint16_t gloDays; + /** Validity mask for below fields */ + GnssGloTimeStructTypeFlags validityMask; + /** GLONASS time of day in Millisecond. Refer to GLONASS ICD. + Units: Millisecond + Check for gloClkTimeUncMs before use */ + uint32_t gloMsec; + /** GLONASS clock time bias (sub-millisecond) + Units: Millisecond + Note: GLO time (TOD Millisecond) = gloMsec - gloClkTimeBias. + Check for gloClkTimeUncMs before use. */ + float gloClkTimeBias; + /** Single sided maximum time bias uncertainty + Units: Millisecond */ + float gloClkTimeUncMs; + /** FCount (free running HW timer) value. Don't use for relative time purpose + due to possible discontinuities. + Unit: Millisecond */ + uint32_t refFCount; + /** Number of clock resets/discontinuities detected, affecting the local hardware counter value. */ + uint32_t numClockResets; + /** GLONASS four year number from 1996. Refer to GLONASS ICD. + Applicable only for GLONASS and shall be ignored for other constellations. + If unknown shall be set to 255 */ + uint8_t gloFourYear; +} GnssGloTimeStructType; + +typedef union { + GnssSystemTimeStructType gpsSystemTime; + GnssSystemTimeStructType galSystemTime; + GnssSystemTimeStructType bdsSystemTime; + GnssSystemTimeStructType qzssSystemTime; + GnssGloTimeStructType gloSytemTime; +} SystemTimeStructUnion; + /** Time applicability of PVT report */ +typedef struct { + /** Specifies GNSS system time reported. Mandatory field */ + Gnss_LocSvSystemEnumType gnssSystemTimeSrc; + /** Reporting of GPS system time is recommended. + If GPS time is unknown & other satellite system time is known, + it should be reported. + Mandatory field + */ + SystemTimeStructUnion u; +} GnssSystemTime; + +typedef struct { + size_t size; // set to sizeof(GnssLocationInfo) + GnssLocationInfoFlagMask flags; // bitwise OR of GnssLocationInfoBits for param validity + float altitudeMeanSeaLevel; // altitude wrt mean sea level + float pdop; // position dilusion of precision + float hdop; // horizontal dilusion of precision + float vdop; // vertical dilusion of precision + float gdop; // geometric dilution of precision + float tdop; // time dilution of precision + float magneticDeviation; // magnetic deviation + LocationReliability horReliability; // horizontal reliability + LocationReliability verReliability; // vertical reliability + float horUncEllipseSemiMajor; // horizontal elliptical accuracy semi-major axis + float horUncEllipseSemiMinor; // horizontal elliptical accuracy semi-minor axis + float horUncEllipseOrientAzimuth; // horizontal elliptical accuracy azimuth + float northVelocity; // North Velocity.Unit: Meters/sec + float eastVelocity; // East Velocity + float upVelocity; + float northVelocityStdDeviation; + float eastVelocityStdDeviation; + float upVelocityStdDeviation; + GnssLocationSvUsedInPosition svUsedInPosition;// Gnss sv used in position data + GnssLocationNavSolutionMask navSolutionMask; // Nav solution mask to indicate sbas corrections + GnssLocationPosTechMask posTechMask; // Position technology used in computing this fix + GnssLocationPositionDynamics bodyFrameData; // Body Frame Dynamics: 4wayAcceleration and + // pitch set with validity + GnssSystemTime gnssSystemTime; // GNSS System Time + Location location; +} GnssLocationInfoNotification; + +typedef struct { + size_t size; // set to sizeof(GnssNiNotification) + GnssNiType type; // type of NI (Voice, SUPL, Control Plane) + GnssNiOptionsMask options; // bitwise OR of GnssNiOptionsBits + uint32_t timeout; // time (seconds) to wait for user input + GnssNiResponse timeoutResponse; // the response that should be sent when timeout expires + char requestor[GNSS_NI_REQUESTOR_MAX]; // the requestor that is making the request + GnssNiEncodingType requestorEncoding; // the encoding type for requestor + char message[GNSS_NI_MESSAGE_ID_MAX]; // the message to show user + GnssNiEncodingType messageEncoding; // the encoding type for message + char extras[GNSS_NI_MESSAGE_ID_MAX]; +} GnssNiNotification; + +typedef struct { + size_t size; // set to sizeof(GnssSv) + uint16_t svId; // Unique Identifier + GnssSvType type; // type of SV (GPS, SBAS, GLONASS, QZSS, BEIDOU, GALILEO) + float cN0Dbhz; // signal strength + float elevation; // elevation of SV (in degrees) + float azimuth; // azimuth of SV (in degrees) + GnssSvOptionsMask gnssSvOptionsMask; // Bitwise OR of GnssSvOptionsBits +} GnssSv; + +typedef struct { + size_t size; // set to sizeof(GnssConfigSetAssistanceServer) + GnssAssistanceType type; // SUPL or C2K + const char* hostName; // null terminated string + uint32_t port; // port of server +} GnssConfigSetAssistanceServer; + +typedef struct { + size_t size; // set to sizeof(GnssMeasurementsData) + GnssMeasurementsDataFlagsMask flags; // bitwise OR of GnssMeasurementsDataFlagsBits + int16_t svId; + GnssSvType svType; + double timeOffsetNs; + GnssMeasurementsStateMask stateMask; // bitwise OR of GnssMeasurementsStateBits + int64_t receivedSvTimeNs; + int64_t receivedSvTimeUncertaintyNs; + double carrierToNoiseDbHz; + double pseudorangeRateMps; + double pseudorangeRateUncertaintyMps; + GnssMeasurementsAdrStateMask adrStateMask; // bitwise OR of GnssMeasurementsAdrStateBits + double adrMeters; + double adrUncertaintyMeters; + float carrierFrequencyHz; + int64_t carrierCycles; + double carrierPhase; + double carrierPhaseUncertainty; + GnssMeasurementsMultipathIndicator multipathIndicator; + double signalToNoiseRatioDb; + double agcLevelDb; +} GnssMeasurementsData; + +typedef struct { + size_t size; // set to sizeof(GnssMeasurementsClock) + GnssMeasurementsClockFlagsMask flags; // bitwise OR of GnssMeasurementsClockFlagsBits + int16_t leapSecond; + int64_t timeNs; + double timeUncertaintyNs; + int64_t fullBiasNs; + double biasNs; + double biasUncertaintyNs; + double driftNsps; + double driftUncertaintyNsps; + uint32_t hwClockDiscontinuityCount; +} GnssMeasurementsClock; + +typedef struct { + size_t size; // set to sizeof(GnssSvNotification) + size_t count; // number of SVs in the GnssSv array + GnssSv gnssSvs[GNSS_SV_MAX]; // information on a number of SVs +} GnssSvNotification; + +typedef struct { + size_t size; // set to sizeof(GnssNmeaNotification) + uint64_t timestamp; // timestamp + const char* nmea; // nmea text + size_t length; // length of the nmea text +} GnssNmeaNotification; + +typedef struct { + size_t size; // set to sizeof(GnssMeasurementsNotification) + size_t count; // number of items in GnssMeasurements array + GnssMeasurementsData measurements[GNSS_MEASUREMENTS_MAX]; + GnssMeasurementsClock clock; // clock +} GnssMeasurementsNotification; + +typedef struct { + size_t size; // set to sizeof(GnssConfig) + GnssConfigFlagsMask flags; // bitwise OR of GnssConfigFlagsBits to mark which params are valid + GnssConfigGpsLock gpsLock; + GnssConfigSuplVersion suplVersion; + GnssConfigSetAssistanceServer assistanceServer; + GnssConfigLppProfile lppProfile; + GnssConfigLppeControlPlaneMask lppeControlPlaneMask; + GnssConfigLppeUserPlaneMask lppeUserPlaneMask; + GnssConfigAGlonassPositionProtocolMask aGlonassPositionProtocolMask; + GnssConfigEmergencyPdnForEmergencySupl emergencyPdnForEmergencySupl; + GnssConfigSuplEmergencyServices suplEmergencyServices; + GnssConfigSuplModeMask suplModeMask; //bitwise OR of GnssConfigSuplModeBits +} GnssConfig; + +typedef struct { + size_t size; // set to sizeof + bool mValid; + Location mLocation; + double verticalAccuracyMeters; + double speedAccuracyMetersPerSecond; + double bearingAccuracyDegrees; + timespec mUtcReported; +} GnssDebugLocation; + +typedef struct { + size_t size; // set to sizeof + bool mValid; + int64_t timeEstimate; + float timeUncertaintyNs; + float frequencyUncertaintyNsPerSec; +} GnssDebugTime; + +typedef struct { + size_t size; // set to sizeof + uint32_t svid; + GnssSvType constellation; + GnssEphemerisType mEphemerisType; + GnssEphemerisSource mEphemerisSource; + GnssEphemerisHealth mEphemerisHealth; + float ephemerisAgeSeconds; + bool serverPredictionIsAvailable; + float serverPredictionAgeSeconds; +} GnssDebugSatelliteInfo; + +typedef struct { + size_t size; // set to sizeof + GnssDebugLocation mLocation; + GnssDebugTime mTime; + std::vector mSatelliteInfo; +} GnssDebugReport; + +/* Provides the capabilities of the system + capabilities callback is called once soon after createInstance is called */ +typedef std::function capabilitiesCallback; + +/* Used by tracking, batching, and miscellanous APIs + responseCallback is called for every Tracking, Batching API, and Miscellanous API */ +typedef std::function responseCallback; + +/* Used by APIs that gets more than one LocationError in it's response + collectiveResponseCallback is called for every geofence API call. + ids array and LocationError array are only valid until collectiveResponseCallback returns. */ +typedef std::function collectiveResponseCallback; + +/* Used for startTracking API, optional can be NULL + trackingCallback is called when delivering a location in a tracking session + broadcasted to all clients, no matter if a session has started by client */ +typedef std::function trackingCallback; + +/* Used for startBatching API, optional can be NULL + batchingCallback is called when delivering locations in a batching session. + broadcasted to all clients, no matter if a session has started by client */ +typedef std::function batchingCallback; + +typedef std::function & listOfCompletedTrips +)> batchingStatusCallback; + +/* Gives GNSS Location information, optional can be NULL + gnssLocationInfoCallback is called only during a tracking session + broadcasted to all clients, no matter if a session has started by client */ +typedef std::function gnssLocationInfoCallback; + +/* Used for addGeofences API, optional can be NULL + geofenceBreachCallback is called when any number of geofences have a state change */ +typedef std::function geofenceBreachCallback; + +/* Used for addGeofences API, optional can be NULL + geofenceStatusCallback is called when any number of geofences have a status change */ +typedef std::function geofenceStatusCallback; + +/* Network Initiated request, optional can be NULL + This callback should be responded to by calling gnssNiResponse */ +typedef std::function gnssNiCallback; + +/* Gives GNSS SV information, optional can be NULL + gnssSvCallback is called only during a tracking session + broadcasted to all clients, no matter if a session has started by client */ +typedef std::function gnssSvCallback; + +/* Gives GNSS NMEA data, optional can be NULL + gnssNmeaCallback is called only during a tracking session + broadcasted to all clients, no matter if a session has started by client */ +typedef std::function gnssNmeaCallback; + +/* Gives GNSS Measurements information, optional can be NULL + gnssMeasurementsCallback is called only during a tracking session + broadcasted to all clients, no matter if a session has started by client */ +typedef std::function gnssMeasurementsCallback; + +typedef struct { + size_t size; // set to sizeof(LocationCallbacks) + capabilitiesCallback capabilitiesCb; // mandatory + responseCallback responseCb; // mandatory + collectiveResponseCallback collectiveResponseCb; // mandatory + trackingCallback trackingCb; // optional + batchingCallback batchingCb; // optional + geofenceBreachCallback geofenceBreachCb; // optional + geofenceStatusCallback geofenceStatusCb; // optional + gnssLocationInfoCallback gnssLocationInfoCb; // optional + gnssNiCallback gnssNiCb; // optional + gnssSvCallback gnssSvCb; // optional + gnssNmeaCallback gnssNmeaCb; // optional + gnssMeasurementsCallback gnssMeasurementsCb; // optional + batchingStatusCallback batchingStatusCb; // optional +} LocationCallbacks; + +#endif /* LOCATIONDATATYPES_H */ diff --git a/location/Makefile.am b/location/Makefile.am index 3688cc86..fccdf94d 100644 --- a/location/Makefile.am +++ b/location/Makefile.am @@ -26,7 +26,9 @@ liblocation_api_la_LIBADD = -lstdc++ -ldl $(GPSUTILS_LIBS) library_include_HEADERS = \ LocationAPI.h \ LocationAPIClientBase.h \ - location_interface.h + location_interface.h \ + LocationDataTypes.h \ + ILocationAPI.h #Create and Install libraries lib_LTLIBRARIES = liblocation_api.la From b47eea6b2373d42c5cf9153d2211fd08b9d9272a Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Wed, 7 Mar 2018 10:19:24 -0800 Subject: [PATCH 12/19] GPS GNSS adapter: connectivity support for engine hub (1) allow engine hub to be able to receive connectivity status update (2) fix kw warning in LocIpc.h Change-Id: I62ac534639003051a8992c143ff273d5ff66ee5a CRs-fixed: 2198446 --- core/EngineHubProxyBase.h | 1 + gnss/GnssAdapter.cpp | 3 ++- gnss/GnssAdapter.h | 1 + utils/LocIpc.h | 6 +++--- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/EngineHubProxyBase.h b/core/EngineHubProxyBase.h index c17b2c29..7b9f3ae8 100644 --- a/core/EngineHubProxyBase.h +++ b/core/EngineHubProxyBase.h @@ -101,6 +101,7 @@ typedef std::function // potential parameters: message queue: MsgTask * msgTask; // callback function to report back dr and ppe position and sv report typedef EngineHubProxyBase* (getEngHubProxyFn)(const MsgTask * msgTask, + IOsObserver* osObserver, GnssAdapterReportPositionEventCb positionEventCb, GnssAdapterReportSvEventCb svEventCb); diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index a57d1a40..f996ebee 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -3310,7 +3310,8 @@ GnssAdapter::initEngHubProxy() { getEngHubProxyFn* getter = (getEngHubProxyFn*) dlsym(handle, "getEngHubProxy"); if(getter != nullptr) { - EngineHubProxyBase* hubProxy = (*getter) (mMsgTask, reportPositionEventCb, + EngineHubProxyBase* hubProxy = (*getter) (mMsgTask, mSystemStatus->getOsObserver(), + reportPositionEventCb, reportSvEventCb); if (hubProxy != nullptr) { mEngHubProxy = hubProxy; diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index e047f75b..c1e17545 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/utils/LocIpc.h b/utils/LocIpc.h index 8598a327..0c37a7ad 100644 --- a/utils/LocIpc.h +++ b/utils/LocIpc.h @@ -140,10 +140,10 @@ private: std::shared_ptr mSocket; struct sockaddr_un mDestAddr; - inline LocIpcSender( - const std::shared_ptr& mySocket, const char* destSocket) : mSocket(mySocket) { + inline LocIpcSender(const std::shared_ptr& mySocket, const char* destSocket) : + mSocket(mySocket), + mDestAddr({.sun_family = AF_UNIX, {}}) { if ((nullptr != mSocket) && (-1 != *mSocket) && (nullptr != destSocket)) { - mDestAddr.sun_family = AF_UNIX; snprintf(mDestAddr.sun_path, sizeof(mDestAddr.sun_path), "%s", destSocket); } } From 8f2e900e9e6aee5d9641b351dfffd5ca1a40ea6b Mon Sep 17 00:00:00 2001 From: Katz Yamada Date: Tue, 13 Mar 2018 09:30:43 -0700 Subject: [PATCH 13/19] fix: Typo in LocationDataTypes Fix typo in SystemTimeStructUnion definition. Change-Id: Idacfe730b4f56ae53f2c2dea72188788691da0f1 CRs-Fixed: 2206673 --- location/LocationDataTypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/location/LocationDataTypes.h b/location/LocationDataTypes.h index d03a8b4d..00cca183 100644 --- a/location/LocationDataTypes.h +++ b/location/LocationDataTypes.h @@ -673,7 +673,7 @@ typedef union { GnssSystemTimeStructType galSystemTime; GnssSystemTimeStructType bdsSystemTime; GnssSystemTimeStructType qzssSystemTime; - GnssGloTimeStructType gloSytemTime; + GnssGloTimeStructType gloSystemTime; } SystemTimeStructUnion; /** Time applicability of PVT report */ typedef struct { From 87c52f1f37b193dcb82500350e6c6efc4e41acac Mon Sep 17 00:00:00 2001 From: Katz Yamada Date: Tue, 20 Mar 2018 15:50:53 -0700 Subject: [PATCH 14/19] fix: add LOC_LOGi macro in log utility Add LOC_LOGi macro in log utility Change-Id: Ib30ce891496d61c10075cac028a80df2a6013a2a CRs-Fixed: 2209625 --- utils/log_util.h | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/log_util.h b/utils/log_util.h index 2fc04e2c..4fed90ba 100644 --- a/utils/log_util.h +++ b/utils/log_util.h @@ -160,6 +160,7 @@ extern char* get_timestamp(char* str, unsigned long buf_size); #define LOC_LOG_HEAD(fmt) "%s:%d] " fmt #define LOC_LOGv(fmt,...) LOC_LOGV(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) #define LOC_LOGw(fmt,...) LOC_LOGW(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define LOC_LOGi(fmt,...) LOC_LOGI(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) #define LOC_LOGd(fmt,...) LOC_LOGD(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) #define LOC_LOGe(fmt,...) LOC_LOGE(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) From 7f9ce9ddd07927aacf4b02333c66e381ac109bd2 Mon Sep 17 00:00:00 2001 From: Naresh Munagala Date: Tue, 27 Mar 2018 11:59:37 +0530 Subject: [PATCH 15/19] Add additional parameters in gps extended file Change-Id: I667b999dc164184d84aac0c5b6c1f3b2e9c761ea CRs-Fixed: 2183994 --- utils/gps_extended_c.h | 205 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 203 insertions(+), 2 deletions(-) diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index bd528d9e..57d9d517 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -105,6 +105,7 @@ typedef uint32_t LocPosTechMask; #define LOC_POS_TECH_MASK_INJECTED_COARSE_POSITION ((LocPosTechMask)0x00000020) #define LOC_POS_TECH_MASK_AFLT ((LocPosTechMask)0x00000040) #define LOC_POS_TECH_MASK_HYBRID ((LocPosTechMask)0x00000080) +#define LOC_POS_TECH_MASK_PPE ((LocPosTechMask)0x00000100) enum loc_registration_mask_status { LOC_REGISTRATION_MASK_ENABLED, @@ -305,6 +306,30 @@ typedef uint32_t GpsLocationExtendedFlags; #define GPS_LOCATION_EXTENDED_HAS_GPS_TIME 0x20000 /** GpsLocationExtended has Extended Dilution of Precision */ #define GPS_LOCATION_EXTENDED_HAS_EXT_DOP 0x40000 +/** GpsLocationExtended has North standard deviation */ +#define GPS_LOCATION_EXTENDED_HAS_NORTH_STD_DEV 0x80000 +/** GpsLocationExtended has East standard deviation*/ +#define GPS_LOCATION_EXTENDED_HAS_EAST_STD_DEV 0x100000 +/** GpsLocationExtended has North Velocity */ +#define GPS_LOCATION_EXTENDED_HAS_NORTH_VEL 0x200000 +/** GpsLocationExtended has East Velocity */ +#define GPS_LOCATION_EXTENDED_HAS_EAST_VEL 0x400000 +/** GpsLocationExtended has up Velocity */ +#define GPS_LOCATION_EXTENDED_HAS_UP_VEL 0x800000 +/** GpsLocationExtended has North Velocity Uncertainty */ +#define GPS_LOCATION_EXTENDED_HAS_NORTH_VEL_UNC 0x1000000 +/** GpsLocationExtended has East Velocity Uncertainty */ +#define GPS_LOCATION_EXTENDED_HAS_EAST_VEL_UNC 0x2000000 +/** GpsLocationExtended has up Velocity Uncertainty */ +#define GPS_LOCATION_EXTENDED_HAS_UP_VEL_UNC 0x4000000 +/** GpsLocationExtended has up Clock Bias */ +#define GPS_LOCATION_EXTENDED_HAS_CLOCK_BIAS 0x8000000 +/** GpsLocationExtended has up Clock Bias std deviation*/ +#define GPS_LOCATION_EXTENDED_HAS_CLOCK_BIAS_STD_DEV 0x10000000 +/** GpsLocationExtended has up Clock drift*/ +#define GPS_LOCATION_EXTENDED_HAS_CLOCK_DRIFT 0x20000000 +/** GpsLocationExtended has up Clock drift std deviation**/ +#define GPS_LOCATION_EXTENDED_HAS_CLOCK_DRIFT_STD_DEV 0x40000000 typedef uint32_t LocNavSolutionMask; /* Bitmask to specify whether SBAS ionospheric correction is used */ @@ -315,6 +340,12 @@ typedef uint32_t LocNavSolutionMask; #define LOC_NAV_MASK_SBAS_CORRECTION_LONG ((LocNavSolutionMask)0x0004) /**< Bitmask to specify whether SBAS integrity information is used */ #define LOC_NAV_MASK_SBAS_INTEGRITY ((LocNavSolutionMask)0x0008) +/**< Bitmask to specify whether Position Report is DGNSS corrected */ +#define LOC_NAV_MASK_DGNSS_CORRECTION ((LocNavSolutionMask)0x0010) +/**< Bitmask to specify whether Position Report is RTK corrected */ +#define LOC_NAV_MASK_RTK_CORRECTION ((LocNavSolutionMask)0x0020) +/**< Bitmask to specify whether Position Report is PPP corrected */ +#define LOC_NAV_MASK_PPP_CORRECTION ((LocNavSolutionMask)0x0040) typedef uint32_t LocPosDataMask; /* Bitmask to specify whether Navigation data has Forward Acceleration */ @@ -425,12 +456,123 @@ typedef struct { uint32_t gpsTimeOfWeekMs; }GPSTimeStruct; +typedef uint8_t CarrierPhaseAmbiguityType; +#define CARRIER_PHASE_AMBIGUITY_RESOLUTION_NONE ((CarrierPhaseAmbiguityType)0) +#define CARRIER_PHASE_AMBIGUITY_RESOLUTION_FLOAT ((CarrierPhaseAmbiguityType)1) +#define CARRIER_PHASE_AMBIGUITY_RESOLUTION_FIXED ((CarrierPhaseAmbiguityType)2) + +/** GNSS Signal Type and RF Band */ +typedef uint32_t GnssSignalTypeMask; +/** GPS L1CA Signal */ +#define GNSS_SIGNAL_GPS_L1CA ((GnssSignalTypeMask)0x00000001ul) +/** GPS L1C Signal */ +#define GNSS_SIGNAL_GPS_L1C ((GnssSignalTypeMask)0x00000002ul) +/** GPS L2 RF Band */ +#define GNSS_SIGNAL_GPS_L2 ((GnssSignalTypeMask)0x00000004ul) +/** GPS L5 RF Band */ +#define GNSS_SIGNAL_GPS_L5 ((GnssSignalTypeMask)0x00000008ul) +/** GLONASS G1 (L1OF) RF Band */ +#define GNSS_SIGNAL_GLONASS_G1 ((GnssSignalTypeMask)0x00000010ul) +/** GLONASS G2 (L2OF) RF Band */ +#define GNSS_SIGNAL_GLONASS_G2 ((GnssSignalTypeMask)0x00000020ul) +/** GALILEO E1 RF Band */ +#define GNSS_SIGNAL_GALILEO_E1 ((GnssSignalTypeMask)0x00000040ul) +/** GALILEO E5A RF Band */ +#define GNSS_SIGNAL_GALILEO_E5A ((GnssSignalTypeMask)0x00000080ul) +/** GALILEO E5B RF Band */ +#define GNSS_SIGNAL_GALILIEO_E5B ((GnssSignalTypeMask)0x00000100ul) +/** BEIDOU B1 RF Band */ +#define GNSS_SIGNAL_BEIDOU_B1 ((GnssSignalTypeMask)0x00000200ul) +/** BEIDOU B2 RF Band */ +#define GNSS_SIGNAL_BEIDOU_B2 ((GnssSignalTypeMask)0x00000400ul) +/** QZSS L1CA RF Band */ +#define GNSS_SIGNAL_QZSS_L1CA ((GnssSignalTypeMask)0x00000800ul) +/** QZSS L1S RF Band */ +#define GNSS_SIGNAL_QZSS_L1S ((GnssSignalTypeMask)0x00001000ul) +/** QZSS L2 RF Band */ +#define GNSS_SIGNAL_QZSS_L2 ((GnssSignalTypeMask)0x00002000ul) +/** QZSS L5 RF Band */ +#define GNSS_SIGNAL_QZSS_L5 ((GnssSignalTypeMask)0x00004000ul) +/** SBAS L1 RF Band */ +#define GNSS_SIGNAL_SBAS_L1 ((GnssSignalTypeMask)0x00008000ul) + +typedef uint16_t GnssMeasUsageStatusBitMask; +/** Used in fix */ +#define GNSS_MEAS_USED_IN_PVT ((GnssMeasUsageStatusBitMask)0x00000001ul) +/** Measurement is Bad */ +#define GNSS_MEAS_USAGE_STATUS_BAD_MEAS ((GnssMeasUsageStatusBitMask)0x00000002ul) +/** Measurement has too low C/N */ +#define GNSS_MEAS_USAGE_STATUS_CNO_TOO_LOW ((GnssMeasUsageStatusBitMask)0x00000004ul) +/** Measurement has too low elevation */ +#define GNSS_MEAS_USAGE_STATUS_ELEVATION_TOO_LOW ((GnssMeasUsageStatusBitMask)0x00000008ul) +/** No ephemeris available for this measurement */ +#define GNSS_MEAS_USAGE_STATUS_NO_EPHEMERIS ((GnssMeasUsageStatusBitMask)0x00000010ul) +/** No corrections available for the measurement */ +#define GNSS_MEAS_USAGE_STATUS_NO_CORRECTIONS ((GnssMeasUsageStatusBitMask)0x00000020ul) +/** Corrections has timed out for the measurement */ +#define GNSS_MEAS_USAGE_STATUS_CORRECTION_TIMEOUT ((GnssMeasUsageStatusBitMask)0x00000040ul) +/** Measurement is unhealthy */ +#define GNSS_MEAS_USAGE_STATUS_UNHEALTHY ((GnssMeasUsageStatusBitMask)0x00000080ul) +/** Configuration is disabled for this measurement */ +#define GNSS_MEAS_USAGE_STATUS_CONFIG_DISABLED ((GnssMeasUsageStatusBitMask)0x00000100ul) +/** Measurement not used for other reasons */ +#define GNSS_MEAS_USAGE_STATUS_OTHER ((GnssMeasUsageStatusBitMask)0x00000200ul) + +/** Flags to indicate valid fields in epMeasUsageInfo */ +typedef uint16_t GnssMeasUsageInfoValidityMask; +#define GNSS_PSEUDO_RANGE_RESIDUAL_VALID ((GnssMeasUsageInfoValidityMask)0x00000001ul) +#define GNSS_DOPPLER_RESIDUAL_VALID ((GnssMeasUsageInfoValidityMask)0x00000002ul) +#define GNSS_CARRIER_PHASE_RESIDUAL_VALID ((GnssMeasUsageInfoValidityMask)0x00000004ul) +#define GNSS_CARRIER_PHASE_AMBIGUITY_TYPE_VALID ((GnssMeasUsageInfoValidityMask)0x00000008ul) + +typedef struct { + /** Specifies GNSS signal type + Mandatory Field*/ + GnssSignalTypeMask gnssSignalType; + /** Specifies GNSS Constellation Type + Mandatory Field*/ + Gnss_LocSvSystemEnumType gnssConstellation; + /** GNSS SV ID. + For GPS: 1 to 32 + For GLONASS: 65 to 96. When slot-number to SV ID mapping is unknown, set as 255. + For SBAS: 120 to 151 + For QZSS-L1CA:193 to 197 + For BDS: 201 to 237 + For GAL: 301 to 336 */ + uint16_t gnssSvId; + /** GLONASS frequency number + 7. + Valid only for a GLONASS system and + is to be ignored for all other systems. + Range: 1 to 14 */ + uint8_t gloFrequency; + /** Carrier phase ambiguity type. */ + CarrierPhaseAmbiguityType carrierPhaseAmbiguityType; + /** Validity mask */ + GnssMeasUsageStatusBitMask measUsageStatusMask; + /** Specifies measurement usage status + Mandatory Field*/ + GnssMeasUsageInfoValidityMask validityMask; + /** Computed pseudorange residual. + Unit: Meters */ + float pseudorangeResidual; + /** Computed doppler residual. + Unit: Meters/sec*/ + float dopplerResidual; + /** Computed carrier phase residual. + Unit: Cycles*/ + float carrierPhaseResidual; + /** Carrier phase ambiguity value. + Unit: Cycles*/ + float carrierPhasAmbiguity; +} GpsMeasUsageInfo; + + /** Represents gps location extended. */ typedef struct { /** set to sizeof(GpsLocationExtended) */ size_t size; /** Contains GpsLocationExtendedFlags bits. */ - uint32_t flags; + uint64_t flags; /** Contains the Altitude wrt mean sea level */ float altitudeMeanSeaLevel; /** Contains Position Dilusion of Precision. */ @@ -471,8 +613,52 @@ typedef struct { LocPositionDynamics bodyFrameData; /** GPS Time */ GPSTimeStruct gpsTime; + GnssSystemTime gnssSystemTime; /** Dilution of precision associated with this position*/ LocExtDOP extDOP; + /** North standard deviation. + Unit: Meters */ + float northStdDeviation; + /** East standard deviation. + Unit: Meters */ + float eastStdDeviation; + /** North Velocity. + Unit: Meters/sec */ + float northVelocity; + /** East Velocity. + Unit: Meters/sec */ + float eastVelocity; + /** Up Velocity. + Unit: Meters/sec */ + float upVelocity; + /** North Velocity standard deviation. + Unit: Meters/sec */ + float northVelocityStdDeviation; + /** East Velocity standard deviation. + Unit: Meters/sec */ + float eastVelocityStdDeviation; + /** Up Velocity standard deviation + Unit: Meters/sec */ + float upVelocityStdDeviation; + /** Estimated clock bias. Unit: Nano seconds */ + float clockbiasMeter; + /** Estimated clock bias std deviation. Unit: Nano seconds */ + float clockBiasStdDeviationMeter; + /** Estimated clock drift. Unit: Meters/sec */ + float clockDrift; + /** Estimated clock drift std deviation. Unit: Meters/sec */ + float clockDriftStdDeviation; + /** Number of valid reference stations. Range:[0-4] */ + uint8_t numValidRefStations; + /** Reference station(s) number */ + uint16_t referenceStation[4]; + /** Number of measurements received for use in fix. + Shall be used as maximum index in-to svUsageInfo[]. + Set to 0, if svUsageInfo reporting is not supported. + Range: 0-EP_GNSS_MAX_MEAS */ + uint8_t numOfMeasReceived; + /** Measurement Usage Information */ + GpsMeasUsageInfo measUsageInfo[GNSS_SV_MAX]; } GpsLocationExtended; enum loc_sess_status { @@ -955,7 +1141,6 @@ typedef enum /**< SV is being tracked */ }Gnss_LocSvSearchStatusEnumT; - typedef struct { size_t size; @@ -1080,6 +1265,19 @@ typedef struct /**< Satellite Elevation - Units: radians \n */ + uint64_t validMeasStatusMask; + /**< Bitmask indicating SV measurement status Validity. + Valid bitmasks: \n + If any MSB bit in 0xFFC0000000000000 DONT_USE is set, the measurement + must not be used by the client. + @MASK() + */ + bool carrierPhaseUncValid; + /**< Validity flag for SV direction */ + + float carrierPhaseUnc; + + } Gnss_SVMeasurementStructType; /**< Maximum number of satellites in measurement block for given system. */ @@ -1141,6 +1339,9 @@ typedef struct bool gnssMeasValid; Gnss_ClockMeasurementStructType gnssMeas; Gnss_ApTimeStampStructType timeStamp; + /* Extended Time Information - Cumulative Number of Clock Resets */ + uint8_t numClockResets_valid; /**< Must be set to true if numClockResets is being passed */ + uint32_t numClockResets; } GnssSvMeasurementSet; From 6530ba80ad184259b0edc3c81d52e48e1259d8af Mon Sep 17 00:00:00 2001 From: Naresh Munagala Date: Fri, 30 Mar 2018 14:08:29 +0530 Subject: [PATCH 16/19] update uptimeMillis to get boot time Change-Id: I0f0c8235898e33ed6cee69d7d4c5a1e9b199c835 CRs-Fixed: 2209099 --- pla/oe/loc_pla.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pla/oe/loc_pla.h b/pla/oe/loc_pla.h index 50b19c2f..094e3f33 100644 --- a/pla/oe/loc_pla.h +++ b/pla/oe/loc_pla.h @@ -31,7 +31,18 @@ #ifdef __cplusplus #include -#define uptimeMillis android::uptimeMillis +#include +#include + +inline int64_t uptimeMillis() +{ + struct timespec ts; + int64_t time_ms = 0; + clock_gettime(CLOCK_BOOTTIME, &ts); + time_ms += (ts.tv_sec * 1000000000LL); + time_ms += ts.tv_nsec + 500000LL; + return time_ms / 1000000LL; +} extern "C" { #endif From 47fa2c06fa13e610d6df472b9fa39e22966a5630 Mon Sep 17 00:00:00 2001 From: Katz Yamada Date: Mon, 26 Mar 2018 20:46:47 -0700 Subject: [PATCH 17/19] Add location client api sockets' strings Add location client api socket path string definitions in utils/gps_extended_c.h. CRs-Fixed: 2196048 Change-Id: Ie2eea05dfe440fa3a96b531fa4ba17605ab53431 --- utils/gps_extended_c.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 57d9d517..1a54278e 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -1489,8 +1489,15 @@ typedef void (*LocAgpsOpenResultCb)(bool isSuccess, AGpsExtType agpsType, const typedef void (*LocAgpsCloseResultCb)(bool isSuccess, AGpsExtType agpsType, void* userDataPtr); /* Shared resources of LocIpc */ -#define LOC_IPC_HAL "/dev/socket/location/socket_hal" -#define LOC_IPC_XTRA "/dev/socket/location/xtra/socket_xtra" +#define LOC_IPC_HAL "/dev/socket/location/socket_hal" +#define LOC_IPC_XTRA "/dev/socket/location/xtra/socket_xtra" + +#define SOCKET_DIR_LOCATION "/dev/socket/location/" +#define SOCKET_DIR_EHUB "/dev/socket/location/ehub" +#define SOCKET_TO_LOCATION_HAL_DAEMON "/dev/socket/location/hal_daemon" + +#define SOCKET_DIR_TO_CLIENT "/dev/socket/loc_client/" +#define SOCKET_TO_LOCATION_CLIENT_BASE "/dev/socket/loc_client/toclient" #ifdef __cplusplus } From 82d0efd99ae4aa5643d6fa844f44c850fa008cc5 Mon Sep 17 00:00:00 2001 From: Yingjie Wang Date: Thu, 15 Mar 2018 11:42:15 +0530 Subject: [PATCH 18/19] Map additional fields in GpsLocationExtended Map velocity and system time fields from GpsLocationExtended to GnssLocationInfoNotification Change-Id: If53575213de575ad71b68018beb8c3f5fd587bcf CRs-fixed: 2184592 --- gnss/GnssAdapter.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index f996ebee..dca3d0f9 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -367,6 +367,35 @@ GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out, out.bodyFrameData.yawRate = locationExtended.bodyFrameData.yawRate; out.bodyFrameData.pitch = locationExtended.bodyFrameData.pitch; } + if (GPS_LOCATION_EXTENDED_HAS_GPS_TIME & locationExtended.flags) { + out.flags |= GPS_LOCATION_EXTENDED_HAS_GPS_TIME; + out.gnssSystemTime.gnssSystemTimeSrc = locationExtended.gnssSystemTime.gnssSystemTimeSrc; + out.gnssSystemTime.u = locationExtended.gnssSystemTime.u; + } + if (GPS_LOCATION_EXTENDED_HAS_NORTH_VEL & locationExtended.flags) { + out.flags |= GPS_LOCATION_EXTENDED_HAS_NORTH_VEL; + out.northVelocity = locationExtended.northVelocity; + } + if (GPS_LOCATION_EXTENDED_HAS_EAST_VEL & locationExtended.flags) { + out.flags |= GPS_LOCATION_EXTENDED_HAS_EAST_VEL; + out.eastVelocity = locationExtended.eastVelocity; + } + if (GPS_LOCATION_EXTENDED_HAS_UP_VEL & locationExtended.flags) { + out.flags |= GPS_LOCATION_EXTENDED_HAS_UP_VEL; + out.upVelocity = locationExtended.upVelocity; + } + if (GPS_LOCATION_EXTENDED_HAS_NORTH_VEL_UNC & locationExtended.flags) { + out.flags |= GPS_LOCATION_EXTENDED_HAS_NORTH_VEL_UNC; + out.northVelocityStdDeviation = locationExtended.northVelocityStdDeviation; + } + if (GPS_LOCATION_EXTENDED_HAS_EAST_VEL_UNC & locationExtended.flags) { + out.flags |= GPS_LOCATION_EXTENDED_HAS_EAST_VEL_UNC; + out.eastVelocityStdDeviation = locationExtended.eastVelocityStdDeviation; + } + if (GPS_LOCATION_EXTENDED_HAS_UP_VEL_UNC & locationExtended.flags) { + out.flags |= GPS_LOCATION_EXTENDED_HAS_UP_VEL_UNC; + out.upVelocityStdDeviation = locationExtended.upVelocityStdDeviation; + } } inline uint32_t From e5c31f33c1fac9129b7141c62d61826dfc041a54 Mon Sep 17 00:00:00 2001 From: Bhavna Sharma Date: Fri, 30 Mar 2018 17:10:59 -0700 Subject: [PATCH 19/19] GPS Adapter: GNSS adapter change to go with engine hub aggregator 1: GNSS adapter change to block out position and SV report from ULP when engine hub aggregator is used 2: Support unpropagated position report Change-Id: Id0cacd87d3f3f8eec893d751b9f7a55a736a4023 CRs-fixed: 2210253 --- core/EngineHubProxyBase.h | 7 +++-- core/LocAdapterBase.cpp | 5 ++-- core/LocAdapterBase.h | 6 +++-- gnss/GnssAdapter.cpp | 54 +++++++++++++++++++++++++++++++-------- gnss/GnssAdapter.h | 7 +++-- utils/gps_extended_c.h | 4 ++- 6 files changed, 64 insertions(+), 19 deletions(-) diff --git a/core/EngineHubProxyBase.h b/core/EngineHubProxyBase.h index 7b9f3ae8..4e259ba7 100644 --- a/core/EngineHubProxyBase.h +++ b/core/EngineHubProxyBase.h @@ -92,10 +92,13 @@ typedef std::function + bool fromUlp, + bool fromEngineHub)> GnssAdapterReportPositionEventCb; -typedef std::function +typedef std::function GnssAdapterReportSvEventCb; // potential parameters: message queue: MsgTask * msgTask; diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp index f3c999c2..5d1b2c21 100644 --- a/core/LocAdapterBase.cpp +++ b/core/LocAdapterBase.cpp @@ -79,7 +79,7 @@ void LocAdapterBase:: const GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask loc_technology_mask, - bool /*fromUlp*/) { + bool /*fromUlp*/, bool /*fromEngineHub*/) { if (mLocAdapterProxyBase != NULL) { mLocAdapterProxyBase->reportPositionEvent((UlpLocation&)location, (GpsLocationExtended&)locationExtended, @@ -91,7 +91,8 @@ void LocAdapterBase:: } void LocAdapterBase:: - reportSvEvent(const GnssSvNotification& /*svNotify*/, bool /*fromUlp*/) + reportSvEvent(const GnssSvNotification& /*svNotify*/, + bool /*fromUlp*/, bool /*fromEngineHub*/) DEFAULT_IMPL() void LocAdapterBase:: diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h index e7beca83..8388c712 100644 --- a/core/LocAdapterBase.h +++ b/core/LocAdapterBase.h @@ -131,8 +131,10 @@ public: const GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask loc_technology_mask, - bool fromUlp=false); - virtual void reportSvEvent(const GnssSvNotification& svNotify, bool fromUlp=false); + bool fromUlp=false, + bool fromEngineHub=false); + virtual void reportSvEvent(const GnssSvNotification& svNotify, + bool fromUlp=false, bool fromEngineHub=false); virtual void reportNmeaEvent(const char* nmea, size_t length, bool fromUlp=false); virtual void reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet); virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial); diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index dca3d0f9..f619a9a3 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -1259,6 +1259,7 @@ GnssAdapter::updateClientsEventMask() (true == initEngHubProxy())) { mask |= LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT; mask |= LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT; + mask |= LOC_API_ADAPTER_BIT_PARSED_UNPROPAGATED_POSITION_REPORT; LOC_LOGD("%s]: Auto usecase, Enable MEAS/POLY - mask 0x%x", __func__, mask); } @@ -2121,22 +2122,43 @@ GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation, const GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask techMask, - bool fromUlp) + bool fromUlp, + bool fromEngineHub) { LOC_LOGD("%s]: fromUlp %u status %u", __func__, fromUlp, status); // if this event is called from QMI LOC API, then try to call into ULP and return if successfull // if the position is called from ULP or engine hub, then send it out directly - if (!fromUlp) { - // report QMI position to engine hub, and engine hub will be - // distributing it to the registered plugins + if (!fromUlp && !fromEngineHub) { + // report QMI position (both propagated and unpropagated) to engine hub, + // and engine hub will be distributing it to the registered plugins mEngHubProxy->gnssReportPosition(ulpLocation, locationExtended, status); + + if (true == ulpLocation.unpropagatedPosition) { + return; + } + + // only send propagated position report to ulp if (mUlpProxy->reportPosition(ulpLocation, locationExtended, status, techMask)) { return; } + + // engine hub is loaded, do not report qmi position to client as + // final position report should come from engine hub + if (true == initEngHubProxy()){ + return; + } + } else if ((true == fromUlp) && (true == initEngHubProxy())) { + LOC_LOGV("%s]: drop ULP GNSS fix as engine hub is loaded", __func__); + return; } + // for all other cases: + // case 1: fix is from ULP and engine hub is not loaded, queue the msg + // case 2: fix is from engine hub, queue the msg + // when message is queued, the position can be dispatched to requesting client + struct MsgReportPosition : public LocMsg { GnssAdapter& mAdapter; const UlpLocation mUlpLocation; @@ -2237,18 +2259,28 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation, void GnssAdapter::reportSvEvent(const GnssSvNotification& svNotify, - bool fromUlp) + bool fromUlp, + bool fromEngineHub) { LOC_LOGD("%s]: fromUlp %u", __func__, fromUlp); // if this event is not called from ULP, then try to call into ULP and return if successfull - if (!fromUlp) { + if (!fromUlp && !fromEngineHub) { // report QMI SV report to eng hub mEngHubProxy->gnssReportSv(svNotify); if (mUlpProxy->reportSv(svNotify)) { return; } + + // engine hub is loaded, do not report sv to client + // as sv report should come from engine hub + if (true == initEngHubProxy()){ + return; + } + } else if ((true == fromUlp) && (true == initEngHubProxy())) { + LOC_LOGV("%s]: drop ULP GNSS SV event as engine hub is loaded", __func__); + return; } struct MsgReportSv : public LocMsg { @@ -3326,15 +3358,17 @@ GnssAdapter::initEngHubProxy() { const GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask techMask, - bool fromUlp) { + bool fromUlp, + bool fromEngineHub) { // report from engine hub on behalf of PPE will be treated as fromUlp - reportPositionEvent(ulpLocation, locationExtended, status, techMask, fromUlp); + reportPositionEvent(ulpLocation, locationExtended, status, + techMask, fromUlp, fromEngineHub); }; // callback function for engine hub to report back sv event GnssAdapterReportSvEventCb reportSvEventCb = - [this](const GnssSvNotification& svNotify, bool fromUlp) { - reportSvEvent(svNotify, fromUlp); + [this](const GnssSvNotification& svNotify, bool fromUlp, bool fromEngineHub) { + reportSvEvent(svNotify, fromUlp, fromEngineHub); }; getEngHubProxyFn* getter = (getEngHubProxyFn*) dlsym(handle, "getEngHubProxy"); diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index c1e17545..85962cfb 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -235,8 +235,11 @@ public: const GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask techMask, - bool fromUlp=false); - virtual void reportSvEvent(const GnssSvNotification& svNotify, bool fromUlp=false); + bool fromUlp=false, + bool fromEngineHub=false); + virtual void reportSvEvent(const GnssSvNotification& svNotify, + bool fromUlp=false, + bool fromEngineHub=false); virtual void reportNmeaEvent(const char* nmea, size_t length, bool fromUlp=false); virtual bool requestNiNotifyEvent(const GnssNiNotification& notify, const void* data); virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurements, diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 57d9d517..95656821 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -128,6 +128,7 @@ typedef struct { /* Provider indicator for HYBRID or GPS */ uint16_t position_source; LocPosTechMask tech_mask; + bool unpropagatedPosition; } UlpLocation; typedef struct { @@ -769,6 +770,7 @@ enum loc_api_adapter_event_index { LOC_API_ADAPTER_REQUEST_POSITION_INJECTION, // Position injection request LOC_API_ADAPTER_BATCH_STATUS, // batch status LOC_API_ADAPTER_FDCL_SERVICE_REQ, // FDCL service request + LOC_API_ADAPTER_REPORT_UNPROPAGATED_POSITION, // Unpropagated Position report LOC_API_ADAPTER_EVENT_MAX }; @@ -805,7 +807,7 @@ enum loc_api_adapter_event_index { #define LOC_API_ADAPTER_BIT_POSITION_INJECTION_REQUEST (1<