diff options
author | sbrissen <sbrissen@hotmail.com> | 2013-05-06 11:43:23 -0400 |
---|---|---|
committer | sbrissen <sbrissen@hotmail.com> | 2013-05-06 11:49:18 -0400 |
commit | 3131ff6ce528dd94bb0d698072eb7a5211e9bb47 (patch) | |
tree | e8f43b48883865cbc4c109cafb27f0a49757ca3e | |
parent | ee82b1b5b04dce2c89008df7e3ec38763ea4910d (diff) | |
download | android_device_samsung_smdk4412-qcom-common-3131ff6ce528dd94bb0d698072eb7a5211e9bb47.tar.gz android_device_samsung_smdk4412-qcom-common-3131ff6ce528dd94bb0d698072eb7a5211e9bb47.tar.bz2 android_device_samsung_smdk4412-qcom-common-3131ff6ce528dd94bb0d698072eb7a5211e9bb47.zip |
update gps from d2-common
Change-Id: I99e0a6600d27e75f1bcb20f927efbd336d4fdc82
45 files changed, 1367 insertions, 244 deletions
diff --git a/gps/Android.mk b/gps/Android.mk index a92484d..484a48d 100644 --- a/gps/Android.mk +++ b/gps/Android.mk @@ -22,4 +22,4 @@ LOCAL_PATH := $(call my-dir) -include $(call all-subdir-makefiles,$(LOCAL_PATH)) +include $(call all-subdir-makefiles,$(LOCAL_PATH))
\ No newline at end of file diff --git a/gps/libloc_api_50001/Android.mk b/gps/libloc_api_50001/Android.mk index 3416fe7..063737a 100644 --- a/gps/libloc_api_50001/Android.mk +++ b/gps/libloc_api_50001/Android.mk @@ -1,12 +1,4 @@ ifneq ($(BUILD_TINY_ANDROID),true) -#Compile this library only for builds with the latest modem image - -BIT_ENABLED_BOARD_PLATFORM_LIST := msm7630_fusion -BIT_ENABLED_BOARD_PLATFORM_LIST += msm8660 -BIT_ENABLED_BOARD_PLATFORM_LIST += msm8960 -ifeq ($(call is-board-platform-in-list,$(BIT_ENABLED_BOARD_PLATFORM_LIST)),true) -FEATURE_GNSS_BIT_API := true -endif # is-board-platform-in-list ifeq ($(BOARD_GPS_SET_PRIVACY),true) LOCAL_CFLAGS += -DSET_PRIVACY @@ -31,24 +23,24 @@ LOCAL_SRC_FILES += \ LocApiAdapter.cpp LOCAL_CFLAGS += \ - -fno-short-enums \ - -D_ANDROID_ \ - -DNEW_QC_GPS + -fno-short-enums \ + -D_ANDROID_ \ + -DNEW_QC_GPS LOCAL_C_INCLUDES:= \ $(TARGET_OUT_HEADERS)/gps.utils LOCAL_COPY_HEADERS_TO:= libloc_eng/ LOCAL_COPY_HEADERS:= \ - LocApiAdapter.h \ - loc.h \ - loc_eng.h \ - loc_eng_xtra.h \ - loc_eng_ni.h \ - loc_eng_agps.h \ - loc_eng_msg.h \ - loc_eng_msg_id.h \ - loc_eng_log.h + LocApiAdapter.h \ + loc.h \ + loc_eng.h \ + loc_eng_xtra.h \ + loc_eng_ni.h \ + loc_eng_agps.h \ + loc_eng_msg.h \ + loc_eng_msg_id.h \ + loc_eng_log.h LOCAL_PRELINK_MODULE := false @@ -71,11 +63,10 @@ LOCAL_SRC_FILES += \ loc_eng_agps.cpp \ loc_eng_xtra.cpp \ loc_eng_ni.cpp \ - loc_eng_log.cpp + loc_eng_log.cpp \ + loc_eng_nmea.cpp -ifeq ($(FEATURE_GNSS_BIT_API), true) LOCAL_CFLAGS += -DFEATURE_GNSS_BIT_API -endif # FEATURE_GNSS_BIT_API LOCAL_SRC_FILES += \ loc_eng_dmn_conn.cpp \ @@ -85,9 +76,9 @@ LOCAL_SRC_FILES += \ loc_eng_dmn_conn_glue_pipe.c LOCAL_CFLAGS += \ - -fno-short-enums \ - -D_ANDROID_ \ - -DNEW_QC_GPS + -fno-short-enums \ + -D_ANDROID_ \ + -DNEW_QC_GPS LOCAL_C_INCLUDES:= \ $(TARGET_OUT_HEADERS)/gps.utils \ @@ -119,7 +110,7 @@ LOCAL_SRC_FILES += \ LOCAL_CFLAGS += \ -fno-short-enums \ -D_ANDROID_ \ - -DNEW_QC_GPS + -DNEW_QC_GPS ## Includes LOCAL_C_INCLUDES:= \ diff --git a/gps/libloc_api_50001/LocApiAdapter.cpp b/gps/libloc_api_50001/LocApiAdapter.cpp index 7689048..cd35646 100644..100755 --- a/gps/libloc_api_50001/LocApiAdapter.cpp +++ b/gps/libloc_api_50001/LocApiAdapter.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011-2012, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -143,13 +143,17 @@ int LocApiAdapter::decodeAddress(char *addr_string, int string_size, } void LocApiAdapter::reportPosition(GpsLocation &location, + GpsLocationExtended &locationExtended, void* locationExt, - enum loc_sess_status status) + enum loc_sess_status status, + LocPosTechMask loc_technology_mask ) { loc_eng_msg_report_position *msg(new loc_eng_msg_report_position(locEngHandle.owner, location, + locationExtended, locationExt, - status)); + status, + loc_technology_mask)); if (locEngHandle.sendUlpMsg) { locEngHandle.sendUlpMsg(locEngHandle.owner, msg); } else { @@ -157,9 +161,9 @@ void LocApiAdapter::reportPosition(GpsLocation &location, } } -void LocApiAdapter::reportSv(GpsSvStatus &svStatus, void* svExt) +void LocApiAdapter::reportSv(GpsSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt) { - loc_eng_msg_report_sv *msg(new loc_eng_msg_report_sv(locEngHandle.owner, svStatus, svExt)); + loc_eng_msg_report_sv *msg(new loc_eng_msg_report_sv(locEngHandle.owner, svStatus, locationExtended, svExt)); //We want to send SV info to ULP to help it in determining GNSS signal strength //ULP will forward the SV reports to HAL without any modifications @@ -204,9 +208,9 @@ void LocApiAdapter::requestXtraData() void LocApiAdapter::requestTime() { - LOC_LOGD("loc_event_cb: XTRA time download request... not supported"); - // loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_REQUEST_TIME)); - // locEngHandle.sendMsge(locEngHandle.owner, msg); + LOC_LOGD("loc_event_cb: XTRA time download request"); + loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_REQUEST_TIME)); + locEngHandle.sendMsge(locEngHandle.owner, msg); } void LocApiAdapter::requestLocation() diff --git a/gps/libloc_api_50001/LocApiAdapter.h b/gps/libloc_api_50001/LocApiAdapter.h index 0b0cf34..48ed7d1 100644..100755 --- a/gps/libloc_api_50001/LocApiAdapter.h +++ b/gps/libloc_api_50001/LocApiAdapter.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011-2012, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -123,9 +123,13 @@ public: const char *data, int data_size); void reportPosition(GpsLocation &location, + GpsLocationExtended &locationExtended, void* locationExt, - enum loc_sess_status status); - void reportSv(GpsSvStatus &svStatus, void* svExt); + enum loc_sess_status status, + LocPosTechMask loc_technology_mask = LOC_POS_TECH_MASK_DEFAULT); + void reportSv(GpsSvStatus &svStatus, + GpsLocationExtended &locationExtended, + void* svExt); void reportStatus(GpsStatusValue status); void reportNmea(const char* nmea, int length); void reportAgpsStatus(AGpsStatus &agpsStatus); diff --git a/gps/libloc_api_50001/gps.c b/gps/libloc_api_50001/gps.c index c9e4999..82bc742 100644 --- a/gps/libloc_api_50001/gps.c +++ b/gps/libloc_api_50001/gps.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/libloc_api_50001/loc.cpp b/gps/libloc_api_50001/loc.cpp index c0378fd..262a761 100644..100755 --- a/gps/libloc_api_50001/loc.cpp +++ b/gps/libloc_api_50001/loc.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 - 2012, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011 - 2012, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -32,15 +32,17 @@ #include <hardware/gps.h> #include <loc_eng.h> +#include <loc_target.h> #include <loc_log.h> #include <msg_q.h> #include <dlfcn.h> - #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> +#include <cutils/properties.h> + //Globals defns static const ulpInterface * loc_eng_ulp_inf = NULL; static const ulpInterface * loc_eng_get_ulp_inf(void); @@ -165,65 +167,6 @@ static const UlpPhoneContextInterface sLocEngUlpPhoneContextInterface = static loc_eng_data_s_type loc_afw_data; static int gss_fd = 0; -#define TARGET_NAME_OTHER 0 -#define TARGET_NAME_APQ8064_STANDALONE 1 -#define TARGET_NAME_APQ8064_FUSION3 2 - -static int read_a_line(const char * file_path, char * line, int line_size) -{ - FILE *fp; - int result = 0; - - * line = '\0'; - fp = fopen(file_path, "r" ); - if( fp == NULL ) { - LOC_LOGE("open failed: %s: %s\n", file_path, strerror(errno)); - result = -1; - } else { - int len; - fgets(line, line_size, fp); - len = strlen(line); - len = len < line_size - 1? len : line_size - 1; - line[len] = '\0'; - LOC_LOGD("cat %s: %s", file_path, line); - fclose(fp); - } - return result; -} - -#define LINE_LEN 100 -#define STR_LIQUID "Liquid" -#define STR_SURF "Surf" -#define STRLEN_LIQUID (sizeof(STR_LIQUID) - 1) -#define STRLEN_SURF (sizeof(STR_SURF) - 1) -#define IS_STR_END(c) ((c) == '\0' || (c) == '\n' || (c) == '\r') - -static int get_target_name(void) -{ - int target_name = TARGET_NAME_OTHER; - - char hw_platform[] = "/sys/devices/system/soc/soc0/hw_platform"; // "Liquid" or "Surf" - char id[] = "/sys/devices/system/soc/soc0/id"; //109 - char mdm[] = "/dev/mdm"; // No such file or directory - - char line[LINE_LEN]; - - read_a_line( hw_platform, line, LINE_LEN); - if(( !memcmp(line, STR_LIQUID, STRLEN_LIQUID) && IS_STR_END(line[STRLEN_LIQUID]) ) || - ( !memcmp(line, STR_SURF, STRLEN_SURF) && IS_STR_END(line[STRLEN_SURF]) ) - ) { - if (!read_a_line( mdm, line, LINE_LEN)) { - target_name = TARGET_NAME_APQ8064_FUSION3; - } else { - read_a_line( id, line, LINE_LEN); - if(!strncmp(line, "109", strlen("109"))) { - target_name = TARGET_NAME_APQ8064_STANDALONE; - } - } - } - return target_name; -} - /*=========================================================================== FUNCTION gps_get_hardware_interface @@ -265,11 +208,30 @@ const GpsInterface* gps_get_hardware_interface () // for gps.c extern "C" const GpsInterface* get_gps_interface() { + targetEnumType target = TARGET_OTHER; loc_eng_read_config(); //We load up libulp module at this point itself if ULP configured to be On if(gps_conf.CAPABILITIES & ULP_CAPABILITY) { loc_eng_ulp_inf = loc_eng_get_ulp_inf(); } + + target = get_target(); + LOC_LOGD("Target name check returned %s", loc_get_target_name(target)); + //APQ8064 + if(target == TARGET_APQ8064_STANDALONE) { + gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); + gss_fd = open("/dev/gss", O_RDONLY); + if (gss_fd < 0) + LOC_LOGE("GSS open failed: %s\n", strerror(errno)); + else { + LOC_LOGD("GSS open success! CAPABILITIES %0lx\n", gps_conf.CAPABILITIES); + } + } + //MPQ8064 + else if(target == TARGET_MPQ8064) { + LOC_LOGE("No GPS HW on this target (MPQ8064). Not returning interface"); + return NULL; + } return &sLocEngInterface; } @@ -304,7 +266,13 @@ SIDE EFFECTS ===========================================================================*/ static int loc_init(GpsCallbacks* callbacks) { + int retVal = -1; ENTRY_LOG(); + if(callbacks == NULL) { + LOC_LOGE("loc_init failed. cb = NULL\n"); + EXIT_LOG(%d, retVal); + return retVal; + } LOC_API_ADAPTER_EVENT_MASK_T event = LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT | LOC_API_ADAPTER_BIT_SATELLITE_REPORT | @@ -323,22 +291,11 @@ static int loc_init(GpsCallbacks* callbacks) callbacks->release_wakelock_cb, /* release_wakelock_cb */ callbacks->create_thread_cb, /* create_thread_cb */ NULL, /* location_ext_parser */ - NULL /* sv_ext_parser */}; + NULL, /* sv_ext_parser */ + callbacks->request_utc_time_cb /* request_utc_time_cb */}; gps_loc_cb = callbacks->location_cb; gps_sv_cb = callbacks->sv_status_cb; - if (get_target_name() == TARGET_NAME_APQ8064_STANDALONE) - { - gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); - gss_fd = open("/dev/gss", O_RDONLY); - if (gss_fd < 0) { - LOC_LOGE("GSS open failed: %s\n", strerror(errno)); - return NULL; - } - LOC_LOGD("GSS open success! CAPABILITIES %0x\n", gps_conf.CAPABILITIES); - } - - int retVal = -1; if (loc_eng_ulp_inf == NULL) retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event, NULL); @@ -375,7 +332,7 @@ static void loc_cleanup() gps_sv_cb = NULL; /* - * if (get_target_name() == TARGET_NAME_APQ8064_STANDALONE) + * if (get_target() == TARGET_NAME_APQ8064_STANDALONE) * { * close(gss_fd); * LOC_LOGD("GSS shutdown.\n"); @@ -499,7 +456,6 @@ static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertain { ENTRY_LOG(); int ret_val = loc_eng_inject_time(loc_afw_data, time, timeReference, uncertainty); - EXIT_LOG(%d, ret_val); return ret_val; } @@ -523,9 +479,32 @@ SIDE EFFECTS ===========================================================================*/ static int loc_inject_location(double latitude, double longitude, float accuracy) { + static bool initialized = false; + static bool enable_cpi = true; ENTRY_LOG(); - int ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy); + if(!initialized) + { + char value[PROPERTY_VALUE_MAX]; + memset(value, 0, sizeof(value)); + (void)property_get("persist.gps.qc_nlp_in_use", value, "0"); + if(0 == strcmp(value, "1")) + { + enable_cpi = false; + LOC_LOGI("GPS HAL coarse position injection disabled"); + } + else + { + LOC_LOGI("GPS HAL coarse position injection enabled"); + } + initialized = true; + } + + int ret_val = 0; + if(enable_cpi) + { + ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy); + } EXIT_LOG(%d, ret_val); return ret_val; } @@ -835,8 +814,12 @@ SIDE EFFECTS static int loc_xtra_inject_data(char* data, int length) { ENTRY_LOG(); - int ret_val = loc_eng_xtra_inject_data(loc_afw_data, data, length); - + int ret_val = -1; + if( (data != NULL) && ((unsigned int)length <= XTRA_DATA_MAX_SIZE)) + ret_val = loc_eng_xtra_inject_data(loc_afw_data, data, length); + else + LOC_LOGE("%s, Could not inject XTRA data. Buffer address: %p, length: %d", + __func__, data, length); EXIT_LOG(%d, ret_val); return ret_val; } diff --git a/gps/libloc_api_50001/loc.h b/gps/libloc_api_50001/loc.h index 233b34c..357ce51 100644..100755 --- a/gps/libloc_api_50001/loc.h +++ b/gps/libloc_api_50001/loc.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -39,6 +39,7 @@ extern "C" { #include <hardware/gps.h> #define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */ +#define XTRA_DATA_MAX_SIZE 100000 /*bytes*/ typedef enum loc_server_type { LOC_AGPS_CDMA_PDE_SERVER, @@ -54,7 +55,8 @@ typedef enum loc_position_mode_type { LOC_POSITION_MODE_RESERVED_1, LOC_POSITION_MODE_RESERVED_2, LOC_POSITION_MODE_RESERVED_3, - LOC_POSITION_MODE_RESERVED_4 + LOC_POSITION_MODE_RESERVED_4, + LOC_POSITION_MODE_RESERVED_5 } LocPositionMode; typedef void (*loc_location_cb_ext) (GpsLocation* location, void* locExt); @@ -72,6 +74,7 @@ typedef struct { gps_create_thread create_thread_cb; loc_ext_parser location_ext_parser; loc_ext_parser sv_ext_parser; + gps_request_utc_time request_utc_time_cb; } LocCallbacks; enum loc_sess_status { @@ -80,6 +83,15 @@ 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) + void loc_ulp_msg_sender(void* loc_eng_data_p, void* msg); #ifdef __cplusplus diff --git a/gps/libloc_api_50001/loc_eng.cpp b/gps/libloc_api_50001/loc_eng.cpp index 007f390..e092f0a 100644..100755 --- a/gps/libloc_api_50001/loc_eng.cpp +++ b/gps/libloc_api_50001/loc_eng.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2012 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2009-2012, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -57,6 +57,7 @@ #include <loc_eng_dmn_conn_handler.h> #include <loc_eng_msg.h> #include <loc_eng_msg_id.h> +#include <loc_eng_nmea.h> #include <msg_q.h> #include <loc.h> @@ -83,6 +84,7 @@ static loc_param_s_type loc_parameter_table[] = {"INTERMEDIATE_POS", &gps_conf.INTERMEDIATE_POS, NULL, 'n'}, {"ACCURACY_THRES", &gps_conf.ACCURACY_THRES, NULL, 'n'}, {"ENABLE_WIPER", &gps_conf.ENABLE_WIPER, NULL, 'n'}, + {"NMEA_PROVIDER", &gps_conf.NMEA_PROVIDER, NULL, 'n'}, {"SUPL_VER", &gps_conf.SUPL_VER, NULL, 'n'}, {"CAPABILITIES", &gps_conf.CAPABILITIES, NULL, 'n'}, {"GYRO_BIAS_RANDOM_WALK", &gps_conf.GYRO_BIAS_RANDOM_WALK, &gps_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'}, @@ -111,6 +113,7 @@ static void loc_default_parameters(void) gps_conf.INTERMEDIATE_POS = 0; gps_conf.ACCURACY_THRES = 0; gps_conf.ENABLE_WIPER = 0; + gps_conf.NMEA_PROVIDER = 0; gps_conf.SUPL_VER = 0x10000; gps_conf.CAPABILITIES = 0x7; @@ -271,11 +274,13 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks, void (*loc_external_msg_sender) (void*, void*)) { + int ret_val =-1; + ENTRY_LOG_CALLFLOW(); if (NULL == callbacks || 0 == event) { LOC_LOGE("loc_eng_init: bad parameters cb %p eMask %d", callbacks, event); - EXIT_LOG(%d, 0); - return NULL; + EXIT_LOG(%d, ret_val); + return ret_val; } if (NULL != loc_eng_data.context) { @@ -303,7 +308,7 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks, loc_eng_data.nmea_cb = callbacks->nmea_cb; loc_eng_data.acquire_wakelock_cb = callbacks->acquire_wakelock_cb; loc_eng_data.release_wakelock_cb = callbacks->release_wakelock_cb; - + loc_eng_data.request_utc_time_cb = callbacks->request_utc_time_cb; loc_eng_data.intermediateFix = gps_conf.INTERMEDIATE_POS; // initial states taken care of by the memset above @@ -311,12 +316,21 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks, // loc_eng_data.fix_session_status -- GPS_STATUS_NONE; // loc_eng_data.mute_session_state -- LOC_MUTE_SESS_NONE; + if ((event & LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT) && (gps_conf.NMEA_PROVIDER == NMEA_PROVIDER_AP)) + { + event = event ^ LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT; // unregister for modem NMEA report + loc_eng_data.generateNmea = true; + } + else + { + loc_eng_data.generateNmea = false; + } + LocEng locEngHandle(&loc_eng_data, event, loc_eng_data.acquire_wakelock_cb, loc_eng_data.release_wakelock_cb, loc_eng_msg_sender, loc_external_msg_sender, callbacks->location_ext_parser, callbacks->sv_ext_parser); loc_eng_data.client_handle = LocApiAdapter::getLocApiAdapter(locEngHandle); - int ret_val =-1; if (NULL == loc_eng_data.client_handle) { // drop the context and declare failure ((LocEngContext*)(loc_eng_data.context))->drop(); @@ -536,8 +550,8 @@ static int loc_eng_start_handler(loc_eng_data_s_type &loc_eng_data) if (ret_val == LOC_API_ADAPTER_ERR_SUCCESS || ret_val == LOC_API_ADAPTER_ERR_ENGINE_DOWN) { - loc_inform_gps_status(loc_eng_data, GPS_STATUS_SESSION_BEGIN); loc_eng_data.client_handle->setInSession(TRUE); + loc_inform_gps_status(loc_eng_data, GPS_STATUS_SESSION_BEGIN); } } @@ -684,7 +698,6 @@ int loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data, GpsUtcTime time, uncertainty)); msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q, msg, loc_eng_free_msg); - EXIT_LOG(%d, 0); return 0; } @@ -854,6 +867,11 @@ void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsCallbacks* callbac STATE_CHECK((NULL == loc_eng_data.agps_status_cb), "agps instance already initialized", return); + if(callbacks == NULL) { + LOC_LOGE("loc_eng_agps_init: bad parameters cb %p", callbacks); + EXIT_LOG(%s, VOID_RET); + return; + } loc_eng_data.agps_status_cb = callbacks->status_cb; loc_eng_data.agnss_nif = new AgpsStateMachine(loc_eng_data.agps_status_cb, @@ -871,10 +889,14 @@ void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsCallbacks* callbac char baseband[PROPERTY_VALUE_MAX]; property_get("ro.baseband", baseband, "msm"); if ((strcmp(baseband,"svlte2a") == 0) || + (strcmp(baseband,"sglte") == 0) || (strcmp(baseband,"msm") == 0)) { loc_eng_dmn_conn_loc_api_server_launch(callbacks->create_thread_cb, NULL, NULL, &loc_eng_data); + } else { + LOC_LOGD("%s:%d] loc_eng_dmn_conn_loc_api_server was not initialized.baseband = %s\n", + __func__, __LINE__, baseband); } } #endif /* FEATURE_GNSS_BIT_API */ @@ -1490,13 +1512,21 @@ static void loc_eng_deferred_action_thread(void* arg) } // what's in the else if is... (line by line) // 1. this is a good fix; or + // 1.1 there is source info; or + // 1.1.1 this is from hybrid provider; + // 1.2 it is a Satellite fix; or + // 1.2.1 it is a sensor fix // 2. (must be intermediate fix... implicit) // 2.1 we accepte intermediate; and // 2.2 it is NOT the case that // 2.2.1 there is inaccuracy; and // 2.2.2 we care about inaccuracy; and // 2.2.3 the inaccuracy exceeds our tolerance - else if (LOC_SESS_SUCCESS == rpMsg->status || + else if ((LOC_SESS_SUCCESS == rpMsg->status && + (((LOCATION_HAS_SOURCE_INFO & rpMsg->location.flags) && + ULP_LOCATION_IS_FROM_HYBRID == rpMsg->location.position_source) || + ((LOC_POS_TECH_MASK_SATELLITE & rpMsg->technology_mask) || + (LOC_POS_TECH_MASK_SENSORS & rpMsg->technology_mask)))) || (LOC_SESS_INTERMEDIATE == loc_eng_data_p->intermediateFix && !((rpMsg->location.flags & GPS_LOCATION_HAS_ACCURACY) && (gps_conf.ACCURACY_THRES != 0) && @@ -1521,6 +1551,11 @@ static void loc_eng_deferred_action_thread(void* arg) loc_eng_data_p->client_handle->setInSession(false); } + if (loc_eng_data_p->generateNmea && rpMsg->location.position_source == ULP_LOCATION_IS_FROM_GNSS) + { + loc_eng_nmea_generate_pos(loc_eng_data_p, rpMsg->location, rpMsg->locationExtended); + } + // Free the allocated memory for rawData GpsLocation* gp = (GpsLocation*)&(rpMsg->location); if (gp != NULL && gp->rawData != NULL) @@ -1541,6 +1576,12 @@ static void loc_eng_deferred_action_thread(void* arg) loc_eng_data_p->sv_status_cb((GpsSvStatus*)&(rsMsg->svStatus), (void*)rsMsg->svExt); } + + if (loc_eng_data_p->generateNmea) + { + loc_eng_nmea_generate_sv(loc_eng_data_p, rsMsg->svStatus, rsMsg->locationExtended); + } + } break; @@ -1635,7 +1676,8 @@ static void loc_eng_deferred_action_thread(void* arg) { loc_eng_msg_request_wifi *wrqMsg = (loc_eng_msg_request_wifi *)msg; if (wrqMsg->senderId == LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC || - wrqMsg->senderId == LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM) { + wrqMsg->senderId == LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM || + wrqMsg->senderId == LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU) { AgpsStateMachine* stateMachine = loc_eng_data_p->wifi_nif; WIFISubscriber subscriber(stateMachine, wrqMsg->ssid, wrqMsg->password, wrqMsg->senderId); stateMachine->subscribeRsrc((Subscriber*)&subscriber); @@ -1663,6 +1705,14 @@ static void loc_eng_deferred_action_thread(void* arg) break; case LOC_ENG_MSG_REQUEST_TIME: + if (loc_eng_data_p->request_utc_time_cb != NULL) + { + loc_eng_data_p->request_utc_time_cb(); + } + else + { + LOC_LOGE("%s] ERROR: Callback function for request_time is NULL", __func__); + } break; case LOC_ENG_MSG_REQUEST_POSITION: @@ -1856,15 +1906,15 @@ int loc_eng_ulp_init(loc_eng_data_s_type &loc_eng_data, const ulpInterface * loc { ENTRY_LOG(); int ret_val=-1; - - if(loc_eng_ulpInf != NULL) + if((loc_eng_ulpInf != NULL) && (((ulpInterface *)loc_eng_ulpInf)->init != NULL)) { // Initialize the ULP interface ((ulpInterface *)loc_eng_ulpInf)->init(loc_eng_data); loc_eng_data.ulp_initialized = TRUE; + ret_val = 0; } - ret_val = 0; -exit: + else + LOC_LOGE("ulp not initialized. NULL parameter"); EXIT_LOG(%d, ret_val); return ret_val; } @@ -2018,9 +2068,14 @@ SIDE EFFECTS ===========================================================================*/ int loc_eng_ulp_phone_context_init(loc_eng_data_s_type &loc_eng_data,UlpPhoneContextCallbacks *callback) { + int ret_val = -1; ENTRY_LOG(); - loc_eng_data.ulp_phone_context_req_cb = callback->ulp_request_phone_context_cb ; - int ret_val =0; + if(callback != NULL) { + loc_eng_data.ulp_phone_context_req_cb = callback->ulp_request_phone_context_cb ; + ret_val = 0; + } + else + LOC_LOGE("loc_eng_ulp_phone_context_init: bad parameters cb %p", callback); EXIT_LOG(%d, ret_val); return ret_val; } @@ -2044,11 +2099,16 @@ SIDE EFFECTS int loc_eng_ulp_network_init(loc_eng_data_s_type &loc_eng_data, UlpNetworkLocationCallbacks *callbacks) { - ENTRY_LOG_CALLFLOW(); - loc_eng_data.ulp_network_callback = callbacks->ulp_network_location_request_cb; - int ret_val =0; - EXIT_LOG(%d, ret_val); - return ret_val; + int ret_val = -1; + ENTRY_LOG_CALLFLOW(); + if(callbacks != NULL) { + loc_eng_data.ulp_network_callback = callbacks->ulp_network_location_request_cb; + ret_val = 0; + } + else + LOC_LOGE("loc_eng_ulp_network_init: bad parameters cb %p", callbacks); + EXIT_LOG(%d, ret_val); + return ret_val; } diff --git a/gps/libloc_api_50001/loc_eng.h b/gps/libloc_api_50001/loc_eng.h index a14f5bd..253d9ef 100644 --- a/gps/libloc_api_50001/loc_eng.h +++ b/gps/libloc_api_50001/loc_eng.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2012 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2009-2012, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -68,6 +68,11 @@ typedef unsigned char boolean; #define FAILURE FALSE #define INVALID_ATL_CONNECTION_HANDLE -1 +enum loc_nmea_provider_e_type { + NMEA_PROVIDER_AP = 0, // Application Processor Provider of NMEA + NMEA_PROVIDER_MP // Modem Processor Provider of NMEA +}; + enum loc_mute_session_e_type { LOC_MUTE_SESS_NONE = 0, LOC_MUTE_SESS_WAIT, @@ -101,6 +106,7 @@ typedef struct gps_ni_notify_callback ni_notify_cb; gps_acquire_wakelock acquire_wakelock_cb; gps_release_wakelock release_wakelock_cb; + gps_request_utc_time request_utc_time_cb; ulp_network_location_request ulp_network_callback; ulp_request_phone_context ulp_phone_context_req_cb; boolean intermediateFix; @@ -128,6 +134,13 @@ typedef struct // For muting session broadcast loc_mute_session_e_type mute_session_state; + // For nmea generation + boolean generateNmea; + uint32_t sv_used_mask; + float hdop; + float pdop; + float vdop; + // Address buffers, for addressing setting before init int supl_host_set; char supl_host_buf[101]; @@ -149,6 +162,7 @@ typedef struct loc_gps_cfg_s unsigned long INTERMEDIATE_POS; unsigned long ACCURACY_THRES; unsigned long ENABLE_WIPER; + uint8_t NMEA_PROVIDER; unsigned long SUPL_VER; unsigned long CAPABILITIES; uint8_t GYRO_BIAS_RANDOM_WALK_VALID; diff --git a/gps/libloc_api_50001/loc_eng_agps.cpp b/gps/libloc_api_50001/loc_eng_agps.cpp index e9524d5..5788040 100644 --- a/gps/libloc_api_50001/loc_eng_agps.cpp +++ b/gps/libloc_api_50001/loc_eng_agps.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011,2012, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011,2012, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/libloc_api_50001/loc_eng_agps.h b/gps/libloc_api_50001/loc_eng_agps.h index a0873d0..b453cdc 100644 --- a/gps/libloc_api_50001/loc_eng_agps.h +++ b/gps/libloc_api_50001/loc_eng_agps.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011,2012, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011,2012, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -204,7 +204,8 @@ struct Subscriber { inline virtual ~Subscriber() {} virtual void setIPAddresses(int &v4, char* v6) = 0; - inline virtual void setWifiInfo(char* ssid, char* password) {} + inline virtual void setWifiInfo(char* ssid, char* password) + { ssid[0] = 0; password[0] = 0; } inline virtual bool equals(const Subscriber *s) const { return ID == s->ID; } diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn.cpp b/gps/libloc_api_50001/loc_eng_dmn_conn.cpp index 2bb2d81..bc5edc2 100644..100755 --- a/gps/libloc_api_50001/loc_eng_dmn_conn.cpp +++ b/gps/libloc_api_50001/loc_eng_dmn_conn.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011,2012, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011,2012, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -48,11 +48,13 @@ static int loc_api_server_msgqid; static int loc_api_resp_msgqid; static int quipc_msgqid; static int msapm_msgqid; +static int msapu_msgqid; static const char * global_loc_api_q_path = GPSONE_LOC_API_Q_PATH; static const char * global_loc_api_resp_q_path = GPSONE_LOC_API_RESP_Q_PATH; static const char * global_quipc_ctrl_q_path = QUIPC_CTRL_Q_PATH; static const char * global_msapm_ctrl_q_path = MSAPM_CTRL_Q_PATH; +static const char * global_msapu_ctrl_q_path = MSAPU_CTRL_Q_PATH; static int loc_api_server_proc_init(void *context) { @@ -70,7 +72,8 @@ static int loc_api_server_proc_init(void *context) result = chown (global_loc_api_q_path, -1, gps_group->gr_gid); if (result != 0) { - LOC_LOGE("chown for pipe failed, gid = %d, result = %d, error = %s\n", gps_group->gr_gid, result, strerror(errno)); + LOC_LOGE("chown for pipe failed, pipe %s, gid = %d, result = %d, error = %s\n", + global_loc_api_q_path, gps_group->gr_gid, result, strerror(errno)); } } else @@ -79,8 +82,28 @@ static int loc_api_server_proc_init(void *context) } loc_api_resp_msgqid = loc_eng_dmn_conn_glue_msgget(global_loc_api_resp_q_path, O_RDWR); + + //change mode/group for the global_loc_api_resp_q_path pipe + result = chmod (global_loc_api_resp_q_path, 0660); + if (result != 0) + { + LOC_LOGE("failed to change mode for %s, error = %s\n", global_loc_api_resp_q_path, strerror(errno)); + } + + if (gps_group != NULL) + { + result = chown (global_loc_api_resp_q_path, -1, gps_group->gr_gid); + if (result != 0) + { + LOC_LOGE("chown for pipe failed, pipe %s, gid = %d, result = %d, error = %s\n", + global_loc_api_resp_q_path, + gps_group->gr_gid, result, strerror(errno)); + } + } + quipc_msgqid = loc_eng_dmn_conn_glue_msgget(global_quipc_ctrl_q_path, O_RDWR); msapm_msgqid = loc_eng_dmn_conn_glue_msgget(global_msapm_ctrl_q_path , O_RDWR); + msapu_msgqid = loc_eng_dmn_conn_glue_msgget(global_msapu_ctrl_q_path , O_RDWR); LOC_LOGD("%s:%d] loc_api_server_msgqid = %d\n", __func__, __LINE__, loc_api_server_msgqid); return 0; @@ -148,6 +171,7 @@ static int loc_api_server_proc_post(void *context) loc_eng_dmn_conn_glue_msgremove( global_loc_api_resp_q_path, loc_api_resp_msgqid); loc_eng_dmn_conn_glue_msgremove( global_quipc_ctrl_q_path, quipc_msgqid); loc_eng_dmn_conn_glue_msgremove( global_msapm_ctrl_q_path, msapm_msgqid); + loc_eng_dmn_conn_glue_msgremove( global_msapu_ctrl_q_path, msapu_msgqid); return 0; } @@ -221,6 +245,14 @@ int loc_eng_dmn_conn_loc_api_server_data_conn(int sender_id, int status) { } break; } + case LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU: { + LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU", __func__, __LINE__); + if (loc_eng_dmn_conn_glue_msgsnd(msapu_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) { + LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__); + return -1; + } + break; + } case LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON: { LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON", __func__, __LINE__); if (loc_eng_dmn_conn_glue_msgsnd(loc_api_resp_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) { diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn.h b/gps/libloc_api_50001/loc_eng_dmn_conn.h index f669248..9aebd4f 100644..100755 --- a/gps/libloc_api_50001/loc_eng_dmn_conn.h +++ b/gps/libloc_api_50001/loc_eng_dmn_conn.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011,2012, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011,2012, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -37,6 +37,7 @@ #define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/gpsone_d/gpsone_loc_api_resp_q" #define QUIPC_CTRL_Q_PATH "/data/misc/gpsone_d/quipc_ctrl_q" #define MSAPM_CTRL_Q_PATH "/data/misc/gpsone_d/msapm_ctrl_q" +#define MSAPU_CTRL_Q_PATH "/data/misc/gpsone_d/msapu_ctrl_q" #else @@ -44,6 +45,7 @@ #define GPSONE_LOC_API_RESP_Q_PATH "/tmp/gpsone_loc_api_resp_q" #define QUIPC_CTRL_Q_PATH "/tmp/quipc_ctrl_q" #define MSAPM_CTRL_Q_PATH "/tmp/msapm_ctrl_q" +#define MSAPU_CTRL_Q_PATH "/tmp/msapu_ctrl_q" #endif diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c index 9cd1922..6b97a23 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c +++ b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h index 8bc6f2a..d685c87 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h +++ b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c index 7476908..5c24f46 100644..100755 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c +++ b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -64,13 +64,21 @@ int loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode) int result; LOC_LOGD("%s, mode = %d\n", pipe_name, mode); - result = mkfifo(pipe_name, 0666); + result = mkfifo(pipe_name, 0660); if ((result == -1) && (errno != EEXIST)) { LOC_LOGE("failed: %s\n", strerror(errno)); return result; } + // The mode in mkfifo is not honoured and does not provide the + // group permissions. Doing chmod to add group permissions. + result = chmod (pipe_name, 0660); + if (result != 0){ + LOC_LOGE ("%s failed to change mode for %s, error = %s\n", __func__, + pipe_name, strerror(errno)); + } + fd = open(pipe_name, mode); if (fd <= 0) { diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h index 3136e41..b2fa3a0 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h +++ b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_handler.cpp b/gps/libloc_api_50001/loc_eng_dmn_conn_handler.cpp index 6077b72..cc81dff 100644..100755 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_handler.cpp +++ b/gps/libloc_api_50001/loc_eng_dmn_conn_handler.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011,2012, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011,2012, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -99,6 +99,18 @@ int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg, loc_eng_msg_sender(loc_api_handle, msg); break; } + case IF_REQUEST_SENDER_ID_MSAPU: + { + LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPU"); + loc_eng_msg_request_wifi *msg( + new loc_eng_msg_request_wifi(loc_api_handle, + type, + LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU, + (char*)pmsg->cmsg.cmsg_if_request.ssid, + (char*)pmsg->cmsg.cmsg_if_request.password)); + loc_eng_msg_sender(loc_api_handle, msg); + break; + } case IF_REQUEST_SENDER_ID_GPSONE_DAEMON: { LOC_LOGD("IF_REQUEST_SENDER_ID_GPSONE_DAEMON"); @@ -179,6 +191,18 @@ int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg, loc_eng_msg_sender(loc_api_handle, msg); break; } + case IF_REQUEST_SENDER_ID_MSAPU: + { + LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPU"); + loc_eng_msg_release_wifi *msg( + new loc_eng_msg_release_wifi(loc_api_handle, + type, + LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU, + (char*)pmsg->cmsg.cmsg_if_request.ssid, + (char*)pmsg->cmsg.cmsg_if_request.password)); + loc_eng_msg_sender(loc_api_handle, msg); + break; + } case IF_REQUEST_SENDER_ID_GPSONE_DAEMON: { LOC_LOGD("IF_REQUEST_SENDER_ID_GPSONE_DAEMON"); diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_handler.h b/gps/libloc_api_50001/loc_eng_dmn_conn_handler.h index 7aa22bf..f5b3ee0 100644..100755 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_handler.h +++ b/gps/libloc_api_50001/loc_eng_dmn_conn_handler.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011,2012, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011,2012, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -67,6 +67,7 @@ typedef enum { typedef enum { IF_REQUEST_SENDER_ID_QUIPC = 0, IF_REQUEST_SENDER_ID_MSAPM, + IF_REQUEST_SENDER_ID_MSAPU, IF_REQUEST_SENDER_ID_GPSONE_DAEMON, IF_REQUEST_SENDER_ID_MODEM } ctrl_if_req_sender_id_e_type; diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c b/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c index 478b686..67e3187 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c +++ b/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h b/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h index 07869f9..89e598b 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h +++ b/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/libloc_api_50001/loc_eng_log.cpp b/gps/libloc_api_50001/loc_eng_log.cpp index 95db6c3..6e1b4db 100644 --- a/gps/libloc_api_50001/loc_eng_log.cpp +++ b/gps/libloc_api_50001/loc_eng_log.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011,2012 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011,2012 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -125,7 +125,8 @@ static loc_name_val_s_type loc_eng_position_modes[] = NAME_VAL( LOC_POSITION_MODE_RESERVED_1 ), NAME_VAL( LOC_POSITION_MODE_RESERVED_2 ), NAME_VAL( LOC_POSITION_MODE_RESERVED_3 ), - NAME_VAL( LOC_POSITION_MODE_RESERVED_4 ) + NAME_VAL( LOC_POSITION_MODE_RESERVED_4 ), + NAME_VAL( LOC_POSITION_MODE_RESERVED_5 ) }; static int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type); diff --git a/gps/libloc_api_50001/loc_eng_log.h b/gps/libloc_api_50001/loc_eng_log.h index e8a8279..925e3b4 100644 --- a/gps/libloc_api_50001/loc_eng_log.h +++ b/gps/libloc_api_50001/loc_eng_log.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/libloc_api_50001/loc_eng_msg.cpp b/gps/libloc_api_50001/loc_eng_msg.cpp index 97c0457..a296dce 100644 --- a/gps/libloc_api_50001/loc_eng_msg.cpp +++ b/gps/libloc_api_50001/loc_eng_msg.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/libloc_api_50001/loc_eng_msg.h b/gps/libloc_api_50001/loc_eng_msg.h index d1f4011..0728653 100644..100755 --- a/gps/libloc_api_50001/loc_eng_msg.h +++ b/gps/libloc_api_50001/loc_eng_msg.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011,2012 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011-2012, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -98,6 +98,35 @@ struct LocPosMode } }; +/** Flags to indicate which values are valid in a GpsLocationExtended. */ +typedef uint16_t GpsLocationExtendedFlags; +/** GpsLocationExtended has valid pdop, hdop, vdop. */ +#define GPS_LOCATION_EXTENDED_HAS_DOP 0x0001 +/** GpsLocationExtended has valid altitude mean sea level. */ +#define GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL 0x0002 +/** GpsLocation has valid magnetic deviation. */ +#define GPS_LOCATION_EXTENDED_HAS_MAG_DEV 0x0004 +/** GpsLocation has valid mode indicator. */ +#define GPS_LOCATION_EXTENDED_HAS_MODE_IND 0x0008 + +/** Represents gps location extended. */ +typedef struct { + /** set to sizeof(GpsLocationExtended) */ + size_t size; + /** Contains GpsLocationExtendedFlags bits. */ + uint16_t flags; + /** Contains the Altitude wrt mean sea level */ + float altitudeMeanSeaLevel; + /** Contains Position Dilusion of Precision. */ + float pdop; + /** Contains Horizontal Dilusion of Precision. */ + float hdop; + /** Contains Vertical Dilusion of Precision. */ + float vdop; + /** Contains Magnetic Deviation. */ + float magneticDeviation; +} GpsLocationExtended; + typedef enum { LOC_ENG_IF_REQUEST_TYPE_SUPL = 0, LOC_ENG_IF_REQUEST_TYPE_WIFI, @@ -107,6 +136,7 @@ typedef enum { typedef enum { LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0, LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM, + LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU, LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, LOC_ENG_IF_REQUEST_SENDER_ID_MODEM, LOC_ENG_IF_REQUEST_SENDER_ID_UNKNOWN @@ -317,25 +347,38 @@ struct loc_eng_msg_delete_aiding_data : public loc_eng_msg { struct loc_eng_msg_report_position : public loc_eng_msg { const GpsLocation location; + const GpsLocationExtended locationExtended; const void* locationExt; const enum loc_sess_status status; - inline loc_eng_msg_report_position(void* instance, GpsLocation &loc, void* locExt, + const LocPosTechMask technology_mask; + inline loc_eng_msg_report_position(void* instance, GpsLocation &loc, GpsLocationExtended &locExtended, void* locExt, enum loc_sess_status st) : loc_eng_msg(instance, LOC_ENG_MSG_REPORT_POSITION), - location(loc), locationExt(locExt), status(st) + location(loc), locationExtended(locExtended), locationExt(locExt), status(st), technology_mask(LOC_POS_TECH_MASK_DEFAULT) + { + LOC_LOGV("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: %lld\n rawDataSize: %d\n rawData: %p\n Session status: %d\n Technology mask: %u", + location.flags, location.position_source, location.latitude, location.longitude, + location.altitude, location.speed, location.bearing, location.accuracy, + location.timestamp, location.rawDataSize, location.rawData,status,technology_mask); + } + inline loc_eng_msg_report_position(void* instance, GpsLocation &loc, GpsLocationExtended &locExtended, void* locExt, + enum loc_sess_status st, LocPosTechMask technology) : + loc_eng_msg(instance, LOC_ENG_MSG_REPORT_POSITION), + location(loc), locationExtended(locExtended), locationExt(locExt), status(st), technology_mask(technology) { - LOC_LOGV("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: %lld\n rawDataSize: %d\n rawData: %p\n Session status: %d", + LOC_LOGV("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: %lld\n rawDataSize: %d\n rawData: %p\n Session status: %d\n Technology mask: %u", location.flags, location.position_source, location.latitude, location.longitude, location.altitude, location.speed, location.bearing, location.accuracy, - location.timestamp, location.rawDataSize, location.rawData,status); + location.timestamp, location.rawDataSize, location.rawData,status,technology_mask); } }; struct loc_eng_msg_report_sv : public loc_eng_msg { const GpsSvStatus svStatus; + const GpsLocationExtended locationExtended; const void* svExt; - inline loc_eng_msg_report_sv(void* instance, GpsSvStatus &sv, void* ext) : - loc_eng_msg(instance, LOC_ENG_MSG_REPORT_SV), svStatus(sv), svExt(ext) + inline loc_eng_msg_report_sv(void* instance, GpsSvStatus &sv, GpsLocationExtended &locExtended, void* ext) : + loc_eng_msg(instance, LOC_ENG_MSG_REPORT_SV), svStatus(sv), locationExtended(locExtended), svExt(ext) { LOC_LOGV("num sv: %d\n ephemeris mask: %dxn almanac mask: %x\n used in fix mask: %x\n sv: prn snr elevation azimuth", svStatus.num_svs, svStatus.ephemeris_mask, svStatus.almanac_mask, svStatus.used_in_fix_mask); diff --git a/gps/libloc_api_50001/loc_eng_msg_id.h b/gps/libloc_api_50001/loc_eng_msg_id.h index 829b632..0f374cd 100644..100755 --- a/gps/libloc_api_50001/loc_eng_msg_id.h +++ b/gps/libloc_api_50001/loc_eng_msg_id.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011,2012 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011,2012 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -115,6 +115,12 @@ enum loc_eng_msg_ids_t { // Message is sent by QUIPC module in order to request some info from ULP ULP_MSG_REQUEST_COARSE_POSITION, + // Message is sent to ULP module to re-evaluate its subsystems + ULP_MSG_MONITOR, + + // Last ULP MSG + ULP_MSG_LAST = 0x700, + /* Message is sent by HAL to LOC API to configure LTE Positioning Profile in modem */ LOC_ENG_MSG_LPP_CONFIG, diff --git a/gps/libloc_api_50001/loc_eng_ni.cpp b/gps/libloc_api_50001/loc_eng_ni.cpp index c2d78af..3a6e1d0 100644 --- a/gps/libloc_api_50001/loc_eng_ni.cpp +++ b/gps/libloc_api_50001/loc_eng_ni.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2009,2011 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -249,7 +249,9 @@ void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, GpsNiCallbacks *callback { ENTRY_LOG_CALLFLOW(); - if (NULL == callbacks->notify_cb) { + if(callbacks == NULL) + EXIT_LOG(%s, "loc_eng_ni_init: failed, cb is NULL"); + else if (NULL == callbacks->notify_cb) { EXIT_LOG(%s, "loc_eng_ni_init: failed, no cb."); } else if (NULL != loc_eng_data.ni_notify_cb) { EXIT_LOG(%s, "loc_eng_ni_init: already inited."); diff --git a/gps/libloc_api_50001/loc_eng_ni.h b/gps/libloc_api_50001/loc_eng_ni.h index 9b1c5f3..9cbc57d 100644 --- a/gps/libloc_api_50001/loc_eng_ni.h +++ b/gps/libloc_api_50001/loc_eng_ni.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2009,2011 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/libloc_api_50001/loc_eng_nmea.cpp b/gps/libloc_api_50001/loc_eng_nmea.cpp new file mode 100644 index 0000000..d2507a5 --- /dev/null +++ b/gps/libloc_api_50001/loc_eng_nmea.cpp @@ -0,0 +1,703 @@ +/* Copyright (c) 2012, 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. + * + */ + +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_eng_nmea" + +#include <loc_eng.h> +#include <loc_eng_nmea.h> +#include <math.h> +#include "log_util.h" + +/*=========================================================================== +FUNCTION loc_eng_nmea_send + +DESCRIPTION + send out NMEA sentence + +DEPENDENCIES + NONE + +RETURN VALUE + Total length of the nmea sentence + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p) +{ + struct timeval tv; + gettimeofday(&tv, (struct timezone *) NULL); + int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000; + CALLBACK_LOG_CALLFLOW("nmea_cb", %p, pNmea); + loc_eng_data_p->nmea_cb(now, pNmea, length); + LOC_LOGD("NMEA <%s", pNmea); +} + +/*=========================================================================== +FUNCTION loc_eng_nmea_put_checksum + +DESCRIPTION + Generate NMEA sentences generated based on position report + +DEPENDENCIES + NONE + +RETURN VALUE + Total length of the nmea sentence + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_nmea_put_checksum(char *pNmea, int maxSize) +{ + uint8_t checksum = 0; + int length = 0; + + pNmea++; //skip the $ + while (*pNmea != '\0') + { + checksum ^= *pNmea++; + length++; + } + + int checksumLength = snprintf(pNmea, maxSize,"*%02X\r\n", checksum); + return (length + checksumLength); +} + +/*=========================================================================== +FUNCTION loc_eng_nmea_generate_pos + +DESCRIPTION + Generate NMEA sentences generated based on position report + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, + const GpsLocation &location, const GpsLocationExtended &locationExtended) +{ + ENTRY_LOG(); + + char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0}; + char* pMarker = sentence; + int lengthRemaining = sizeof(sentence); + int length = 0; + + time_t utcTime(location.timestamp/1000); + tm * pTm = gmtime(&utcTime); + int utcYear = pTm->tm_year % 100; // 2 digit year + int utcMonth = pTm->tm_mon + 1; // tm_mon starts at zero + int utcDay = pTm->tm_mday; + int utcHours = pTm->tm_hour; + int utcMinutes = pTm->tm_min; + int utcSeconds = pTm->tm_sec; + + // ------------------ + // ------$GPGSA------ + // ------------------ + + uint32_t svUsedCount = 0; + uint32_t svUsedList[32] = {0}; + uint32_t mask = loc_eng_data_p->sv_used_mask; + for (uint8_t i = 1; mask > 0 && svUsedCount < 32; i++) + { + if (mask & 1) + svUsedList[svUsedCount++] = i; + mask = mask >> 1; + } + // clear the cache so they can't be used again + loc_eng_data_p->sv_used_mask = 0; + + char fixType; + if (svUsedCount == 0) + fixType = '1'; // no fix + else if (svUsedCount <= 3) + fixType = '2'; // 2D fix + else + fixType = '3'; // 3D fix + + length = snprintf(pMarker, lengthRemaining, "$GPGSA,A,%c,", fixType); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + for (uint8_t i = 0; i < 12; i++) // only the first 12 sv go in sentence + { + if (i < svUsedCount) + length = snprintf(pMarker, lengthRemaining, "%02d,", svUsedList[i]); + else + length = snprintf(pMarker, lengthRemaining, ","); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + } + + 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, ",,"); + } + + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + // ------------------ + // ------$GPVTG------ + // ------------------ + + pMarker = sentence; + lengthRemaining = sizeof(sentence); + + if (location.flags & GPS_LOCATION_HAS_BEARING) + { + float magTrack = location.bearing; + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV) + { + float magTrack = location.bearing - locationExtended.magneticDeviation; + if (magTrack < 0.0) + magTrack += 360.0; + else if (magTrack > 360.0) + magTrack -= 360.0; + } + + length = snprintf(pMarker, lengthRemaining, "$GPVTG,%.1lf,T,%.1lf,M,", location.bearing, magTrack); + } + else + { + length = snprintf(pMarker, lengthRemaining, "$GPVTG,,T,,M,"); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (location.flags & GPS_LOCATION_HAS_SPEED) + { + float speedKnots = location.speed * (3600.0/1852.0); + float speedKmPerHour = location.speed * 3.6; + + length = snprintf(pMarker, lengthRemaining, "%.1lf,N,%.1lf,K,", speedKnots, speedKmPerHour); + } + else + { + length = snprintf(pMarker, lengthRemaining, ",N,,K,"); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (!(location.flags & GPS_LOCATION_HAS_LAT_LONG)) + length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix + else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->client_handle->getPositionMode().mode) + length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous + else + length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential + + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + // ------------------ + // ------$GPRMC------ + // ------------------ + + pMarker = sentence; + lengthRemaining = sizeof(sentence); + + length = snprintf(pMarker, lengthRemaining, "$GPRMC,%02d%02d%02d,A," , + utcHours, utcMinutes, utcSeconds); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (location.flags & GPS_LOCATION_HAS_LAT_LONG) + { + double latitude = location.latitude; + double longitude = location.longitude; + char latHemisphere; + char lonHemisphere; + double latMinutes; + double lonMinutes; + + if (latitude > 0) + { + latHemisphere = 'N'; + } + else + { + latHemisphere = 'S'; + latitude *= -1.0; + } + + if (longitude < 0) + { + lonHemisphere = 'W'; + longitude *= -1.0; + } + else + { + lonHemisphere = 'E'; + } + + latMinutes = fmod(latitude * 60.0 , 60.0); + lonMinutes = fmod(longitude * 60.0 , 60.0); + + length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,", + (uint8_t)floor(latitude), latMinutes, latHemisphere, + (uint8_t)floor(longitude),lonMinutes, lonHemisphere); + } + else + { + length = snprintf(pMarker, lengthRemaining,",,,,"); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (location.flags & GPS_LOCATION_HAS_SPEED) + { + float speedKnots = location.speed * (3600.0/1852.0); + length = snprintf(pMarker, lengthRemaining, "%.1lf,", speedKnots); + } + else + { + length = snprintf(pMarker, lengthRemaining, ","); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (location.flags & GPS_LOCATION_HAS_BEARING) + { + length = snprintf(pMarker, lengthRemaining, "%.1lf,", location.bearing); + } + else + { + length = snprintf(pMarker, lengthRemaining, ","); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + length = snprintf(pMarker, lengthRemaining, "%2.2d%2.2d%2.2d,", + utcDay, utcMonth, utcYear); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV) + { + float magneticVariation = locationExtended.magneticDeviation; + char direction; + if (magneticVariation < 0.0) + { + direction = 'W'; + magneticVariation *= -1.0; + } + else + { + direction = 'E'; + } + + length = snprintf(pMarker, lengthRemaining, "%.1lf,%c,", + magneticVariation, direction); + } + else + { + length = snprintf(pMarker, lengthRemaining, ",,"); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (!(location.flags & GPS_LOCATION_HAS_LAT_LONG)) + length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix + else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->client_handle->getPositionMode().mode) + length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous + else + length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential + + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + // ------------------ + // ------$GPGGA------ + // ------------------ + + pMarker = sentence; + lengthRemaining = sizeof(sentence); + + length = snprintf(pMarker, lengthRemaining, "$GPGGA,%02d%02d%02d," , + utcHours, utcMinutes, utcSeconds); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (location.flags & GPS_LOCATION_HAS_LAT_LONG) + { + double latitude = location.latitude; + double longitude = location.longitude; + char latHemisphere; + char lonHemisphere; + double latMinutes; + double lonMinutes; + + if (latitude > 0) + { + latHemisphere = 'N'; + } + else + { + latHemisphere = 'S'; + latitude *= -1.0; + } + + if (longitude < 0) + { + lonHemisphere = 'W'; + longitude *= -1.0; + } + else + { + lonHemisphere = 'E'; + } + + latMinutes = fmod(latitude * 60.0 , 60.0); + lonMinutes = fmod(longitude * 60.0 , 60.0); + + length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,", + (uint8_t)floor(latitude), latMinutes, latHemisphere, + (uint8_t)floor(longitude),lonMinutes, lonHemisphere); + } + else + { + length = snprintf(pMarker, lengthRemaining,",,,,"); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + char gpsQuality; + if (!(location.flags & GPS_LOCATION_HAS_LAT_LONG)) + gpsQuality = '0'; // 0 means no fix + else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->client_handle->getPositionMode().mode) + gpsQuality = '1'; // 1 means GPS fix + else + gpsQuality = '2'; // 2 means DGPS fix + + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP) + { // dop is in locationExtended, (QMI) + length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,", + gpsQuality, svUsedCount, locationExtended.hdop); + } + 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, "%c,%02d,%.1f,", + gpsQuality, svUsedCount, loc_eng_data_p->hdop); + } + else + { // no hdop + length = snprintf(pMarker, lengthRemaining, "%c,%02d,,", + gpsQuality, svUsedCount); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL) + { + length = snprintf(pMarker, lengthRemaining, "%.1lf,M,", + locationExtended.altitudeMeanSeaLevel); + } + else + { + length = snprintf(pMarker, lengthRemaining,",,"); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if ((location.flags & GPS_LOCATION_HAS_ALTITUDE) && + (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL)) + { + length = snprintf(pMarker, lengthRemaining, "%.1lf,M,,", + location.altitude - locationExtended.altitudeMeanSeaLevel); + } + else + { + length = snprintf(pMarker, lengthRemaining,",,,"); + } + + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + // clear the dop cache so they can't be used again + loc_eng_data_p->pdop = 0; + loc_eng_data_p->hdop = 0; + loc_eng_data_p->vdop = 0; + + EXIT_LOG(%d, 0); +} + + + +/*=========================================================================== +FUNCTION loc_eng_nmea_generate_sv + +DESCRIPTION + Generate NMEA sentences generated based on sv report + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, + const GpsSvStatus &svStatus, const GpsLocationExtended &locationExtended) +{ + ENTRY_LOG(); + + char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0}; + char* pMarker = sentence; + int lengthRemaining = sizeof(sentence); + int length = 0; + + // ------------------ + // ------$GPGSV------ + // ------------------ + + if (svStatus.num_svs <= 0) + { + // no svs in view, so just send a blank $GPGSV sentence + strlcpy(sentence, "$GPGSV,1,1,0,", sizeof(sentence)); + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + } + else + { + int svCount = svStatus.num_svs; + int sentenceCount = svCount / 4; + if (svStatus.num_svs % 4) + sentenceCount++; + int sentenceNumber = 1; + int svNumber = 1; + + while (sentenceNumber <= sentenceCount) + { + pMarker = sentence; + lengthRemaining = sizeof(sentence); + + length = snprintf(pMarker, lengthRemaining, "$GPGSV,%d,%d,%02d", + sentenceCount, sentenceNumber, svCount); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + for (int i=0; (svNumber <= svCount) && (i < 4); i++, svNumber++) + { + length = snprintf(pMarker, lengthRemaining,",%02d,%02d,%03d,", + svStatus.sv_list[svNumber-1].prn, + (int)(0.5 + svStatus.sv_list[svNumber-1].elevation), //float to int + (int)(0.5 + svStatus.sv_list[svNumber-1].azimuth)); //float to int + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (svStatus.sv_list[svNumber-1].snr > 0) + { + length = snprintf(pMarker, lengthRemaining,"%02d", + (int)(0.5 + svStatus.sv_list[svNumber-1].snr)); //float to int + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + } + } + + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + sentenceNumber++; + + } + } + + if (svStatus.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)); + 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); + + strlcpy(sentence, "$GPRMC,,V,,,,,,,,,,N", sizeof(sentence)); + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + strlcpy(sentence, "$GPGGA,,,,,,0,,,,,,,,", sizeof(sentence)); + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, 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; + + // For RPC, the DOP are sent during sv report, so cache them + // now to be sent during position report. + // For QMI, the DOP will be in position report. + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP) + { + loc_eng_data_p->pdop = locationExtended.pdop; + loc_eng_data_p->hdop = locationExtended.hdop; + loc_eng_data_p->vdop = locationExtended.vdop; + } + else + { + loc_eng_data_p->pdop = 0; + loc_eng_data_p->hdop = 0; + loc_eng_data_p->vdop = 0; + } + + } + + EXIT_LOG(%d, 0); +} diff --git a/gps/libloc_api_50001/loc_eng_nmea.h b/gps/libloc_api_50001/loc_eng_nmea.h new file mode 100644 index 0000000..29ca6c5 --- /dev/null +++ b/gps/libloc_api_50001/loc_eng_nmea.h @@ -0,0 +1,42 @@ +/* Copyright (c) 2012, 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 LOC_ENG_NMEA_H +#define LOC_ENG_NMEA_H + +#include <hardware/gps.h> + +#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_pos(loc_eng_data_s_type *loc_eng_data_p, const GpsLocation &location, const GpsLocationExtended &locationExtended); + +#endif // LOC_ENG_NMEA_H diff --git a/gps/libloc_api_50001/loc_eng_xtra.cpp b/gps/libloc_api_50001/loc_eng_xtra.cpp index ebc7c6f..b8d9218 100644 --- a/gps/libloc_api_50001/loc_eng_xtra.cpp +++ b/gps/libloc_api_50001/loc_eng_xtra.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2009,2011 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -54,12 +54,17 @@ SIDE EFFECTS int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data, GpsXtraCallbacks* callbacks) { - loc_eng_xtra_data_s_type *xtra_module_data_ptr; - - xtra_module_data_ptr = &loc_eng_data.xtra_module_data; - xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb; - - return 0; + int ret_val = -1; + loc_eng_xtra_data_s_type *xtra_module_data_ptr; + + if(callbacks == NULL) + LOC_LOGE("loc_eng_xtra_init: failed, cb is NULL"); + else { + xtra_module_data_ptr = &loc_eng_data.xtra_module_data; + xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb; + ret_val = 0; + } + return ret_val; } /*=========================================================================== diff --git a/gps/libloc_api_50001/loc_eng_xtra.h b/gps/libloc_api_50001/loc_eng_xtra.h index 7e01e14..614348d 100644 --- a/gps/libloc_api_50001/loc_eng_xtra.h +++ b/gps/libloc_api_50001/loc_eng_xtra.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2009,2011 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/ulp/inc/ulp.h b/gps/ulp/inc/ulp.h index 50d6c91..ce27c96 100644 --- a/gps/ulp/inc/ulp.h +++ b/gps/ulp/inc/ulp.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/utils/Android.mk b/gps/utils/Android.mk index 9df5e79..205fb16 100644 --- a/gps/utils/Android.mk +++ b/gps/utils/Android.mk @@ -14,11 +14,12 @@ LOCAL_SRC_FILES += \ loc_log.cpp \ loc_cfg.cpp \ msg_q.c \ - linked_list.c + linked_list.c \ + loc_target.cpp LOCAL_CFLAGS += \ - -fno-short-enums \ - -D_ANDROID_ + -fno-short-enums \ + -D_ANDROID_ LOCAL_LDFLAGS += -Wl,--export-dynamic @@ -27,11 +28,12 @@ LOCAL_C_INCLUDES:= LOCAL_COPY_HEADERS_TO:= gps.utils/ LOCAL_COPY_HEADERS:= \ - loc_log.h \ - loc_cfg.h \ - log_util.h \ - linked_list.h \ - msg_q.h + loc_log.h \ + loc_cfg.h \ + log_util.h \ + linked_list.h \ + msg_q.h \ + loc_target.h LOCAL_MODULE := libgps.utils diff --git a/gps/utils/linked_list.c b/gps/utils/linked_list.c index 16f2aa2..31ec52d 100644 --- a/gps/utils/linked_list.c +++ b/gps/utils/linked_list.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/utils/linked_list.h b/gps/utils/linked_list.h index cfc945a..a85f09a 100644 --- a/gps/utils/linked_list.h +++ b/gps/utils/linked_list.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/utils/loc_cfg.cpp b/gps/utils/loc_cfg.cpp index 574c958..3f7dec9 100644 --- a/gps/utils/loc_cfg.cpp +++ b/gps/utils/loc_cfg.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/utils/loc_cfg.h b/gps/utils/loc_cfg.h index bc3b1c3..155db65 100644 --- a/gps/utils/loc_cfg.h +++ b/gps/utils/loc_cfg.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/utils/loc_log.cpp b/gps/utils/loc_log.cpp index e4fb76c..b75cf93 100644 --- a/gps/utils/loc_log.cpp +++ b/gps/utils/loc_log.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -34,7 +34,6 @@ #include <sys/time.h> #include "loc_log.h" #include "msg_q.h" - #include "log_util.h" // Logging Improvements @@ -100,6 +99,35 @@ const char* log_succ_fail_string(int is_succ) return is_succ? "successful" : "failed"; } +//Target names +loc_name_val_s_type target_name[] = +{ + NAME_VAL(TARGET_OTHER), + NAME_VAL(TARGET_APQ8064_STANDALONE), + NAME_VAL(TARGET_APQ8064_FUSION3), + NAME_VAL(TARGET_MPQ8064), + NAME_VAL(TARGET_MSM8930) +}; + +static int target_name_num = sizeof(target_name)/sizeof(loc_name_val_s_type); + +/*=========================================================================== + +FUNCTION loc_get_target_name + +DESCRIPTION + Returns pointer to a string that contains name of the target + + XX:XX:XX.000\0 + +RETURN VALUE + The target name string + +===========================================================================*/ +const char *loc_get_target_name(targetEnumType target) +{ + return loc_get_name_from_val(target_name, target_name_num, (long)target); +} /*=========================================================================== diff --git a/gps/utils/loc_log.h b/gps/utils/loc_log.h index 8b071a4..46f4e3e 100644 --- a/gps/utils/loc_log.h +++ b/gps/utils/loc_log.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -36,6 +36,7 @@ extern "C" #endif #include <ctype.h> +#include "loc_target.h" typedef struct { @@ -54,6 +55,7 @@ typedef struct const char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, long mask); const char* loc_get_name_from_val(loc_name_val_s_type table[], int table_size, long value); const char* loc_get_msg_q_status(int status); +const char* loc_get_target_name(targetEnumType target); extern const char* log_succ_fail_string(int is_succ); diff --git a/gps/utils/loc_target.cpp b/gps/utils/loc_target.cpp new file mode 100644 index 0000000..348ad9d --- /dev/null +++ b/gps/utils/loc_target.cpp @@ -0,0 +1,109 @@ +/* Copyright (c) 2012, 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. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> +#include <hardware/gps.h> +#include <cutils/properties.h> +#include "loc_target.h" +#include "loc_log.h" +#include "log_util.h" + +#define APQ8064_ID_1 "109" +#define APQ8064_ID_2 "153" +#define MPQ8064_ID_1 "130" +#define MSM8930_ID_1 "142" +#define MSM8930_ID_2 "116" + +#define LINE_LEN 100 +#define STR_LIQUID "Liquid" +#define STR_SURF "Surf" +#define IS_STR_END(c) ((c) == '\0' || (c) == '\n' || (c) == '\r') +#define LENGTH(s) (sizeof(s) - 1) +#define GPS_CHECK_NO_ERROR 0 +#define GPS_CHECK_NO_GPS_HW 1 + +static int gss_fd = 0; + +static int read_a_line(const char * file_path, char * line, int line_size) +{ + FILE *fp; + int result = 0; + + * line = '\0'; + fp = fopen(file_path, "r" ); + if( fp == NULL ) { + LOC_LOGE("open failed: %s: %s\n", file_path, strerror(errno)); + result = -1; + } else { + int len; + fgets(line, line_size, fp); + len = strlen(line); + len = len < line_size - 1? len : line_size - 1; + line[len] = '\0'; + LOC_LOGD("cat %s: %s", file_path, line); + fclose(fp); + } + return result; +} + +targetEnumType get_target(void) +{ + targetEnumType target = TARGET_OTHER; + + char hw_platform[] = "/sys/devices/system/soc/soc0/hw_platform"; + char id[] = "/sys/devices/system/soc/soc0/id"; + char mdm[] = "/dev/mdm"; // No such file or directory + + char rd_hw_platform[LINE_LEN]; + char rd_id[LINE_LEN]; + char rd_mdm[LINE_LEN]; + + read_a_line(hw_platform, rd_hw_platform, LINE_LEN); + read_a_line(id, rd_id, LINE_LEN); + + if(!memcmp(rd_id, MPQ8064_ID_1, LENGTH(MPQ8064_ID_1)) && IS_STR_END(rd_id[LENGTH(MPQ8064_ID_1)]) ) + target = TARGET_MPQ8064; + else if( (!memcmp(rd_hw_platform, STR_LIQUID, LENGTH(STR_LIQUID)) && IS_STR_END(rd_hw_platform[LENGTH(STR_LIQUID)])) || + (!memcmp(rd_hw_platform, STR_SURF, LENGTH(STR_SURF)) && IS_STR_END(rd_hw_platform[LENGTH(STR_SURF)])) ) { + if(!read_a_line( mdm, rd_mdm, LINE_LEN)) + target = TARGET_APQ8064_FUSION3; + else if( (!memcmp(rd_id, APQ8064_ID_1, LENGTH(APQ8064_ID_1)) && IS_STR_END(rd_id[LENGTH(APQ8064_ID_1)])) || + (!memcmp(rd_id, APQ8064_ID_2, LENGTH(APQ8064_ID_2)) && IS_STR_END(rd_id[LENGTH(APQ8064_ID_2)])) ) + target = TARGET_APQ8064_STANDALONE; + } + else if( (!memcmp(rd_id, MSM8930_ID_1, LENGTH(MSM8930_ID_1)) && IS_STR_END(rd_id[LENGTH(MSM8930_ID_1)])) || + (!memcmp(rd_id, MSM8930_ID_2, LENGTH(MSM8930_ID_2)) && IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) ) + target = TARGET_MSM8930; + return target; +} diff --git a/gps/utils/loc_target.h b/gps/utils/loc_target.h new file mode 100644 index 0000000..489aadd --- /dev/null +++ b/gps/utils/loc_target.h @@ -0,0 +1,51 @@ +/* Copyright (c) 2012, 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 LOC_TARGET_H +#define LOC_TARGET_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef enum { + TARGET_OTHER = 0, + TARGET_APQ8064_STANDALONE, + TARGET_APQ8064_FUSION3, + TARGET_MPQ8064, + TARGET_MSM8930 +}targetEnumType; + +targetEnumType get_target(void); + +#ifdef __cplusplus +} +#endif + +#endif /*LOC_TARGET_H*/ diff --git a/gps/utils/log_util.h b/gps/utils/log_util.h index b3dae3c..9187e4f 100644 --- a/gps/utils/log_util.h +++ b/gps/utils/log_util.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * @@ -135,7 +135,6 @@ else if (loc_logger.DEBUG_LEVEL <= 0) { ALOGV("W/"__VA_ARGS__); } #define EXIT_LOG(SPEC, VAL) LOG_V(EXIT_TAG, __func__, SPEC, VAL) -#ifdef DEBUG_TRACE_CALLFLOW // Used for logging callflow from Android Framework #define ENTRY_LOG_CALLFLOW() LOG_I(FROM_AFW, __func__, %s, "") // Used for logging callflow to Modem @@ -144,12 +143,6 @@ else if (loc_logger.DEBUG_LEVEL <= 0) { ALOGV("W/"__VA_ARGS__); } #define MODEM_LOG_CALLFLOW(SPEC, VAL) LOG_I(FROM_MODEM, __func__, SPEC, VAL) // Used for logging callflow to Android Framework #define CALLBACK_LOG_CALLFLOW(CB, SPEC, VAL) LOG_I(TO_AFW, CB, SPEC, VAL) -#else -#define ENTRY_LOG_CALLFLOW() -#define EXIT_LOG_CALLFLOW(SPEC, VAL) -#define MODEM_LOG_CALLFLOW(SPEC, VAL) -#define CALLBACK_LOG_CALLFLOW(CB, SPEC, VAL) -#endif #ifdef __cplusplus } diff --git a/gps/utils/msg_q.c b/gps/utils/msg_q.c index cc024e4..df1d7a5 100644 --- a/gps/utils/msg_q.c +++ b/gps/utils/msg_q.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * diff --git a/gps/utils/msg_q.h b/gps/utils/msg_q.h index 4171540..d3d5cc5 100644 --- a/gps/utils/msg_q.h +++ b/gps/utils/msg_q.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2011, 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 @@ -9,7 +9,7 @@ * 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 Code Aurora Forum, Inc. nor the names of its + * * 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. * |