* 'lineage-16.0' of http://www.github.com/LineageOS/android_device_samsung_msm8974-common:
  msm8974-common: gps: Correct week rollover timestamps
  msm8974-common: gps: Fix race condition when GPS app is closed around an SSR event
  msm8974-common: gps: Adding fix for KW warning
  msm8974-common: gps: Assure event mask is set properly to get positions
  msm8974-common: gps: Fix unable to clear existing event bitmasks
  msm8974-common: gps: Add tech_mask in UlpLocation to support report
  msm8974-common: gps: NMEA report indication to ULP
  msm8974-common: gps: Making SUPL ES run time configurable
  msm8974-common: gps: Fixes SUPL_MODE
  msm8974-common: gps: Consider nsec while ranking the timer objects
  msm8974-common: gps: Adding a new NMEA sentence : $GNGSA.
  msm8974-common: gps: Set correct target for msm baseband
  msm8974-common: gps: Add Cleanstep.mk

Change-Id: Ibfdb99e86d3bc3829b565ee8732a7a399ff27915
This commit is contained in:
Kevin F. Haggerty 2020-06-26 18:06:01 -06:00
commit 7cae0f93e6
No known key found for this signature in database
GPG key ID: 6D95512933112729
14 changed files with 253 additions and 45 deletions

50
gps/CleanSpec.mk Normal file
View file

@ -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*)

View file

@ -30,6 +30,7 @@
#define LOG_TAG "LocSvc_LocApiBase" #define LOG_TAG "LocSvc_LocApiBase"
#include <dlfcn.h> #include <dlfcn.h>
#include <inttypes.h>
#include <LocApiBase.h> #include <LocApiBase.h>
#include <LocAdapterBase.h> #include <LocAdapterBase.h>
#include <log_util.h> #include <log_util.h>
@ -106,19 +107,16 @@ struct LocSsrMsg : public LocMsg {
struct LocOpenMsg : public LocMsg { struct LocOpenMsg : public LocMsg {
LocApiBase* mLocApi; LocApiBase* mLocApi;
LOC_API_ADAPTER_EVENT_MASK_T mMask; inline LocOpenMsg(LocApiBase* locApi) :
inline LocOpenMsg(LocApiBase* locApi, LocMsg(), mLocApi(locApi)
LOC_API_ADAPTER_EVENT_MASK_T mask) :
LocMsg(), mLocApi(locApi), mMask(mask)
{ {
locallog(); locallog();
} }
inline virtual void proc() const { inline virtual void proc() const {
mLocApi->open(mMask); mLocApi->open(mLocApi->getEvtMask());
} }
inline void locallog() { inline void locallog() {
LOC_LOGV("%s:%d]: LocOpen Mask: %x\n", LOC_LOGV("LocOpen Mask: %" PRIx32 "\n", mLocApi->getEvtMask());
__func__, __LINE__, mMask);
} }
inline virtual void log() { inline virtual void log() {
locallog(); locallog();
@ -161,8 +159,7 @@ void LocApiBase::addAdapter(LocAdapterBase* adapter)
for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) { for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) {
if (mLocAdapters[i] == NULL) { if (mLocAdapters[i] == NULL) {
mLocAdapters[i] = adapter; mLocAdapters[i] = adapter;
mMsgTask->sendMsg(new LocOpenMsg(this, mMsgTask->sendMsg(new LocOpenMsg(this));
(adapter->getEvtMask())));
break; break;
} }
} }
@ -198,7 +195,7 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter)
close(); close();
} else { } else {
// else we need to remove the bit // 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() void LocApiBase::updateEvtMask()
{ {
mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask())); mMsgTask->sendMsg(new LocOpenMsg(this));
} }
void LocApiBase::handleEngineUpEvent() void LocApiBase::handleEngineUpEvent()
@ -243,6 +240,12 @@ void LocApiBase::reportPosition(UlpLocation &location,
location.gpsLocation.bearing, location.gpsLocation.accuracy, location.gpsLocation.bearing, location.gpsLocation.accuracy,
location.gpsLocation.timestamp, location.rawDataSize, location.gpsLocation.timestamp, location.rawDataSize,
location.rawData, status, loc_technology_mask); 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. // loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS( TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportPosition(location, mLocAdapters[i]->reportPosition(location,

