From dd823bc93e10e9a25967d2e9bbfee3d0bb0e454e Mon Sep 17 00:00:00 2001 From: Dante Russo Date: Wed, 17 Jun 2015 14:27:50 -0700 Subject: [PATCH] Add glo and bds to used-in-fix mask The used-in-fix mask is only keeping track of GPS SVs, so add a used-in-fix mask for GlONASS SVs and BDS SVs as well to avoid NMEA generation issues CRs-fixed: 826152 Change-Id: I33862cf8d40db1d667179ef68d18703edc359843 --- core/LocAdapterBase.cpp | 2 +- core/LocAdapterBase.h | 2 +- core/LocApiBase.cpp | 9 ++-- core/LocApiBase.h | 2 +- core/UlpProxyBase.h | 2 +- core/gps_extended_c.h | 41 +++++++++++++++++++ .../libloc_api-rpc-glue/src/LocApiRpc.cpp | 12 ++++-- loc_api/libloc_api_50001/LocEngAdapter.cpp | 4 +- loc_api/libloc_api_50001/LocEngAdapter.h | 4 +- loc_api/libloc_api_50001/loc_eng.cpp | 2 +- loc_api/libloc_api_50001/loc_eng_msg.h | 4 +- loc_api/libloc_api_50001/loc_eng_nmea.cpp | 8 ++-- loc_api/libloc_api_50001/loc_eng_nmea.h | 3 +- 13 files changed, 73 insertions(+), 22 deletions(-) diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp index b304653a..4e62693d 100644 --- a/core/LocAdapterBase.cpp +++ b/core/LocAdapterBase.cpp @@ -79,7 +79,7 @@ void LocAdapterBase:: } void LocAdapterBase:: - reportSv(GpsSvStatus &svStatus, + reportSv(GnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt) DEFAULT_IMPL() diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h index 9d5f6a81..c7e3f1c1 100644 --- a/core/LocAdapterBase.h +++ b/core/LocAdapterBase.h @@ -92,7 +92,7 @@ public: void* locationExt, enum loc_sess_status status, LocPosTechMask loc_technology_mask); - virtual void reportSv(GpsSvStatus &svStatus, + virtual void reportSv(GnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt); virtual void reportStatus(GpsStatusValue status); diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index f56694e7..5c852729 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -253,15 +253,16 @@ void LocApiBase::reportPosition(UlpLocation &location, ); } -void LocApiBase::reportSv(GpsSvStatus &svStatus, +void LocApiBase::reportSv(GnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt) { // print the SV info before delivering - LOC_LOGV("num sv: %d\n ephemeris mask: %dxn almanac mask: %x\n used" - " in fix mask: %x\n sv: prn snr elevation azimuth", + LOC_LOGV("num sv: %d\n ephemeris mask: %dxn almanac mask: %x\n gps/glo/bds in use" + " mask: %x/%x/%x\n sv: prn snr elevation azimuth", svStatus.num_svs, svStatus.ephemeris_mask, - svStatus.almanac_mask, svStatus.used_in_fix_mask); + svStatus.almanac_mask, svStatus.gps_used_in_fix_mask, + svStatus.glo_used_in_fix_mask, svStatus.bds_used_in_fix_mask); for (int i = 0; i < svStatus.num_svs && i < GPS_MAX_SVS; i++) { LOC_LOGV(" %d: %d %f %f %f", i, diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 414769b5..b1c3d30a 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -113,7 +113,7 @@ public: enum loc_sess_status status, LocPosTechMask loc_technology_mask = LOC_POS_TECH_MASK_DEFAULT); - void reportSv(GpsSvStatus &svStatus, + void reportSv(GnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt); void reportStatus(GpsStatusValue status); diff --git a/core/UlpProxyBase.h b/core/UlpProxyBase.h index b9a8224f..d08ad711 100644 --- a/core/UlpProxyBase.h +++ b/core/UlpProxyBase.h @@ -58,7 +58,7 @@ public: LocPosTechMask loc_technology_mask) { return false; } - inline virtual bool reportSv(GpsSvStatus &svStatus, + inline virtual bool reportSv(GnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt) { return false; diff --git a/core/gps_extended_c.h b/core/gps_extended_c.h index ff66ef5b..4f3e8fe9 100644 --- a/core/gps_extended_c.h +++ b/core/gps_extended_c.h @@ -290,6 +290,47 @@ typedef struct GpsExtLocation_s { uint32_t sources_used; } GpsExtLocation; +/** Represents SV status. */ +typedef struct { + /** set to sizeof(GnssSvStatus) */ + size_t size; + + /** Number of SVs currently visible. */ + int num_svs; + + /** Contains an array of SV information. */ + GpsSvInfo sv_list[GPS_MAX_SVS]; + + /** Represents a bit mask indicating which SVs + * have ephemeris data. + */ + uint32_t ephemeris_mask; + + /** Represents a bit mask indicating which SVs + * have almanac data. + */ + uint32_t almanac_mask; + + /** + * Represents a bit mask indicating which GPS SVs + * were used for computing the most recent position fix. + */ + uint32_t gps_used_in_fix_mask; + + /** + * Represents a bit mask indicating which GLONASS SVs + * were used for computing the most recent position fix. + */ + uint32_t glo_used_in_fix_mask; + + /** + * Represents a bit mask indicating which BDS SVs + * were used for computing the most recent position fix. + */ + uint64_t bds_used_in_fix_mask; + +} GnssSvStatus; + enum loc_sess_status { LOC_SESS_SUCCESS, LOC_SESS_INTERMEDIATE, diff --git a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp index dbfc2fb7..c7447543 100644 --- a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp +++ b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp @@ -797,7 +797,7 @@ void LocApiRpc::reportPosition(const rpc_loc_parsed_position_s_type *location_re void LocApiRpc::reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr) { - GpsSvStatus SvStatus = {0}; + GnssSvStatus SvStatus = {0}; GpsLocationExtended locationExtended = {0}; locationExtended.size = sizeof(locationExtended); int num_svs_max = 0; @@ -823,7 +823,7 @@ void LocApiRpc::reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr) { if (sv_info_ptr->system == RPC_LOC_SV_SYSTEM_GPS) { - SvStatus.sv_list[SvStatus.num_svs].size = sizeof(GpsSvStatus); + SvStatus.sv_list[SvStatus.num_svs].size = sizeof(GpsSvInfo); SvStatus.sv_list[SvStatus.num_svs].prn = sv_info_ptr->prn; // We only have the data field to report gps eph and alm mask @@ -842,7 +842,7 @@ void LocApiRpc::reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr) if ((sv_info_ptr->valid_mask & RPC_LOC_SV_INFO_VALID_PROCESS_STATUS) && (sv_info_ptr->process_status == RPC_LOC_SV_STATUS_TRACK)) { - SvStatus.used_in_fix_mask |= (1 << (sv_info_ptr->prn-1)); + SvStatus.gps_used_in_fix_mask |= (1 << (sv_info_ptr->prn-1)); } } // SBAS: GPS RPN: 120-151, @@ -855,6 +855,12 @@ void LocApiRpc::reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr) // In extended measurement report, we follow nmea standard, which is 65-96 else if (sv_info_ptr->system == RPC_LOC_SV_SYSTEM_GLONASS) { + if ((sv_info_ptr->valid_mask & RPC_LOC_SV_INFO_VALID_PROCESS_STATUS) && + (sv_info_ptr->process_status == RPC_LOC_SV_STATUS_TRACK)) + { + SvStatus.glo_used_in_fix_mask |= (1 << (sv_info_ptr->prn-1)); + } + SvStatus.sv_list[SvStatus.num_svs].prn = sv_info_ptr->prn + (65-1); } // Unsupported SV system diff --git a/loc_api/libloc_api_50001/LocEngAdapter.cpp b/loc_api/libloc_api_50001/LocEngAdapter.cpp index 2f025af2..0c497aa3 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.cpp +++ b/loc_api/libloc_api_50001/LocEngAdapter.cpp @@ -203,14 +203,14 @@ void LocEngAdapter::reportPosition(UlpLocation &location, } } -void LocInternalAdapter::reportSv(GpsSvStatus &svStatus, +void LocInternalAdapter::reportSv(GnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt){ sendMsg(new LocEngReportSv(mLocEngAdapter, svStatus, locationExtended, svExt)); } -void LocEngAdapter::reportSv(GpsSvStatus &svStatus, +void LocEngAdapter::reportSv(GnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt) { diff --git a/loc_api/libloc_api_50001/LocEngAdapter.h b/loc_api/libloc_api_50001/LocEngAdapter.h index e5d10184..8ae8992a 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.h +++ b/loc_api/libloc_api_50001/LocEngAdapter.h @@ -55,7 +55,7 @@ public: void* locationExt, enum loc_sess_status status, LocPosTechMask loc_technology_mask); - virtual void reportSv(GpsSvStatus &svStatus, + virtual void reportSv(GnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt); virtual void reportStatus(GpsStatusValue status); @@ -269,7 +269,7 @@ public: void* locationExt, enum loc_sess_status status, LocPosTechMask loc_technology_mask); - virtual void reportSv(GpsSvStatus &svStatus, + virtual void reportSv(GnssSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt); virtual void reportStatus(GpsStatusValue status); diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index 9f62ce22..722f99a2 100644 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -850,7 +850,7 @@ void LocEngReportPosition::send() const { // case LOC_ENG_MSG_REPORT_SV: LocEngReportSv::LocEngReportSv(LocAdapterBase* adapter, - GpsSvStatus &sv, + GnssSvStatus &sv, GpsLocationExtended &locExtended, void* svExt) : LocMsg(), mAdapter(adapter), mSvStatus(sv), diff --git a/loc_api/libloc_api_50001/loc_eng_msg.h b/loc_api/libloc_api_50001/loc_eng_msg.h index e3c48fb4..731f9288 100644 --- a/loc_api/libloc_api_50001/loc_eng_msg.h +++ b/loc_api/libloc_api_50001/loc_eng_msg.h @@ -105,11 +105,11 @@ struct LocEngReportPosition : public LocMsg { struct LocEngReportSv : public LocMsg { LocAdapterBase* mAdapter; - const GpsSvStatus mSvStatus; + const GnssSvStatus mSvStatus; const GpsLocationExtended mLocationExtended; const void* mSvExt; LocEngReportSv(LocAdapterBase* adapter, - GpsSvStatus &sv, + GnssSvStatus &sv, GpsLocationExtended &locExtended, void* svExtended); virtual void proc() const; diff --git a/loc_api/libloc_api_50001/loc_eng_nmea.cpp b/loc_api/libloc_api_50001/loc_eng_nmea.cpp index 4c6b9a3a..7bc58bd0 100644 --- a/loc_api/libloc_api_50001/loc_eng_nmea.cpp +++ b/loc_api/libloc_api_50001/loc_eng_nmea.cpp @@ -604,7 +604,7 @@ SIDE EFFECTS ===========================================================================*/ void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, - const GpsSvStatus &svStatus, const GpsLocationExtended &locationExtended) + const GnssSvStatus &svStatus, const GpsLocationExtended &locationExtended) { ENTRY_LOG(); @@ -790,7 +790,9 @@ void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, }//if - if (svStatus.used_in_fix_mask == 0) + if (svStatus.gps_used_in_fix_mask == 0 && + svStatus.glo_used_in_fix_mask == 0 && + svStatus.bds_used_in_fix_mask == 0) { // No sv used, so there will be no position report, so send // blank NMEA sentences strlcpy(sentence, "$GPGSA,A,1,,,,,,,,,,,,,,,", sizeof(sentence)); @@ -812,7 +814,7 @@ void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, else { // cache the used in fix mask, as it will be needed to send $GPGSA // during the position report - loc_eng_data_p->sv_used_mask = svStatus.used_in_fix_mask; + loc_eng_data_p->sv_used_mask = svStatus.gps_used_in_fix_mask; // For RPC, the DOP are sent during sv report, so cache them // now to be sent during position report. diff --git a/loc_api/libloc_api_50001/loc_eng_nmea.h b/loc_api/libloc_api_50001/loc_eng_nmea.h index 40c6dbbd..066943aa 100644 --- a/loc_api/libloc_api_50001/loc_eng_nmea.h +++ b/loc_api/libloc_api_50001/loc_eng_nmea.h @@ -31,12 +31,13 @@ #define LOC_ENG_NMEA_H #include +#include #define NMEA_SENTENCE_MAX_LENGTH 200 void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p); int loc_eng_nmea_put_checksum(char *pNmea, int maxSize); -void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, const GpsSvStatus &svStatus, const GpsLocationExtended &locationExtended); +void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, const GnssSvStatus &svStatus, const GpsLocationExtended &locationExtended); void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, const UlpLocation &location, const GpsLocationExtended &locationExtended, unsigned char generate_nmea); #endif // LOC_ENG_NMEA_H