1f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *
3f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * Redistribution and use in source and binary forms, with or without
4f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * modification, are permitted provided that the following conditions are
5f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * met:
6f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *     * Redistributions of source code must retain the above copyright
7f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *       notice, this list of conditions and the following disclaimer.
8f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *     * Redistributions in binary form must reproduce the above
9f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *       copyright notice, this list of conditions and the following
10f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *       disclaimer in the documentation and/or other materials provided
11f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *       with the distribution.
12f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *     * Neither the name of Code Aurora Forum, Inc. nor the names of its
13f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *       contributors may be used to endorse or promote products derived
14f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *       from this software without specific prior written permission.
15f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *
16f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani */
28f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
29f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include "qmi_client.h"
30f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include "qmi_idl_lib.h"
31f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include "qmi_cci_target_ext.h"
32f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
33f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#if defined( _ANDROID_)
34f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include "qmi_cci_target.h"
35f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include "qmi_cci_common.h"
36f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#elif defined(LOC_UTIL_TARGET_OFF_TARGET)
37f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include <stdlib.h>
38f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include <sys/time.h>
39f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include <errno.h>
40f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#endif //_ANDROID_
41f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
42f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include <string.h>
43f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include <stdint.h>
44f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include <stdio.h>
45f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include <stdbool.h>
46f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include <stddef.h>
47f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include "loc_api_v02_client.h"
48f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include "loc_api_v02_log.h"
49f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
50f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#define LOG_NDEBUG 0
51f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#define LOG_TAG "LocSvc_api_v02"
52f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
53f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include "loc_util_log.h"
54f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
55f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#ifdef LOC_UTIL_TARGET_OFF_TARGET
56f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
57f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani// timeout in ms before send_msg_sync should return
58f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#define LOC_CLIENT_ACK_TIMEOUT (5000)
59f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
60f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani// timeout in ms before a sync request should return
61f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#define LOC_CLIENT_SYNC_REQ_TIMEOUT (5000)
62f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
63f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#else
64f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
65f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani// timeout in ms before send_msg_sync should return
66f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#define LOC_CLIENT_ACK_TIMEOUT (1000)
67f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
68f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani// timeout in ms before a sync request should return
69f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#define LOC_CLIENT_SYNC_REQ_TIMEOUT (1000)
70f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
71f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#endif //LOC_UTIL_TARGET_OFF_TARGET
72f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
73f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani//timeout in ms to wait for the service to come up
749365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin#define LOC_CLIENT_SERVICE_TIMEOUT_UNIT  (4000)
759365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin#define LOC_CLIENT_SERVICE_TIMEOUT_TOTAL  (60000)
76f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
77f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/* Table to relate eventId, size and mask value used to enable the event*/
78f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanitypedef struct
79f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
80f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  uint32_t               eventId;
81f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  size_t                 eventSize;
82f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientEventMaskType eventMask;
83f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}locClientEventIndTableStructT;
84f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
85f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
86f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic locClientEventIndTableStructT locClientEventIndTable[]= {
87f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
88f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // position report ind
89f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_POSITION_REPORT_IND_V02,
90f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventPositionReportIndMsgT_v02),
91f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_POSITION_REPORT_V02 },
92f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
93f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // satellite report ind
94f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_GNSS_SV_INFO_IND_V02,
95f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventGnssSvInfoIndMsgT_v02),
96f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_GNSS_SV_INFO_V02 },
97f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
98f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // NMEA report ind
99f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_NMEA_IND_V02,
100f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventNmeaIndMsgT_v02),
101f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_NMEA_V02 },
102f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
103f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //NI event ind
104f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_NI_NOTIFY_VERIFY_REQ_IND_V02,
105f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventNiNotifyVerifyReqIndMsgT_v02),
106f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_NI_NOTIFY_VERIFY_REQ_V02 },
107f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
108f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //Time Injection Request Ind
109f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_INJECT_TIME_REQ_IND_V02,
110f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventInjectTimeReqIndMsgT_v02),
111f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_INJECT_TIME_REQ_V02 },
112f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
113f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //Predicted Orbits Injection Request
114f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_INJECT_PREDICTED_ORBITS_REQ_IND_V02,
115f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventInjectPredictedOrbitsReqIndMsgT_v02),
116f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_INJECT_PREDICTED_ORBITS_REQ_V02 },
117f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
118f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //Position Injection Request Ind
119f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_INJECT_POSITION_REQ_IND_V02,
120f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventInjectPositionReqIndMsgT_v02),
121f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_INJECT_POSITION_REQ_V02 } ,
122f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
123f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //Engine State Report Ind
124f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_ENGINE_STATE_IND_V02,
125f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventEngineStateIndMsgT_v02),
126f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_ENGINE_STATE_V02 },
127f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
128f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //Fix Session State Report Ind
129f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_FIX_SESSION_STATE_IND_V02,
130f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventFixSessionStateIndMsgT_v02),
131f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_FIX_SESSION_STATE_V02 },
132f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
133f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //Wifi Request Indication
134f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_WIFI_REQ_IND_V02,
135f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventWifiReqIndMsgT_v02),
136f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_WIFI_REQ_V02 },
137f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
138f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //Sensor Streaming Ready Status Ind
139f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_SENSOR_STREAMING_READY_STATUS_IND_V02,
140f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventSensorStreamingReadyStatusIndMsgT_v02),
141f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_SENSOR_STREAMING_READY_STATUS_V02 },
142f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
143f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // Time Sync Request Indication
144f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_TIME_SYNC_REQ_IND_V02,
145f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventTimeSyncReqIndMsgT_v02),
146f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_TIME_SYNC_REQ_V02 },
147f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
148f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //Set Spi Streaming Report Event
149f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_SET_SPI_STREAMING_REPORT_IND_V02,
150f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventSetSpiStreamingReportIndMsgT_v02),
151f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_SET_SPI_STREAMING_REPORT_V02 },
152f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
153f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //Location Server Connection Request event
154f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_EVENT_LOCATION_SERVER_CONNECTION_REQ_IND_V02,
155f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocEventLocationServerConnectionReqIndMsgT_v02),
156f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    QMI_LOC_EVENT_MASK_LOCATION_SERVER_CONNECTION_REQ_V02 }
157f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani};
158f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
159f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/* table to relate the respInd Id with its size */
160f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanitypedef struct
161f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
162f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  uint32_t respIndId;
163f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  size_t   respIndSize;
164f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}locClientRespIndTableStructT;
165f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
166f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic locClientRespIndTableStructT locClientRespIndTable[]= {
167f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
168f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // get service revision ind
169f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_GET_SERVICE_REVISION_IND_V02,
170f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocGetServiceRevisionIndMsgT_v02)},
171f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
172f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // Get Fix Criteria Resp Ind
173f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_GET_FIX_CRITERIA_IND_V02,
174f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetFixCriteriaIndMsgT_v02)},
175f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
176f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // NI User Resp In
177f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_NI_USER_RESPONSE_IND_V02,
178f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocNiUserRespIndMsgT_v02)},
179f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
180f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //Inject Predicted Orbits Data Resp Ind
181f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_INJECT_PREDICTED_ORBITS_DATA_IND_V02,
182f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocInjectPredictedOrbitsDataIndMsgT_v02)},
183f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
184f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //Get Predicted Orbits Data Src Resp Ind
185f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  { QMI_LOC_GET_PREDICTED_ORBITS_DATA_SOURCE_IND_V02,
186f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    sizeof(qmiLocGetPredictedOrbitsDataSourceIndMsgT_v02)},
187f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
188f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // Get Predicted Orbits Data Validity Resp Ind
189f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_PREDICTED_ORBITS_DATA_VALIDITY_IND_V02,
190f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetPredictedOrbitsDataValidityIndMsgT_v02)},
191f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
192f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   // Inject UTC Time Resp Ind
193f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_INJECT_UTC_TIME_IND_V02,
194f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocInjectUtcTimeIndMsgT_v02)},
195f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
196f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Inject Position Resp Ind
197f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_INJECT_POSITION_IND_V02,
198f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocInjectPositionIndMsgT_v02)},
199f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
200f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set Engine Lock Resp Ind
201f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_ENGINE_LOCK_IND_V02,
202f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetEngineLockIndMsgT_v02)},
203f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
204f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get Engine Lock Resp Ind
205f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_ENGINE_LOCK_IND_V02,
206f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetEngineLockIndMsgT_v02)},
207f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
208f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set SBAS Config Resp Ind
209f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_SBAS_CONFIG_IND_V02,
210f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetSbasConfigIndMsgT_v02)},
211f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
212f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get SBAS Config Resp Ind
213f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_SBAS_CONFIG_IND_V02,
214f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetSbasConfigIndMsgT_v02)},
215f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
216f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set NMEA Types Resp Ind
217f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_NMEA_TYPES_IND_V02,
218f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetNmeaTypesIndMsgT_v02)},
219f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
220f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get NMEA Types Resp Ind
221f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_NMEA_TYPES_IND_V02,
222f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetNmeaTypesIndMsgT_v02)},
223f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
224f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set Low Power Mode Resp Ind
225f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_LOW_POWER_MODE_IND_V02,
226f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetLowPowerModeIndMsgT_v02)},
227f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
228f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get Low Power Mode Resp Ind
229f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_LOW_POWER_MODE_IND_V02,
230f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetLowPowerModeIndMsgT_v02)},
231f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
232f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set Server Resp Ind
233f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_SERVER_IND_V02,
234f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetServerIndMsgT_v02)},
235f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
236f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get Server Resp Ind
237f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_SERVER_IND_V02,
238f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetServerIndMsgT_v02)},
239f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
240f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    //Delete Assist Data Resp Ind
241f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_DELETE_ASSIST_DATA_IND_V02,
242f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocDeleteAssistDataIndMsgT_v02)},
243f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
244f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set XTRA-T Session Control Resp Ind
245f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_XTRA_T_SESSION_CONTROL_IND_V02,
246f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetXtraTSessionControlIndMsgT_v02)},
247f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
248f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get XTRA-T Session Control Resp Ind
249f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_XTRA_T_SESSION_CONTROL_IND_V02,
250f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetXtraTSessionControlIndMsgT_v02)},
251f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
252f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Inject Wifi Position Resp Ind
253f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_INJECT_WIFI_POSITION_IND_V02,
254f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocInjectWifiPositionIndMsgT_v02)},
255f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
256f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Notify Wifi Status Resp Ind
257f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_NOTIFY_WIFI_STATUS_IND_V02,
258f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocNotifyWifiStatusIndMsgT_v02)},
259f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
260f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get Registered Events Resp Ind
261f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_REGISTERED_EVENTS_IND_V02,
262f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetRegisteredEventsIndMsgT_v02)},
263f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
264f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set Operation Mode Resp Ind
265f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_OPERATION_MODE_IND_V02,
266f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetOperationModeIndMsgT_v02)},
267f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
268f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get Operation Mode Resp Ind
269f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_OPERATION_MODE_IND_V02,
270f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetOperationModeIndMsgT_v02)},
271f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
272f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set SPI Status Resp Ind
273f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_SPI_STATUS_IND_V02,
274f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetSpiStatusIndMsgT_v02)},
275f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
276f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Inject Sensor Data Resp Ind
277f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_INJECT_SENSOR_DATA_IND_V02,
278f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocInjectSensorDataIndMsgT_v02)},
279f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
280f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Inject Time Sync Data Resp Ind
281f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_INJECT_TIME_SYNC_DATA_IND_V02,
282f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocInjectTimeSyncDataIndMsgT_v02)},
283f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
284f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set Cradle Mount config Resp Ind
285f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_CRADLE_MOUNT_CONFIG_IND_V02,
286f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetCradleMountConfigIndMsgT_v02)},
287f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
288f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get Cradle Mount config Resp Ind
289f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_CRADLE_MOUNT_CONFIG_IND_V02,
290f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetCradleMountConfigIndMsgT_v02)},
291f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
292f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set External Power config Resp Ind
293f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_EXTERNAL_POWER_CONFIG_IND_V02,
294f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetExternalPowerConfigIndMsgT_v02)},
295f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
296f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get External Power config Resp Ind
297f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_EXTERNAL_POWER_CONFIG_IND_V02,
298f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetExternalPowerConfigIndMsgT_v02)},
299f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
300f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Location server connection status
301f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_INFORM_LOCATION_SERVER_CONN_STATUS_IND_V02,
302f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocInformLocationServerConnStatusIndMsgT_v02)},
303f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
304f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set Protocol Config Parameters
305f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_PROTOCOL_CONFIG_PARAMETERS_IND_V02,
306f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetProtocolConfigParametersIndMsgT_v02)},
307f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
308f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get Protocol Config Parameters
309f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_PROTOCOL_CONFIG_PARAMETERS_IND_V02,
310f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetProtocolConfigParametersIndMsgT_v02)},
311f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
312f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set Sensor Control Config
313f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_SENSOR_CONTROL_CONFIG_IND_V02,
314f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetSensorControlConfigIndMsgT_v02)},
315f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
316f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get Sensor Control Config
317f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_SENSOR_CONTROL_CONFIG_IND_V02,
318f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetSensorControlConfigIndMsgT_v02)},
319f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
320f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set Sensor Properties
321f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_SENSOR_PROPERTIES_IND_V02,
322f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetSensorPropertiesIndMsgT_v02)},
323f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
324f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get Sensor Properties
325f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_SENSOR_PROPERTIES_IND_V02,
326f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetSensorPropertiesIndMsgT_v02)},
327f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
328f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Set Sensor Performance Control Config
329f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_SENSOR_PERFORMANCE_CONTROL_CONFIGURATION_IND_V02,
330f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetSensorPerformanceControlConfigIndMsgT_v02)},
331f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
332f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Get Sensor Performance Control Config
333f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_SENSOR_PERFORMANCE_CONTROL_CONFIGURATION_IND_V02,
334f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetSensorPerformanceControlConfigIndMsgT_v02)},
335f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Inject SUPL certificate
336f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_INJECT_SUPL_CERTIFICATE_IND_V02,
337f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocInjectSuplCertificateIndMsgT_v02) },
338f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
339f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   //Delete SUPL certificate
340f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_DELETE_SUPL_CERTIFICATE_IND_V02,
341f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocDeleteSuplCertificateIndMsgT_v02) },
342f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
343f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   // Set Position Engine Config
344f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_SET_POSITION_ENGINE_CONFIG_PARAMETERS_IND_V02,
345f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocSetPositionEngineConfigParametersIndMsgT_v02)},
346f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
347f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   // Get Position Engine Config
348f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   { QMI_LOC_GET_POSITION_ENGINE_CONFIG_PARAMETERS_IND_V02,
349f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     sizeof(qmiLocGetPositionEngineConfigParametersIndMsgT_v02)}
350f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
351f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani};
352f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
353f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
354f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** whether indication is an event or a response */
355f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanitypedef enum { eventIndType =0, respIndType = 1 } locClientIndEnumT;
356f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
357f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
358f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** @struct locClientInternalState
359f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani */
360f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
361f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanitypedef struct
362f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
363f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani // client cookie
364f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  void *pClientCookie;
365f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //QCCI handle for this control point
366f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmi_client_type userHandle;
367f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
368f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // callbacks registered by the clients
369f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientEventIndCbType eventCallback;
370f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientRespIndCbType respCallback;
371f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientErrorCbType   errorCallback;
372f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
373f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // the event mask the client has registered for
374f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientEventMaskType eventRegMask;
375f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
376f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}locClientCallbackDataType;
377f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
378f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/*===========================================================================
379f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *
380f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *                          FUNCTION DECLARATION
381f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *
382f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *==========================================================================*/
383f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
384f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientGetSizeAndTypeByIndId
385f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @brief this function gets the size and the type (event,
386f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *         response)of the indication structure from its ID
387f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in]  indId  ID of the indication
388f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [out] type   event or response indication
389f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [out] size   size of the indications
390f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *
391f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @return true if the ID was found, false otherwise */
392f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
393f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic bool locClientGetSizeAndTypeByIndId (uint32_t indId, size_t *pIndSize,
394f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                                         locClientIndEnumT *pIndType)
395f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
396f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // look in the event table
397f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if(true == locClientGetSizeByEventIndId(indId, pIndSize))
398f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
399f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    *pIndType = eventIndType;
400f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
401f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGV("%s:%d]: indId %d is an event size = %d\n", __func__, __LINE__,
402f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                  indId, (uint32_t)*pIndSize);
403f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    return true;
404f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
405f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
406f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //else look in response table
407f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if(true == locClientGetSizeByRespIndId(indId, pIndSize))
408f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
409f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    *pIndType = respIndType;
410f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
411f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGV("%s:%d]: indId %d is a resp size = %d\n", __func__, __LINE__,
412f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                  indId, (uint32_t)*pIndSize);
413f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    return true;
414f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
415f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
416f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // Id not found
417f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGW("%s:%d]: indId %d not found\n", __func__, __LINE__, indId);
418f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return false;
419f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
420f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
421f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** isClientRegisteredForEvent
422f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*  @brief checks the mask to identify if the client has
423f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*         registered for the specified event Id
424f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*  @param [in] eventIndId
425f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*  @param [in] eventRegMask
426f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*  @return true if client regstered for event; else false */
427f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
428f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic bool isClientRegisteredForEvent(
429f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    locClientEventMaskType eventRegMask,
430f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    uint32_t eventIndId)
431f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
432f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  size_t idx = 0, eventIndTableSize = 0;
433f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
434f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // look in the event table
435f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  eventIndTableSize =
436f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    (sizeof(locClientEventIndTable)/sizeof(locClientEventIndTableStructT));
437f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
438f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  for(idx=0; idx<eventIndTableSize; idx++ )
439f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
440f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    if(eventIndId == locClientEventIndTable[idx].eventId)
441f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
442f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      LOC_LOGV("%s:%d]: eventId %d registered mask = %llu, "
443f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                    "eventMask = %llu\n", __func__, __LINE__,
444f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                     eventIndId, eventRegMask,
445f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                     locClientEventIndTable[idx].eventMask);
446f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
447f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      return((
448f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          eventRegMask & locClientEventIndTable[idx].eventMask)?
449f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          true:false);
450f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
451f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
452f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGW("%s:%d]: eventId %d not found\n", __func__, __LINE__,
453f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                 eventIndId);
454f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return false;
455f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
456f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
457f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** convertQmiResponseToLocStatus
458f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani @brief converts a qmiLocGenRespMsgT to locClientStatusEnumType*
459f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani @param [in] pResponse; pointer to the response received from
460f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        QMI_LOC service.
461f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani @return locClientStatusEnumType corresponding to the
462f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani         response.
463f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*/
464f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
465f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic locClientStatusEnumType convertQmiResponseToLocStatus(
466f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmiLocGenRespMsgT_v02 *pResponse)
467f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
468f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientStatusEnumType status =  eLOC_CLIENT_FAILURE_INTERNAL;
469f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
470f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // if result == SUCCESS don't look at error code
471f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if(pResponse->resp.result == QMI_RESULT_SUCCESS )
472f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
473f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    status  = eLOC_CLIENT_SUCCESS;
474f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
475f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  else
476f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
477f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    switch(pResponse->resp.error)
478f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
479f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      case QMI_ERR_MALFORMED_MSG_V01:
480f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        status = eLOC_CLIENT_FAILURE_INVALID_PARAMETER;
481f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        break;
482f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
483f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      case QMI_ERR_DEVICE_IN_USE_V01:
484f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        status = eLOC_CLIENT_FAILURE_ENGINE_BUSY;
485f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        break;
486f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
487f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      default:
488f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        status = eLOC_CLIENT_FAILURE_INTERNAL;
489f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        break;
490f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
491f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
492f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV("%s:%d]: result = %d, error = %d, status = %d\n",
493f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                __func__, __LINE__, pResponse->resp.result,
494f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                pResponse->resp.error, status);
495f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return status;
496f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
497f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
498f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** convertQmiErrorToLocError
499f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani @brief converts a qmi service error type to
500f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        locClientErrorEnumType
501f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani @param [in] error received QMI service.
502f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani @return locClientErrorEnumType corresponding to the error.
503f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*/
504f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
505f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic locClientErrorEnumType convertQmiErrorToLocError(
506f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmi_client_error_type error)
507f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
508f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientErrorEnumType locError ;
509f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  switch(error)
510f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
511f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_SERVICE_ERR:
512f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      locError = eLOC_CLIENT_ERROR_SERVICE_UNAVAILABLE;
513f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
514f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
515f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    default:
516f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      locError = eLOC_CLIENT_ERROR_SERVICE_UNAVAILABLE;
517f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
518f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
519f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV("%s:%d]: qmi error = %d, loc error = %d\n",
520f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                __func__, __LINE__, error, locError);
521f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return locError;
522f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
523f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
524f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClienHandlePosReportInd
525f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @brief Validates a position report ind
526f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] msg_id
527f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] ind_buf
528f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] ind_buf_len
529f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @return true if pos report is valid, false otherwise
530f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*/
531f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic bool locClientHandlePosReportInd
532f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani(
533f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani uint32_t        msg_id,
534f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani const void*     ind_buf,
535f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani uint32_t        ind_buf_len
536f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani)
537f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
538f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // validate position report
539f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmiLocEventPositionReportIndMsgT_v02 *posReport =
540f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    (qmiLocEventPositionReportIndMsgT_v02 *)ind_buf;
541f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
542f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV ("%s:%d]: len = %d lat = %f, lon = %f, alt = %f\n",
543f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                 __func__, __LINE__, ind_buf_len,
544f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                 posReport->latitude, posReport->longitude,
545f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                 posReport->altitudeWrtEllipsoid);
546f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
547f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return true;
548f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
549f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani//-----------------------------------------------------------------------------
550f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
551f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientHandleSatReportInd
552f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @brief Validates a satellite report indication. Dk
553f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] msg_id
554f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] ind_buf
555f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] ind_buf_len
556f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @return true if sat report is valid, false otherwise
557f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*/
558f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic bool locClientHandleSatReportInd
559f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani(
560f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani uint32_t        msg_id,
561f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani const void*     ind_buf,
562f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani uint32_t        ind_buf_len
563f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani)
564f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
565f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // validate sat reports
566f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  unsigned int idx = 0;
567f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmiLocEventGnssSvInfoIndMsgT_v02 *satReport =
568f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    (qmiLocEventGnssSvInfoIndMsgT_v02 *)ind_buf;
569f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
570f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV ("%s:%d]: len = %u , altitude assumed = %u, num SV's = %u"
571f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                 " validity = %d \n ", __func__, __LINE__,
572f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                 ind_buf_len, satReport->altitudeAssumed,
573f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                 satReport->svList_len, satReport->svList_valid);
574f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //Log SV report
575f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  for( idx = 0; idx <satReport->svList_len; idx++ )
576f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
577f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGV("%s:%d]: valid_mask = %x, prn = %u, system = %d, "
578f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                  "status = %d \n", __func__, __LINE__,
579f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                  satReport->svList[idx].validMask, satReport->svList[idx].gnssSvId,
580f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                  satReport->svList[idx].system, satReport->svList[idx].svStatus);
581f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
582f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
583f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   return true;
584f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
585f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
586f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
587f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientHandleNmeaReportInd
588f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @brief Validate a NMEA report indication.
589f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] msg_id
590f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] ind_buf
591f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] ind_buf_len
592f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @return true if nmea report is valid, false otherwise
593f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*/
594f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
595f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
596f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic bool locClientHandleNmeaReportInd
597f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani(
598f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani uint32_t        msg_id,
599f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani const void*     ind_buf,
600f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani uint32_t        ind_buf_len
601f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani)
602f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
603f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani // validate NMEA report
604f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return true;
605f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
606f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
607f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientHandleGetServiceRevisionRespInd
608f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @brief Handles a Get Service Revision Rresponse indication.
609f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] msg_id
610f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] ind_buf
611f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] ind_buf_len
612f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @return true if service revision is valid, false otherwise
613f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*/
614f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
615f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic bool locClientHandleGetServiceRevisionRespInd
616f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani(
617f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani uint32_t        msg_id,
618f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani const void*     ind_buf,
619f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani uint32_t        ind_buf_len
620f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani)
621f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
622f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV("%s:%d] :\n", __func__, __LINE__);
623f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return true;
624f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
625f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
626f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientHandleIndication
627f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @brief looks at each indication and calls the appropriate
628f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *         validation handler
629f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] indId
630f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] indBuffer
631f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] indSize
632f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @return true if indication was validated; else false */
633f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
634f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic bool locClientHandleIndication(
635f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  uint32_t        indId,
636f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  void*           indBuffer,
637f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  size_t          indSize
638f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani )
639f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
640f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  bool status = false;
641f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  switch(indId)
642f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
643f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle the event indications
644f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    //-------------------------------------------------------------------------
645f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
646f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle position report
647f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_POSITION_REPORT_IND_V02:
648f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
649f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = locClientHandlePosReportInd(indId, indBuffer, indSize);
650f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
651f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
652f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle satellite report
653f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_GNSS_SV_INFO_IND_V02:
654f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
655f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = locClientHandleSatReportInd(indId, indBuffer, indSize);
656f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
657f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
658f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
659f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle NMEA report
660f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_NMEA_IND_V02:
661f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
662f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = locClientHandleNmeaReportInd(indId, indBuffer, indSize);
663f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
664f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
665f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
666f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle NI Notify Verify Request Ind
667f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_NI_NOTIFY_VERIFY_REQ_IND_V02:
668f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
669f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     // locClientHandleNiReqInd(user_handle, msg_id, ind_buf, ind_buf_len);
670f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
671f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
672f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
673f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
674f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle Time Inject request Ind
675f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_INJECT_TIME_REQ_IND_V02:
676f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
677f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     // locClientHandleTimeInjectReqInd(user_handle, msg_id, ind_buf, ind_buf_len);
678f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
679f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
680f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
681f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
682f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle XTRA data Inject request Ind
683f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_INJECT_PREDICTED_ORBITS_REQ_IND_V02:
684f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
685f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     // locClientHandleXtraInjectReqInd(user_handle, msg_id, ind_buf, ind_buf_len);
686f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
687f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
688f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
689f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
690f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle position inject request Ind
691f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_INJECT_POSITION_REQ_IND_V02:
692f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
693f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     // locClientHandlePositionInjectReqInd(user_handle, msg_id, ind_buf, ind_buf_len);
694f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
695f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
696f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
697f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
698f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle engine state Ind
699f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_ENGINE_STATE_IND_V02:
700f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
701f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     // locClientHandleEngineStateInd(user_handle, msg_id, ind_buf, ind_buf_len);
702f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
703f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
704f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
705f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
706f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle fix session state Ind
707f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_FIX_SESSION_STATE_IND_V02:
708f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
709f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     // locClientHandleFixSessionStateInd(user_handle, msg_id, ind_buf, ind_buf_len);
710f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
711f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
712f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
713f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
714f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle Wifi request Ind
715f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_WIFI_REQ_IND_V02:
716f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
717f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     // locClientHandleWifiReqInd(user_handle, msg_id, ind_buf, ind_buf_len);
718f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
719f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
720f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
721f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
722f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle sensor streaming ready status Ind
723f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_SENSOR_STREAMING_READY_STATUS_IND_V02:
724f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
725f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     // locClientHandleSensorStreamingReadyInd(user_handle, msg_id, ind_buf, ind_buf_len);
726f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
727f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
728f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
729f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
730f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle time sync  Ind
731f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_TIME_SYNC_REQ_IND_V02:
732f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
733f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     // locClientHandleTimeSyncReqInd(user_handle, msg_id, ind_buf, ind_buf_len);
734f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
735f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
736f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
737f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
738f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle set streaming report ind
739f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_SET_SPI_STREAMING_REPORT_IND_V02:
740f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
741f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     // locClientHandleSetSpiStreamingInd(user_handle, msg_id, ind_buf, ind_buf_len);
742f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
743f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
744f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
745f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
746f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_EVENT_LOCATION_SERVER_CONNECTION_REQ_IND_V02:
747f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
748f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      //locClientHandleLocServerConnReqInd(user_handle, msg_id, ind_buf, ind_buf_len);
749f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
750f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
751f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
752f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
753f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    //-------------------------------------------------------------------------
754f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
755f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // handle the response indications
756f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    //-------------------------------------------------------------------------
757f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
758f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // Get service Revision response indication
759f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_SERVICE_REVISION_IND_V02:
760f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
761f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = locClientHandleGetServiceRevisionRespInd(indId,
762f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                                                        indBuffer, indSize);
763f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
764f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
765f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // predicted orbits data response indication
766f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_PREDICTED_ORBITS_DATA_IND_V02:
767f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
768f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      //locClientHandleInjectPredictedOrbitsDataInd(user_handle, msg_id, ind_buf, ind_buf_len);
769f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
770f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
771f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
772f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
773f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_SENSOR_DATA_IND_V02 :
774f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
775f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      //locClientHandleInjectSensorDataInd(user_handle, msg_id, ind_buf, ind_buf_len);
776f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
777f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
778f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
779f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
780f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_PROTOCOL_CONFIG_PARAMETERS_IND_V02:
781f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
782f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      //locClientHandleGetProtocolConfigParametersInd(user_handle, msg_id, ind_buf, ind_buf_len);
783f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
784f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
785f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
786f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
787f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_PROTOCOL_CONFIG_PARAMETERS_IND_V02:
788f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
789f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      //locClientHandleSetProtocolConfigParametersInd(user_handle, msg_id, ind_buf, ind_buf_len);
790f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
791f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
792f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
793f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
794f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_EXTERNAL_POWER_CONFIG_IND_V02:
795f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
796f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      //locClientHandleGetExtPowerConfigInd(user_handle, msg_id, ind_buf, ind_buf_len);
797f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
798f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
799f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
800f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
801f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_CRADLE_MOUNT_CONFIG_IND_V02:
802f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
803f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      //locClientHandleGetCradleMountConfigInd(user_handle, msg_id, ind_buf, ind_buf_len);
804f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
805f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
806f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
807f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
808f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_SENSOR_CONTROL_CONFIG_IND_V02:
809f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
810f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      //locClientHandleGetSensorControlConfigInd(user_handle, msg_id, ind_buf, ind_buf_len);
811f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
812f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
813f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
814f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
815f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_SENSOR_PERFORMANCE_CONTROL_CONFIGURATION_IND_V02:
816f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
817f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      //locClientHandleGetSensorPerformanceControlConfigInd(user_handle, msg_id, ind_buf, ind_buf_len);
818f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
819f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
820f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
821f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
822f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_SENSOR_PROPERTIES_IND_V02:
823f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
824f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      //locClientHandleGetSensorPropertiesInd(user_handle, msg_id, ind_buf, ind_buf_len);
825f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
826f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
827f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
828f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
829f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_SENSOR_PERFORMANCE_CONTROL_CONFIGURATION_IND_V02:
830f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
831f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      //locClientHandleSetSensorPerformanceControlConfigInd(user_handle, msg_id, ind_buf, ind_buf_len);
832f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
833f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
834f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
835f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
836f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_POSITION_ENGINE_CONFIG_PARAMETERS_IND_V02:
837f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
838f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // locClientHandleSetPositionEngineConfigParam(
839f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    //     user_handle, msg_id, ind_buf, ind_buf_len);
840f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
841f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
842f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
843f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
844f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_POSITION_ENGINE_CONFIG_PARAMETERS_IND_V02:
845f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
846f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      // locClientHandleSetPositionEngineConfigParam(
847f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      //     user_handle, msg_id, ind_buf, ind_buf_len);
848f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
849f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
850f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
851f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // for indications that only have a "status" field
852f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_NI_USER_RESPONSE_IND_V02:
853f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_UTC_TIME_IND_V02:
854f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_POSITION_IND_V02:
855f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_ENGINE_LOCK_IND_V02:
856f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_SBAS_CONFIG_IND_V02:
857f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_NMEA_TYPES_IND_V02:
858f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_LOW_POWER_MODE_IND_V02:
859f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_SERVER_IND_V02:
860f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_DELETE_ASSIST_DATA_IND_V02:
861f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_XTRA_T_SESSION_CONTROL_IND_V02:
862f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_WIFI_POSITION_IND_V02:
863f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_NOTIFY_WIFI_STATUS_IND_V02:
864f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_OPERATION_MODE_IND_V02:
865f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_SPI_STATUS_IND_V02:
866f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_TIME_SYNC_DATA_IND_V02:
867f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_CRADLE_MOUNT_CONFIG_IND_V02:
868f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_EXTERNAL_POWER_CONFIG_IND_V02:
869f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INFORM_LOCATION_SERVER_CONN_STATUS_IND_V02:
870f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_SENSOR_CONTROL_CONFIG_IND_V02:
871f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_SENSOR_PROPERTIES_IND_V02:
872f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_SUPL_CERTIFICATE_IND_V02:
873f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_DELETE_SUPL_CERTIFICATE_IND_V02:
874f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
875f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = true;
876f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
877f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
878f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    default:
879f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      LOC_LOGW("%s:%d]: unknown ind id %d\n", __func__, __LINE__,
880f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                   (uint32_t)indId);
881f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = false;
882f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
883f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
884f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return status;
885f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
886f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
887f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
888f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientErrorCb
889f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @brief handles the QCCI error events, this is called by the
890f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *         QCCI infrastructure when the service is no longer
891f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *         available.
892f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] user handle
893f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] error
894f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] *err_cb_data
895f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani */
896f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
897f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic void locClientErrorCb
898f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani(
899f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmi_client_type user_handle,
900f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmi_client_error_type error,
901f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  void *err_cb_data
902f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani)
903f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
904f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientCallbackDataType* pCallbackData =
905f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        (locClientCallbackDataType *)err_cb_data;
906f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
907f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  /* copy the errorCallback function pointer from the callback
908f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   * data to local variable. This is to protect against the race
909f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   * condition between open/close and error callback.
910f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   */
911f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientErrorCbType localErrorCallback =
912f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      pCallbackData->errorCallback;
913f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
914f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGD("%s:%d]: Service Error %d received, pCallbackData = %p\n",
915f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      __func__, __LINE__, error, err_cb_data);
916f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
917f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  /* call the error callback
918f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   * To avoid calling the errorCallback after locClientClose
919f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   * is called, check pCallbackData->errorCallback again here
920f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   */
921f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
922f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if( (NULL != pCallbackData) &&
923f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      (NULL != localErrorCallback) &&
924f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      (NULL != pCallbackData->errorCallback) )
925f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
926f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    //invoke the error callback for the corresponding client
927f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    localErrorCallback(
928f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        (locClientHandleType)pCallbackData,
929f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        convertQmiErrorToLocError(error),
930f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        pCallbackData->pClientCookie);
931f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
932f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
933f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
934f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
935f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientIndCb
936f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @brief handles the indications sent from the service, if a
937f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *         response indication was received then the it is sent
938f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *         to the response callback. If a event indication was
939f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *         received then it is sent to the event callback
940f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] user handle
941f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] msg_id
942f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] ind_buf
943f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] ind_buf_len
944f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] ind_cb_data */
945f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
946f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic void locClientIndCb
947f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani(
948f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani qmi_client_type                user_handle,
949f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani unsigned int                   msg_id,
950f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani void                           *ind_buf,
951f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani unsigned int                   ind_buf_len,
952f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani void                           *ind_cb_data
953f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani)
954f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
955f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientIndEnumT indType;
956f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  size_t indSize = 0;
957f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmi_client_error_type rc ;
958f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientCallbackDataType* pCallbackData =
959f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      (locClientCallbackDataType *)ind_cb_data;
960f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
961f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV("%s:%d]: Indication: msg_id=%d buf_len=%d pCallbackData = %p\n",
962f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                __func__, __LINE__, (uint32_t)msg_id, ind_buf_len,
963f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                pCallbackData);
964f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
965f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // check callback data
966f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if(NULL == pCallbackData)
967f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
968f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGE("%s:%d]: invalid callback data", __func__, __LINE__);
969f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    return;
970f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
971f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
972f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // check user handle
973f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if(memcmp(&pCallbackData->userHandle, &user_handle, sizeof(user_handle)))
974f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
975f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGE("%s:%d]: invalid user_handle got 0x%x expected 0x%x\n",
976f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        __func__, __LINE__,
977f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        user_handle, pCallbackData->userHandle);
978f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    return;
979f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
980f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // Get the indication size and type ( eventInd or respInd)
981f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if( true == locClientGetSizeAndTypeByIndId(msg_id, &indSize, &indType))
982f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
983f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    void *indBuffer = NULL;
984f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
985f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // if the client did not register for this event then just drop it
986f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     if( (eventIndType == indType) &&
987f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani         ( (NULL == pCallbackData->eventCallback) ||
988f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani         (false == isClientRegisteredForEvent(pCallbackData->eventRegMask, msg_id)) ) )
989f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
990f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani       LOC_LOGW("%s:%d]: client is not registered for event %d\n",
991f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                     __func__, __LINE__, (uint32_t)msg_id);
992f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani       return;
993f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
994f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
995f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // decode the indication
996f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    indBuffer = malloc(indSize);
997f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
998f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    if(NULL == indBuffer)
999f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1000f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      LOC_LOGE("%s:%d]: memory allocation failed\n", __func__, __LINE__);
1001f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      return;
1002f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1003f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1004f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // decode the indication
1005f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    rc = qmi_client_message_decode(
1006f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        user_handle,
1007f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        QMI_IDL_INDICATION,
1008f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        msg_id,
1009f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        ind_buf,
1010f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        ind_buf_len,
1011f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        indBuffer,
1012f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        indSize);
1013f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1014f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    if( rc == QMI_NO_ERR )
1015f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1016f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      //validate indication
1017f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      if (true == locClientHandleIndication(msg_id, indBuffer, indSize))
1018f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      {
1019f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        if(eventIndType == indType)
1020f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        {
1021f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          locClientEventIndUnionType eventIndUnion;
1022f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1023f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          /* copy the eventCallback function pointer from the callback
1024f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani           * data to local variable. This is to protect against the race
1025f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani           * condition between open/close and indication callback.
1026f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani           */
1027f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani           locClientEventIndCbType localEventCallback =
1028f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani               pCallbackData->eventCallback;
1029f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1030f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          // dummy event
1031f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          eventIndUnion.pPositionReportEvent =
1032f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani            (qmiLocEventPositionReportIndMsgT_v02 *)indBuffer;
1033f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1034f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          /* call the event callback
1035f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani           * To avoid calling the eventCallback after locClientClose
1036f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani           * is called, check pCallbackData->eventCallback again here
1037f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani           */
1038f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          if((NULL != localEventCallback) &&
1039f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani              (NULL != pCallbackData->eventCallback))
1040f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          {
1041f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani            localEventCallback(
1042f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                (locClientHandleType)pCallbackData,
1043f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                msg_id,
1044f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                eventIndUnion,
1045f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                pCallbackData->pClientCookie);
1046f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          }
1047f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        }
1048f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        else if(respIndType == indType)
1049f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        {
1050f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          locClientRespIndUnionType respIndUnion;
1051f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1052f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          /* copy the respCallback function pointer from the callback
1053f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani           * data to local variable. This is to protect against the race
1054f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani           * condition between open/close and indication callback.
1055f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani           */
1056f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          locClientRespIndCbType localRespCallback =
1057f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani              pCallbackData->respCallback;
1058f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1059f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          // dummy to suppress compiler warnings
1060f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          respIndUnion.pDeleteAssistDataInd =
1061f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani            (qmiLocDeleteAssistDataIndMsgT_v02 *)indBuffer;
1062f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1063f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          /* call the response callback
1064f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani           * To avoid calling the respCallback after locClientClose
1065f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani           * is called, check pCallbackData->respCallback again here
1066f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani           */
1067f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          if((NULL != localRespCallback) &&
1068f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani              (NULL != pCallbackData->respCallback))
1069f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          {
1070f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani            localRespCallback(
1071f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                (locClientHandleType)pCallbackData,
1072f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                msg_id,
1073f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                respIndUnion,
1074f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                pCallbackData->pClientCookie);
1075f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani          }
1076f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        }
1077f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      }
1078f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      else // error handling indication
1079f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      {
1080f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        LOC_LOGE("%s:%d]: Error handling the indication %d\n",
1081f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                      __func__, __LINE__, (uint32_t)msg_id);
1082f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      }
1083f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1084f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    else
1085f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1086f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      LOC_LOGE("%s:%d]: Error decoding indication %d\n",
1087f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                    __func__, __LINE__, rc);
1088f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1089f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    if(indBuffer)
1090f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1091f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      free (indBuffer);
1092f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1093f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1094f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  else // Id not found
1095f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1096f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGE("%s:%d]: Error indication not found %d\n",
1097f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                  __func__, __LINE__,(uint32_t)msg_id);
1098f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1099f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return;
1100f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
1101f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1102f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1103f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientRegisterEventMask
1104f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @brief registers the event mask with loc service
1105f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] clientHandle
1106f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in] eventRegMask
1107f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @return true if indication was validated; else false */
1108f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1109f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic bool locClientRegisterEventMask(
1110f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    locClientHandleType clientHandle,
1111f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    locClientEventMaskType eventRegMask)
1112f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
1113f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientStatusEnumType status = eLOC_CLIENT_SUCCESS;
1114f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientReqUnionType reqUnion;
1115f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmiLocRegEventsReqMsgT_v02 regEventsReq;
1116f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1117f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  memset(&regEventsReq, 0, sizeof(regEventsReq));
1118f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1119f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  regEventsReq.eventRegMask = eventRegMask;
1120f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  reqUnion.pRegEventsReq = &regEventsReq;
1121f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1122f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  status = locClientSendReq(clientHandle,
1123f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                            QMI_LOC_REG_EVENTS_REQ_V02,
1124f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                            reqUnion);
1125f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1126f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if(eLOC_CLIENT_SUCCESS != status )
1127f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1128f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGE("%s:%d] status %s\n", __func__, __LINE__,
1129f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani             loc_get_v02_client_status_name(status) );
1130f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    return false;
1131f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1132f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1133f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return true;
1134f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
1135f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1136f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/**  validateRequest
1137f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @brief validates the input request
1138f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @param [in] reqId       request ID
1139f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @param [in] reqPayload  Union of pointers to message payload
1140f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @param [out] ppOutData  Pointer to void *data if successful
1141f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @param [out] pOutLen    Pointer to length of data if succesful.
1142f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @return false on failure, true on Success
1143f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*/
1144f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1145f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic bool validateRequest(
1146f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  uint32_t                    reqId,
1147f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  const locClientReqUnionType reqPayload,
1148f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  void                        **ppOutData,
1149f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  uint32_t                    *pOutLen )
1150f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1151f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
1152f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  bool noPayloadFlag = false;
1153f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1154f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV("%s:%d]: reqId = %d\n", __func__, __LINE__, reqId);
1155f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  switch(reqId)
1156f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1157f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INFORM_CLIENT_REVISION_REQ_V02:
1158f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1159f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocInformClientRevisionReqMsgT_v02);
1160f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1161f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1162f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1163f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_REG_EVENTS_REQ_V02:
1164f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1165f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocRegEventsReqMsgT_v02);
1166f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani       break;
1167f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1168f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1169f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_START_REQ_V02:
1170f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1171f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocStartReqMsgT_v02);
1172f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani       break;
1173f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1174f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1175f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_STOP_REQ_V02:
1176f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1177f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocStopReqMsgT_v02);
1178f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani       break;
1179f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1180f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1181f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_NI_USER_RESPONSE_REQ_V02:
1182f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1183f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocNiUserRespReqMsgT_v02);
1184f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani       break;
1185f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1186f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1187f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_PREDICTED_ORBITS_DATA_REQ_V02:
1188f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1189f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocInjectPredictedOrbitsDataReqMsgT_v02);
1190f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1191f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1192f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1193f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_UTC_TIME_REQ_V02:
1194f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1195f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocInjectUtcTimeReqMsgT_v02);
1196f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1197f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1198f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1199f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_POSITION_REQ_V02:
1200f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1201f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocInjectPositionReqMsgT_v02);
1202f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1203f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1204f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1205f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_ENGINE_LOCK_REQ_V02:
1206f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1207f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetEngineLockReqMsgT_v02);
1208f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1209f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1210f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1211f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_SBAS_CONFIG_REQ_V02:
1212f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1213f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetSbasConfigReqMsgT_v02);
1214f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1215f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1216f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1217f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_NMEA_TYPES_REQ_V02:
1218f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1219f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetNmeaTypesReqMsgT_v02);
1220f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1221f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1222f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1223f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_LOW_POWER_MODE_REQ_V02:
1224f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1225f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetLowPowerModeReqMsgT_v02);
1226f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1227f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1228f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1229f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_SERVER_REQ_V02:
1230f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1231f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetServerReqMsgT_v02);
1232f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1233f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1234f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1235f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_DELETE_ASSIST_DATA_REQ_V02:
1236f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1237f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocDeleteAssistDataReqMsgT_v02);
1238f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1239f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1240f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1241f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_XTRA_T_SESSION_CONTROL_REQ_V02:
1242f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1243f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetXtraTSessionControlReqMsgT_v02);
1244f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1245f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1246f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1247f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_WIFI_POSITION_REQ_V02:
1248f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1249f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocInjectWifiPositionReqMsgT_v02);
1250f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1251f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1252f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1253f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_NOTIFY_WIFI_STATUS_REQ_V02:
1254f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1255f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocNotifyWifiStatusReqMsgT_v02);
1256f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1257f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1258f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1259f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_OPERATION_MODE_REQ_V02:
1260f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1261f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetOperationModeReqMsgT_v02);
1262f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1263f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1264f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1265f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_SPI_STATUS_REQ_V02:
1266f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1267f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetSpiStatusReqMsgT_v02);
1268f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1269f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1270f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1271f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_SENSOR_DATA_REQ_V02:
1272f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1273f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocInjectSensorDataReqMsgT_v02);
1274f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1275f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1276f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1277f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_TIME_SYNC_DATA_REQ_V02:
1278f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1279f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocInjectTimeSyncDataReqMsgT_v02);
1280f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1281f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1282f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1283f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_CRADLE_MOUNT_CONFIG_REQ_V02:
1284f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1285f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetCradleMountConfigReqMsgT_v02);
1286f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1287f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1288f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1289f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_EXTERNAL_POWER_CONFIG_REQ_V02:
1290f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1291f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetExternalPowerConfigReqMsgT_v02);
1292f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1293f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1294f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1295f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INFORM_LOCATION_SERVER_CONN_STATUS_REQ_V02:
1296f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1297f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocInformLocationServerConnStatusReqMsgT_v02);
1298f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1299f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1300f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1301f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_PROTOCOL_CONFIG_PARAMETERS_REQ_V02:
1302f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1303f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetProtocolConfigParametersReqMsgT_v02);
1304f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1305f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1306f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1307f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_PROTOCOL_CONFIG_PARAMETERS_REQ_V02:
1308f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1309f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocGetProtocolConfigParametersReqMsgT_v02);
1310f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1311f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1312f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1313f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_SENSOR_CONTROL_CONFIG_REQ_V02:
1314f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1315f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetSensorControlConfigReqMsgT_v02);
1316f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1317f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1318f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1319f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_SENSOR_PROPERTIES_REQ_V02:
1320f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1321f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetSensorPropertiesReqMsgT_v02);
1322f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1323f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1324f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1325f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_SENSOR_PERFORMANCE_CONTROL_CONFIGURATION_REQ_V02:
1326f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1327f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetSensorPerformanceControlConfigReqMsgT_v02);
1328f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1329f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1330f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1331f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_INJECT_SUPL_CERTIFICATE_REQ_V02:
1332f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1333f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocInjectSuplCertificateReqMsgT_v02);
1334f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1335f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1336f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_DELETE_SUPL_CERTIFICATE_REQ_V02:
1337f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1338f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocDeleteSuplCertificateReqMsgT_v02);
1339f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1340f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1341f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_SET_POSITION_ENGINE_CONFIG_PARAMETERS_REQ_V02:
1342f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1343f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocSetPositionEngineConfigParametersReqMsgT_v02);
1344f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1345f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1346f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_POSITION_ENGINE_CONFIG_PARAMETERS_REQ_V02:
1347f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1348f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pOutLen = sizeof(qmiLocGetPositionEngineConfigParametersReqMsgT_v02);
1349f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1350f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1351f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1352f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // ALL requests with no payload
1353f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_SERVICE_REVISION_REQ_V02:
1354f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_FIX_CRITERIA_REQ_V02:
1355f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_PREDICTED_ORBITS_DATA_SOURCE_REQ_V02:
1356f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_PREDICTED_ORBITS_DATA_VALIDITY_REQ_V02:
1357f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_ENGINE_LOCK_REQ_V02:
1358f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_SBAS_CONFIG_REQ_V02:
1359f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_NMEA_TYPES_REQ_V02:
1360f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_LOW_POWER_MODE_REQ_V02:
1361f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_SERVER_REQ_V02:
1362f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_XTRA_T_SESSION_CONTROL_REQ_V02:
1363f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_REGISTERED_EVENTS_REQ_V02:
1364f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_OPERATION_MODE_REQ_V02:
1365f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_CRADLE_MOUNT_CONFIG_REQ_V02:
1366f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_EXTERNAL_POWER_CONFIG_REQ_V02:
1367f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_SENSOR_CONTROL_CONFIG_REQ_V02:
1368f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_SENSOR_PROPERTIES_REQ_V02:
1369f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    case QMI_LOC_GET_SENSOR_PERFORMANCE_CONTROL_CONFIGURATION_REQ_V02:
1370f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1371f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      noPayloadFlag = true;
1372f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1373f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1374f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1375f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    default:
1376f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      LOC_LOGW("%s:%d]: Error unknown reqId=%d\n", __func__, __LINE__,
1377f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                    reqId);
1378f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      return false;
1379f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1380f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if(true == noPayloadFlag)
1381f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1382f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    *ppOutData = NULL;
1383f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    *pOutLen = 0;
1384f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1385f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  else
1386f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1387f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    //set dummy pointer for request union
1388f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    *ppOutData = (void*) reqPayload.pInformClientRevisionReq;
1389f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1390f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV("%s:%d]: reqId=%d, len = %d\n", __func__, __LINE__,
1391f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                reqId, *pOutLen);
1392f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return true;
1393f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
1394f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1395f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientQmiCtrlPointInit
1396f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani @brief wait for the service to come up or timeout; when the
1397f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        service comes up initialize the control point and set
1398f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        internal handle and indication callback.
1399f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani @param pQmiClient,
1400f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*/
1401f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1402f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanistatic locClientStatusEnumType locClientQmiCtrlPointInit(
1403f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    locClientCallbackDataType *pLocClientCbData)
1404f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
1405f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmi_client_type clnt, notifier;
14069365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  bool notifierInitFlag = false;
14079365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  locClientStatusEnumType status = eLOC_CLIENT_SUCCESS;
14089365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  // instances of this service
14099365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  qmi_service_info *pServiceInfo = NULL;
1410f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
14119365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  do
14129365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  {
14139365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  uint32_t num_services = 0, num_entries = 0;
1414f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmi_client_error_type rc = QMI_NO_ERR;
14159365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  bool nosignal = false;
1416f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1417f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // Get the service object for the qmiLoc Service
1418f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmi_idl_service_object_type locClientServiceObject =
1419f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    loc_get_service_object_v02();
1420f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1421f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // Verify that qmiLoc_get_service_object did not return NULL
1422f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if (NULL == locClientServiceObject)
1423f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1424f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      LOC_LOGE("%s:%d]: qmiLoc_get_service_object_v02 failed\n" ,
1425f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                  __func__, __LINE__ );
14269365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin       status = eLOC_CLIENT_FAILURE_INTERNAL;
14279365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin       break;
1428f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1429f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1430f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // get the service addressing information
1431f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    rc = qmi_client_get_service_list( locClientServiceObject, NULL, NULL,
1432f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                                      &num_services);
14339365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    LOC_LOGV("%s:%d]: qmi_client_get_service_list() first try rc %d, "
14349365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin             "num_services %d", __func__, __LINE__, rc, num_services);
14359365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
14369365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    if (rc != QMI_NO_ERR) {
14379365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        // bummer, service list is not up.
14389365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        // We need to try again after a timed wait
14399365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        qmi_client_os_params os_params;
14409365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        int timeout = 0;
14419365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
14429365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        // register for service notification
14439365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        rc = qmi_client_notifier_init(locClientServiceObject, &os_params, &notifier);
14449365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        notifierInitFlag = (NULL != notifier);
14459365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
14469365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        if (rc != QMI_NO_ERR) {
14479365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            LOC_LOGE("%s:%d]: qmi_client_notifier_init failed %d\n",
14489365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin                     __func__, __LINE__, rc);
14499365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            status = eLOC_CLIENT_FAILURE_INTERNAL;
14509365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            break;
14519365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        }
1452f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
14539365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        do {
14549365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            QMI_CCI_OS_SIGNAL_CLEAR(&os_params);
14559365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            /* If service is not up wait on a signal until the service is up
14569365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin             * or a timeout occurs. */
14579365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            QMI_CCI_OS_SIGNAL_WAIT(&os_params, LOC_CLIENT_SERVICE_TIMEOUT_UNIT);
14589365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            nosignal = QMI_CCI_OS_SIGNAL_TIMED_OUT(&os_params);
14599365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
14609365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            // get the service addressing information
14619365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            rc = qmi_client_get_service_list(locClientServiceObject, NULL, NULL,
14629365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin                                             &num_services);
14639365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
14649365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            timeout += LOC_CLIENT_SERVICE_TIMEOUT_UNIT;
14659365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
14669365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            LOC_LOGV("%s:%d]: qmi_client_get_service_list() rc %d, nosignal %d, "
14679365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin                     "total timeout %d", __func__, __LINE__, rc, nosignal, timeout);
14689365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        } while (timeout < LOC_CLIENT_SERVICE_TIMEOUT_TOTAL && nosignal && rc != QMI_NO_ERR);
14699365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    }
14709365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
14719365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    if (0 == num_services || rc != QMI_NO_ERR) {
14729365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        if (!nosignal) {
14739365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            LOC_LOGE("%s:%d]: qmi_client_get_service_list failed even though"
14749365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin                     "service is up !!!  Error %d \n", __func__, __LINE__, rc);
14759365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            status = eLOC_CLIENT_FAILURE_INTERNAL;
14769365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        } else {
14779365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            LOC_LOGE("%s:%d]: qmi_client_get_service_list failed after retries,"
14789365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin                     " final Err %d", __func__, __LINE__, rc);
14799365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin            status = eLOC_CLIENT_FAILURE_TIMEOUT;
14809365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        }
14819365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin        break;
14829365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    }
14839365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
14849365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    pServiceInfo =
14859365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin      (qmi_service_info *)malloc(num_services * sizeof(qmi_service_info));
14869365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
14879365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    if(NULL == pServiceInfo)
1488f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
14899365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin      LOC_LOGE("%s:%d]: could not allocate memory for serviceInfo !!\n",
14909365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin               __func__, __LINE__);
1491f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
14929365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin      status = eLOC_CLIENT_FAILURE_INTERNAL;
14939365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin      break;
1494f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1495f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
14969365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    //set the number of entries to get equal to the total number of
14979365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    //services.
14989365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    num_entries = num_services;
14999365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    //populate the serviceInfo
15009365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    rc = qmi_client_get_service_list( locClientServiceObject, pServiceInfo,
15019365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin                                      &num_entries, &num_services);
1502f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1503f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
15049365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    LOC_LOGV("%s:%d]: qmi_client_get_service_list()"
15059365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin                  " returned %d num_entries = %d num_services = %d\n",
15069365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin                  __func__, __LINE__,
15079365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin                   rc, num_entries, num_services);
1508f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
15099365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    if(rc != QMI_NO_ERR)
15109365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    {
15119365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin      LOC_LOGE("%s:%d]: qmi_client_get_service_list Error %d \n",
15129365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin                    __func__, __LINE__, rc);
1513f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
15149365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin      status = eLOC_CLIENT_FAILURE_INTERNAL;
15159365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin      break;
15169365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    }
1517f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1518f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV("%s:%d]: passing the pointer %p to qmi_client_init \n",
1519f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                    __func__, __LINE__, pLocClientCbData);
15209365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
1521f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // initialize the client
15229365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    //sent the address of the first service found
15239365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    // if IPC router is present, this will go to the service instance
15249365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    // enumerated over IPC router, else it will go over the next transport where
15259365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    // the service was enumerated.
15269365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    rc = qmi_client_init(&pServiceInfo[0], locClientServiceObject,
1527f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                       locClientIndCb, (void *) pLocClientCbData,
1528f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                       NULL, &clnt);
1529f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1530f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if(rc != QMI_NO_ERR)
1531f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1532f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGE("%s:%d]: qmi_client_init error %d\n",
1533f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                  __func__, __LINE__, rc);
15349365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
15359365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin      status = eLOC_CLIENT_FAILURE_INTERNAL;
15369365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin      break;
1537f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1538f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1539f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV("%s:%d]: passing the pointer %p to"
1540f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                "qmi_client_register_error_cb \n",
1541f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                 __func__, __LINE__, pLocClientCbData);
1542f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1543f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // register error callback
1544f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  rc  = qmi_client_register_error_cb(clnt,
1545f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      locClientErrorCb, (void *) pLocClientCbData);
1546f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1547f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if( QMI_NO_ERR != rc)
1548f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1549f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGE("%s:%d]: could not register QCCI error callback error:%d\n",
1550f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                  __func__, __LINE__, rc);
15519365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
15529365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin      status = eLOC_CLIENT_FAILURE_INTERNAL;
15539365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin      break;
1554f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1555f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1556f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // copy the clnt handle returned in qmi_client_init
1557f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  memcpy(&(pLocClientCbData->userHandle), &clnt, sizeof(qmi_client_type));
1558f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
15599365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    status = eLOC_CLIENT_SUCCESS;
15609365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
15619365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  } while(0);
15629365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
15639365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  /* release the notifier handle */
15649365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  if(true == notifierInitFlag)
15659365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  {
15669365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    qmi_client_release(notifier);
15679365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  }
15689365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin
15699365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  if(NULL != pServiceInfo)
15709365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  {
15719365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin    free((void *)pServiceInfo);
15729365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  }
1573f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
15749365bf1ffd633b65bad7f95af90dcbb53e41652bwoojin.shin  return status;
1575f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
1576f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani//----------------------- END INTERNAL FUNCTIONS ----------------------------------------
1577f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1578f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientOpen
1579f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @brief Connects a location client to the location engine. If the connection
1580f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani         is successful, returns a handle that the location client uses for
1581f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani         future location operations.
1582f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1583f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @param [in] eventRegMask     Mask of asynchronous events the client is
1584f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                               interested in receiving
1585f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @param [in] eventIndCb       Function to be invoked to handle an event.
1586f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @param [in] respIndCb        Function to be invoked to handle a response
1587f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                               indication.
1588f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @param [out] locClientHandle Handle to be used by the client
1589f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                               for any subsequent requests.
1590f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1591f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @return
1592f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  One of the following error codes:
1593f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  - eLOC_CLIENT_SUCCESS  -- If the connection is opened.
1594f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  - non-zero error code(see locClientStatusEnumType)--  On failure.
1595f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*/
1596f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1597f77c85bb51137f5ba854184e5e9194197027438aAjay DudanilocClientStatusEnumType locClientOpen (
1598f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientEventMaskType         eventRegMask,
1599f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  const locClientCallbacksType*  pLocClientCallbacks,
1600f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientHandleType*           pLocClientHandle,
1601f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  const void*                    pClientCookie)
1602f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
1603f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientStatusEnumType status = eLOC_CLIENT_SUCCESS;
1604f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientCallbackDataType *pCallbackData = NULL;
1605f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1606f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV("%s:%d] \n", __func__, __LINE__);
1607f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1608f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  do
1609f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1610f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // check input parameters
1611f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    if( (NULL == pLocClientCallbacks) || (NULL == pLocClientHandle)
1612f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        || (NULL == pLocClientCallbacks->respIndCb) ||
1613f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        (pLocClientCallbacks->size != sizeof(locClientCallbacksType)))
1614f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1615f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      LOC_LOGE("%s:%d]: Invalid parameters in locClientOpen\n",
1616f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                              __func__, __LINE__);
1617f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = eLOC_CLIENT_FAILURE_INVALID_PARAMETER;
1618f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1619f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1620f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1621f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // Allocate memory for the callback data
1622f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    pCallbackData =
1623f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        ( locClientCallbackDataType*)calloc(
1624f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani            1, sizeof(locClientCallbackDataType));
1625f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1626f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    if(NULL == pCallbackData)
1627f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1628f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      LOC_LOGE("%s:%d]: Could not allocate memory for callback data \n",
1629f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                        __func__, __LINE__);
1630f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = eLOC_CLIENT_FAILURE_INTERNAL;
1631f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1632f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1633f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1634f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    /* Initialize the QMI control point; this function will block
1635f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     * until a service is up or a timeout occurs. If the connection to
1636f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     * the service succeeds the callback data will be filled in with
1637f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     * a qmi_client value.
1638f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     */
1639f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1640f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1641f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    EXIT_LOG_CALLFLOW(%s, "loc client open");
1642f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    status = locClientQmiCtrlPointInit(pCallbackData);
1643f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1644f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGV ("%s:%d] locClientQmiCtrlPointInit returned %d\n",
1645f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                    __func__, __LINE__, status);
1646f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1647f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    if(status != eLOC_CLIENT_SUCCESS)
1648f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1649f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      free(pCallbackData);
1650f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      pCallbackData = NULL;
1651f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1652f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1653f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1654f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     // set the handle to the callback data
1655f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    *pLocClientHandle = (locClientHandleType)pCallbackData;
1656f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1657f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    if(true != locClientRegisterEventMask(*pLocClientHandle,eventRegMask))
1658f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1659f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      LOC_LOGE("%s:%d]: Error sending registration mask\n",
1660f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                  __func__, __LINE__);
1661f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1662f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      // release the client
1663f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      locClientClose(pLocClientHandle);
1664f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1665f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      status = eLOC_CLIENT_FAILURE_INTERNAL;
1666f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      break;
1667f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1668f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1669f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    /* Initialize rest of the client structure now that the connection
1670f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     * to the service has been created successfully.
1671f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     */
1672f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1673f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    //fill in the event callback
1674f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     pCallbackData->eventCallback = pLocClientCallbacks->eventIndCb;
1675f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1676f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     //fill in the response callback
1677f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     pCallbackData->respCallback = pLocClientCallbacks->respIndCb;
1678f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1679f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     //fill in the error callback
1680f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     pCallbackData->errorCallback = pLocClientCallbacks->errorCb;
1681f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1682f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     //set the client event registration mask
1683f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     pCallbackData->eventRegMask = eventRegMask;
1684f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1685f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     // set the client cookie
1686f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     pCallbackData->pClientCookie = (void *)pClientCookie;
1687f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1688f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     LOC_LOGD("%s:%d]: returning handle = 0x%x, user_handle=0x%x, status = %d\n",
1689f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani              __func__, __LINE__, *pLocClientHandle,
1690f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani              pCallbackData->userHandle, status);
1691f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1692f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }while(0);
1693f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1694f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if(eLOC_CLIENT_SUCCESS != status)
1695f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1696f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    *pLocClientHandle = LOC_CLIENT_INVALID_HANDLE_VALUE;
1697f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1698f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1699f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return(status);
1700f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
1701f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1702f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientClose
1703f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @brief Disconnects a client from the location engine.
1704f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @param [in] pLocClientHandle  Pointer to the handle returned by the
1705f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                                locClientOpen() function.
1706f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @return
1707f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  One of the following error codes:
1708f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  - 0 (eLOC_CLIENT_SUCCESS) - On success.
1709f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  - non-zero error code(see locClientStatusEnumType) - On failure.
1710f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*/
1711f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1712f77c85bb51137f5ba854184e5e9194197027438aAjay DudanilocClientStatusEnumType locClientClose(
1713f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientHandleType* pLocClientHandle)
1714f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
1715f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmi_client_error_type rc = QMI_NO_ERR; //No error
1716f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1717f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if(NULL == pLocClientHandle)
1718f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1719f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // invalid handle
1720f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGE("%s:%d]: invalid pointer to handle \n",
1721f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                  __func__, __LINE__);
1722f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1723f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    return(eLOC_CLIENT_FAILURE_INVALID_PARAMETER);
1724f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1725f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1726f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // convert handle to callback data
1727f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientCallbackDataType *pCallbackData =
1728f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      (locClientCallbackDataType *)(*pLocClientHandle);
1729f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1730f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV("%s:%d]:\n", __func__, __LINE__ );
1731f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1732f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // check the input handle for sanity
1733f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if(NULL == pCallbackData ||
1734f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     NULL == pCallbackData->userHandle)
1735f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1736f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // invalid handle
1737f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGE("%s:%d]: invalid handle \n",
1738f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                  __func__, __LINE__);
1739f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1740f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    return(eLOC_CLIENT_FAILURE_INVALID_HANDLE);
1741f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1742f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1743f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV("locClientClose releasing handle 0x%x, user handle 0x%x\n",
1744f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pLocClientHandle, pCallbackData->userHandle );
1745f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1746f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // NEXT call goes out to modem. We log the callflow before it
1747f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // actually happens to ensure the this comes before resp callflow
1748f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // back from the modem, to avoid confusing log order. We trust
1749f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // that the QMI framework is robust.
1750f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  EXIT_LOG_CALLFLOW(%s, "loc client close");
1751f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // release the handle
1752f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  rc = qmi_client_release(pCallbackData->userHandle);
1753f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if(QMI_NO_ERR != rc )
1754f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1755f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGW("%s:%d]: qmi_client_release error %d for client %p\n",
1756f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                   __func__, __LINE__, rc, pCallbackData->userHandle);
1757f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    return(eLOC_CLIENT_FAILURE_INTERNAL);
1758f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1759f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1760f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  /* clear the memory allocated to callback data to minimize the chances
1761f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   *  of a race condition occurring between close and the indication
1762f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   *  callback
1763f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   */
1764f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  memset(pCallbackData, 0, sizeof(*pCallbackData));
1765f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1766f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // free the memory assigned in locClientOpen
1767f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  free(pCallbackData);
1768f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  pCallbackData= NULL;
1769f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1770f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // set the handle to invalid value
1771f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  *pLocClientHandle = LOC_CLIENT_INVALID_HANDLE_VALUE;
1772f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1773f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return eLOC_CLIENT_SUCCESS;
1774f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
1775f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1776f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientSendReq
1777f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @brief Sends a message to the location engine. If the locClientSendMsg()
1778f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani         function is successful, the client should expect an indication
1779f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani         (except start, stop, event reg and sensor injection messages),
1780f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani         through the registered callback in the locOpen() function. The
1781f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani         indication will contain the status of the request and if status is a
1782f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani         success, indication also contains the payload
1783f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani         associated with response.
1784f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @param [in] handle Handle returned by the locClientOpen()
1785f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani              function.
1786f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @param [in] reqId         message ID of the request
1787f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @param [in] reqPayload   Payload of the request, can be NULL
1788f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                            if request has no payload
1789f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1790f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  @return
1791f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  One of the following error codes:
1792f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  - 0 (eLOC_CLIENT_SUCCESS ) - On success.
1793f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  - non-zero error code (see locClientStatusEnumType) - On failure.
1794f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*/
1795f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1796f77c85bb51137f5ba854184e5e9194197027438aAjay DudanilocClientStatusEnumType locClientSendReq(
1797f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientHandleType      handle,
1798f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  uint32_t                 reqId,
1799f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientReqUnionType    reqPayload )
1800f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
1801f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientStatusEnumType status = eLOC_CLIENT_SUCCESS;
1802f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmi_client_error_type rc = QMI_NO_ERR; //No error
1803f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  qmiLocGenRespMsgT_v02 resp;
1804f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  uint32_t reqLen = 0;
1805f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  void *pReqData = NULL;
1806f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  locClientCallbackDataType *pCallbackData =
1807f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        (locClientCallbackDataType *)handle;
1808f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1809f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // check the input handle for sanity
1810f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   if(NULL == pCallbackData ||
1811f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      NULL == pCallbackData->userHandle )
1812f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   {
1813f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     // did not find the handle in the client List
1814f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     LOC_LOGE("%s:%d]: invalid handle \n",
1815f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                   __func__, __LINE__);
1816f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1817f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani     return(eLOC_CLIENT_FAILURE_INVALID_HANDLE);
1818f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani   }
1819f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1820f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // validate that the request is correct
1821f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if (validateRequest(reqId, reqPayload, &pReqData, &reqLen) == false)
1822f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1823f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1824f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGE("%s:%d] error invalid request\n", __func__,
1825f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                __LINE__);
1826f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1827f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    return(eLOC_CLIENT_FAILURE_INVALID_PARAMETER);
1828f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1829f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1830f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV("%s:%d] sending reqId= %d, len = %d\n", __func__,
1831f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                __LINE__, reqId, reqLen);
1832f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1833f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // NEXT call goes out to modem. We log the callflow before it
1834f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // actually happens to ensure the this comes before resp callflow
1835f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // back from the modem, to avoid confusing log order. We trust
1836f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // that the QMI framework is robust.
1837f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  EXIT_LOG_CALLFLOW(%s, loc_get_v02_event_name(reqId));
1838f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1839f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  rc = qmi_client_send_msg_sync(
1840f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      pCallbackData->userHandle,
1841f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      reqId,
1842f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      pReqData,
1843f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      reqLen,
1844f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      &resp,
1845f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      sizeof(resp),
1846f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      LOC_CLIENT_ACK_TIMEOUT);
1847f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1848f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  LOC_LOGV("%s:%d] qmi_client_send_msg_sync returned %d\n", __func__,
1849f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                __LINE__, rc);
1850f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1851f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  if (rc != QMI_NO_ERR)
1852f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1853f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LOC_LOGE("%s:%d]: send_msg_sync error: %d\n",__func__, __LINE__, rc);
1854f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    return(eLOC_CLIENT_FAILURE_INTERNAL);
1855f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1856f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1857f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // map the QCCI response to Loc API v02 status
1858f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  status = convertQmiResponseToLocStatus(&resp);
1859f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1860f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return(status);
1861f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
1862f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1863f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientGetSizeByRespIndId
1864f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @brief Get the size of the response indication structure,
1865f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *         from a specified id
1866f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in]  respIndId
1867f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [out] pRespIndSize
1868f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @return true if resp ID was found; else false
1869f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*/
1870f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1871f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanibool locClientGetSizeByRespIndId(uint32_t respIndId, size_t *pRespIndSize)
1872f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
1873f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  size_t idx = 0, respIndTableSize = 0;
1874f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  respIndTableSize = (sizeof(locClientRespIndTable)/sizeof(locClientRespIndTableStructT));
1875f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  for(idx=0; idx<respIndTableSize; idx++ )
1876f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1877f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    if(respIndId == locClientRespIndTable[idx].respIndId)
1878f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1879f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      // found
1880f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pRespIndSize = locClientRespIndTable[idx].respIndSize;
1881f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1882f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      LOC_LOGV("%s:%d]: resp ind Id %d size = %d\n", __func__, __LINE__,
1883f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                    respIndId, (uint32_t)*pRespIndSize);
1884f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      return true;
1885f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1886f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1887f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1888f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  //not found
1889f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return false;
1890f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
1891f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1892f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1893f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/** locClientGetSizeByEventIndId
1894f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @brief Gets the size of the event indication structure, from
1895f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *         a specified id
1896f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [in]  eventIndId
1897f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @param [out] pEventIndSize
1898f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *  @return true if event ID was found; else false
1899f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani*/
1900f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanibool locClientGetSizeByEventIndId(uint32_t eventIndId, size_t *pEventIndSize)
1901f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani{
1902f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  size_t idx = 0, eventIndTableSize = 0;
1903f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1904f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // look in the event table
1905f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  eventIndTableSize =
1906f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    (sizeof(locClientEventIndTable)/sizeof(locClientEventIndTableStructT));
1907f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1908f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  for(idx=0; idx<eventIndTableSize; idx++ )
1909f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  {
1910f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    if(eventIndId == locClientEventIndTable[idx].eventId)
1911f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    {
1912f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      // found
1913f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      *pEventIndSize = locClientEventIndTable[idx].eventSize;
1914f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1915f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      LOC_LOGV("%s:%d]: event ind Id %d size = %d\n", __func__, __LINE__,
1916f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                    eventIndId, (uint32_t)*pEventIndSize);
1917f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani      return true;
1918f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    }
1919f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  }
1920f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  // not found
1921f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani  return false;
1922f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani}
1923f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
1924