diff --git a/gps/CleanSpec.mk b/gps/CleanSpec.mk new file mode 100644 index 0000000..dd1849d --- /dev/null +++ b/gps/CleanSpec.mk @@ -0,0 +1,50 @@ +# Copyright (C) 2007 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# If you don't need to do a full clean build but would like to touch +# a file or delete some intermediate files, add a clean step to the end +# of the list. These steps will only be run once, if they haven't been +# run before. +# +# E.g.: +# $(call add-clean-step, touch -c external/sqlite/sqlite3.h) +# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) +# +# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with +# files that are missing or have been moved. +# +# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. +# Use $(OUT_DIR) to refer to the "out" directory. +# +# If you need to re-do something that's already mentioned, just copy +# the command and add it to the bottom of the list. E.g., if a change +# that you made last week required touching a file and a change you +# made today requires touching the same file, just copy the old +# touch step and add it to the end of the list. +# +# ************************************************ +# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST +# ************************************************ + +# For example: +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) +#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) +#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) + +# ************************************************ +# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST +# ************************************************ +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libloc_api*) diff --git a/gps/core/LocApiBase.cpp b/gps/core/LocApiBase.cpp index 1278155..c7f8f6a 100644 --- a/gps/core/LocApiBase.cpp +++ b/gps/core/LocApiBase.cpp @@ -30,6 +30,7 @@ #define LOG_TAG "LocSvc_LocApiBase" #include +#include #include #include #include @@ -106,19 +107,16 @@ struct LocSsrMsg : public LocMsg { struct LocOpenMsg : public LocMsg { LocApiBase* mLocApi; - LOC_API_ADAPTER_EVENT_MASK_T mMask; - inline LocOpenMsg(LocApiBase* locApi, - LOC_API_ADAPTER_EVENT_MASK_T mask) : - LocMsg(), mLocApi(locApi), mMask(mask) + inline LocOpenMsg(LocApiBase* locApi) : + LocMsg(), mLocApi(locApi) { locallog(); } inline virtual void proc() const { - mLocApi->open(mMask); + mLocApi->open(mLocApi->getEvtMask()); } inline void locallog() { - LOC_LOGV("%s:%d]: LocOpen Mask: %x\n", - __func__, __LINE__, mMask); + LOC_LOGV("LocOpen Mask: %" PRIx32 "\n", mLocApi->getEvtMask()); } inline virtual void log() { locallog(); @@ -161,8 +159,7 @@ void LocApiBase::addAdapter(LocAdapterBase* adapter) for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) { if (mLocAdapters[i] == NULL) { mLocAdapters[i] = adapter; - mMsgTask->sendMsg(new LocOpenMsg(this, - (adapter->getEvtMask()))); + mMsgTask->sendMsg(new LocOpenMsg(this)); break; } } @@ -198,7 +195,7 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter) close(); } else { // else we need to remove the bit - mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask())); + mMsgTask->sendMsg(new LocOpenMsg(this)); } } } @@ -206,7 +203,7 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter) void LocApiBase::updateEvtMask() { - mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask())); + mMsgTask->sendMsg(new LocOpenMsg(this)); } void LocApiBase::handleEngineUpEvent() @@ -243,6 +240,12 @@ void LocApiBase::reportPosition(UlpLocation &location, location.gpsLocation.bearing, location.gpsLocation.accuracy, location.gpsLocation.timestamp, location.rawDataSize, location.rawData, status, loc_technology_mask); + + if (location.gpsLocation.timestamp > 0 && location.gpsLocation.timestamp < 1580000000000) { + location.gpsLocation.timestamp += 619315200000; /* 1024 * 7 * 24 * 60 * 60 * 1000 */ + LOC_LOGV("week rollover fixed, timestamp: %lld.", location.gpsLocation.timestamp); + } + // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS( mLocAdapters[i]->reportPosition(location, diff --git a/gps/core/UlpProxyBase.h b/gps/core/UlpProxyBase.h index 79b5248..1f807a7 100644 --- a/gps/core/UlpProxyBase.h +++ b/gps/core/UlpProxyBase.h @@ -100,6 +100,12 @@ public: (void)number_of_locations; return false; } + inline virtual bool reportNmea(const char* nmea, int length) + { + (void)nmea; + (void)length; + return false; + } }; } // namespace loc_core diff --git a/gps/core/gps_extended_c.h b/gps/core/gps_extended_c.h index fb08364..60ed12d 100644 --- a/gps/core/gps_extended_c.h +++ b/gps/core/gps_extended_c.h @@ -70,6 +70,7 @@ extern "C" { #define ULP_LOCATION_IS_FROM_PIP 0x0040 #define ULP_MIN_INTERVAL_INVALID 0xffffffff +#define ULP_MAX_NMEA_STRING_SIZE 201 /*Emergency SUPL*/ #define GPS_NI_TYPE_EMERGENCY_SUPL 4 @@ -77,6 +78,17 @@ extern "C" { #define AGPS_CERTIFICATE_MAX_LENGTH 2000 #define AGPS_CERTIFICATE_MAX_SLOTS 10 +typedef uint32_t LocPosTechMask; +#define LOC_POS_TECH_MASK_DEFAULT ((LocPosTechMask)0x00000000) +#define LOC_POS_TECH_MASK_SATELLITE ((LocPosTechMask)0x00000001) +#define LOC_POS_TECH_MASK_CELLID ((LocPosTechMask)0x00000002) +#define LOC_POS_TECH_MASK_WIFI ((LocPosTechMask)0x00000004) +#define LOC_POS_TECH_MASK_SENSORS ((LocPosTechMask)0x00000008) +#define LOC_POS_TECH_MASK_REFERENCE_LOCATION ((LocPosTechMask)0x00000010) +#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) + enum loc_registration_mask_status { LOC_REGISTRATION_MASK_ENABLED, LOC_REGISTRATION_MASK_DISABLED @@ -88,6 +100,7 @@ typedef struct { GpsLocation gpsLocation; /* 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; @@ -97,6 +110,13 @@ typedef struct { unsigned char map_index[GPS_LOCATION_MAP_INDEX_SIZE]; } UlpLocation; +typedef struct { + /** set to sizeof(UlpNmea) */ + size_t size; + char nmea_str[ULP_MAX_NMEA_STRING_SIZE]; + unsigned int len; +} UlpNmea; + /** AGPS type */ typedef int16_t AGpsExtType; #define AGPS_TYPE_INVALID -1 @@ -165,14 +185,14 @@ typedef struct { } AGpsExtCallbacks; +typedef void (*loc_ni_notify_callback)(GpsNiNotification *notification, bool esEnalbed); /** GPS NI callback structure. */ typedef struct { /** * Sends the notification request from HAL to GPSLocationProvider. */ - gps_ni_notify_callback notify_cb; - gps_create_thread create_thread_cb; + loc_ni_notify_callback notify_cb; } GpsNiExtCallbacks; typedef enum loc_server_type { @@ -301,17 +321,6 @@ enum loc_sess_status { LOC_SESS_FAILURE }; -typedef uint32_t LocPosTechMask; -#define LOC_POS_TECH_MASK_DEFAULT ((LocPosTechMask)0x00000000) -#define LOC_POS_TECH_MASK_SATELLITE ((LocPosTechMask)0x00000001) -#define LOC_POS_TECH_MASK_CELLID ((LocPosTechMask)0x00000002) -#define LOC_POS_TECH_MASK_WIFI ((LocPosTechMask)0x00000004) -#define LOC_POS_TECH_MASK_SENSORS ((LocPosTechMask)0x00000008) -#define LOC_POS_TECH_MASK_REFERENCE_LOCATION ((LocPosTechMask)0x00000010) -#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) - typedef enum { LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0, LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM, diff --git a/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp b/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp index f8c103a..89be583 100644 --- a/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp +++ b/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2016, 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 @@ -418,10 +418,17 @@ void LocEngAdapter::reportStatus(GpsStatusValue status) } } -inline -void LocEngAdapter::reportNmea(const char* nmea, int length) +void LocInternalAdapter::reportNmea(const char* nmea, int length) { - sendMsg(new LocEngReportNmea(mOwner, nmea, length)); + sendMsg(new LocEngReportNmea(mLocEngAdapter->getOwner(), nmea, length)); +} + +inline void LocEngAdapter::reportNmea(const char* nmea, int length) +{ + if (!mUlp->reportNmea(nmea, length)) { + //Report it to HAL + mInternalAdapter->reportNmea(nmea, length); + } } inline diff --git a/gps/loc_api/libloc_api_50001/LocEngAdapter.h b/gps/loc_api/libloc_api_50001/LocEngAdapter.h index b58c8e7..eabd0ea 100644 --- a/gps/loc_api/libloc_api_50001/LocEngAdapter.h +++ b/gps/loc_api/libloc_api_50001/LocEngAdapter.h @@ -64,6 +64,7 @@ public: virtual void stopFixInt(); virtual void getZppInt(); virtual void setUlpProxy(UlpProxyBase* ulp); + virtual void reportNmea(const char* nmea, int length); }; typedef void (*loc_msg_sender)(void* loc_eng_data_p, void* msgp); diff --git a/gps/loc_api/libloc_api_50001/loc.cpp b/gps/loc_api/libloc_api_50001/loc.cpp index 505fc94..67e6efe 100644 --- a/gps/loc_api/libloc_api_50001/loc.cpp +++ b/gps/loc_api/libloc_api_50001/loc.cpp @@ -52,9 +52,15 @@ using namespace loc_core; //Globals defns static gps_location_callback gps_loc_cb = NULL; static gps_sv_status_callback gps_sv_cb = NULL; +static gps_ni_notify_callback gps_ni_cb = NULL; static void local_loc_cb(UlpLocation* location, void* locExt); static void local_sv_cb(GpsSvStatus* sv_status, void* svExt); +static void local_ni_cb(GpsNiNotification *notification, bool esEnalbed); + +GpsNiExtCallbacks sGpsNiExtCallbacks = { + local_ni_cb +}; static const GpsGeofencingInterface* get_geofence_interface(void); @@ -960,7 +966,8 @@ SIDE EFFECTS void loc_ni_init(GpsNiCallbacks *callbacks) { ENTRY_LOG(); - loc_eng_ni_init(loc_afw_data,(GpsNiExtCallbacks*) callbacks); + gps_ni_cb = callbacks->notify_cb; + loc_eng_ni_init(loc_afw_data, &sGpsNiExtCallbacks); EXIT_LOG(%s, VOID_RET); } @@ -1075,3 +1082,10 @@ static void local_sv_cb(GpsSvStatus* sv_status, void* svExt) EXIT_LOG(%s, VOID_RET); } +static void local_ni_cb(GpsNiNotification *notification, bool esEnalbed) +{ + if (NULL != gps_ni_cb) { + gps_ni_cb(notification); + } +} + diff --git a/gps/loc_api/libloc_api_50001/loc_eng.cpp b/gps/loc_api/libloc_api_50001/loc_eng.cpp index 0aa1c8b..d7e2895 100644 --- a/gps/loc_api/libloc_api_50001/loc_eng.cpp +++ b/gps/loc_api/libloc_api_50001/loc_eng.cpp @@ -102,6 +102,7 @@ static const loc_param_s_type gps_conf_table[] = {"A_GLONASS_POS_PROTOCOL_SELECT", &gps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'}, {"AGPS_CERT_WRITABLE_MASK", &gps_conf.AGPS_CERT_WRITABLE_MASK, NULL, 'n'}, {"SUPL_MODE", &gps_conf.SUPL_MODE, NULL, 'n'}, + {"SUPL_ES", &gps_conf.SUPL_ES, NULL, 'n'}, {"INTERMEDIATE_POS", &gps_conf.INTERMEDIATE_POS, NULL, 'n'}, {"ACCURACY_THRES", &gps_conf.ACCURACY_THRES, NULL, 'n'}, {"NMEA_PROVIDER", &gps_conf.NMEA_PROVIDER, NULL, 'n'}, @@ -143,6 +144,7 @@ static void loc_default_parameters(void) gps_conf.GPS_LOCK = 0; gps_conf.SUPL_VER = 0x10000; gps_conf.SUPL_MODE = 0x3; + gps_conf.SUPL_ES = 0; gps_conf.CAPABILITIES = 0x7; /* LTE Positioning Profile configuration is disable by default*/ gps_conf.LPP_PROFILE = 0; @@ -1976,7 +1978,6 @@ static int loc_eng_stop_handler(loc_eng_data_s_type &loc_eng_data) int ret_val = LOC_API_ADAPTER_ERR_SUCCESS; if (loc_eng_data.adapter->isInSession()) { - ret_val = loc_eng_data.adapter->stopFix(); loc_eng_data.adapter->setInSession(FALSE); } @@ -2737,6 +2738,8 @@ void loc_eng_configuration_update (loc_eng_data_s_type &loc_eng_data, gps_conf_tmp.SUPL_VER = gps_conf.SUPL_VER; gps_conf_tmp.LPP_PROFILE = gps_conf.LPP_PROFILE; gps_conf_tmp.A_GLONASS_POS_PROTOCOL_SELECT = gps_conf.A_GLONASS_POS_PROTOCOL_SELECT; + gps_conf_tmp.SUPL_MODE = gps_conf.SUPL_MODE; + gps_conf_tmp.SUPL_ES = gps_conf.SUPL_ES; gps_conf_tmp.GPS_LOCK = gps_conf.GPS_LOCK; gps_conf = gps_conf_tmp; } @@ -2858,7 +2861,7 @@ void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data) if (loc_eng_data.adapter->isInSession()) { // This sets the copy in adapter to modem loc_eng_data.adapter->setInSession(false); - loc_eng_data.adapter->sendMsg(new LocEngStartFix(loc_eng_data.adapter)); + loc_eng_start_handler(loc_eng_data); } EXIT_LOG(%s, VOID_RET); } diff --git a/gps/loc_api/libloc_api_50001/loc_eng.h b/gps/loc_api/libloc_api_50001/loc_eng.h index a203e6b..59e6c14 100644 --- a/gps/loc_api/libloc_api_50001/loc_eng.h +++ b/gps/loc_api/libloc_api_50001/loc_eng.h @@ -89,7 +89,7 @@ typedef struct loc_eng_data_s loc_sv_status_cb_ext sv_status_cb; agps_status_extended agps_status_cb; gps_nmea_callback nmea_cb; - gps_ni_notify_callback ni_notify_cb; + loc_ni_notify_callback ni_notify_cb; gps_set_capabilities set_capabilities_cb; gps_acquire_wakelock acquire_wakelock_cb; gps_release_wakelock release_wakelock_cb; @@ -119,7 +119,8 @@ typedef struct loc_eng_data_s // For nmea generation boolean generateNmea; - uint32_t sv_used_mask; + uint32_t gps_used_mask; + uint32_t glo_used_mask; float hdop; float pdop; float vdop; @@ -149,12 +150,13 @@ typedef struct loc_gps_cfg_s uint32_t ACCURACY_THRES; uint32_t SUPL_VER; uint32_t SUPL_MODE; + uint32_t SUPL_ES; uint32_t CAPABILITIES; uint32_t LPP_PROFILE; uint32_t XTRA_VERSION_CHECK; - char XTRA_SERVER_1[MAX_XTRA_SERVER_URL_LENGTH]; - char XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH]; - char XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH]; + char XTRA_SERVER_1[MAX_XTRA_SERVER_URL_LENGTH]; + char XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH]; + char XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH]; uint32_t USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL; uint32_t NMEA_PROVIDER; uint32_t GPS_LOCK; diff --git a/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp b/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp index 4597b98..d79e635 100644 --- a/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp +++ b/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp @@ -189,7 +189,7 @@ void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data, } CALLBACK_LOG_CALLFLOW("ni_notify_cb - id", %d, notif->notification_id); - loc_eng_data.ni_notify_cb((GpsNiNotification*)notif); + loc_eng_data.ni_notify_cb((GpsNiNotification*)notif, gps_conf.SUPL_ES != 0); } EXIT_LOG(%s, VOID_RET); } diff --git a/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp b/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp index e6fbec8..c29ab91 100644 --- a/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp +++ b/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp @@ -62,6 +62,9 @@ void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_dat CALLBACK_LOG_CALLFLOW("nmea_cb", %p, pNmea); if (loc_eng_data_p->nmea_cb != NULL) loc_eng_data_p->nmea_cb(now, pNmea, length); + + loc_eng_data_p->adapter->getUlpProxy()->reportNmea(pNmea, length); + LOC_LOGD("NMEA <%s", pNmea); } @@ -102,6 +105,12 @@ FUNCTION loc_eng_nmea_generate_pos DESCRIPTION Generate NMEA sentences generated based on position report + Currently below sentences are generated within this function: + - $GPGSA : GPS DOP and active SVs + - $GNGSA : GLONASS DOP and active SVs + - $GPVTG : Track made good and ground speed + - $GPRMC : Recommended minimum navigation information + - $GPGGA : Time, position and fix related data DEPENDENCIES NONE @@ -144,7 +153,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, uint32_t svUsedCount = 0; uint32_t svUsedList[32] = {0}; - uint32_t mask = loc_eng_data_p->sv_used_mask; + uint32_t mask = loc_eng_data_p->gps_used_mask; for (uint8_t i = 1; mask > 0 && svUsedCount < 32; i++) { if (mask & 1) @@ -152,7 +161,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, mask = mask >> 1; } // clear the cache so they can't be used again - loc_eng_data_p->sv_used_mask = 0; + loc_eng_data_p->gps_used_mask = 0; char fixType; if (svUsedCount == 0) @@ -210,6 +219,99 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); loc_eng_nmea_send(sentence, length, loc_eng_data_p); + // ------------------ + // ------$GNGSA------ + // ------------------ + uint32_t gloUsedCount = 0; + uint32_t gloUsedList[32] = {0}; + + // Reset locals for GNGSA sentence generation + pMarker = sentence; + lengthRemaining = sizeof(sentence); + mask = loc_eng_data_p->glo_used_mask; + fixType = '\0'; + + // Parse the glonass sv mask, and fetch glo sv ids + // Mask corresponds to the offset. + // GLONASS SV ids are from 65-96 + const int GLONASS_SV_ID_OFFSET = 64; + for (uint8_t i = 1; mask > 0 && gloUsedCount < 32; i++) + { + if (mask & 1) + gloUsedList[gloUsedCount++] = i + GLONASS_SV_ID_OFFSET; + mask = mask >> 1; + } + // clear the cache so they can't be used again + loc_eng_data_p->glo_used_mask = 0; + + if (gloUsedCount == 0) + fixType = '1'; // no fix + else if (gloUsedCount <= 3) + fixType = '2'; // 2D fix + else + fixType = '3'; // 3D fix + + // Start printing the sentence + // Format: $--GSA,a,x,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,p.p,h.h,v.v*cc + // GNGSA : for glonass SVs + // a : Mode : A : Automatic, allowed to automatically switch 2D/3D + // x : Fixtype : 1 (no fix), 2 (2D fix), 3 (3D fix) + // xx : 12 SV ID + // p.p : Position DOP (Dilution of Precision) + // h.h : Horizontal DOP + // v.v : Vertical DOP + // cc : Checksum value + length = snprintf(pMarker, lengthRemaining, "$GNGSA,A,%c,", fixType); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + // Add first 12 GLONASS satellite IDs + for (uint8_t i = 0; i < 12; i++) + { + if (i < gloUsedCount) + length = snprintf(pMarker, lengthRemaining, "%02d,", gloUsedList[i]); + else + length = snprintf(pMarker, lengthRemaining, ","); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + } + + // Add the position/horizontal/vertical DOP values + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP) + { // dop is in locationExtended, (QMI) + length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f", + locationExtended.pdop, + locationExtended.hdop, + locationExtended.vdop); + } + else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0) + { // dop was cached from sv report (RPC) + length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f", + loc_eng_data_p->pdop, + loc_eng_data_p->hdop, + loc_eng_data_p->vdop); + } + else + { // no dop + length = snprintf(pMarker, lengthRemaining, ",,"); + } + + /* Sentence is ready, add checksum and broadcast */ + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + // ------------------ // ------$GPVTG------ // ------------------ @@ -565,6 +667,10 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); loc_eng_nmea_send(sentence, length, loc_eng_data_p); + strlcpy(sentence, "$GNGSA,A,1,,,,,,,,,,,,,,,", sizeof(sentence)); + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + strlcpy(sentence, "$GPVTG,,T,,M,,N,,K,N", sizeof(sentence)); length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); loc_eng_nmea_send(sentence, length, loc_eng_data_p); @@ -790,9 +896,10 @@ void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, }//if - // cache the used in fix mask, as it will be needed to send $GPGSA + // cache the used in fix mask, as it will be needed to send $GPGSA/$GNGSA // during the position report - loc_eng_data_p->sv_used_mask = svStatus.gps_used_in_fix_mask; + loc_eng_data_p->gps_used_mask = svStatus.gps_used_in_fix_mask; + loc_eng_data_p->glo_used_mask = svStatus.glo_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/gps/utils/LocThread.cpp b/gps/utils/LocThread.cpp index 19bf101..a7fd1c8 100644 --- a/gps/utils/LocThread.cpp +++ b/gps/utils/LocThread.cpp @@ -84,9 +84,7 @@ LocThreadDelegate::LocThreadDelegate(LocThread::tCreate creator, if (mThandle) { // set thread name char lname[16]; - int len = sizeof(lname) - 1; - memcpy(lname, threadName, len); - lname[len] = 0; + strlcpy(lname, threadName, sizeof(lname)); // set the thread name here pthread_setname_np(mThandle, lname); diff --git a/gps/utils/LocTimer.cpp b/gps/utils/LocTimer.cpp index 70904b2..4de6b40 100644 --- a/gps/utils/LocTimer.cpp +++ b/gps/utils/LocTimer.cpp @@ -505,8 +505,13 @@ int LocTimerDelegate::ranks(LocRankable& rankable) { LocTimerDelegate* timer = (LocTimerDelegate*)(&rankable); if (timer) { // larger time ranks lower!!! - // IOW, if input obj has bigger tv_sec, this obj outRanks higher + // IOW, if input obj has bigger tv_sec/tv_nsec, this obj outRanks higher rank = timer->mFutureTime.tv_sec - mFutureTime.tv_sec; + if(0 == rank) + { + //rank against tv_nsec for msec accuracy + rank = (int)(timer->mFutureTime.tv_nsec - mFutureTime.tv_nsec); + } } return rank; } diff --git a/gps/utils/loc_target.cpp b/gps/utils/loc_target.cpp index faaedf6..d491a3e 100644 --- a/gps/utils/loc_target.cpp +++ b/gps/utils/loc_target.cpp @@ -53,6 +53,7 @@ #define STR_SURF "Surf" #define STR_MTP "MTP" #define STR_APQ "apq" +#define STR_MSM "msm" #define STR_AUTO "auto" #define IS_STR_END(c) ((c) == '\0' || (c) == '\n' || (c) == '\r') #define LENGTH(s) (sizeof(s) - 1) @@ -237,6 +238,8 @@ unsigned int loc_get_target(void) (!memcmp(rd_id, MSM8930_ID_2, LENGTH(MSM8930_ID_2)) && IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) ) gTarget = TARGET_MSM_NO_SSC; + else if ( !memcmp(baseband, STR_MSM, LENGTH(STR_MSM)) ) + gTarget = TARGET_DEFAULT; else gTarget = TARGET_UNKNOWN; }