View file

@ -100,6 +100,12 @@ public:
(void)number_of_locations; (void)number_of_locations;
return false; return false;
} }
inline virtual bool reportNmea(const char* nmea, int length)
{
(void)nmea;
(void)length;
return false;
}
}; };
} // namespace loc_core } // namespace loc_core

View file

@ -70,6 +70,7 @@ extern "C" {
#define ULP_LOCATION_IS_FROM_PIP 0x0040 #define ULP_LOCATION_IS_FROM_PIP 0x0040
#define ULP_MIN_INTERVAL_INVALID 0xffffffff #define ULP_MIN_INTERVAL_INVALID 0xffffffff
#define ULP_MAX_NMEA_STRING_SIZE 201
/*Emergency SUPL*/ /*Emergency SUPL*/
#define GPS_NI_TYPE_EMERGENCY_SUPL 4 #define GPS_NI_TYPE_EMERGENCY_SUPL 4
@ -77,6 +78,17 @@ extern "C" {
#define AGPS_CERTIFICATE_MAX_LENGTH 2000 #define AGPS_CERTIFICATE_MAX_LENGTH 2000
#define AGPS_CERTIFICATE_MAX_SLOTS 10 #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 { enum loc_registration_mask_status {
LOC_REGISTRATION_MASK_ENABLED, LOC_REGISTRATION_MASK_ENABLED,
LOC_REGISTRATION_MASK_DISABLED LOC_REGISTRATION_MASK_DISABLED
@ -88,6 +100,7 @@ typedef struct {
GpsLocation gpsLocation; GpsLocation gpsLocation;
/* Provider indicator for HYBRID or GPS */ /* Provider indicator for HYBRID or GPS */
uint16_t position_source; uint16_t position_source;
LocPosTechMask tech_mask;
/*allows HAL to pass additional information related to the location */ /*allows HAL to pass additional information related to the location */
int rawDataSize; /* in # of bytes */ int rawDataSize; /* in # of bytes */
void * rawData; void * rawData;
@ -97,6 +110,13 @@ typedef struct {
unsigned char map_index[GPS_LOCATION_MAP_INDEX_SIZE]; unsigned char map_index[GPS_LOCATION_MAP_INDEX_SIZE];
} UlpLocation; } UlpLocation;
typedef struct {
/** set to sizeof(UlpNmea) */
size_t size;
char nmea_str[ULP_MAX_NMEA_STRING_SIZE];
unsigned int len;
} UlpNmea;
/** AGPS type */ /** AGPS type */
typedef int16_t AGpsExtType; typedef int16_t AGpsExtType;
#define AGPS_TYPE_INVALID -1 #define AGPS_TYPE_INVALID -1
@ -165,14 +185,14 @@ typedef struct {
} AGpsExtCallbacks; } AGpsExtCallbacks;
typedef void (*loc_ni_notify_callback)(GpsNiNotification *notification, bool esEnalbed);
/** GPS NI callback structure. */ /** GPS NI callback structure. */
typedef struct typedef struct
{ {
/** /**
* Sends the notification request from HAL to GPSLocationProvider. * Sends the notification request from HAL to GPSLocationProvider.
*/ */
gps_ni_notify_callback notify_cb; loc_ni_notify_callback notify_cb;
gps_create_thread create_thread_cb;
} GpsNiExtCallbacks; } GpsNiExtCallbacks;
typedef enum loc_server_type { typedef enum loc_server_type {
@ -301,17 +321,6 @@ enum loc_sess_status {
LOC_SESS_FAILURE 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 { typedef enum {
LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0, LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0,
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM, LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,

View file

@ -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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@ -418,10 +418,17 @@ void LocEngAdapter::reportStatus(GpsStatusValue status)
} }
} }
inline void LocInternalAdapter::reportNmea(const char* nmea, int length)
void LocEngAdapter::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 inline

View file

@ -64,6 +64,7 @@ public:
virtual void stopFixInt(); virtual void stopFixInt();
virtual void getZppInt(); virtual void getZppInt();
virtual void setUlpProxy(UlpProxyBase* ulp); 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); typedef void (*loc_msg_sender)(void* loc_eng_data_p, void* msgp);

View file

@ -52,9 +52,15 @@ using namespace loc_core;
//Globals defns //Globals defns
static gps_location_callback gps_loc_cb = NULL; static gps_location_callback gps_loc_cb = NULL;
static gps_sv_status_callback gps_sv_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_loc_cb(UlpLocation* location, void* locExt);
static void local_sv_cb(GpsSvStatus* sv_status, void* svExt); 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); static const GpsGeofencingInterface* get_geofence_interface(void);
@ -960,7 +966,8 @@ SIDE EFFECTS
void loc_ni_init(GpsNiCallbacks *callbacks) void loc_ni_init(GpsNiCallbacks *callbacks)
{ {
ENTRY_LOG(); 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); EXIT_LOG(%s, VOID_RET);
} }
@ -1075,3 +1082,10 @@ static void local_sv_cb(GpsSvStatus* sv_status, void* svExt)
EXIT_LOG(%s, VOID_RET); EXIT_LOG(%s, VOID_RET);
} }
static void local_ni_cb(GpsNiNotification *notification, bool esEnalbed)
{
if (NULL != gps_ni_cb) {
gps_ni_cb(notification);
}
}

