diff options
author | qctecmdr <qctecmdr@localhost> | 2019-05-09 01:39:27 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2019-05-09 01:39:27 -0700 |
commit | 9391fe52a410e33e51cdd904e9522347d8b9462d (patch) | |
tree | 80d1ea081077a5b9686f99c59ce381da5f693ce8 /gnss | |
parent | ce5531372403e918b782d5b8d5d6c56de22bd69f (diff) | |
parent | 81f47db3f25e00ca7f2571c9211ce47d273d6f97 (diff) | |
download | gps-9391fe52a410e33e51cdd904e9522347d8b9462d.tar.gz |
Merge "GPS: add numSVUsedInFix in location api"
Diffstat (limited to 'gnss')
-rw-r--r-- | gnss/GnssAdapter.cpp | 39 | ||||
-rw-r--r-- | gnss/GnssAdapter.h | 2 |
2 files changed, 40 insertions, 1 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 1c80443..de85353 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -229,6 +229,31 @@ GnssAdapter::convertLocation(Location& out, const UlpLocation& ulpLocation, } } +/* This is utility routine that computes number of SV used + in the fix from the svUsedIdsMask. + */ +#define MAX_SV_CNT_SUPPORTED_IN_ONE_CONSTELLATION 64 +uint16_t GnssAdapter::getNumSvUsed(uint64_t svUsedIdsMask, + int totalSvCntInThisConstellation) +{ + if (totalSvCntInThisConstellation > MAX_SV_CNT_SUPPORTED_IN_ONE_CONSTELLATION) { + LOC_LOGe ("error: total SV count in this constellation %d exceeded limit of %d", + totalSvCntInThisConstellation, MAX_SV_CNT_SUPPORTED_IN_ONE_CONSTELLATION); + return 0; + } + + uint16_t numSvUsed = 0; + uint64_t mask = 0x1; + for (int i = 0; i < totalSvCntInThisConstellation; i++) { + if (svUsedIdsMask & mask) { + numSvUsed++; + } + mask <<= 1; + } + + return numSvUsed; +} + void GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out, const GpsLocationExtended& locationExtended) @@ -349,8 +374,20 @@ GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out, locationExtended.gnss_sv_used_ids.bds_sv_used_ids_mask; out.svUsedInPosition.qzssSvUsedIdsMask = locationExtended.gnss_sv_used_ids.qzss_sv_used_ids_mask; - out.numOfMeasReceived = locationExtended.numOfMeasReceived; + out.flags |= GNSS_LOCATION_INFO_NUM_SV_USED_IN_POSITION_BIT; + out.numSvUsedInPosition = getNumSvUsed(out.svUsedInPosition.gpsSvUsedIdsMask, + GPS_SV_PRN_MAX - GPS_SV_PRN_MIN + 1); + out.numSvUsedInPosition += getNumSvUsed(out.svUsedInPosition.gloSvUsedIdsMask, + GLO_SV_PRN_MAX - GLO_SV_PRN_MIN + 1); + out.numSvUsedInPosition += getNumSvUsed(out.svUsedInPosition.qzssSvUsedIdsMask, + QZSS_SV_PRN_MAX - QZSS_SV_PRN_MIN + 1); + out.numSvUsedInPosition += getNumSvUsed(out.svUsedInPosition.bdsSvUsedIdsMask, + BDS_SV_PRN_MAX - BDS_SV_PRN_MIN + 1); + out.numSvUsedInPosition += getNumSvUsed(out.svUsedInPosition.galSvUsedIdsMask, + GAL_SV_PRN_MAX - GAL_SV_PRN_MIN + 1); + + out.numOfMeasReceived = locationExtended.numOfMeasReceived; for (int idx =0; idx < locationExtended.numOfMeasReceived; idx++) { out.measUsageInfo[idx].gnssSignalType = locationExtended.measUsageInfo[idx].gnssSignalType; diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 13efab1..1e6d1b8 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -205,6 +205,8 @@ class GnssAdapter : public LocAdapterBase { const LocPosTechMask techMask); static void convertLocationInfo(GnssLocationInfoNotification& out, const GpsLocationExtended& locationExtended); + static uint16_t getNumSvUsed(uint64_t svUsedIdsMask, + int totalSvCntInThisConstellation); /* ======== UTILITIES ================================================================== */ inline void initOdcpi(const OdcpiRequestCallback& callback); |