From 0ebaba253fa0a53bfe6c165073d5e17e66c99e8a Mon Sep 17 00:00:00 2001 From: Harikrishnan Hariharan Date: Mon, 18 Sep 2017 14:41:35 +0530 Subject: [PATCH] Set SUPL_HOST to modem on GnssAdapter init. On init of GnssAdapter, SUPL_HOST and SUPL_PORT are set to modem if the configs are set in gps.conf. Change-Id: I079879adf31022cfbf0098da8dba3bb86feed069 CRs-Fixed: 2110547 --- core/ContextBase.cpp | 4 ++++ core/ContextBase.h | 5 +++- gnss/GnssAdapter.cpp | 55 +++++++++++++++++++++++++------------------- gnss/GnssAdapter.h | 1 + 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index 8af48fc7..05a0ad31 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -65,6 +65,8 @@ const loc_param_s_type ContextBase::mGps_conf_table[] = {"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL", &mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'}, {"AGPS_CONFIG_INJECT", &mGps_conf.AGPS_CONFIG_INJECT, NULL, 'n'}, {"EXTERNAL_DR_ENABLED", &mGps_conf.EXTERNAL_DR_ENABLED, NULL, 'n'}, + {"SUPL_HOST", &mGps_conf.SUPL_HOST, NULL, 's'}, + {"SUPL_PORT", &mGps_conf.SUPL_PORT, NULL, 'n'}, }; const loc_param_s_type ContextBase::mSap_conf_table[] = @@ -98,6 +100,8 @@ void ContextBase::readConfig() mGps_conf.SUPL_VER = 0x10000; mGps_conf.SUPL_MODE = 0x1; mGps_conf.SUPL_ES = 0; + mGps_conf.SUPL_HOST[0] = 0; + mGps_conf.SUPL_PORT = 0; mGps_conf.CAPABILITIES = 0x7; /* LTE Positioning Profile configuration is disable by default*/ mGps_conf.LPP_PROFILE = 0; diff --git a/core/ContextBase.h b/core/ContextBase.h index 83de9996..dc64b6ab 100644 --- a/core/ContextBase.h +++ b/core/ContextBase.h @@ -36,7 +36,8 @@ #include #include -#define MAX_XTRA_SERVER_URL_LENGTH 256 +#define MAX_XTRA_SERVER_URL_LENGTH (256) +#define MAX_SUPL_SERVER_URL_LENGTH (256) /* GPS.conf support */ /* NOTE: the implementaiton of the parser casts number @@ -64,6 +65,8 @@ typedef struct loc_gps_cfg_s uint32_t LPPE_CP_TECHNOLOGY; uint32_t LPPE_UP_TECHNOLOGY; uint32_t EXTERNAL_DR_ENABLED; + char SUPL_HOST[MAX_SUPL_SERVER_URL_LENGTH]; + uint32_t SUPL_PORT; } loc_gps_cfg_s_type; /* NOTE: the implementaiton of the parser casts number diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index ee9f8410..63f0eff7 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -513,6 +513,33 @@ GnssAdapter::readConfigCommand() } } +LocationError +GnssAdapter::setSuplHostServer(const char* server, int port) +{ + LocationError locErr = LOCATION_ERROR_SUCCESS; + if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) { + char serverUrl[MAX_URL_LEN] = {}; + int32_t length = 0; + const char noHost[] = "NONE"; + if ((NULL == server) || (server[0] == 0) || (port == 0) || + (strncasecmp(noHost, server, sizeof(noHost)) == 0)) { + locErr = LOCATION_ERROR_INVALID_PARAMETER; + } else { + length = snprintf(serverUrl, sizeof(serverUrl), "%s:%u", server, port); + if (length > 0 && strncasecmp(getServerUrl().c_str(), + serverUrl, sizeof(serverUrl)) != 0) { + setServerUrl(serverUrl); + locErr = mLocApi->setServer(serverUrl, length); + if (locErr != LOCATION_ERROR_SUCCESS) { + LOC_LOGE("%s]:Error while setting SUPL_HOST server:%s", + __func__, serverUrl); + } + } + } + } + return locErr; +} + void GnssAdapter::setConfigCommand() { @@ -532,6 +559,8 @@ GnssAdapter::setConfigCommand() mApi.setLPPConfig(mAdapter.convertLppProfile(ContextBase::mGps_conf.LPP_PROFILE)); mApi.setAGLONASSProtocol(ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT); } + mAdapter.setSuplHostServer(ContextBase::mGps_conf.SUPL_HOST, + ContextBase::mGps_conf.SUPL_PORT); mApi.setSensorControlConfig(ContextBase::mSap_conf.SENSOR_USAGE, ContextBase::mSap_conf.SENSOR_PROVIDER); mApi.setLPPeProtocolCp( @@ -665,30 +694,8 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) } if (mConfig.flags & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) { if (GNSS_ASSISTANCE_TYPE_SUPL == mConfig.assistanceServer.type) { - if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) { - char serverUrl[MAX_URL_LEN] = {}; - int32_t length = 0; - const char noHost[] = "NONE"; - if (NULL == mConfig.assistanceServer.hostName || - strncasecmp(noHost, - mConfig.assistanceServer.hostName, - sizeof(noHost)) == 0) { - err = LOCATION_ERROR_INVALID_PARAMETER; - } else { - length = snprintf(serverUrl, sizeof(serverUrl), "%s:%u", - mConfig.assistanceServer.hostName, - mConfig.assistanceServer.port); - } - - if (length > 0 && strncasecmp(mAdapter.getServerUrl().c_str(), - serverUrl, sizeof(serverUrl)) != 0) { - mAdapter.setServerUrl(serverUrl); - err = mApi.setServer(serverUrl, length); - } - - } else { - err = LOCATION_ERROR_SUCCESS; - } + err = mAdapter.setSuplHostServer(mConfig.assistanceServer.hostName, + mConfig.assistanceServer.port); } else if (GNSS_ASSISTANCE_TYPE_C2K == mConfig.assistanceServer.type) { if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) { struct in_addr addr; diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index fb151076..0d9031ac 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -151,6 +151,7 @@ public: LocationCallbacks getClientCallbacks(LocationAPI* client); LocationCapabilitiesMask getCapabilities(); void broadcastCapabilities(LocationCapabilitiesMask); + LocationError setSuplHostServer(const char* server, int port); /* ==== TRACKING ======================================================================= */ /* ======== COMMANDS ====(Called from Client Thread)==================================== */