View file

@ -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'}, {"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'}, {"AGPS_CERT_WRITABLE_MASK", &gps_conf.AGPS_CERT_WRITABLE_MASK, NULL, 'n'},
{"SUPL_MODE", &gps_conf.SUPL_MODE, 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'}, {"INTERMEDIATE_POS", &gps_conf.INTERMEDIATE_POS, NULL, 'n'},
{"ACCURACY_THRES", &gps_conf.ACCURACY_THRES, NULL, 'n'}, {"ACCURACY_THRES", &gps_conf.ACCURACY_THRES, NULL, 'n'},
{"NMEA_PROVIDER", &gps_conf.NMEA_PROVIDER, 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.GPS_LOCK = 0;
gps_conf.SUPL_VER = 0x10000; gps_conf.SUPL_VER = 0x10000;
gps_conf.SUPL_MODE = 0x3; gps_conf.SUPL_MODE = 0x3;
gps_conf.SUPL_ES = 0;
gps_conf.CAPABILITIES = 0x7; gps_conf.CAPABILITIES = 0x7;
/* LTE Positioning Profile configuration is disable by default*/ /* LTE Positioning Profile configuration is disable by default*/
gps_conf.LPP_PROFILE = 0; 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; int ret_val = LOC_API_ADAPTER_ERR_SUCCESS;
if (loc_eng_data.adapter->isInSession()) { if (loc_eng_data.adapter->isInSession()) {
ret_val = loc_eng_data.adapter->stopFix(); ret_val = loc_eng_data.adapter->stopFix();
loc_eng_data.adapter->setInSession(FALSE); 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.SUPL_VER = gps_conf.SUPL_VER;
gps_conf_tmp.LPP_PROFILE = gps_conf.LPP_PROFILE; 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.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_tmp.GPS_LOCK = gps_conf.GPS_LOCK;
gps_conf = gps_conf_tmp; 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()) { if (loc_eng_data.adapter->isInSession()) {
// This sets the copy in adapter to modem // This sets the copy in adapter to modem
loc_eng_data.adapter->setInSession(false); 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); EXIT_LOG(%s, VOID_RET);
} }

View file

@ -89,7 +89,7 @@ typedef struct loc_eng_data_s
loc_sv_status_cb_ext sv_status_cb; loc_sv_status_cb_ext sv_status_cb;
agps_status_extended agps_status_cb; agps_status_extended agps_status_cb;
gps_nmea_callback nmea_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_set_capabilities set_capabilities_cb;
gps_acquire_wakelock acquire_wakelock_cb; gps_acquire_wakelock acquire_wakelock_cb;
gps_release_wakelock release_wakelock_cb; gps_release_wakelock release_wakelock_cb;
@ -119,7 +119,8 @@ typedef struct loc_eng_data_s
// For nmea generation // For nmea generation
boolean generateNmea; boolean generateNmea;
uint32_t sv_used_mask; uint32_t gps_used_mask;
uint32_t glo_used_mask;
float hdop; float hdop;
float pdop; float pdop;
float vdop; float vdop;
@ -149,6 +150,7 @@ typedef struct loc_gps_cfg_s
uint32_t ACCURACY_THRES; uint32_t ACCURACY_THRES;
uint32_t SUPL_VER; uint32_t SUPL_VER;
uint32_t SUPL_MODE; uint32_t SUPL_MODE;
uint32_t SUPL_ES;
uint32_t CAPABILITIES; uint32_t CAPABILITIES;
uint32_t LPP_PROFILE; uint32_t LPP_PROFILE;
uint32_t XTRA_VERSION_CHECK; uint32_t XTRA_VERSION_CHECK;

View file

@ -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); 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); EXIT_LOG(%s, VOID_RET);
} }

