gps: Added xtra server query loc api
In order to prevent the issue where the xtra server url that stored in gps.conf is incorrect (like xtra.bin instead of xtra2.bin) for a particular modem, I've made this change so that the xtra server url can be queried through loc api. CRs-fixed: 366599 Change-Id: If65de98d837f068fd61a235cbf1104026246e5a9
This commit is contained in:
parent
926d20ad77
commit
399f53047e
14 changed files with 202 additions and 4 deletions
|
@ -1,6 +1,8 @@
|
|||
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
|
||||
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
|
||||
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
|
||||
# Customized XTRA server urls can go here, which will
|
||||
# override the default urls that are given by the modem
|
||||
#XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
|
||||
#XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
|
||||
#XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
|
||||
|
||||
# Error Estimate
|
||||
# _SET = 1
|
||||
|
|
|
@ -96,6 +96,8 @@ public:
|
|||
setServer(unsigned int ip, int port, LocServerType type);
|
||||
virtual enum loc_api_adapter_err
|
||||
setXtraData(char* data, int length);
|
||||
virtual enum loc_api_adapter_err
|
||||
requestXtraServer();
|
||||
virtual enum loc_api_adapter_err
|
||||
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType);
|
||||
virtual enum loc_api_adapter_err
|
||||
|
|
|
@ -958,6 +958,49 @@ LocApiRpcAdapter::setXtraData(char* data, int length)
|
|||
return convertErr(rpc_ret_val);
|
||||
}
|
||||
|
||||
/* Request the Xtra Server Url from the modem */
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::requestXtraServer()
|
||||
{
|
||||
loc_api_adapter_err err;
|
||||
rpc_loc_ioctl_data_u_type data;
|
||||
rpc_loc_ioctl_callback_s_type callback_data;
|
||||
|
||||
err = convertErr(loc_eng_ioctl(client_handle,
|
||||
RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE,
|
||||
&data,
|
||||
LOC_IOCTL_DEFAULT_TIMEOUT,
|
||||
&callback_data));
|
||||
|
||||
if (LOC_API_ADAPTER_ERR_SUCCESS != err)
|
||||
{
|
||||
LOC_LOGE("RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE failed!: err=%d\n", err);
|
||||
return err;
|
||||
}
|
||||
else if (RPC_LOC_SESS_STATUS_SUCCESS != callback_data.status)
|
||||
{
|
||||
LOC_LOGE("RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE failed!: status=%ld\n", callback_data.status);
|
||||
return LOC_API_ADAPTER_ERR_GENERAL_FAILURE;
|
||||
}
|
||||
else if (RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE != callback_data.type)
|
||||
{
|
||||
LOC_LOGE("RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE is not the type expected! type=%d\n", callback_data.type);
|
||||
return LOC_API_ADAPTER_ERR_GENERAL_FAILURE;
|
||||
}
|
||||
else if (RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE != callback_data.data.disc)
|
||||
{
|
||||
LOC_LOGE("RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE is not the disc expected! disc=%d\n", callback_data.data.disc);
|
||||
return LOC_API_ADAPTER_ERR_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
LocApiAdapter::reportXtraServer(callback_data.data.rpc_loc_ioctl_callback_data_u_type_u.predicted_orbits_data_source.servers[0],
|
||||
callback_data.data.rpc_loc_ioctl_callback_data_u_type_u.predicted_orbits_data_source.servers[1],
|
||||
callback_data.data.rpc_loc_ioctl_callback_data_u_type_u.predicted_orbits_data_source.servers[2],
|
||||
255);
|
||||
|
||||
return LOC_API_ADAPTER_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, AGpsType agpsType)
|
||||
{
|
||||
|
|
|
@ -180,6 +180,12 @@ void LocApiAdapter::reportNmea(const char* nmea, int length)
|
|||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::reportXtraServer(const char* url1, const char* url2, const char* url3, const int maxlength)
|
||||
{
|
||||
loc_eng_msg_report_xtra_server *msg(new loc_eng_msg_report_xtra_server(locEngHandle.owner, url1, url2, url3, maxlength));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::requestATL(int connHandle, AGpsType agps_type)
|
||||
{
|
||||
loc_eng_msg_request_atl *msg(new loc_eng_msg_request_atl(locEngHandle.owner, connHandle, agps_type));
|
||||
|
|
|
@ -132,7 +132,8 @@ public:
|
|||
void* svExt);
|
||||
void reportStatus(GpsStatusValue status);
|
||||
void reportNmea(const char* nmea, int length);
|
||||
void reportAgpsStatus(AGpsExtStatus &agpsStatus);
|
||||
void reportXtraServer(const char* url1, const char* url2, const char* url3, const int maxlength);
|
||||
void reportAgpsStatus(AGpsStatus &agpsStatus);
|
||||
void requestXtraData();
|
||||
void requestTime();
|
||||
void requestLocation();
|
||||
|
@ -171,6 +172,9 @@ public:
|
|||
inline virtual enum loc_api_adapter_err
|
||||
setXtraData(char* data, int length)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
requestXtraServer()
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
|
|
|
@ -49,10 +49,17 @@ typedef struct {
|
|||
gps_request_utc_time request_utc_time_cb;
|
||||
} GpsExtCallbacks;
|
||||
|
||||
/** Callback to report the xtra server url to the client.
|
||||
* The client should use this url when downloading xtra unless overwritten
|
||||
* in the gps.conf file
|
||||
*/
|
||||
typedef void (* report_xtra_server)(const char*, const char*, const char*);
|
||||
|
||||
/** Callback structure for the XTRA interface. */
|
||||
typedef struct {
|
||||
gps_xtra_download_request download_request_cb;
|
||||
gps_create_thread create_thread_cb;
|
||||
report_xtra_server report_xtra_server_cb;
|
||||
} GpsXtraExtCallbacks;
|
||||
|
||||
/** Represents the status of AGPS. */
|
||||
|
|
|
@ -1610,6 +1610,14 @@ static void loc_eng_deferred_action_thread(void* arg)
|
|||
}
|
||||
break;
|
||||
|
||||
case LOC_ENG_MSG_REPORT_XTRA_SERVER:
|
||||
if (NULL != loc_eng_data_p->xtra_module_data.report_xtra_server_cb) {
|
||||
loc_eng_msg_report_xtra_server* xsMsg = (loc_eng_msg_report_xtra_server*)msg;
|
||||
CALLBACK_LOG_CALLFLOW("report_xtra_server_cb", %s, xsMsg->server1);
|
||||
loc_eng_data_p->xtra_module_data.report_xtra_server_cb(xsMsg->server1, xsMsg->server2, xsMsg->server3);
|
||||
}
|
||||
break;
|
||||
|
||||
case LOC_ENG_MSG_REQUEST_BIT:
|
||||
{
|
||||
AgpsStateMachine* stateMachine;
|
||||
|
@ -1748,6 +1756,12 @@ static void loc_eng_deferred_action_thread(void* arg)
|
|||
}
|
||||
break;
|
||||
|
||||
case LOC_ENG_MSG_REQUEST_XTRA_SERVER:
|
||||
{
|
||||
loc_eng_data_p->client_handle->requestXtraServer();
|
||||
}
|
||||
break;
|
||||
|
||||
case LOC_ENG_MSG_ATL_OPEN_SUCCESS:
|
||||
{
|
||||
loc_eng_msg_atl_open_success *aosMsg = (loc_eng_msg_atl_open_success*)msg;
|
||||
|
|
|
@ -250,6 +250,8 @@ int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,
|
|||
int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data,
|
||||
char* data, int length);
|
||||
|
||||
int loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data);
|
||||
|
||||
extern void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data,
|
||||
GpsNiExtCallbacks *callbacks);
|
||||
extern void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data,
|
||||
|
|
|
@ -445,6 +445,33 @@ struct loc_eng_msg_report_nmea : public loc_eng_msg {
|
|||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_report_xtra_server : public loc_eng_msg {
|
||||
char *server1;
|
||||
char *server2;
|
||||
char *server3;
|
||||
inline loc_eng_msg_report_xtra_server(void *instance,
|
||||
const char *url1,
|
||||
const char *url2,
|
||||
const char *url3,
|
||||
const int maxlength) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_REPORT_XTRA_SERVER),
|
||||
server1(new char[maxlength+1]), server2(new char[maxlength+1]), server3(new char[maxlength+1])
|
||||
{
|
||||
strlcpy(server1, url1, maxlength);
|
||||
strlcpy(server2, url2, maxlength);
|
||||
strlcpy(server3, url3, maxlength);
|
||||
|
||||
LOC_LOGV("maxlength: %d\n server1: %s\n server2: %s\n server3: %s\n",
|
||||
maxlength, server1, server2, server3);
|
||||
}
|
||||
inline ~loc_eng_msg_report_xtra_server()
|
||||
{
|
||||
delete[] server1;
|
||||
delete[] server2;
|
||||
delete[] server3;
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_request_bit : public loc_eng_msg {
|
||||
const loc_if_req_type_e_type ifType;
|
||||
const int ipv4Addr;
|
||||
|
@ -716,6 +743,14 @@ struct loc_eng_msg_inject_xtra_data : public loc_eng_msg {
|
|||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_request_xtra_server : public loc_eng_msg {
|
||||
inline loc_eng_msg_request_xtra_server(void *instance) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_XTRA_SERVER)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_atl_open_success : public loc_eng_msg {
|
||||
const AGpsStatusValue agpsType;
|
||||
const int length;
|
||||
|
|
|
@ -51,6 +51,7 @@ enum loc_eng_msg_ids_t {
|
|||
LOC_ENG_MSG_SET_POSITION_MODE,
|
||||
LOC_ENG_MSG_SET_TIME,
|
||||
LOC_ENG_MSG_INJECT_XTRA_DATA,
|
||||
LOC_ENG_MSG_REQUEST_XTRA_SERVER,
|
||||
LOC_ENG_MSG_INJECT_LOCATION,
|
||||
LOC_ENG_MSG_DELETE_AIDING_DATA,
|
||||
LOC_ENG_MSG_SET_APN,
|
||||
|
@ -72,6 +73,7 @@ enum loc_eng_msg_ids_t {
|
|||
LOC_ENG_MSG_REPORT_SV,
|
||||
LOC_ENG_MSG_REPORT_STATUS,
|
||||
LOC_ENG_MSG_REPORT_NMEA,
|
||||
LOC_ENG_MSG_REPORT_XTRA_SERVER,
|
||||
LOC_ENG_MSG_REQUEST_BIT,
|
||||
LOC_ENG_MSG_RELEASE_BIT,
|
||||
LOC_ENG_MSG_REQUEST_ATL,
|
||||
|
|
|
@ -62,6 +62,8 @@ int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,
|
|||
else {
|
||||
xtra_module_data_ptr = &loc_eng_data.xtra_module_data;
|
||||
xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb;
|
||||
xtra_module_data_ptr->report_xtra_server_cb = callbacks->report_xtra_server_cb;
|
||||
|
||||
ret_val = 0;
|
||||
}
|
||||
return ret_val;
|
||||
|
@ -93,3 +95,31 @@ int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data,
|
|||
|
||||
return 0;
|
||||
}
|
||||
/*===========================================================================
|
||||
FUNCTION loc_eng_xtra_request_server
|
||||
|
||||
DESCRIPTION
|
||||
Request the Xtra server url from the modem
|
||||
|
||||
DEPENDENCIES
|
||||
N/A
|
||||
|
||||
RETURN VALUE
|
||||
length of server string
|
||||
|
||||
SIDE EFFECTS
|
||||
N/A
|
||||
|
||||
===========================================================================*/
|
||||
int loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data)
|
||||
{
|
||||
loc_eng_msg_request_xtra_server *msg(new loc_eng_msg_request_xtra_server(&loc_eng_data));
|
||||
|
||||
if (NULL == msg)
|
||||
return -1;
|
||||
|
||||
loc_eng_msg_sender(&loc_eng_data, msg);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ typedef struct
|
|||
{
|
||||
// loc_eng_ioctl_cb_data_s_type ioctl_cb_data;
|
||||
gps_xtra_download_request download_request_cb;
|
||||
report_xtra_server report_xtra_server_cb;
|
||||
|
||||
// XTRA data buffer
|
||||
char *xtra_data_for_injection; // NULL if no pending data
|
||||
|
|
|
@ -1022,6 +1022,54 @@ enum loc_api_adapter_err LocApiV02Adapter :: setXtraData(
|
|||
return LOC_API_ADAPTER_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
/* Request the Xtra Server Url from the modem */
|
||||
enum loc_api_adapter_err LocApiV02Adapter :: requestXtraServer()
|
||||
{
|
||||
locClientStatusEnumType status = eLOC_CLIENT_SUCCESS;
|
||||
|
||||
locClientReqUnionType req_union;
|
||||
qmiLocGetPredictedOrbitsDataSourceIndMsgT_v02 request_xtra_server_ind;
|
||||
|
||||
status = loc_sync_send_req( clientHandle,
|
||||
QMI_LOC_GET_PREDICTED_ORBITS_DATA_SOURCE_REQ_V02,
|
||||
req_union, LOC_ENGINE_SYNC_REQUEST_TIMEOUT,
|
||||
QMI_LOC_GET_PREDICTED_ORBITS_DATA_SOURCE_IND_V02,
|
||||
&request_xtra_server_ind);
|
||||
|
||||
if (status != eLOC_CLIENT_SUCCESS ||
|
||||
eQMI_LOC_SUCCESS_V02 != request_xtra_server_ind.status ||
|
||||
false == request_xtra_server_ind.serverList_valid ||
|
||||
0 == request_xtra_server_ind.serverList.serverList_len)
|
||||
{
|
||||
return LOC_API_ADAPTER_ERR_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
if (request_xtra_server_ind.serverList.serverList_len == 1)
|
||||
{
|
||||
LocApiAdapter::reportXtraServer(request_xtra_server_ind.serverList.serverList[0].serverUrl,
|
||||
"",
|
||||
"",
|
||||
QMI_LOC_MAX_SERVER_ADDR_LENGTH_V02);
|
||||
}
|
||||
else if (request_xtra_server_ind.serverList.serverList_len == 2)
|
||||
{
|
||||
LocApiAdapter::reportXtraServer(request_xtra_server_ind.serverList.serverList[0].serverUrl,
|
||||
request_xtra_server_ind.serverList.serverList[1].serverUrl,
|
||||
"",
|
||||
QMI_LOC_MAX_SERVER_ADDR_LENGTH_V02);
|
||||
}
|
||||
else
|
||||
{
|
||||
LocApiAdapter::reportXtraServer(request_xtra_server_ind.serverList.serverList[0].serverUrl,
|
||||
request_xtra_server_ind.serverList.serverList[1].serverUrl,
|
||||
request_xtra_server_ind.serverList.serverList[2].serverUrl,
|
||||
QMI_LOC_MAX_SERVER_ADDR_LENGTH_V02);
|
||||
}
|
||||
|
||||
return LOC_API_ADAPTER_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
enum loc_api_adapter_err LocApiV02Adapter :: atlOpenStatus(
|
||||
int handle, int is_succ, char* apn, AGpsBearerType bear,
|
||||
AGpsType agpsType)
|
||||
|
|
|
@ -138,6 +138,8 @@ public:
|
|||
setServer(unsigned int ip, int port, LocServerType type);
|
||||
virtual enum loc_api_adapter_err
|
||||
setXtraData(char* data, int length);
|
||||
virtual enum loc_api_adapter_err
|
||||
requestXtraServer();
|
||||
virtual enum loc_api_adapter_err
|
||||
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear,
|
||||
AGpsType agpsType);
|
||||
|
|
Loading…
Reference in a new issue