View file

@ -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); CALLBACK_LOG_CALLFLOW("nmea_cb", %p, pNmea);
if (loc_eng_data_p->nmea_cb != NULL) if (loc_eng_data_p->nmea_cb != NULL)
loc_eng_data_p->nmea_cb(now, pNmea, length); loc_eng_data_p->nmea_cb(now, pNmea, length);
loc_eng_data_p->adapter->getUlpProxy()->reportNmea(pNmea, length);
LOC_LOGD("NMEA <%s", pNmea); LOC_LOGD("NMEA <%s", pNmea);
} }
@ -102,6 +105,12 @@ FUNCTION loc_eng_nmea_generate_pos
DESCRIPTION DESCRIPTION
Generate NMEA sentences generated based on position report 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 DEPENDENCIES
NONE 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 svUsedCount = 0;
uint32_t svUsedList[32] = {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++) for (uint8_t i = 1; mask > 0 && svUsedCount < 32; i++)
{ {
if (mask & 1) 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; mask = mask >> 1;
} }
// clear the cache so they can't be used again // 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; char fixType;
if (svUsedCount == 0) 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)); length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
loc_eng_nmea_send(sentence, length, loc_eng_data_p); 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------ // ------$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)); length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
loc_eng_nmea_send(sentence, length, loc_eng_data_p); 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)); strlcpy(sentence, "$GPVTG,,T,,M,,N,,K,N", sizeof(sentence));
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
loc_eng_nmea_send(sentence, length, loc_eng_data_p); 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 }//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 // 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 // For RPC, the DOP are sent during sv report, so cache them
// now to be sent during position report. // now to be sent during position report.

View file

@ -84,9 +84,7 @@ LocThreadDelegate::LocThreadDelegate(LocThread::tCreate creator,
if (mThandle) { if (mThandle) {
// set thread name // set thread name
char lname[16]; char lname[16];
int len = sizeof(lname) - 1; strlcpy(lname, threadName, sizeof(lname));
memcpy(lname, threadName, len);
lname[len] = 0;
// set the thread name here // set the thread name here
pthread_setname_np(mThandle, lname); pthread_setname_np(mThandle, lname);

View file

@ -505,8 +505,13 @@ int LocTimerDelegate::ranks(LocRankable& rankable) {
LocTimerDelegate* timer = (LocTimerDelegate*)(&rankable); LocTimerDelegate* timer = (LocTimerDelegate*)(&rankable);
if (timer) { if (timer) {
// larger time ranks lower!!! // 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; 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; return rank;
} }

View file

@ -53,6 +53,7 @@
#define STR_SURF "Surf" #define STR_SURF "Surf"
#define STR_MTP "MTP" #define STR_MTP "MTP"
#define STR_APQ "apq" #define STR_APQ "apq"
#define STR_MSM "msm"
#define STR_AUTO "auto" #define STR_AUTO "auto"
#define IS_STR_END(c) ((c) == '\0' || (c) == '\n' || (c) == '\r') #define IS_STR_END(c) ((c) == '\0' || (c) == '\n' || (c) == '\r')
#define LENGTH(s) (sizeof(s) - 1) #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)) (!memcmp(rd_id, MSM8930_ID_2, LENGTH(MSM8930_ID_2))
&& IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) ) && IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) )
gTarget = TARGET_MSM_NO_SSC; gTarget = TARGET_MSM_NO_SSC;
else if ( !memcmp(baseband, STR_MSM, LENGTH(STR_MSM)) )
gTarget = TARGET_DEFAULT;
else else
gTarget = TARGET_UNKNOWN; gTarget = TARGET_UNKNOWN;
} }