1 /* Copyright (c) 2013-2019 The Linux Foundation. All rights reserved.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are
5  * met:
6  *     * Redistributions of source code must retain the above copyright
7  *       notice, this list of conditions and the following disclaimer.
8  *     * Redistributions in binary form must reproduce the above
9  *       copyright notice, this list of conditions and the following
10  *       disclaimer in the documentation and/or other materials provided
11  *       with the distribution.
12  *     * Neither the name of The Linux Foundation nor the names of its
13  *       contributors may be used to endorse or promote products derived
14  *       from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef GPS_EXTENDED_C_H
30 #define GPS_EXTENDED_C_H
31 
32 #include <ctype.h>
33 #include <stdbool.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <loc_gps.h>
37 #include <LocationAPI.h>
38 
39 struct timespec32_t {
40   uint32_t  tv_sec;   /* seconds */
41   uint32_t  tv_nsec;  /* and nanoseconds */
42 };
43 
44 
45 /**
46  * @file
47  * @brief C++ declarations for GPS types
48  */
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif /* __cplusplus */
53 
54 /** Location has valid source information. */
55 #define LOCATION_HAS_SOURCE_INFO   0x0020
56 /** LocGpsLocation has valid "is indoor?" flag */
57 #define LOC_GPS_LOCATION_HAS_IS_INDOOR   0x0040
58 /** LocGpsLocation has valid floor number */
59 #define LOC_GPS_LOCATION_HAS_FLOOR_NUMBER   0x0080
60 /** LocGpsLocation has valid map URL*/
61 #define LOC_GPS_LOCATION_HAS_MAP_URL   0x0100
62 /** LocGpsLocation has valid map index */
63 #define LOC_GPS_LOCATION_HAS_MAP_INDEX   0x0200
64 
65 #define GNSS_INVALID_JAMMER_IND 0x7FFFFFFF
66 
67 /** Sizes for indoor fields */
68 #define GPS_LOCATION_MAP_URL_SIZE 400
69 #define GPS_LOCATION_MAP_INDEX_SIZE 16
70 
71 /** Position source is ULP */
72 #define ULP_LOCATION_IS_FROM_HYBRID   0x0001
73 /** Position source is GNSS only */
74 #define ULP_LOCATION_IS_FROM_GNSS     0x0002
75 /** Position is from a Geofence Breach Event */
76 #define ULP_LOCATION_IS_FROM_GEOFENCE 0X0004
77 /** Position is from Hardware FLP */
78 #define ULP_LOCATION_IS_FROM_HW_FLP   0x0008
79 /** Position is from NLP */
80 #define ULP_LOCATION_IS_FROM_NLP      0x0010
81 /** Position is from external DR solution*/
82 #define ULP_LOCATION_IS_FROM_EXT_DR   0X0020
83 /** Raw GNSS position fixes */
84 #define ULP_LOCATION_IS_FROM_GNSS_RAW   0X0040
85 
86 typedef uint32_t LocSvInfoSource;
87 /** SVinfo source is GNSS/DR */
88 #define ULP_SVINFO_IS_FROM_GNSS       ((LocSvInfoSource)0x0001)
89 /** Raw SVinfo from GNSS */
90 #define ULP_SVINFO_IS_FROM_DR         ((LocSvInfoSource)0x0002)
91 
92 #define ULP_MIN_INTERVAL_INVALID 0xffffffff
93 #define ULP_MAX_NMEA_STRING_SIZE 201
94 
95 /*Emergency SUPL*/
96 #define LOC_GPS_NI_TYPE_EMERGENCY_SUPL    4
97 
98 #define LOC_AGPS_CERTIFICATE_MAX_LENGTH 2000
99 #define LOC_AGPS_CERTIFICATE_MAX_SLOTS 10
100 
101 /* TBM Threshold for tracking in background power mode : in millis */
102 #define TRACKING_TBM_THRESHOLD_MILLIS 480000
103 
104 /**  Maximum number of satellites in an ephemeris report.  */
105 #define GNSS_EPHEMERIS_LIST_MAX_SIZE_V02 32
106 
107 typedef uint32_t LocPosTechMask;
108 #define LOC_POS_TECH_MASK_DEFAULT ((LocPosTechMask)0x00000000)
109 #define LOC_POS_TECH_MASK_SATELLITE ((LocPosTechMask)0x00000001)
110 #define LOC_POS_TECH_MASK_CELLID ((LocPosTechMask)0x00000002)
111 #define LOC_POS_TECH_MASK_WIFI ((LocPosTechMask)0x00000004)
112 #define LOC_POS_TECH_MASK_SENSORS ((LocPosTechMask)0x00000008)
113 #define LOC_POS_TECH_MASK_REFERENCE_LOCATION ((LocPosTechMask)0x00000010)
114 #define LOC_POS_TECH_MASK_INJECTED_COARSE_POSITION ((LocPosTechMask)0x00000020)
115 #define LOC_POS_TECH_MASK_AFLT ((LocPosTechMask)0x00000040)
116 #define LOC_POS_TECH_MASK_HYBRID ((LocPosTechMask)0x00000080)
117 #define LOC_POS_TECH_MASK_PPE ((LocPosTechMask)0x00000100)
118 
119 enum loc_registration_mask_status {
120     LOC_REGISTRATION_MASK_ENABLED,
121     LOC_REGISTRATION_MASK_DISABLED,
122     LOC_REGISTRATION_MASK_SET
123 };
124 
125 typedef enum {
126     LOC_SUPPORTED_FEATURE_ODCPI_2_V02 = 0, /**<  Support ODCPI version 2 feature  */
127     LOC_SUPPORTED_FEATURE_WIFI_AP_DATA_INJECT_2_V02, /**<  Support Wifi AP data inject version 2 feature  */
128     LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02, /**< Support debug NMEA feature */
129     LOC_SUPPORTED_FEATURE_GNSS_ONLY_POSITION_REPORT, /**< Support GNSS Only position reports */
130     LOC_SUPPORTED_FEATURE_FDCL, /**< Support FDCL */
131     LOC_SUPPORTED_FEATURE_CONSTELLATION_ENABLEMENT_V02, /**< Support constellation enablement */
132     LOC_SUPPORTED_FEATURE_AGPM_V02, /**< Support AGPM feature */
133     LOC_SUPPORTED_FEATURE_XTRA_INTEGRITY, /**< Support XTRA integrity */
134     LOC_SUPPORTED_FEATURE_FDCL_2, /**< Support FDCL V2 */
135     LOC_SUPPORTED_FEATURE_LOCATION_PRIVACY /**< Support location privacy */
136 } loc_supported_feature_enum;
137 
138 typedef struct {
139     /** set to sizeof(UlpLocation) */
140     uint32_t          size;
141     LocGpsLocation     gpsLocation;
142     /* Provider indicator for HYBRID or GPS */
143     uint16_t        position_source;
144     LocPosTechMask  tech_mask;
145     bool            unpropagatedPosition;
146 } UlpLocation;
147 
148 typedef struct {
149     /** set to sizeof(UlpNmea) */
150     uint32_t          size;
151     char            nmea_str[ULP_MAX_NMEA_STRING_SIZE];
152     unsigned int    len;
153 } UlpNmea;
154 
155 
156 /** AGPS type */
157 typedef int8_t AGpsExtType;
158 #define LOC_AGPS_TYPE_INVALID       -1
159 #define LOC_AGPS_TYPE_ANY           0
160 #define LOC_AGPS_TYPE_SUPL          1
161 #define LOC_AGPS_TYPE_C2K           2
162 #define LOC_AGPS_TYPE_WWAN_ANY      3
163 #define LOC_AGPS_TYPE_WIFI          4
164 #define LOC_AGPS_TYPE_SUPL_ES       5
165 
166 /** SSID length */
167 #define SSID_BUF_SIZE (32+1)
168 
169 typedef int16_t AGpsBearerType;
170 #define AGPS_APN_BEARER_INVALID     0
171 #define AGPS_APN_BEARER_IPV4        1
172 #define AGPS_APN_BEARER_IPV6        2
173 #define AGPS_APN_BEARER_IPV4V6      3
174 
175 typedef uint32_t LocApnTypeMask;
176 /**<  Denotes APN type for Default/Internet traffic  */
177 #define LOC_APN_TYPE_MASK_DEFAULT   ((LocApnTypeMask)0x00000001)
178 /**<  Denotes  APN type for IP Multimedia Subsystem  */
179 #define LOC_APN_TYPE_MASK_IMS       ((LocApnTypeMask)0x00000002)
180 /**<  Denotes APN type for Multimedia Messaging Service  */
181 #define LOC_APN_TYPE_MASK_MMS       ((LocApnTypeMask)0x00000004)
182 /**<  Denotes APN type for Dial Up Network  */
183 #define LOC_APN_TYPE_MASK_DUN       ((LocApnTypeMask)0x00000008)
184 /**<  Denotes APN type for Secure User Plane Location  */
185 #define LOC_APN_TYPE_MASK_SUPL      ((LocApnTypeMask)0x00000010)
186 /**<  Denotes APN type for High Priority Mobile Data  */
187 #define LOC_APN_TYPE_MASK_HIPRI     ((LocApnTypeMask)0x00000020)
188 /**<  Denotes APN type for over the air administration  */
189 #define LOC_APN_TYPE_MASK_FOTA      ((LocApnTypeMask)0x00000040)
190 /**<  Denotes APN type for Carrier Branded Services  */
191 #define LOC_APN_TYPE_MASK_CBS       ((LocApnTypeMask)0x00000080)
192 /**<  Denotes APN type for Initial Attach  */
193 #define LOC_APN_TYPE_MASK_IA        ((LocApnTypeMask)0x00000100)
194 /**<  Denotes APN type for emergency  */
195 #define LOC_APN_TYPE_MASK_EMERGENCY ((LocApnTypeMask)0x00000200)
196 
197 typedef uint32_t AGpsTypeMask;
198 #define AGPS_ATL_TYPE_SUPL       ((AGpsTypeMask)0x00000001)
199 #define AGPS_ATL_TYPE_SUPL_ES   ((AGpsTypeMask)0x00000002)
200 #define AGPS_ATL_TYPE_WWAN       ((AGpsTypeMask)0x00000004)
201 
202 typedef struct {
203     void* statusV4Cb;
204     AGpsTypeMask atlType;
205 } AgpsCbInfo;
206 
207 typedef struct {
208     void* visibilityControlCb;
209     void* isInEmergencySession;
210 } NfwCbInfo;
211 
212 /** GPS extended callback structure. */
213 typedef struct {
214     /** set to sizeof(LocGpsCallbacks) */
215     uint32_t      size;
216     loc_gps_set_capabilities set_capabilities_cb;
217     loc_gps_acquire_wakelock acquire_wakelock_cb;
218     loc_gps_release_wakelock release_wakelock_cb;
219     loc_gps_create_thread create_thread_cb;
220     loc_gps_request_utc_time request_utc_time_cb;
221 } GpsExtCallbacks;
222 
223 /** Callback to report the xtra server url to the client.
224  *  The client should use this url when downloading xtra unless overwritten
225  *  in the gps.conf file
226  */
227 typedef void (* report_xtra_server)(const char*, const char*, const char*);
228 
229 /** Callback structure for the XTRA interface. */
230 typedef struct {
231     loc_gps_xtra_download_request download_request_cb;
232     loc_gps_create_thread create_thread_cb;
233     report_xtra_server report_xtra_server_cb;
234 } GpsXtraExtCallbacks;
235 
236 /** Represents the status of AGPS. */
237 typedef struct {
238     /** set to sizeof(AGpsExtStatus) */
239     uint32_t          size;
240 
241     AGpsExtType type;
242     LocAGpsStatusValue status;
243     uint32_t        ipv4_addr;
244     struct sockaddr_storage addr;
245     char            ssid[SSID_BUF_SIZE];
246     char            password[SSID_BUF_SIZE];
247 } AGpsExtStatus;
248 
249 /** Callback with AGPS status information.
250  *  Can only be called from a thread created by create_thread_cb.
251  */
252 typedef void (* agps_status_extended)(AGpsExtStatus* status);
253 
254 /** Callback structure for the AGPS interface. */
255 typedef struct {
256     agps_status_extended status_cb;
257     loc_gps_create_thread create_thread_cb;
258 } AGpsExtCallbacks;
259 
260 
261 typedef void (*loc_ni_notify_callback)(LocGpsNiNotification *notification, bool esEnalbed);
262 /** GPS NI callback structure. */
263 typedef struct
264 {
265     /**
266      * Sends the notification request from HAL to GPSLocationProvider.
267      */
268     loc_ni_notify_callback notify_cb;
269 } GpsNiExtCallbacks;
270 
271 typedef enum loc_server_type {
272     LOC_AGPS_CDMA_PDE_SERVER,
273     LOC_AGPS_CUSTOM_PDE_SERVER,
274     LOC_AGPS_MPC_SERVER,
275     LOC_AGPS_SUPL_SERVER,
276     LOC_AGPS_MO_SUPL_SERVER
277 } LocServerType;
278 
279 typedef enum loc_position_mode_type {
280     LOC_POSITION_MODE_INVALID = -1,
281     LOC_POSITION_MODE_STANDALONE = 0,
282     LOC_POSITION_MODE_MS_BASED,
283     LOC_POSITION_MODE_MS_ASSISTED,
284     LOC_POSITION_MODE_RESERVED_1,
285     LOC_POSITION_MODE_RESERVED_2,
286     LOC_POSITION_MODE_RESERVED_3,
287     LOC_POSITION_MODE_RESERVED_4,
288     LOC_POSITION_MODE_RESERVED_5
289 
290 } LocPositionMode;
291 
292 /**
293  * @brief Minimum allowed value for fix interval.
294  *
295  * This value is a sanity limit in GPS framework. The hardware has own internal
296  * limits that may not match this value
297  *
298  * @sa GPS_DEFAULT_FIX_INTERVAL_MS
299  */
300 
301 #define GPS_MIN_POSSIBLE_FIX_INTERVAL_MS 100
302 /**
303  * @brief Default value for fix interval.
304  *
305  * This value is used by default whenever appropriate.
306  *
307  * @sa GPS_MIN_POSSIBLE_FIX_INTERVAL_MS
308  */
309 #define GPS_DEFAULT_FIX_INTERVAL_MS      1000
310 
311 /** Flags to indicate which values are valid in a GpsLocationExtended. */
312 typedef uint64_t GpsLocationExtendedFlags;
313 /** GpsLocationExtended has valid pdop, hdop, vdop. */
314 #define GPS_LOCATION_EXTENDED_HAS_DOP 0x0001
315 /** GpsLocationExtended has valid altitude mean sea level. */
316 #define GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL 0x0002
317 /** UlpLocation has valid magnetic deviation. */
318 #define GPS_LOCATION_EXTENDED_HAS_MAG_DEV 0x0004
319 /** UlpLocation has valid mode indicator. */
320 #define GPS_LOCATION_EXTENDED_HAS_MODE_IND 0x0008
321 /** GpsLocationExtended has valid vertical uncertainty */
322 #define GPS_LOCATION_EXTENDED_HAS_VERT_UNC 0x0010
323 /** GpsLocationExtended has valid speed uncertainty */
324 #define GPS_LOCATION_EXTENDED_HAS_SPEED_UNC 0x0020
325 /** GpsLocationExtended has valid heading uncertainty */
326 #define GPS_LOCATION_EXTENDED_HAS_BEARING_UNC 0x0040
327 /** GpsLocationExtended has valid horizontal reliability */
328 #define GPS_LOCATION_EXTENDED_HAS_HOR_RELIABILITY 0x0080
329 /** GpsLocationExtended has valid vertical reliability */
330 #define GPS_LOCATION_EXTENDED_HAS_VERT_RELIABILITY 0x0100
331 /** GpsLocationExtended has valid Horizontal Elliptical Uncertainty (Semi-Major Axis) */
332 #define GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_MAJOR 0x0200
333 /** GpsLocationExtended has valid Horizontal Elliptical Uncertainty (Semi-Minor Axis) */
334 #define GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_MINOR 0x0400
335 /** GpsLocationExtended has valid Elliptical Horizontal Uncertainty Azimuth */
336 #define GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_AZIMUTH 0x0800
337 /** GpsLocationExtended has valid gnss sv used in position data */
338 #define GPS_LOCATION_EXTENDED_HAS_GNSS_SV_USED_DATA 0x1000
339 /** GpsLocationExtended has valid navSolutionMask */
340 #define GPS_LOCATION_EXTENDED_HAS_NAV_SOLUTION_MASK 0x2000
341 /** GpsLocationExtended has valid LocPosTechMask */
342 #define GPS_LOCATION_EXTENDED_HAS_POS_TECH_MASK   0x4000
343 /** GpsLocationExtended has valid LocSvInfoSource */
344 #define GPS_LOCATION_EXTENDED_HAS_SV_SOURCE_INFO   0x8000
345 /** GpsLocationExtended has valid position dynamics data */
346 #define GPS_LOCATION_EXTENDED_HAS_POS_DYNAMICS_DATA   0x10000
347 /** GpsLocationExtended has GPS Time */
348 #define GPS_LOCATION_EXTENDED_HAS_GPS_TIME   0x20000
349 /** GpsLocationExtended has Extended Dilution of Precision */
350 #define GPS_LOCATION_EXTENDED_HAS_EXT_DOP   0x40000
351 /** GpsLocationExtended has North standard deviation */
352 #define GPS_LOCATION_EXTENDED_HAS_NORTH_STD_DEV   0x80000
353 /** GpsLocationExtended has East standard deviation*/
354 #define GPS_LOCATION_EXTENDED_HAS_EAST_STD_DEV   0x100000
355 /** GpsLocationExtended has North Velocity */
356 #define GPS_LOCATION_EXTENDED_HAS_NORTH_VEL   0x200000
357 /** GpsLocationExtended has East Velocity */
358 #define GPS_LOCATION_EXTENDED_HAS_EAST_VEL   0x400000
359 /** GpsLocationExtended has up Velocity */
360 #define GPS_LOCATION_EXTENDED_HAS_UP_VEL   0x800000
361 /** GpsLocationExtended has North Velocity Uncertainty */
362 #define GPS_LOCATION_EXTENDED_HAS_NORTH_VEL_UNC   0x1000000
363 /** GpsLocationExtended has East Velocity Uncertainty */
364 #define GPS_LOCATION_EXTENDED_HAS_EAST_VEL_UNC   0x2000000
365 /** GpsLocationExtended has up Velocity Uncertainty */
366 #define GPS_LOCATION_EXTENDED_HAS_UP_VEL_UNC   0x4000000
367 /** GpsLocationExtended has Clock Bias */
368 #define GPS_LOCATION_EXTENDED_HAS_CLOCK_BIAS   0x8000000
369 /** GpsLocationExtended has Clock Bias std deviation*/
370 #define GPS_LOCATION_EXTENDED_HAS_CLOCK_BIAS_STD_DEV   0x10000000
371 /** GpsLocationExtended has Clock drift*/
372 #define GPS_LOCATION_EXTENDED_HAS_CLOCK_DRIFT   0x20000000
373 /** GpsLocationExtended has Clock drift std deviation**/
374 #define GPS_LOCATION_EXTENDED_HAS_CLOCK_DRIFT_STD_DEV    0x40000000
375 /** GpsLocationExtended has leap seconds **/
376 #define GPS_LOCATION_EXTENDED_HAS_LEAP_SECONDS           0x80000000
377 /** GpsLocationExtended has time uncertainty **/
378 #define GPS_LOCATION_EXTENDED_HAS_TIME_UNC               0x100000000
379 /** GpsLocationExtended has heading rate  **/
380 #define GPS_LOCATION_EXTENDED_HAS_HEADING_RATE           0x200000000
381 /** GpsLocationExtended has multiband signals  **/
382 #define GPS_LOCATION_EXTENDED_HAS_MULTIBAND              0x400000000
383 /** GpsLocationExtended has sensor calibration confidence */
384 #define GPS_LOCATION_EXTENDED_HAS_CALIBRATION_CONFIDENCE 0x800000000
385 /** GpsLocationExtended has sensor calibration status */
386 #define GPS_LOCATION_EXTENDED_HAS_CALIBRATION_STATUS     0x1000000000
387 /** GpsLocationExtended has the engine type that produced this
388  *  position, the bit mask will only be set when there are two
389  *  or more position engines running in the system */
390 #define GPS_LOCATION_EXTENDED_HAS_OUTPUT_ENG_TYPE       0x2000000000
391  /** GpsLocationExtended has the engine mask that indicates the
392   *     set of engines contribute to the fix. */
393 #define GPS_LOCATION_EXTENDED_HAS_OUTPUT_ENG_MASK       0x4000000000
394 
395 typedef uint32_t LocNavSolutionMask;
396 /* Bitmask to specify whether SBAS ionospheric correction is used  */
397 #define LOC_NAV_MASK_SBAS_CORRECTION_IONO ((LocNavSolutionMask)0x0001)
398 /* Bitmask to specify whether SBAS fast correction is used  */
399 #define LOC_NAV_MASK_SBAS_CORRECTION_FAST ((LocNavSolutionMask)0x0002)
400 /**<  Bitmask to specify whether SBAS long-tem correction is used  */
401 #define LOC_NAV_MASK_SBAS_CORRECTION_LONG ((LocNavSolutionMask)0x0004)
402 /**<  Bitmask to specify whether SBAS integrity information is used  */
403 #define LOC_NAV_MASK_SBAS_INTEGRITY ((LocNavSolutionMask)0x0008)
404 /**<  Bitmask to specify whether Position Report is DGNSS corrected  */
405 #define LOC_NAV_MASK_DGNSS_CORRECTION ((LocNavSolutionMask)0x0010)
406 /**<  Bitmask to specify whether Position Report is RTK corrected   */
407 #define LOC_NAV_MASK_RTK_CORRECTION ((LocNavSolutionMask)0x0020)
408 /**<  Bitmask to specify whether Position Report is PPP corrected   */
409 #define LOC_NAV_MASK_PPP_CORRECTION ((LocNavSolutionMask)0x0040)
410 /**<  Bitmask to specify whether Position Report is RTK fixed corrected   */
411 #define LOC_NAV_MASK_RTK_FIXED_CORRECTION ((LocNavSolutionMask)0x0080)
412 
413 typedef uint32_t LocPosDataMask;
414 /* Bitmask to specify whether Navigation data has Forward Acceleration  */
415 #define LOC_NAV_DATA_HAS_LONG_ACCEL ((LocPosDataMask)0x0001)
416 /* Bitmask to specify whether Navigation data has Sideward Acceleration */
417 #define LOC_NAV_DATA_HAS_LAT_ACCEL ((LocPosDataMask)0x0002)
418 /* Bitmask to specify whether Navigation data has Vertical Acceleration */
419 #define LOC_NAV_DATA_HAS_VERT_ACCEL ((LocPosDataMask)0x0004)
420 /* Bitmask to specify whether Navigation data has Heading Rate */
421 #define LOC_NAV_DATA_HAS_YAW_RATE ((LocPosDataMask)0x0008)
422 /* Bitmask to specify whether Navigation data has Body pitch */
423 #define LOC_NAV_DATA_HAS_PITCH ((LocPosDataMask)0x0010)
424 /* Bitmask to specify whether Navigation data has Forward Acceleration Unc  */
425 #define LOC_NAV_DATA_HAS_LONG_ACCEL_UNC ((LocPosDataMask)0x0020)
426 /* Bitmask to specify whether Navigation data has Sideward Acceleration Unc*/
427 #define LOC_NAV_DATA_HAS_LAT_ACCEL_UNC ((LocPosDataMask)0x0040)
428 /* Bitmask to specify whether Navigation data has Vertical Acceleration Unc*/
429 #define LOC_NAV_DATA_HAS_VERT_ACCEL_UNC ((LocPosDataMask)0x0080)
430 /* Bitmask to specify whether Navigation data has Heading Rate Unc*/
431 #define LOC_NAV_DATA_HAS_YAW_RATE_UNC ((LocPosDataMask)0x0100)
432 /* Bitmask to specify whether Navigation data has Body pitch Unc*/
433 #define LOC_NAV_DATA_HAS_PITCH_UNC ((LocPosDataMask)0x0200)
434 
435 typedef uint32_t GnssAdditionalSystemInfoMask;
436 /* Bitmask to specify whether Tauc is valid */
437 #define GNSS_ADDITIONAL_SYSTEMINFO_HAS_TAUC ((GnssAdditionalSystemInfoMask)0x0001)
438 /* Bitmask to specify whether leapSec is valid */
439 #define GNSS_ADDITIONAL_SYSTEMINFO_HAS_LEAP_SEC ((GnssAdditionalSystemInfoMask)0x0002)
440 
441 
442 /** GPS PRN Range */
443 #define GPS_SV_PRN_MIN      1
444 #define GPS_SV_PRN_MAX      32
445 #define SBAS_SV_PRN_MIN     33
446 #define SBAS_SV_PRN_MAX     64
447 #define GLO_SV_PRN_MIN      65
448 #define GLO_SV_PRN_MAX      96
449 #define QZSS_SV_PRN_MIN     193
450 #define QZSS_SV_PRN_MAX     197
451 #define BDS_SV_PRN_MIN      201
452 #define BDS_SV_PRN_MAX      235
453 #define GAL_SV_PRN_MIN      301
454 #define GAL_SV_PRN_MAX      336
455 #define NAVIC_SV_PRN_MIN    401
456 #define NAVIC_SV_PRN_MAX    414
457 
458 typedef enum {
459     LOC_RELIABILITY_NOT_SET = 0,
460     LOC_RELIABILITY_VERY_LOW = 1,
461     LOC_RELIABILITY_LOW = 2,
462     LOC_RELIABILITY_MEDIUM = 3,
463     LOC_RELIABILITY_HIGH = 4
464 }LocReliability;
465 
466 typedef enum {
467     LOC_IN_EMERGENCY_UNKNOWN = 0,
468     LOC_IN_EMERGENCY_SET = 1,
469     LOC_IN_EMERGENCY_NOT_SET = 2
470 }LocInEmergency;
471 
472 typedef struct {
473     struct timespec32_t apTimeStamp;
474     /*boottime received from pps-ktimer*/
475     float apTimeStampUncertaintyMs;
476     /* timestamp uncertainty in milli seconds */
477 }Gnss_ApTimeStampStructType;
478 
479 typedef struct {
480     uint64_t gps_sv_used_ids_mask;
481     uint64_t glo_sv_used_ids_mask;
482     uint64_t gal_sv_used_ids_mask;
483     uint64_t bds_sv_used_ids_mask;
484     uint64_t qzss_sv_used_ids_mask;
485     uint64_t navic_sv_used_ids_mask;
486 } GnssSvUsedInPosition;
487 
488 typedef struct {
489     uint64_t gps_l1ca_sv_used_ids_mask;     // GPS L1CA
490     uint64_t gps_l1c_sv_used_ids_mask;      // GPS L1C
491     uint64_t gps_l2_sv_used_ids_mask;       // GPS L2
492     uint64_t gps_l5_sv_used_ids_mask;       // GPS L5
493     uint64_t glo_g1_sv_used_ids_mask;       // GLO G1
494     uint64_t glo_g2_sv_used_ids_mask;       // GLO G2
495     uint64_t gal_e1_sv_used_ids_mask;       // GAL E1
496     uint64_t gal_e5a_sv_used_ids_mask;      // GAL E5A
497     uint64_t gal_e5b_sv_used_ids_mask;      // GAL E5B
498     uint64_t bds_b1i_sv_used_ids_mask;      // BDS B1I
499     uint64_t bds_b1c_sv_used_ids_mask;      // BDS B1C
500     uint64_t bds_b2i_sv_used_ids_mask;      // BDS B2I
501     uint64_t bds_b2ai_sv_used_ids_mask;     // BDS B2AI
502     uint64_t qzss_l1ca_sv_used_ids_mask;    // QZSS L1CA
503     uint64_t qzss_l1s_sv_used_ids_mask;     // QZSS L1S
504     uint64_t qzss_l2_sv_used_ids_mask;      // QZSS L2
505     uint64_t qzss_l5_sv_used_ids_mask;      // QZSS L5
506     uint64_t sbas_l1_sv_used_ids_mask;      // SBAS L1
507     uint64_t bds_b2aq_sv_used_ids_mask;     // BDS B2AQ
508 } GnssSvMbUsedInPosition;
509 
510 /* Body Frame parameters */
511 typedef struct {
512     /** Contains Body frame LocPosDataMask bits. */
513    uint32_t        bodyFrameDatamask;
514    /* Forward Acceleration in body frame (m/s2)*/
515    float           longAccel;
516    /** Uncertainty of Forward Acceleration in body frame */
517    float           longAccelUnc;
518    /* Sideward Acceleration in body frame (m/s2)*/
519    float           latAccel;
520    /** Uncertainty of Side-ward Acceleration in body frame */
521    float           latAccelUnc;
522    /* Vertical Acceleration in body frame (m/s2)*/
523    float           vertAccel;
524    /** Uncertainty of Vertical Acceleration in body frame */
525    float           vertAccelUnc;
526    /* Heading Rate (Radians/second) */
527    float           yawRate;
528    /** Uncertainty of Heading Rate */
529    float           yawRateUnc;
530    /* Body pitch (Radians) */
531    float           pitch;
532    /** Uncertainty of Body pitch */
533    float           pitchRadUnc;
534 }LocPositionDynamics;
535 
536 typedef struct {
537 
538   /**  Position dilution of precision.
539        Range: 1 (highest accuracy) to 50 (lowest accuracy) */
540   float PDOP;
541 
542   /**  Horizontal dilution of precision.
543        Range: 1 (highest accuracy) to 50 (lowest accuracy) */
544   float HDOP;
545 
546   /**  Vertical dilution of precision.
547        Range: 1 (highest accuracy) to 50 (lowest accuracy) */
548   float VDOP;
549 
550   /**  geometric  dilution of precision.
551        Range: 1 (highest accuracy) to 50 (lowest accuracy) */
552   float GDOP;
553 
554   /**  time dilution of precision.
555        Range: 1 (highest accuracy) to 50 (lowest accuracy) */
556   float TDOP;
557 }LocExtDOP;
558 
559 /* GPS Time structure */
560 typedef struct {
561 
562   /**<   Current GPS week as calculated from midnight, Jan. 6, 1980. \n
563        - Units: Weeks */
564   uint16_t gpsWeek;
565 
566   /**<   Amount of time into the current GPS week. \n
567        - Units: Milliseconds */
568   uint32_t gpsTimeOfWeekMs;
569 }GPSTimeStruct;
570 
571 typedef uint8_t CarrierPhaseAmbiguityType;
572 #define CARRIER_PHASE_AMBIGUITY_RESOLUTION_NONE ((CarrierPhaseAmbiguityType)0)
573 #define CARRIER_PHASE_AMBIGUITY_RESOLUTION_FLOAT ((CarrierPhaseAmbiguityType)1)
574 #define CARRIER_PHASE_AMBIGUITY_RESOLUTION_FIXED ((CarrierPhaseAmbiguityType)2)
575 
576 /** GNSS Signal Type and RF Band */
577 typedef uint32_t GnssSignalTypeMask;
578 /** GPS L1CA Signal */
579 #define GNSS_SIGNAL_GPS_L1CA     ((GnssSignalTypeMask)0x00000001ul)
580 /** GPS L1C Signal */
581 #define GNSS_SIGNAL_GPS_L1C      ((GnssSignalTypeMask)0x00000002ul)
582 /** GPS L2 RF Band */
583 #define GNSS_SIGNAL_GPS_L2       ((GnssSignalTypeMask)0x00000004ul)
584 /** GPS L5 RF Band */
585 #define GNSS_SIGNAL_GPS_L5       ((GnssSignalTypeMask)0x00000008ul)
586 /** GLONASS G1 (L1OF) RF Band */
587 #define GNSS_SIGNAL_GLONASS_G1   ((GnssSignalTypeMask)0x00000010ul)
588 /** GLONASS G2 (L2OF) RF Band */
589 #define GNSS_SIGNAL_GLONASS_G2   ((GnssSignalTypeMask)0x00000020ul)
590 /** GALILEO E1 RF Band */
591 #define GNSS_SIGNAL_GALILEO_E1   ((GnssSignalTypeMask)0x00000040ul)
592 /** GALILEO E5A RF Band */
593 #define GNSS_SIGNAL_GALILEO_E5A  ((GnssSignalTypeMask)0x00000080ul)
594 /** GALILEO E5B RF Band */
595 #define GNSS_SIGNAL_GALILIEO_E5B ((GnssSignalTypeMask)0x00000100ul)
596 /** BEIDOU B1_I RF Band */
597 #define GNSS_SIGNAL_BEIDOU_B1I    ((GnssSignalTypeMask)0x00000200ul)
598 /** BEIDOU B1C RF Band */
599 #define GNSS_SIGNAL_BEIDOU_B1C    ((GnssSignalTypeMask)0x00000400ul)
600 /** BEIDOU B2_I RF Band */
601 #define GNSS_SIGNAL_BEIDOU_B2I    ((GnssSignalTypeMask)0x00000800ul)
602 /** BEIDOU B2A_I RF Band */
603 #define GNSS_SIGNAL_BEIDOU_B2AI   ((GnssSignalTypeMask)0x00001000ul)
604 /** QZSS L1CA RF Band */
605 #define GNSS_SIGNAL_QZSS_L1CA     ((GnssSignalTypeMask)0x00002000ul)
606 /** QZSS L1S RF Band */
607 #define GNSS_SIGNAL_QZSS_L1S      ((GnssSignalTypeMask)0x00004000ul)
608 /** QZSS L2 RF Band */
609 #define GNSS_SIGNAL_QZSS_L2      ((GnssSignalTypeMask)0x00008000ul)
610 /** QZSS L5 RF Band */
611 #define GNSS_SIGNAL_QZSS_L5      ((GnssSignalTypeMask)0x00010000ul)
612 /** SBAS L1 RF Band */
613 #define GNSS_SIGNAL_SBAS_L1      ((GnssSignalTypeMask)0x00020000ul)
614 /** NAVIC L5 RF Band */
615 #define GNSS_SIGNAL_NAVIC_L5     ((GnssSignalTypeMask)0x00040000ul)
616 /** BEIDOU B2A_Q RF Band */
617 #define GNSS_SIGNAL_BEIDOU_B2AQ   ((GnssSignalTypeMask)0x00080000ul)
618 
619 typedef uint16_t GnssMeasUsageStatusBitMask;
620 /** Used in fix */
621 #define GNSS_MEAS_USED_IN_PVT ((GnssMeasUsageStatusBitMask)0x00000001ul)
622 /** Measurement is Bad */
623 #define GNSS_MEAS_USAGE_STATUS_BAD_MEAS ((GnssMeasUsageStatusBitMask)0x00000002ul)
624 /** Measurement has too low C/N */
625 #define GNSS_MEAS_USAGE_STATUS_CNO_TOO_LOW ((GnssMeasUsageStatusBitMask)0x00000004ul)
626 /** Measurement has too low elevation */
627 #define GNSS_MEAS_USAGE_STATUS_ELEVATION_TOO_LOW ((GnssMeasUsageStatusBitMask)0x00000008ul)
628 /** No ephemeris available for this measurement */
629 #define GNSS_MEAS_USAGE_STATUS_NO_EPHEMERIS ((GnssMeasUsageStatusBitMask)0x00000010ul)
630 /** No corrections available for the measurement */
631 #define GNSS_MEAS_USAGE_STATUS_NO_CORRECTIONS ((GnssMeasUsageStatusBitMask)0x00000020ul)
632 /** Corrections has timed out for the measurement */
633 #define GNSS_MEAS_USAGE_STATUS_CORRECTION_TIMEOUT ((GnssMeasUsageStatusBitMask)0x00000040ul)
634 /** Measurement is unhealthy */
635 #define GNSS_MEAS_USAGE_STATUS_UNHEALTHY ((GnssMeasUsageStatusBitMask)0x00000080ul)
636 /** Configuration is disabled for this measurement */
637 #define GNSS_MEAS_USAGE_STATUS_CONFIG_DISABLED ((GnssMeasUsageStatusBitMask)0x00000100ul)
638 /** Measurement not used for other reasons */
639 #define GNSS_MEAS_USAGE_STATUS_OTHER ((GnssMeasUsageStatusBitMask)0x00000200ul)
640 
641 /** Flags to indicate valid fields in epMeasUsageInfo */
642 typedef uint16_t GnssMeasUsageInfoValidityMask;
643 #define GNSS_PSEUDO_RANGE_RESIDUAL_VALID        ((GnssMeasUsageInfoValidityMask)0x00000001ul)
644 #define GNSS_DOPPLER_RESIDUAL_VALID             ((GnssMeasUsageInfoValidityMask)0x00000002ul)
645 #define GNSS_CARRIER_PHASE_RESIDUAL_VALID       ((GnssMeasUsageInfoValidityMask)0x00000004ul)
646 #define GNSS_CARRIER_PHASE_AMBIGUITY_TYPE_VALID ((GnssMeasUsageInfoValidityMask)0x00000008ul)
647 
648 typedef uint16_t GnssSvPolyStatusMask;
649 #define GNSS_SV_POLY_SRC_ALM_CORR_V02 ((GnssSvPolyStatusMask)0x01)
650 #define GNSS_SV_POLY_GLO_STR4_V02 ((GnssSvPolyStatusMask)0x02)
651 #define GNSS_SV_POLY_DELETE_V02 ((GnssSvPolyStatusMask)0x04)
652 #define GNSS_SV_POLY_SRC_GAL_FNAV_OR_INAV_V02 ((GnssSvPolyStatusMask)0x08)
653 typedef uint16_t GnssSvPolyStatusMaskValidity;
654 #define GNSS_SV_POLY_SRC_ALM_CORR_VALID_V02 ((GnssSvPolyStatusMaskValidity)0x01)
655 #define GNSS_SV_POLY_GLO_STR4_VALID_V02 ((GnssSvPolyStatusMaskValidity)0x02)
656 #define GNSS_SV_POLY_DELETE_VALID_V02 ((GnssSvPolyStatusMaskValidity)0x04)
657 #define GNSS_SV_POLY_SRC_GAL_FNAV_OR_INAV_VALID_V02 ((GnssSvPolyStatusMaskValidity)0x08)
658 
659 
660 typedef struct {
661     /** Specifies GNSS signal type
662         Mandatory Field*/
663     GnssSignalTypeMask gnssSignalType;
664     /** Specifies GNSS Constellation Type
665         Mandatory Field*/
666     Gnss_LocSvSystemEnumType gnssConstellation;
667     /**  GNSS SV ID.
668          For GPS:      1 to 32
669          For GLONASS:  65 to 96. When slot-number to SV ID mapping is unknown, set as 255.
670          For SBAS:     120 to 151
671          For QZSS-L1CA:193 to 197
672          For BDS:      201 to 237
673          For GAL:      301 to 336 */
674     uint16_t gnssSvId;
675     /** GLONASS frequency number + 7.
676         Valid only for a GLONASS system and
677         is to be ignored for all other systems.
678         Range: 1 to 14 */
679     uint8_t gloFrequency;
680     /** Carrier phase ambiguity type. */
681     CarrierPhaseAmbiguityType carrierPhaseAmbiguityType;
682     /** Validity mask */
683     GnssMeasUsageStatusBitMask measUsageStatusMask;
684     /** Specifies measurement usage status
685         Mandatory Field*/
686     GnssMeasUsageInfoValidityMask validityMask;
687     /** Computed pseudorange residual.
688         Unit: Meters */
689     float pseudorangeResidual;
690     /** Computed doppler residual.
691         Unit: Meters/sec*/
692     float dopplerResidual;
693     /** Computed carrier phase residual.
694         Unit: Cycles*/
695     float carrierPhaseResidual;
696     /** Carrier phase ambiguity value.
697         Unit: Cycles*/
698     float carrierPhasAmbiguity;
699 } GpsMeasUsageInfo;
700 
701 
702 /** Represents gps location extended. */
703 typedef struct {
704     /** set to sizeof(GpsLocationExtended) */
705     uint32_t          size;
706     /** Contains GpsLocationExtendedFlags bits. */
707     uint64_t        flags;
708     /** Contains the Altitude wrt mean sea level */
709     float           altitudeMeanSeaLevel;
710     /** Contains Position Dilusion of Precision. */
711     float           pdop;
712     /** Contains Horizontal Dilusion of Precision. */
713     float           hdop;
714     /** Contains Vertical Dilusion of Precision. */
715     float           vdop;
716     /** Contains Magnetic Deviation. */
717     float           magneticDeviation;
718     /** vertical uncertainty in meters */
719     float           vert_unc;
720     /** speed uncertainty in m/s */
721     float           speed_unc;
722     /** heading uncertainty in degrees (0 to 359.999) */
723     float           bearing_unc;
724     /** horizontal reliability. */
725     LocReliability  horizontal_reliability;
726     /** vertical reliability. */
727     LocReliability  vertical_reliability;
728     /*  Horizontal Elliptical Uncertainty (Semi-Major Axis) */
729     float           horUncEllipseSemiMajor;
730     /*  Horizontal Elliptical Uncertainty (Semi-Minor Axis) */
731     float           horUncEllipseSemiMinor;
732     /*    Elliptical Horizontal Uncertainty Azimuth */
733     float           horUncEllipseOrientAzimuth;
734 
735     Gnss_ApTimeStampStructType               timeStamp;
736     /** Gnss sv used in position data */
737     GnssSvUsedInPosition gnss_sv_used_ids;
738     /** Gnss sv used in position data for multiband */
739     GnssSvMbUsedInPosition gnss_mb_sv_used_ids;
740     /** Nav solution mask to indicate sbas corrections */
741     LocNavSolutionMask  navSolutionMask;
742     /** Position technology used in computing this fix */
743     LocPosTechMask tech_mask;
744     /** SV Info source used in computing this fix */
745     LocSvInfoSource sv_source;
746     /** Body Frame Dynamics: 4wayAcceleration and pitch set with validity */
747     GnssLocationPositionDynamics bodyFrameData;
748     /** GPS Time */
749     GPSTimeStruct gpsTime;
750     GnssSystemTime gnssSystemTime;
751     /** Dilution of precision associated with this position*/
752     LocExtDOP extDOP;
753     /** North standard deviation.
754         Unit: Meters */
755     float northStdDeviation;
756     /** East standard deviation.
757         Unit: Meters */
758     float eastStdDeviation;
759     /** North Velocity.
760         Unit: Meters/sec */
761     float northVelocity;
762     /** East Velocity.
763         Unit: Meters/sec */
764     float eastVelocity;
765     /** Up Velocity.
766         Unit: Meters/sec */
767     float upVelocity;
768     /** North Velocity standard deviation.
769         Unit: Meters/sec */
770     float northVelocityStdDeviation;
771     /** East Velocity standard deviation.
772         Unit: Meters/sec */
773     float eastVelocityStdDeviation;
774     /** Up Velocity standard deviation
775         Unit: Meters/sec */
776     float upVelocityStdDeviation;
777     /** Estimated clock bias. Unit: Nano seconds */
778     float clockbiasMeter;
779     /** Estimated clock bias std deviation. Unit: Nano seconds */
780     float clockBiasStdDeviationMeter;
781     /** Estimated clock drift. Unit: Meters/sec */
782     float clockDrift;
783     /** Estimated clock drift std deviation. Unit: Meters/sec */
784     float clockDriftStdDeviation;
785     /** Number of valid reference stations. Range:[0-4] */
786     uint8_t numValidRefStations;
787     /** Reference station(s) number */
788     uint16_t referenceStation[4];
789     /** Number of measurements received for use in fix.
790         Shall be used as maximum index in-to svUsageInfo[].
791         Set to 0, if svUsageInfo reporting is not supported.
792         Range: 0-EP_GNSS_MAX_MEAS */
793     uint8_t numOfMeasReceived;
794     /** Measurement Usage Information */
795     GpsMeasUsageInfo measUsageInfo[GNSS_SV_MAX];
796     /** Leap Seconds */
797     uint8_t leapSeconds;
798     /** Time uncertainty in milliseconds   */
799     float timeUncMs;
800     /** Heading Rate is in NED frame.
801         Range: 0 to 359.999. 946
802         Unit: Degrees per Seconds */
803     float headingRateDeg;
804     /** Sensor calibration confidence percent. Range: 0 - 100 */
805     uint8_t calibrationConfidence;
806     DrCalibrationStatusMask calibrationStatus;
807     /* location engine type. When the fix. when the type is set to
808         LOC_ENGINE_SRC_FUSED, the fix is the propagated/aggregated
809         reports from all engines running on the system (e.g.:
810         DR/SPE/PPE). To check which location engine contributes to
811         the fused output, check for locOutputEngMask. */
812     LocOutputEngineType locOutputEngType;
813     /* when loc output eng type is set to fused, this field
814         indicates the set of engines contribute to the fix. */
815     PositioningEngineMask locOutputEngMask;
816 } GpsLocationExtended;
817 
818 enum loc_sess_status {
819     LOC_SESS_SUCCESS,
820     LOC_SESS_INTERMEDIATE,
821     LOC_SESS_FAILURE
822 };
823 
824 // struct that contains complete position info from engine
825 typedef struct {
826     UlpLocation location;
827     GpsLocationExtended locationExtended;
828     enum loc_sess_status sessionStatus;
829 } EngineLocationInfo;
830 
831 // Nmea sentence types mask
832 typedef uint32_t NmeaSentenceTypesMask;
833 #define LOC_NMEA_MASK_GGA_V02   ((NmeaSentenceTypesMask)0x00000001) /**<  Enable GGA type  */
834 #define LOC_NMEA_MASK_RMC_V02   ((NmeaSentenceTypesMask)0x00000002) /**<  Enable RMC type  */
835 #define LOC_NMEA_MASK_GSV_V02   ((NmeaSentenceTypesMask)0x00000004) /**<  Enable GSV type  */
836 #define LOC_NMEA_MASK_GSA_V02   ((NmeaSentenceTypesMask)0x00000008) /**<  Enable GSA type  */
837 #define LOC_NMEA_MASK_VTG_V02   ((NmeaSentenceTypesMask)0x00000010) /**<  Enable VTG type  */
838 #define LOC_NMEA_MASK_PQXFI_V02 ((NmeaSentenceTypesMask)0x00000020) /**<  Enable PQXFI type  */
839 #define LOC_NMEA_MASK_PSTIS_V02 ((NmeaSentenceTypesMask)0x00000040) /**<  Enable PSTIS type  */
840 #define LOC_NMEA_MASK_GLGSV_V02 ((NmeaSentenceTypesMask)0x00000080) /**<  Enable GLGSV type  */
841 #define LOC_NMEA_MASK_GNGSA_V02 ((NmeaSentenceTypesMask)0x00000100) /**<  Enable GNGSA type  */
842 #define LOC_NMEA_MASK_GNGNS_V02 ((NmeaSentenceTypesMask)0x00000200) /**<  Enable GNGNS type  */
843 #define LOC_NMEA_MASK_GARMC_V02 ((NmeaSentenceTypesMask)0x00000400) /**<  Enable GARMC type  */
844 #define LOC_NMEA_MASK_GAGSV_V02 ((NmeaSentenceTypesMask)0x00000800) /**<  Enable GAGSV type  */
845 #define LOC_NMEA_MASK_GAGSA_V02 ((NmeaSentenceTypesMask)0x00001000) /**<  Enable GAGSA type  */
846 #define LOC_NMEA_MASK_GAVTG_V02 ((NmeaSentenceTypesMask)0x00002000) /**<  Enable GAVTG type  */
847 #define LOC_NMEA_MASK_GAGGA_V02 ((NmeaSentenceTypesMask)0x00004000) /**<  Enable GAGGA type  */
848 #define LOC_NMEA_MASK_PQGSA_V02 ((NmeaSentenceTypesMask)0x00008000) /**<  Enable PQGSA type  */
849 #define LOC_NMEA_MASK_PQGSV_V02 ((NmeaSentenceTypesMask)0x00010000) /**<  Enable PQGSV type  */
850 #define LOC_NMEA_MASK_DEBUG_V02 ((NmeaSentenceTypesMask)0x00020000) /**<  Enable DEBUG type  */
851 #define LOC_NMEA_MASK_GPDTM_V02 ((NmeaSentenceTypesMask)0x00040000) /**<  Enable GPDTM type  */
852 #define LOC_NMEA_MASK_GNGGA_V02 ((NmeaSentenceTypesMask)0x00080000) /**<  Enable GNGGA type  */
853 #define LOC_NMEA_MASK_GNRMC_V02 ((NmeaSentenceTypesMask)0x00100000) /**<  Enable GNRMC type  */
854 #define LOC_NMEA_MASK_GNVTG_V02 ((NmeaSentenceTypesMask)0x00200000) /**<  Enable GNVTG type  */
855 #define LOC_NMEA_MASK_GAGNS_V02 ((NmeaSentenceTypesMask)0x00400000) /**<  Enable GAGNS type  */
856 #define LOC_NMEA_MASK_GBGGA_V02 ((NmeaSentenceTypesMask)0x00800000) /**<  Enable GBGGA type  */
857 #define LOC_NMEA_MASK_GBGSA_V02 ((NmeaSentenceTypesMask)0x01000000) /**<  Enable GBGSA type  */
858 #define LOC_NMEA_MASK_GBGSV_V02 ((NmeaSentenceTypesMask)0x02000000) /**<  Enable GBGSV type  */
859 #define LOC_NMEA_MASK_GBRMC_V02 ((NmeaSentenceTypesMask)0x04000000) /**<  Enable GBRMC type  */
860 #define LOC_NMEA_MASK_GBVTG_V02 ((NmeaSentenceTypesMask)0x08000000) /**<  Enable GBVTG type  */
861 #define LOC_NMEA_MASK_GQGSV_V02 ((NmeaSentenceTypesMask)0x10000000) /**<  Enable GQGSV type  */
862 #define LOC_NMEA_MASK_GIGSV_V02 ((NmeaSentenceTypesMask)0x20000000) /**<  Enable GIGSV type  */
863 #define LOC_NMEA_MASK_GNDTM_V02 ((NmeaSentenceTypesMask)0x40000000) /**<  Enable GNDTM type  */
864 
865 
866 // all bitmasks of general supported NMEA sentenses - debug is not part of this
867 #define LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK  (LOC_NMEA_MASK_GGA_V02 | LOC_NMEA_MASK_RMC_V02 | \
868               LOC_NMEA_MASK_GSV_V02 | LOC_NMEA_MASK_GSA_V02 | LOC_NMEA_MASK_VTG_V02 | \
869         LOC_NMEA_MASK_PQXFI_V02 | LOC_NMEA_MASK_PSTIS_V02 | LOC_NMEA_MASK_GLGSV_V02 | \
870         LOC_NMEA_MASK_GNGSA_V02 | LOC_NMEA_MASK_GNGNS_V02 | LOC_NMEA_MASK_GARMC_V02 | \
871         LOC_NMEA_MASK_GAGSV_V02 | LOC_NMEA_MASK_GAGSA_V02 | LOC_NMEA_MASK_GAVTG_V02 | \
872         LOC_NMEA_MASK_GAGGA_V02 | LOC_NMEA_MASK_PQGSA_V02 | LOC_NMEA_MASK_PQGSV_V02 | \
873         LOC_NMEA_MASK_GPDTM_V02 | LOC_NMEA_MASK_GNGGA_V02 | LOC_NMEA_MASK_GNRMC_V02 | \
874         LOC_NMEA_MASK_GNVTG_V02 | LOC_NMEA_MASK_GAGNS_V02 | LOC_NMEA_MASK_GBGGA_V02 | \
875         LOC_NMEA_MASK_GBGSA_V02 | LOC_NMEA_MASK_GBGSV_V02 | LOC_NMEA_MASK_GBRMC_V02 | \
876         LOC_NMEA_MASK_GBVTG_V02 | LOC_NMEA_MASK_GQGSV_V02 | LOC_NMEA_MASK_GIGSV_V02 | \
877         LOC_NMEA_MASK_GNDTM_V02)
878 
879 typedef enum {
880   LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0,
881   LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,
882   LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,
883   LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
884   LOC_ENG_IF_REQUEST_SENDER_ID_MODEM,
885   LOC_ENG_IF_REQUEST_SENDER_ID_UNKNOWN
886 } loc_if_req_sender_id_e_type;
887 
888 
889 #define smaller_of(a, b) (((a) > (b)) ? (b) : (a))
890 #define MAX_APN_LEN 100
891 
892 // This will be overridden by the individual adapters
893 // if necessary.
894 #define DEFAULT_IMPL(rtv)                                     \
895 {                                                             \
896     LOC_LOGD("%s: default implementation invoked", __func__); \
897     return rtv;                                               \
898 }
899 
900 enum loc_api_adapter_err {
901     LOC_API_ADAPTER_ERR_SUCCESS             = 0,
902     LOC_API_ADAPTER_ERR_GENERAL_FAILURE     = 1,
903     LOC_API_ADAPTER_ERR_UNSUPPORTED         = 2,
904     LOC_API_ADAPTER_ERR_INVALID_HANDLE      = 4,
905     LOC_API_ADAPTER_ERR_INVALID_PARAMETER   = 5,
906     LOC_API_ADAPTER_ERR_ENGINE_BUSY         = 6,
907     LOC_API_ADAPTER_ERR_PHONE_OFFLINE       = 7,
908     LOC_API_ADAPTER_ERR_TIMEOUT             = 8,
909     LOC_API_ADAPTER_ERR_SERVICE_NOT_PRESENT = 9,
910     LOC_API_ADAPTER_ERR_INTERNAL            = 10,
911 
912     /* equating engine down to phone offline, as they are the same errror */
913     LOC_API_ADAPTER_ERR_ENGINE_DOWN         = LOC_API_ADAPTER_ERR_PHONE_OFFLINE,
914     LOC_API_ADAPTER_ERR_FAILURE             = 101,
915     LOC_API_ADAPTER_ERR_UNKNOWN
916 };
917 
918 enum loc_api_adapter_event_index {
919     LOC_API_ADAPTER_REPORT_POSITION = 0,               // Position report comes in loc_parsed_position_s_type
920     LOC_API_ADAPTER_REPORT_SATELLITE,                  // Satellite in view report
921     LOC_API_ADAPTER_REPORT_NMEA_1HZ,                   // NMEA report at 1HZ rate
922     LOC_API_ADAPTER_REPORT_NMEA_POSITION,              // NMEA report at position report rate
923     LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY,          // NI notification/verification request
924     LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA,           // Assistance data, eg: time, predicted orbits request
925     LOC_API_ADAPTER_REQUEST_LOCATION_SERVER,           // Request for location server
926     LOC_API_ADAPTER_REPORT_IOCTL,                      // Callback report for loc_ioctl
927     LOC_API_ADAPTER_REPORT_STATUS,                     // Misc status report: eg, engine state
928     LOC_API_ADAPTER_REQUEST_WIFI,                      //
929     LOC_API_ADAPTER_SENSOR_STATUS,                     //
930     LOC_API_ADAPTER_REQUEST_TIME_SYNC,                 //
931     LOC_API_ADAPTER_REPORT_SPI,                        //
932     LOC_API_ADAPTER_REPORT_NI_GEOFENCE,                //
933     LOC_API_ADAPTER_GEOFENCE_GEN_ALERT,                //
934     LOC_API_ADAPTER_REPORT_GENFENCE_BREACH,            //
935     LOC_API_ADAPTER_PEDOMETER_CTRL,                    //
936     LOC_API_ADAPTER_MOTION_CTRL,                       //
937     LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA,              // Wifi ap data
938     LOC_API_ADAPTER_BATCH_FULL,                        // Batching on full
939     LOC_API_ADAPTER_BATCHED_POSITION_REPORT,           // Batching on fix
940     LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT,    //
941     LOC_API_ADAPTER_GNSS_MEASUREMENT_REPORT,           // GNSS Measurement Report
942     LOC_API_ADAPTER_GNSS_SV_POLYNOMIAL_REPORT,         // GNSS SV Polynomial Report
943     LOC_API_ADAPTER_GDT_UPLOAD_BEGIN_REQ,              // GDT upload start request
944     LOC_API_ADAPTER_GDT_UPLOAD_END_REQ,                // GDT upload end request
945     LOC_API_ADAPTER_GNSS_MEASUREMENT,                  // GNSS Measurement report
946     LOC_API_ADAPTER_REQUEST_TIMEZONE,                  // Timezone injection request
947     LOC_API_ADAPTER_REPORT_GENFENCE_DWELL_REPORT,      // Geofence dwell report
948     LOC_API_ADAPTER_REQUEST_SRN_DATA,                  // request srn data from AP
949     LOC_API_ADAPTER_REQUEST_POSITION_INJECTION,        // Position injection request
950     LOC_API_ADAPTER_BATCH_STATUS,                      // batch status
951     LOC_API_ADAPTER_FDCL_SERVICE_REQ,                  // FDCL service request
952     LOC_API_ADAPTER_REPORT_UNPROPAGATED_POSITION,      // Unpropagated Position report
953     LOC_API_ADAPTER_BS_OBS_DATA_SERVICE_REQ,           // BS observation data request
954     LOC_API_ADAPTER_GNSS_SV_EPHEMERIS_REPORT,          // GNSS SV Ephemeris Report
955     LOC_API_ADAPTER_LOC_SYSTEM_INFO,                   // Location system info event
956     LOC_API_ADAPTER_GNSS_NHZ_MEASUREMENT_REPORT,       // GNSS SV nHz measurement report
957     LOC_API_ADAPTER_EVENT_REPORT_INFO,                 // Event report info
958     LOC_API_ADAPTER_EVENT_MAX
959 };
960 
961 #define LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT           (1<<LOC_API_ADAPTER_REPORT_POSITION)
962 #define LOC_API_ADAPTER_BIT_SATELLITE_REPORT                 (1<<LOC_API_ADAPTER_REPORT_SATELLITE)
963 #define LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT                  (1<<LOC_API_ADAPTER_REPORT_NMEA_1HZ)
964 #define LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT             (1<<LOC_API_ADAPTER_REPORT_NMEA_POSITION)
965 #define LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST         (1<<LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY)
966 #define LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST          (1<<LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA)
967 #define LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST          (1<<LOC_API_ADAPTER_REQUEST_LOCATION_SERVER)
968 #define LOC_API_ADAPTER_BIT_IOCTL_REPORT                     (1<<LOC_API_ADAPTER_REPORT_IOCTL)
969 #define LOC_API_ADAPTER_BIT_STATUS_REPORT                    (1<<LOC_API_ADAPTER_REPORT_STATUS)
970 #define LOC_API_ADAPTER_BIT_REQUEST_WIFI                     (1<<LOC_API_ADAPTER_REQUEST_WIFI)
971 #define LOC_API_ADAPTER_BIT_SENSOR_STATUS                    (1<<LOC_API_ADAPTER_SENSOR_STATUS)
972 #define LOC_API_ADAPTER_BIT_REQUEST_TIME_SYNC                (1<<LOC_API_ADAPTER_REQUEST_TIME_SYNC)
973 #define LOC_API_ADAPTER_BIT_REPORT_SPI                       (1<<LOC_API_ADAPTER_REPORT_SPI)
974 #define LOC_API_ADAPTER_BIT_REPORT_NI_GEOFENCE               (1<<LOC_API_ADAPTER_REPORT_NI_GEOFENCE)
975 #define LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT               (1<<LOC_API_ADAPTER_GEOFENCE_GEN_ALERT)
976 #define LOC_API_ADAPTER_BIT_REPORT_GENFENCE_BREACH           (1<<LOC_API_ADAPTER_REPORT_GENFENCE_BREACH)
977 #define LOC_API_ADAPTER_BIT_BATCHED_GENFENCE_BREACH_REPORT   (1<<LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT)
978 #define LOC_API_ADAPTER_BIT_PEDOMETER_CTRL                   (1<<LOC_API_ADAPTER_PEDOMETER_CTRL)
979 #define LOC_API_ADAPTER_BIT_MOTION_CTRL                      (1<<LOC_API_ADAPTER_MOTION_CTRL)
980 #define LOC_API_ADAPTER_BIT_REQUEST_WIFI_AP_DATA             (1<<LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA)
981 #define LOC_API_ADAPTER_BIT_BATCH_FULL                       (1<<LOC_API_ADAPTER_BATCH_FULL)
982 #define LOC_API_ADAPTER_BIT_BATCHED_POSITION_REPORT          (1<<LOC_API_ADAPTER_BATCHED_POSITION_REPORT)
983 #define LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT_REPORT          (1<<LOC_API_ADAPTER_GNSS_MEASUREMENT_REPORT)
984 #define LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT        (1<<LOC_API_ADAPTER_GNSS_SV_POLYNOMIAL_REPORT)
985 #define LOC_API_ADAPTER_BIT_GDT_UPLOAD_BEGIN_REQ             (1<<LOC_API_ADAPTER_GDT_UPLOAD_BEGIN_REQ)
986 #define LOC_API_ADAPTER_BIT_GDT_UPLOAD_END_REQ               (1<<LOC_API_ADAPTER_GDT_UPLOAD_END_REQ)
987 #define LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT                 (1<<LOC_API_ADAPTER_GNSS_MEASUREMENT)
988 #define LOC_API_ADAPTER_BIT_REQUEST_TIMEZONE                 (1<<LOC_API_ADAPTER_REQUEST_TIMEZONE)
989 #define LOC_API_ADAPTER_BIT_REPORT_GENFENCE_DWELL            (1<<LOC_API_ADAPTER_REPORT_GENFENCE_DWELL_REPORT)
990 #define LOC_API_ADAPTER_BIT_REQUEST_SRN_DATA                 (1<<LOC_API_ADAPTER_REQUEST_SRN_DATA)
991 #define LOC_API_ADAPTER_BIT_POSITION_INJECTION_REQUEST       (1<<LOC_API_ADAPTER_REQUEST_POSITION_INJECTION)
992 #define LOC_API_ADAPTER_BIT_BATCH_STATUS                     (1<<LOC_API_ADAPTER_BATCH_STATUS)
993 #define LOC_API_ADAPTER_BIT_FDCL_SERVICE_REQ                 (1ULL<<LOC_API_ADAPTER_FDCL_SERVICE_REQ)
994 #define LOC_API_ADAPTER_BIT_PARSED_UNPROPAGATED_POSITION_REPORT (1ULL<<LOC_API_ADAPTER_REPORT_UNPROPAGATED_POSITION)
995 #define LOC_API_ADAPTER_BIT_BS_OBS_DATA_SERVICE_REQ          (1ULL<<LOC_API_ADAPTER_BS_OBS_DATA_SERVICE_REQ)
996 #define LOC_API_ADAPTER_BIT_GNSS_SV_EPHEMERIS_REPORT         (1ULL<<LOC_API_ADAPTER_GNSS_SV_EPHEMERIS_REPORT)
997 #define LOC_API_ADAPTER_BIT_LOC_SYSTEM_INFO                  (1ULL<<LOC_API_ADAPTER_LOC_SYSTEM_INFO)
998 #define LOC_API_ADAPTER_BIT_GNSS_NHZ_MEASUREMENT             (1ULL<<LOC_API_ADAPTER_GNSS_NHZ_MEASUREMENT_REPORT)
999 #define LOC_API_ADAPTER_BIT_EVENT_REPORT_INFO                (1ULL<<LOC_API_ADAPTER_EVENT_REPORT_INFO)
1000 
1001 typedef uint64_t LOC_API_ADAPTER_EVENT_MASK_T;
1002 
1003 typedef enum loc_api_adapter_msg_to_check_supported {
1004     LOC_API_ADAPTER_MESSAGE_LOCATION_BATCHING,               // Batching 1.0
1005     LOC_API_ADAPTER_MESSAGE_BATCHED_GENFENCE_BREACH,         // Geofence Batched Breach
1006     LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_TRACKING,          // DBT 2.0
1007     LOC_API_ADAPTER_MESSAGE_ADAPTIVE_LOCATION_BATCHING,      // Batching 1.5
1008     LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_LOCATION_BATCHING, // Batching 2.0
1009     LOC_API_ADAPTER_MESSAGE_UPDATE_TBF_ON_THE_FLY,           // Updating Tracking TBF On The Fly
1010     LOC_API_ADAPTER_MESSAGE_OUTDOOR_TRIP_BATCHING,           // Outdoor Trip Batching
1011 
1012     LOC_API_ADAPTER_MESSAGE_MAX
1013 } LocCheckingMessagesID;
1014 
1015 typedef int IzatDevId_t;
1016 
1017 typedef uint32_t LOC_GPS_LOCK_MASK;
1018 #define isGpsLockNone(lock) ((lock) == 0)
1019 #define isGpsLockMO(lock) ((lock) & ((LOC_GPS_LOCK_MASK)1))
1020 #define isGpsLockMT(lock) ((lock) & ((LOC_GPS_LOCK_MASK)2))
1021 #define isGpsLockAll(lock) (((lock) & ((LOC_GPS_LOCK_MASK)3)) == 3)
1022 
1023 /*++ ***********************************************
1024 **  Satellite Measurement and Satellite Polynomial
1025 **  Structure definitions
1026 **  ***********************************************
1027 --*/
1028 #define GNSS_SV_POLY_VELOCITY_COEF_MAX_SIZE         12
1029 #define GNSS_SV_POLY_XYZ_0_TH_ORDER_COEFF_MAX_SIZE  3
1030 #define GNSS_SV_POLY_XYZ_N_TH_ORDER_COEFF_MAX_SIZE  9
1031 #define GNSS_SV_POLY_SV_CLKBIAS_COEFF_MAX_SIZE      4
1032 /** Max number of GNSS SV measurement */
1033 #define GNSS_LOC_SV_MEAS_LIST_MAX_SIZE              128
1034 
1035 enum ulp_gnss_sv_measurement_valid_flags{
1036 
1037     ULP_GNSS_SV_MEAS_GPS_TIME = 0,
1038     ULP_GNSS_SV_MEAS_PSUEDO_RANGE,
1039     ULP_GNSS_SV_MEAS_MS_IN_WEEK,
1040     ULP_GNSS_SV_MEAS_SUB_MSEC,
1041     ULP_GNSS_SV_MEAS_CARRIER_PHASE,
1042     ULP_GNSS_SV_MEAS_DOPPLER_SHIFT,
1043     ULP_GNSS_SV_MEAS_CNO,
1044     ULP_GNSS_SV_MEAS_LOSS_OF_LOCK,
1045 
1046     ULP_GNSS_SV_MEAS_MAX_VALID_FLAGS
1047 };
1048 
1049 #define ULP_GNSS_SV_MEAS_BIT_GPS_TIME        (1<<ULP_GNSS_SV_MEAS_GPS_TIME)
1050 #define ULP_GNSS_SV_MEAS_BIT_PSUEDO_RANGE    (1<<ULP_GNSS_SV_MEAS_PSUEDO_RANGE)
1051 #define ULP_GNSS_SV_MEAS_BIT_MS_IN_WEEK      (1<<ULP_GNSS_SV_MEAS_MS_IN_WEEK)
1052 #define ULP_GNSS_SV_MEAS_BIT_SUB_MSEC        (1<<ULP_GNSS_SV_MEAS_SUB_MSEC)
1053 #define ULP_GNSS_SV_MEAS_BIT_CARRIER_PHASE   (1<<ULP_GNSS_SV_MEAS_CARRIER_PHASE)
1054 #define ULP_GNSS_SV_MEAS_BIT_DOPPLER_SHIFT   (1<<ULP_GNSS_SV_MEAS_DOPPLER_SHIFT)
1055 #define ULP_GNSS_SV_MEAS_BIT_CNO             (1<<ULP_GNSS_SV_MEAS_CNO)
1056 #define ULP_GNSS_SV_MEAS_BIT_LOSS_OF_LOCK    (1<<ULP_GNSS_SV_MEAS_LOSS_OF_LOCK)
1057 
1058 enum ulp_gnss_sv_poly_valid_flags{
1059 
1060     ULP_GNSS_SV_POLY_GLO_FREQ = 0,
1061     ULP_GNSS_SV_POLY_T0,
1062     ULP_GNSS_SV_POLY_IODE,
1063     ULP_GNSS_SV_POLY_FLAG,
1064     ULP_GNSS_SV_POLY_POLYCOEFF_XYZ0,
1065     ULP_GNSS_SV_POLY_POLYCOEFF_XYZN,
1066     ULP_GNSS_SV_POLY_POLYCOEFF_OTHER,
1067     ULP_GNSS_SV_POLY_SV_POSUNC,
1068     ULP_GNSS_SV_POLY_IONODELAY,
1069     ULP_GNSS_SV_POLY_IONODOT,
1070     ULP_GNSS_SV_POLY_SBAS_IONODELAY,
1071     ULP_GNSS_SV_POLY_SBAS_IONODOT,
1072     ULP_GNSS_SV_POLY_TROPODELAY,
1073     ULP_GNSS_SV_POLY_ELEVATION,
1074     ULP_GNSS_SV_POLY_ELEVATIONDOT,
1075     ULP_GNSS_SV_POLY_ELEVATIONUNC,
1076     ULP_GNSS_SV_POLY_VELO_COEFF,
1077     ULP_GNSS_SV_POLY_ENHANCED_IOD,
1078     ULP_GNSS_SV_POLY_GPS_ISC_L1CA,
1079     ULP_GNSS_SV_POLY_GPS_ISC_L2C,
1080     ULP_GNSS_SV_POLY_GPS_ISC_L5I5,
1081     ULP_GNSS_SV_POLY_GPS_ISC_L5Q5,
1082     ULP_GNSS_SV_POLY_GPS_TGD,
1083     ULP_GNSS_SV_POLY_GLO_TGD_G1G2,
1084     ULP_GNSS_SV_POLY_BDS_TGD_B1,
1085     ULP_GNSS_SV_POLY_BDS_TGD_B2,
1086     ULP_GNSS_SV_POLY_BDS_TGD_B2A,
1087     ULP_GNSS_SV_POLY_BDS_ISC_B2A,
1088     ULP_GNSS_SV_POLY_GAL_BGD_E1E5A,
1089     ULP_GNSS_SV_POLY_GAL_BGD_E1E5B,
1090     ULP_GNSS_SV_POLY_NAVIC_TGD_L5
1091 };
1092 
1093 #define ULP_GNSS_SV_POLY_BIT_GLO_FREQ               (1<<ULP_GNSS_SV_POLY_GLO_FREQ)
1094 #define ULP_GNSS_SV_POLY_BIT_T0                     (1<<ULP_GNSS_SV_POLY_T0)
1095 #define ULP_GNSS_SV_POLY_BIT_IODE                   (1<<ULP_GNSS_SV_POLY_IODE)
1096 #define ULP_GNSS_SV_POLY_BIT_FLAG                   (1<<ULP_GNSS_SV_POLY_FLAG)
1097 #define ULP_GNSS_SV_POLY_BIT_POLYCOEFF_XYZ0         (1<<ULP_GNSS_SV_POLY_POLYCOEFF_XYZ0)
1098 #define ULP_GNSS_SV_POLY_BIT_POLYCOEFF_XYZN         (1<<ULP_GNSS_SV_POLY_POLYCOEFF_XYZN)
1099 #define ULP_GNSS_SV_POLY_BIT_POLYCOEFF_OTHER        (1<<ULP_GNSS_SV_POLY_POLYCOEFF_OTHER)
1100 #define ULP_GNSS_SV_POLY_BIT_SV_POSUNC              (1<<ULP_GNSS_SV_POLY_SV_POSUNC)
1101 #define ULP_GNSS_SV_POLY_BIT_IONODELAY              (1<<ULP_GNSS_SV_POLY_IONODELAY)
1102 #define ULP_GNSS_SV_POLY_BIT_IONODOT                (1<<ULP_GNSS_SV_POLY_IONODOT)
1103 #define ULP_GNSS_SV_POLY_BIT_SBAS_IONODELAY         (1<<ULP_GNSS_SV_POLY_SBAS_IONODELAY)
1104 #define ULP_GNSS_SV_POLY_BIT_SBAS_IONODOT           (1<<ULP_GNSS_SV_POLY_SBAS_IONODOT)
1105 #define ULP_GNSS_SV_POLY_BIT_TROPODELAY             (1<<ULP_GNSS_SV_POLY_TROPODELAY)
1106 #define ULP_GNSS_SV_POLY_BIT_ELEVATION              (1<<ULP_GNSS_SV_POLY_ELEVATION)
1107 #define ULP_GNSS_SV_POLY_BIT_ELEVATIONDOT           (1<<ULP_GNSS_SV_POLY_ELEVATIONDOT)
1108 #define ULP_GNSS_SV_POLY_BIT_ELEVATIONUNC           (1<<ULP_GNSS_SV_POLY_ELEVATIONUNC)
1109 #define ULP_GNSS_SV_POLY_BIT_VELO_COEFF             (1<<ULP_GNSS_SV_POLY_VELO_COEFF)
1110 #define ULP_GNSS_SV_POLY_BIT_ENHANCED_IOD           (1<<ULP_GNSS_SV_POLY_ENHANCED_IOD)
1111 #define ULP_GNSS_SV_POLY_BIT_GPS_ISC_L1CA           (1<<ULP_GNSS_SV_POLY_GPS_ISC_L1CA)
1112 #define ULP_GNSS_SV_POLY_BIT_GPS_ISC_L2C            (1<<ULP_GNSS_SV_POLY_GPS_ISC_L2C)
1113 #define ULP_GNSS_SV_POLY_BIT_GPS_ISC_L5I5           (1<<ULP_GNSS_SV_POLY_GPS_ISC_L5I5)
1114 #define ULP_GNSS_SV_POLY_BIT_GPS_ISC_L5Q5           (1<<ULP_GNSS_SV_POLY_GPS_ISC_L5Q5)
1115 #define ULP_GNSS_SV_POLY_BIT_GPS_TGD                (1<<ULP_GNSS_SV_POLY_GPS_TGD)
1116 #define ULP_GNSS_SV_POLY_BIT_GLO_TGD_G1G2           (1<<ULP_GNSS_SV_POLY_GLO_TGD_G1G2)
1117 #define ULP_GNSS_SV_POLY_BIT_BDS_TGD_B1             (1<<ULP_GNSS_SV_POLY_BDS_TGD_B1)
1118 #define ULP_GNSS_SV_POLY_BIT_BDS_TGD_B2             (1<<ULP_GNSS_SV_POLY_BDS_TGD_B2)
1119 #define ULP_GNSS_SV_POLY_BIT_BDS_TGD_B2A            (1<<ULP_GNSS_SV_POLY_BDS_TGD_B2A)
1120 #define ULP_GNSS_SV_POLY_BIT_BDS_ISC_B2A            (1<<ULP_GNSS_SV_POLY_BDS_ISC_B2A)
1121 #define ULP_GNSS_SV_POLY_BIT_GAL_BGD_E1E5A          (1<<ULP_GNSS_SV_POLY_GAL_BGD_E1E5A)
1122 #define ULP_GNSS_SV_POLY_BIT_GAL_BGD_E1E5B          (1<<ULP_GNSS_SV_POLY_GAL_BGD_E1E5B)
1123 #define ULP_GNSS_SV_POLY_BIT_NAVIC_TGD_L5           (1<<ULP_GNSS_SV_POLY_NAVIC_TGD_L5)
1124 
1125 typedef enum
1126 {
1127     GNSS_LOC_FREQ_SOURCE_INVALID = 0,
1128     /**< Source of the frequency is invalid */
1129     GNSS_LOC_FREQ_SOURCE_EXTERNAL = 1,
1130     /**< Source of the frequency is from external injection */
1131     GNSS_LOC_FREQ_SOURCE_PE_CLK_REPORT = 2,
1132     /**< Source of the frequency is from Navigation engine */
1133     GNSS_LOC_FREQ_SOURCE_UNKNOWN = 3
1134     /**< Source of the frequency is unknown */
1135 } Gnss_LocSourceofFreqEnumType;
1136 
1137 typedef struct
1138 {
1139     uint32_t                          size;
1140     float                           clockDrift;
1141     /**< Receiver clock Drift \n
1142          - Units: meter per sec \n
1143     */
1144     float                           clockDriftUnc;
1145     /**< Receiver clock Drift uncertainty \n
1146          - Units: meter per sec \n
1147     */
1148     Gnss_LocSourceofFreqEnumType    sourceOfFreq;
1149 }Gnss_LocRcvrClockFrequencyInfoStructType;
1150 
1151 typedef struct
1152 {
1153     uint32_t      size;
1154     uint8_t     leapSec;
1155     /**< GPS time leap second delta to UTC time  \n
1156          - Units: sec \n
1157        */
1158     uint8_t     leapSecUnc;
1159     /**< Uncertainty for GPS leap second \n
1160          - Units: sec \n
1161        */
1162 }Gnss_LeapSecondInfoStructType;
1163 
1164 typedef enum
1165 {
1166    GNSS_LOC_SYS_TIME_BIAS_VALID                = 0x01,
1167    /**< System time bias valid */
1168    GNSS_LOC_SYS_TIME_BIAS_UNC_VALID            = 0x02,
1169    /**< System time bias uncertainty valid */
1170 }Gnss_LocInterSystemBiasValidMaskType;
1171 
1172 typedef struct
1173 {
1174     uint32_t          size;
1175     uint32_t        validMask;
1176     /* Validity mask as per Gnss_LocInterSystemBiasValidMaskType */
1177 
1178     float           timeBias;
1179     /**< System-1 to System-2 Time Bias  \n
1180         - Units: msec \n
1181     */
1182     float           timeBiasUnc;
1183     /**< System-1 to System-2 Time Bias uncertainty  \n
1184         - Units: msec \n
1185     */
1186 } Gnss_InterSystemBiasStructType;
1187 
1188 
1189 typedef struct {
1190 
1191   uint32_t    size;
1192 
1193   uint8_t   systemRtc_valid;
1194   /**<   Validity indicator for System RTC */
1195 
1196   uint64_t  systemRtcMs;
1197   /**<   Platform system RTC value \n
1198         - Units: msec \n
1199         */
1200 
1201 }Gnss_LocGnssTimeExtStructType;
1202 
1203 typedef enum
1204 {
1205     GNSS_LOC_MEAS_STATUS_NULL                    = 0x00000000,
1206     /**< No information state */
1207     GNSS_LOC_MEAS_STATUS_SM_VALID                = 0x00000001,
1208     /**< Code phase is known */
1209     GNSS_LOC_MEAS_STATUS_SB_VALID                = 0x00000002,
1210     /**< Sub-bit time is known */
1211     GNSS_LOC_MEAS_STATUS_MS_VALID                = 0x00000004,
1212     /**< Satellite time is known */
1213     GNSS_LOC_MEAS_STATUS_BE_CONFIRM              = 0x00000008,
1214     /**< Bit edge is confirmed from signal   */
1215     GNSS_LOC_MEAS_STATUS_VELOCITY_VALID          = 0x00000010,
1216     /**< Satellite Doppler measured */
1217     GNSS_LOC_MEAS_STATUS_VELOCITY_FINE           = 0x00000020,
1218     /**< TRUE: Fine Doppler measured, FALSE: Coarse Doppler measured */
1219     GNSS_LOC_MEAS_STATUS_FROM_RNG_DIFF           = 0x00000200,
1220     /**< Range update from Satellite differences */
1221     GNSS_LOC_MEAS_STATUS_FROM_VE_DIFF            = 0x00000400,
1222     /**< Doppler update from Satellite differences */
1223     GNSS_LOC_MEAS_STATUS_DONT_USE_X              = 0x00000800,
1224     /**< Don't use measurement if bit is set */
1225     GNSS_LOC_MEAS_STATUS_DONT_USE_M              = 0x000001000,
1226     /**< Don't use measurement if bit is set */
1227     GNSS_LOC_MEAS_STATUS_DONT_USE_D              = 0x000002000,
1228     /**< Don't use measurement if bit is set */
1229     GNSS_LOC_MEAS_STATUS_DONT_USE_S              = 0x000004000,
1230     /**< Don't use measurement if bit is set */
1231     GNSS_LOC_MEAS_STATUS_DONT_USE_P              = 0x000008000
1232     /**< Don't use measurement if bit is set */
1233 }Gnss_LocSvMeasStatusMaskType;
1234 
1235 typedef struct
1236 {
1237     uint32_t              size;
1238     uint32_t            svMs;
1239     /**<  Satellite time milisecond.\n
1240           For GPS, BDS, GAL range of 0 thru (604800000-1) \n
1241           For GLONASS range of 0 thru (86400000-1) \n
1242           Valid when PD_LOC_MEAS_STATUS_MS_VALID bit is set in measurement status \n
1243           Note: All SV times in the current measurement block are alredy propagated to common reference time epoch. \n
1244             - Units: msec \n
1245        */
1246     float               svSubMs;
1247     /**<Satellite time sub-millisecond. \n
1248         Total SV Time = svMs + svSubMs \n
1249         - Units: msec \n
1250        */
1251     float               svTimeUncMs;
1252     /**<  Satellite Time uncertainty \n
1253           - Units: msec \n
1254        */
1255     float               dopplerShift;
1256     /**< Satellite Doppler \n
1257             - Units: meter per sec \n
1258        */
1259     float               dopplerShiftUnc;
1260     /**< Satellite Doppler uncertainty\n
1261             - Units: meter per sec \n
1262        */
1263 }Gnss_LocSVTimeSpeedStructType;
1264 
1265 typedef enum
1266 {
1267   GNSS_SV_STATE_IDLE = 0,
1268   GNSS_SV_STATE_SEARCH = 1,
1269   GNSS_SV_STATE_SEARCH_VERIFY = 2,
1270   GNSS_SV_STATE_BIT_EDGE = 3,
1271   GNSS_SV_STATE_VERIFY_TRACK = 4,
1272   GNSS_SV_STATE_TRACK = 5,
1273   GNSS_SV_STATE_RESTART = 6,
1274   GNSS_SV_STATE_DPO_TRACK = 7
1275 } Gnss_LocSVStateEnumType;
1276 
1277 typedef enum
1278 {
1279   GNSS_LOC_SVINFO_MASK_HAS_EPHEMERIS   = 0x01,
1280   /**< Ephemeris is available for this SV */
1281   GNSS_LOC_SVINFO_MASK_HAS_ALMANAC     = 0x02
1282   /**< Almanac is available for this SV */
1283 }Gnss_LocSvInfoMaskT;
1284 
1285 typedef enum
1286 {
1287   GNSS_LOC_SV_SRCH_STATUS_IDLE      = 1,
1288     /**< SV is not being actively processed */
1289   GNSS_LOC_SV_SRCH_STATUS_SEARCH    = 2,
1290     /**< The system is searching for this SV */
1291   GNSS_LOC_SV_SRCH_STATUS_TRACK     = 3
1292     /**< SV is being tracked */
1293 }Gnss_LocSvSearchStatusEnumT;
1294 
1295 typedef struct
1296 {
1297     uint32_t                          size;
1298     Gnss_LocSvSystemEnumType        gnssSystem;
1299     // 0 signal type mask indicates invalid value
1300     GnssSignalTypeMask              gnssSignalTypeMask;
1301     uint16_t                        gnssSvId;
1302     /**< GNSS SV ID.
1303          \begin{itemize1}
1304          \item Range:  \begin{itemize1}
1305            \item For GPS:      1 to 32
1306            \item For GLONASS:  1 to 32
1307            \item For SBAS:     120 to 151
1308            \item For BDS:      201 to 237
1309          \end{itemize1} \end{itemize1}
1310         The GPS and GLONASS SVs can be disambiguated using the system field.
1311     */
1312     uint8_t                         gloFrequency;
1313     /**< GLONASS frequency number + 7 \n
1314          Valid only for GLONASS System \n
1315          Shall be ignored for all other systems \n
1316           - Range: 1 to 14 \n
1317     */
1318     Gnss_LocSvSearchStatusEnumT     svStatus;
1319     /**< Satellite search state \n
1320         @ENUM()
1321     */
1322     bool                         healthStatus_valid;
1323     /**< SV Health Status validity flag\n
1324         - 0: Not valid \n
1325         - 1: Valid \n
1326     */
1327     uint8_t                         healthStatus;
1328     /**< Health status.
1329          \begin{itemize1}
1330          \item    Range: 0 to 1; 0 = unhealthy, \n 1 = healthy, 2 = unknown
1331          \vspace{-0.18in} \end{itemize1}
1332     */
1333     Gnss_LocSvInfoMaskT             svInfoMask;
1334     /**< Indicates whether almanac and ephemeris information is available. \n
1335         @MASK()
1336     */
1337     uint64_t                        measurementStatus;
1338     /**< Bitmask indicating SV measurement status.
1339         Valid bitmasks: \n
1340         If any MSB bit in 0xFFC0000000000000 DONT_USE is set, the measurement
1341         must not be used by the client.
1342         @MASK()
1343     */
1344     uint16_t                        CNo;
1345     /**< Carrier to Noise ratio  \n
1346         - Units: 0.1 dBHz \n
1347     */
1348     uint16_t                          gloRfLoss;
1349     /**< GLONASS Rf loss reference to Antenna. \n
1350          - Units: dB, Scale: 0.1 \n
1351     */
1352     bool                         lossOfLock;
1353     /**< Loss of signal lock indicator  \n
1354          - 0: Signal in continuous track \n
1355          - 1: Signal not in track \n
1356     */
1357     int16_t                         measLatency;
1358     /**< Age of the measurement. Positive value means measurement precedes ref time. \n
1359          - Units: msec \n
1360     */
1361     Gnss_LocSVTimeSpeedStructType   svTimeSpeed;
1362     /**< Unfiltered SV Time and Speed information
1363     */
1364     float                           dopplerAccel;
1365     /**< Satellite Doppler Accelertion\n
1366          - Units: Hz/s \n
1367     */
1368     bool                         multipathEstValid;
1369     /**< Multipath estimate validity flag\n
1370         - 0: Multipath estimate not valid \n
1371         - 1: Multipath estimate valid \n
1372     */
1373     float                           multipathEstimate;
1374     /**< Estimate of multipath in measurement\n
1375          - Units: Meters \n
1376     */
1377     bool                         fineSpeedValid;
1378     /**< Fine speed validity flag\n
1379          - 0: Fine speed not valid \n
1380          - 1: Fine speed valid \n
1381     */
1382     float                           fineSpeed;
1383     /**< Carrier phase derived speed \n
1384          - Units: m/s \n
1385     */
1386     bool                         fineSpeedUncValid;
1387     /**< Fine speed uncertainty validity flag\n
1388          - 0: Fine speed uncertainty not valid \n
1389          - 1: Fine speed uncertainty valid \n
1390     */
1391     float                           fineSpeedUnc;
1392     /**< Carrier phase derived speed \n
1393         - Units: m/s \n
1394     */
1395     bool                         carrierPhaseValid;
1396     /**< Carrier Phase measurement validity flag\n
1397          - 0: Carrier Phase not valid \n
1398          - 1: Carrier Phase valid \n
1399     */
1400     double                          carrierPhase;
1401     /**< Carrier phase measurement [L1 cycles] \n
1402     */
1403     bool                         cycleSlipCountValid;
1404      /**< Cycle slup count validity flag\n
1405          - 0: Not valid \n
1406          - 1: Valid \n
1407     */
1408     uint8_t                         cycleSlipCount;
1409     /**< Increments when a CSlip is detected */
1410 
1411     bool                         svDirectionValid;
1412     /**< Validity flag for SV direction */
1413 
1414     float                           svAzimuth;
1415     /**< Satellite Azimuth
1416         - Units: radians \n
1417     */
1418     float                           svElevation;
1419     /**< Satellite Elevation
1420         - Units: radians \n
1421     */
1422     uint64_t                        validMeasStatusMask;
1423     /**< Bitmask indicating SV measurement status Validity.
1424         Valid bitmasks: \n
1425         If any MSB bit in 0xFFC0000000000000 DONT_USE is set, the measurement
1426         must not be used by the client.
1427         @MASK()
1428     */
1429     bool                         carrierPhaseUncValid;
1430     /**< Validity flag for SV direction */
1431 
1432     float                           carrierPhaseUnc;
1433 
1434 
1435 } Gnss_SVMeasurementStructType;
1436 
1437 
1438 typedef uint64_t GpsSvMeasHeaderFlags;
1439 #define GNSS_SV_MEAS_HEADER_HAS_LEAP_SECOND                  0x00000001
1440 #define GNSS_SV_MEAS_HEADER_HAS_CLOCK_FREQ                   0x00000002
1441 #define GNSS_SV_MEAS_HEADER_HAS_AP_TIMESTAMP                 0x00000004
1442 #define GNSS_SV_MEAS_HEADER_HAS_GPS_GLO_INTER_SYSTEM_BIAS    0x00000008
1443 #define GNSS_SV_MEAS_HEADER_HAS_GPS_BDS_INTER_SYSTEM_BIAS    0x00000010
1444 #define GNSS_SV_MEAS_HEADER_HAS_GPS_GAL_INTER_SYSTEM_BIAS    0x00000020
1445 #define GNSS_SV_MEAS_HEADER_HAS_BDS_GLO_INTER_SYSTEM_BIAS    0x00000040
1446 #define GNSS_SV_MEAS_HEADER_HAS_GAL_GLO_INTER_SYSTEM_BIAS    0x00000080
1447 #define GNSS_SV_MEAS_HEADER_HAS_GAL_BDS_INTER_SYSTEM_BIAS    0x00000100
1448 #define GNSS_SV_MEAS_HEADER_HAS_GPS_SYSTEM_TIME              0x00000200
1449 #define GNSS_SV_MEAS_HEADER_HAS_GAL_SYSTEM_TIME              0x00000400
1450 #define GNSS_SV_MEAS_HEADER_HAS_BDS_SYSTEM_TIME              0x00000800
1451 #define GNSS_SV_MEAS_HEADER_HAS_QZSS_SYSTEM_TIME             0x00001000
1452 #define GNSS_SV_MEAS_HEADER_HAS_GLO_SYSTEM_TIME              0x00002000
1453 #define GNSS_SV_MEAS_HEADER_HAS_GPS_SYSTEM_TIME_EXT          0x00004000
1454 #define GNSS_SV_MEAS_HEADER_HAS_GAL_SYSTEM_TIME_EXT          0x00008000
1455 #define GNSS_SV_MEAS_HEADER_HAS_BDS_SYSTEM_TIME_EXT          0x00010000
1456 #define GNSS_SV_MEAS_HEADER_HAS_QZSS_SYSTEM_TIME_EXT         0x00020000
1457 #define GNSS_SV_MEAS_HEADER_HAS_GLO_SYSTEM_TIME_EXT          0x00040000
1458 #define GNSS_SV_MEAS_HEADER_HAS_GPSL1L5_TIME_BIAS            0x00080000
1459 #define GNSS_SV_MEAS_HEADER_HAS_GALE1E5A_TIME_BIAS           0x00100000
1460 #define GNSS_SV_MEAS_HEADER_HAS_GPS_NAVIC_INTER_SYSTEM_BIAS  0x00200000
1461 #define GNSS_SV_MEAS_HEADER_HAS_GAL_NAVIC_INTER_SYSTEM_BIAS  0x00400000
1462 #define GNSS_SV_MEAS_HEADER_HAS_GLO_NAVIC_INTER_SYSTEM_BIAS  0x00800000
1463 #define GNSS_SV_MEAS_HEADER_HAS_BDS_NAVIC_INTER_SYSTEM_BIAS  0x01000000
1464 #define GNSS_SV_MEAS_HEADER_HAS_NAVIC_SYSTEM_TIME            0x02000000
1465 #define GNSS_SV_MEAS_HEADER_HAS_NAVIC_SYSTEM_TIME_EXT        0x04000000
1466 
1467 typedef struct
1468 {
1469     uint32_t                                      size;
1470     // see defines in GNSS_SV_MEAS_HEADER_HAS_XXX_XXX
1471     uint64_t                                    flags;
1472 
1473     Gnss_LeapSecondInfoStructType               leapSec;
1474 
1475     Gnss_LocRcvrClockFrequencyInfoStructType    clockFreq;   /* Freq */
1476 
1477     Gnss_ApTimeStampStructType                  apBootTimeStamp;
1478 
1479     Gnss_InterSystemBiasStructType              gpsGloInterSystemBias;
1480     Gnss_InterSystemBiasStructType              gpsBdsInterSystemBias;
1481     Gnss_InterSystemBiasStructType              gpsGalInterSystemBias;
1482     Gnss_InterSystemBiasStructType              bdsGloInterSystemBias;
1483     Gnss_InterSystemBiasStructType              galGloInterSystemBias;
1484     Gnss_InterSystemBiasStructType              galBdsInterSystemBias;
1485     Gnss_InterSystemBiasStructType              gpsNavicInterSystemBias;
1486     Gnss_InterSystemBiasStructType              galNavicInterSystemBias;
1487     Gnss_InterSystemBiasStructType              gloNavicInterSystemBias;
1488     Gnss_InterSystemBiasStructType              bdsNavicInterSystemBias;
1489     Gnss_InterSystemBiasStructType              gpsL1L5TimeBias;
1490     Gnss_InterSystemBiasStructType              galE1E5aTimeBias;
1491 
1492     GnssSystemTimeStructType                    gpsSystemTime;
1493     GnssSystemTimeStructType                    galSystemTime;
1494     GnssSystemTimeStructType                    bdsSystemTime;
1495     GnssSystemTimeStructType                    qzssSystemTime;
1496     GnssSystemTimeStructType                    navicSystemTime;
1497     GnssGloTimeStructType                       gloSystemTime;
1498 
1499     /** GPS system RTC time information. */
1500     Gnss_LocGnssTimeExtStructType               gpsSystemTimeExt;
1501     /** GAL system RTC time information. */
1502     Gnss_LocGnssTimeExtStructType               galSystemTimeExt;
1503     /** BDS system RTC time information. */
1504     Gnss_LocGnssTimeExtStructType               bdsSystemTimeExt;
1505     /** QZSS system RTC time information. */
1506     Gnss_LocGnssTimeExtStructType               qzssSystemTimeExt;
1507     /** GLONASS system RTC time information. */
1508     Gnss_LocGnssTimeExtStructType               gloSystemTimeExt;
1509     /** NAVIC system RTC time information. */
1510     Gnss_LocGnssTimeExtStructType               navicSystemTimeExt;
1511 } GnssSvMeasurementHeader;
1512 
1513 typedef struct {
1514     uint32_t                        size;
1515     bool                          isNhz;
1516     GnssSvMeasurementHeader       svMeasSetHeader;
1517     uint32_t                      svMeasCount;
1518     Gnss_SVMeasurementStructType  svMeas[GNSS_LOC_SV_MEAS_LIST_MAX_SIZE];
1519 
1520 } GnssSvMeasurementSet;
1521 
1522 typedef struct {
1523     uint32_t size;                  // set to sizeof(GnssMeasurements)
1524     GnssSvMeasurementSet            gnssSvMeasurementSet;
1525     GnssMeasurementsNotification    gnssMeasNotification;
1526 } GnssMeasurements;
1527 
1528 typedef enum
1529 {
1530    GNSS_SV_POLY_COEFF_VALID             = 0x01,
1531    /**< SV position in orbit coefficients are valid */
1532    GNSS_SV_POLY_IONO_VALID              = 0x02,
1533    /**< Iono estimates are valid */
1534 
1535    GNSS_SV_POLY_TROPO_VALID             = 0x04,
1536    /**< Tropo estimates are valid */
1537 
1538    GNSS_SV_POLY_ELEV_VALID              = 0x08,
1539    /**< Elevation, rate, uncertainty are valid */
1540 
1541    GNSS_SV_POLY_SRC_ALM_CORR            = 0x10,
1542    /**< Polynomials based on XTRA */
1543 
1544    GNSS_SV_POLY_SBAS_IONO_VALID         = 0x20,
1545    /**< SBAS IONO and rate are valid */
1546 
1547    GNSS_SV_POLY_GLO_STR4                = 0x40
1548    /**< GLONASS String 4 has been received */
1549 }Gnss_SvPolyStatusMaskType;
1550 
1551 
1552 typedef struct
1553 {
1554     uint32_t      size;
1555     uint16_t     gnssSvId;
1556     /* GPS: 1-32, GLO: 65-96, 0: Invalid,
1557        SBAS: 120-151, BDS:201-237,GAL:301 to 336
1558        All others are reserved
1559     */
1560     int8_t      freqNum;
1561     /* Freq index, only valid if u_SysInd is GLO */
1562 
1563     GnssSvPolyStatusMaskValidity svPolyStatusMaskValidity;
1564     GnssSvPolyStatusMask         svPolyStatusMask;
1565 
1566     uint32_t    is_valid;
1567 
1568     uint16_t     iode;
1569     /* Ephemeris reference time
1570        GPS:Issue of Data Ephemeris used [unitless].
1571        GLO: Tb 7-bit, refer to ICD02
1572     */
1573     double      T0;
1574     /* Reference time for polynominal calculations
1575        GPS: Secs in week.
1576        GLO: Full secs since Jan/01/96
1577     */
1578     double      polyCoeffXYZ0[GNSS_SV_POLY_XYZ_0_TH_ORDER_COEFF_MAX_SIZE];
1579     /* C0X, C0Y, C0Z */
1580     double      polyCoefXYZN[GNSS_SV_POLY_XYZ_N_TH_ORDER_COEFF_MAX_SIZE];
1581     /* C1X, C2X ... C2Z, C3Z */
1582     float       polyCoefOther[GNSS_SV_POLY_SV_CLKBIAS_COEFF_MAX_SIZE];
1583     /* C0T, C1T, C2T, C3T */
1584     float       svPosUnc;       /* SV position uncertainty [m]. */
1585     float       ionoDelay;    /* Ionospheric delay at d_T0 [m]. */
1586     float       ionoDot;      /* Iono delay rate [m/s].  */
1587     float       sbasIonoDelay;/* SBAS Ionospheric delay at d_T0 [m]. */
1588     float       sbasIonoDot;  /* SBAS Iono delay rate [m/s].  */
1589     float       tropoDelay;   /* Tropospheric delay [m]. */
1590     float       elevation;    /* Elevation [rad] at d_T0 */
1591     float       elevationDot;      /* Elevation rate [rad/s] */
1592     float       elevationUnc;      /* SV elevation [rad] uncertainty */
1593     double      velCoef[GNSS_SV_POLY_VELOCITY_COEF_MAX_SIZE];
1594     /* Coefficients of velocity poly */
1595     uint32_t    enhancedIOD;    /*  Enhanced Reference Time */
1596     float gpsIscL1ca;
1597     float gpsIscL2c;
1598     float gpsIscL5I5;
1599     float gpsIscL5Q5;
1600     float gpsTgd;
1601     float gloTgdG1G2;
1602     float bdsTgdB1;
1603     float bdsTgdB2;
1604     float bdsTgdB2a;
1605     float bdsIscB2a;
1606     float galBgdE1E5a;
1607     float galBgdE1E5b;
1608     float navicTgdL5;
1609 } GnssSvPolynomial;
1610 
1611 typedef enum {
1612     GNSS_EPH_ACTION_UPDATE_SRC_UNKNOWN_V02 = 0, /**<Update ephemeris. Source of ephemeris is unknown  */
1613     GNSS_EPH_ACTION_UPDATE_SRC_OTA_V02         = 1, /**<Update ephemeris. Source of ephemeris is OTA  */
1614     GNSS_EPH_ACTION_UPDATE_SRC_NETWORK_V02     = 2, /**<Update ephemeris. Source of ephemeris is Network  */
1615     GNSS_EPH_ACTION_UPDATE_MAX_V02         = 999, /**<Max value for update ephemeris action. DO NOT USE  */
1616     GNSS_EPH_ACTION_DELETE_SRC_UNKNOWN_V02 = 1000, /**<Delete previous ephemeris from unknown source  */
1617     GNSS_EPH_ACTION_DELETE_SRC_NETWORK_V02 = 1001, /**<Delete previous ephemeris from network  */
1618     GNSS_EPH_ACTION_DELETE_SRC_OTA_V02     = 1002, /**<Delete previous ephemeris from OTA  */
1619     GNSS_EPH_ACTION_DELETE_MAX_V02     = 1999, /**<Max value for delete ephemeris action. DO NOT USE  */
1620 } GnssEphAction;
1621 
1622 typedef enum {
1623     GAL_EPH_SIGNAL_SRC_UNKNOWN_V02 = 0, /**<  GALILEO signal is unknown  */
1624     GAL_EPH_SIGNAL_SRC_E1B_V02     = 1, /**<  GALILEO signal is E1B  */
1625     GAL_EPH_SIGNAL_SRC_E5A_V02     = 2, /**<  GALILEO signal is E5A  */
1626     GAL_EPH_SIGNAL_SRC_E5B_V02     = 3, /**<  GALILEO signal is E5B  */
1627 } GalEphSignalSource;
1628 
1629 typedef struct {
1630     uint16_t gnssSvId;
1631     /**<   GNSS SV ID.
1632       - Type: uint16
1633       \begin{itemize1}
1634       \item    Range:    \begin{itemize1}
1635         \item    For GPS:     1 to 32
1636         \item    For QZSS:    193 to 197
1637         \item    For BDS:     201 to 237
1638         \item    For GAL:     301 to 336
1639       \vspace{-0.18in} \end{itemize1} \end{itemize1} */
1640 
1641     GnssEphAction updateAction;
1642     /**<   Specifies the action and source of ephemeris. \n
1643     - Type: int32 enum */
1644 
1645     uint16_t IODE;
1646     /**<   Issue of data ephemeris used (unit-less). \n
1647         GPS: IODE 8 bits.\n
1648         BDS: AODE 5 bits. \n
1649         GAL: SIS IOD 10 bits. \n
1650         - Type: uint16
1651         - Units: Unit-less */
1652 
1653     double aSqrt;
1654     /**<   Square root of semi-major axis. \n
1655       - Type: double
1656       - Units: Square Root of Meters */
1657 
1658     double deltaN;
1659     /**<   Mean motion difference from computed value. \n
1660       - Type: double
1661       - Units: Radians/Second */
1662 
1663     double m0;
1664     /**<   Mean anomaly at reference time. \n
1665       - Type: double
1666       - Units: Radians */
1667 
1668     double eccentricity;
1669     /**<   Eccentricity . \n
1670       - Type: double
1671       - Units: Unit-less */
1672 
1673     double omega0;
1674     /**<   Longitude of ascending node of orbital plane at the weekly epoch. \n
1675       - Type: double
1676       - Units: Radians */
1677 
1678     double i0;
1679     /**<   Inclination angle at reference time. \n
1680       - Type: double
1681       - Units: Radians */
1682 
1683     double omega;
1684     /**<   Argument of Perigee. \n
1685       - Type: double
1686       - Units: Radians */
1687 
1688     double omegaDot;
1689     /**<   Rate of change of right ascension. \n
1690       - Type: double
1691       - Units: Radians/Second */
1692 
1693     double iDot;
1694     /**<   Rate of change of inclination angle. \n
1695       - Type: double
1696       - Units: Radians/Second */
1697 
1698     double cUc;
1699     /**<   Amplitude of the cosine harmonic correction term to the argument of latitude. \n
1700       - Type: double
1701       - Units: Radians */
1702 
1703     double cUs;
1704     /**<   Amplitude of the sine harmonic correction term to the argument of latitude. \n
1705       - Type: double
1706       - Units: Radians */
1707 
1708     double cRc;
1709     /**<   Amplitude of the cosine harmonic correction term to the orbit radius. \n
1710       - Type: double
1711       - Units: Meters */
1712 
1713     double cRs;
1714     /**<   Amplitude of the sine harmonic correction term to the orbit radius. \n
1715       - Type: double
1716       - Units: Meters */
1717 
1718     double cIc;
1719     /**<   Amplitude of the cosine harmonic correction term to the angle of inclination. \n
1720       - Type: double
1721       - Units: Radians */
1722 
1723     double cIs;
1724     /**<   Amplitude of the sine harmonic correction term to the angle of inclination. \n
1725       - Type: double
1726       - Units: Radians */
1727 
1728     uint32_t toe;
1729     /**<   Reference time of ephemeris. \n
1730       - Type: uint32
1731       - Units: Seconds */
1732 
1733     uint32_t toc;
1734     /**<   Clock data reference time of week.  \n
1735       - Type: uint32
1736       - Units: Seconds */
1737 
1738     double af0;
1739     /**<   Clock bias correction coefficient. \n
1740       - Type: double
1741       - Units: Seconds */
1742 
1743     double af1;
1744     /**<   Clock drift coefficient. \n
1745       - Type: double
1746       - Units: Seconds/Second */
1747 
1748     double af2;
1749     /**<   Clock drift rate correction coefficient. \n
1750       - Type: double
1751       - Units: Seconds/Seconds^2 */
1752 
1753 } GnssEphCommon;
1754 
1755 /* GPS Navigation Model Info */
1756 typedef struct {
1757     GnssEphCommon commonEphemerisData;
1758     /**<   Common ephemeris data.   */
1759 
1760     uint8_t signalHealth;
1761     /**<   Signal health. \n
1762          Bit 0 : L5 Signal Health. \n
1763          Bit 1 : L2 Signal Health. \n
1764          Bit 2 : L1 Signal Health. \n
1765          - Type: uint8
1766          - Values: 3 bit mask of signal health, where set bit indicates unhealthy signal */
1767 
1768     uint8_t URAI;
1769     /**<   User Range Accuracy Index. \n
1770          - Type: uint8
1771          - Units: Unit-less */
1772 
1773     uint8_t codeL2;
1774     /**<   Indicates which codes are commanded ON for the L2 channel (2-bits). \n
1775          - Type: uint8
1776          Valid Values: \n
1777          - 00 : Reserved
1778          - 01 : P code ON
1779          - 10 : C/A code ON */
1780 
1781     uint8_t dataFlagL2P;
1782     /**<   L2 P-code indication flag. \n
1783          - Type: uint8
1784          - Value 1 indicates that the Nav data stream was commanded OFF on the P-code of the L2 channel. */
1785 
1786     double tgd;
1787     /**<   Time of group delay. \n
1788          - Type: double
1789          - Units: Seconds */
1790 
1791     uint8_t fitInterval;
1792     /**<   Indicates the curve-fit interval used by the CS. \n
1793          - Type: uint8
1794          Valid Values:
1795          - 0 : Four hours
1796          - 1 : Greater than four hours */
1797 
1798     uint16_t IODC;
1799     /**<   Issue of Data, Clock. \n
1800          - Type: uint16
1801          - Units: Unit-less */
1802 } GpsEphemeris;
1803 
1804 /* GLONASS Navigation Model Info */
1805 typedef struct {
1806 
1807     uint16_t gnssSvId;
1808     /**<   GNSS SV ID.
1809        - Type: uint16
1810        - Range: 65 to 96 if known. When the slot number to SV ID mapping is unknown, set to 255 */
1811 
1812     GnssEphAction updateAction;
1813     /**<   Specifies the action and source of ephemeris. \n
1814     - Type: int32 enum */
1815 
1816     uint8_t bnHealth;
1817     /**<   SV health flags. \n
1818        - Type: uint8
1819        Valid Values: \n
1820     - 0 : Healthy
1821     - 1 : Unhealthy */
1822 
1823     uint8_t lnHealth;
1824     /**<   Ln SV health flags. GLONASS-M. \n
1825        - Type: uint8
1826        Valid Values: \n
1827     - 0 : Healthy
1828     - 1 : Unhealthy */
1829 
1830     uint8_t tb;
1831     /**<   Index of a time interval within current day according to UTC(SU) + 03 hours 00 min. \n
1832        - Type: uint8
1833        - Units: Unit-less */
1834 
1835     uint8_t ft;
1836     /**<   SV accuracy index. \n
1837        - Type: uint8
1838        - Units: Unit-less */
1839 
1840     uint8_t gloM;
1841     /**<   GLONASS-M flag. \n
1842        - Type: uint8
1843        Valid Values: \n
1844     - 0 : GLONASS
1845     - 1 : GLONASS-M */
1846 
1847     uint8_t enAge;
1848     /**<   Characterizes "Age" of current information. \n
1849        - Type: uint8
1850        - Units: Days */
1851 
1852     uint8_t gloFrequency;
1853     /**<   GLONASS frequency number + 8. \n
1854        - Type: uint8
1855        - Range: 1 to 14
1856     */
1857 
1858     uint8_t p1;
1859     /**<   Time interval between two adjacent values of tb parameter. \n
1860        - Type: uint8
1861        - Units: Minutes */
1862 
1863     uint8_t p2;
1864     /**<   Flag of oddness ("1") or evenness ("0") of the value of tb \n
1865        for intervals 30 or 60 minutes. \n
1866        - Type: uint8 */
1867 
1868     float deltaTau;
1869     /**<   Time difference between navigation RF signal transmitted in L2 sub-band \n
1870        and aviation RF signal transmitted in L1 sub-band. \n
1871        - Type: floating point
1872        - Units: Seconds */
1873 
1874     double position[3];
1875     /**<   Satellite XYZ position. \n
1876        - Type: array of doubles
1877        - Units: Meters */
1878 
1879     double velocity[3];
1880     /**<   Satellite XYZ velocity. \n
1881        - Type: array of doubles
1882        - Units: Meters/Second */
1883 
1884     double acceleration[3];
1885     /**<   Satellite XYZ sola-luni acceleration. \n
1886        - Type: array of doubles
1887        - Units: Meters/Second^2 */
1888 
1889     float tauN;
1890     /**<   Satellite clock correction relative to GLONASS time. \n
1891        - Type: floating point
1892        - Units: Seconds */
1893 
1894     float gamma;
1895     /**<   Relative deviation of predicted carrier frequency value \n
1896        from nominal value at the instant tb. \n
1897        - Type: floating point
1898        - Units: Unit-less */
1899 
1900     double toe;
1901     /**<   Complete ephemeris time, including N4, NT and Tb. \n
1902        [(N4-1)*1461 + (NT-1)]*86400 + tb*900 \n
1903        - Type: double
1904        - Units: Seconds */
1905 
1906     uint16_t nt;
1907     /**<   Current date, calendar number of day within four-year interval. \n
1908        Starting from the 1-st of January in a leap year. \n
1909        - Type: uint16
1910        - Units: Days */
1911 } GlonassEphemeris;
1912 
1913 /* BDS Navigation Model Info */
1914 typedef struct {
1915 
1916     GnssEphCommon commonEphemerisData;
1917     /**<   Common ephemeris data.   */
1918 
1919     uint8_t svHealth;
1920     /**<   Satellite health information applied to both B1 and B2 (SatH1). \n
1921        - Type: uint8
1922        Valid Values: \n
1923        - 0 : Healthy
1924        - 1 : Unhealthy */
1925 
1926     uint8_t AODC;
1927     /**<   Age of data clock. \n
1928        - Type: uint8
1929        - Units: Hours */
1930 
1931     double tgd1;
1932     /**<   Equipment group delay differential on B1 signal. \n
1933        - Type: double
1934        - Units: Nano-Seconds */
1935 
1936     double tgd2;
1937     /**<   Equipment group delay differential on B2 signal. \n
1938        - Type: double
1939        - Units: Nano-Seconds */
1940 
1941     uint8_t URAI;
1942     /**<   User range accuracy index (4-bits). \n
1943        - Type: uint8
1944        - Units: Unit-less */
1945 } BdsEphemeris;
1946 
1947 /* GALIELO Navigation Model Info */
1948 typedef struct {
1949 
1950     GnssEphCommon commonEphemerisData;
1951     /**<   Common ephemeris data.   */
1952 
1953     GalEphSignalSource dataSourceSignal;
1954     /**<   Galileo Signal Source. \n
1955     Valid Values: \n
1956       - GAL_EPH_SIGNAL_SRC_UNKNOWN (0) --  GALILEO signal is unknown
1957       - GAL_EPH_SIGNAL_SRC_E1B (1) --  GALILEO signal is E1B
1958       - GAL_EPH_SIGNAL_SRC_E5A (2) --  GALILEO signal is E5A
1959       - GAL_EPH_SIGNAL_SRC_E5B (3) --  GALILEO signal is E5B  */
1960 
1961     uint8_t sisIndex;
1962     /**<   Signal-in-space index for dual frequency E1-E5b/E5a depending on dataSignalSource. \n
1963        - Type: uint8
1964        - Units: Unit-less */
1965 
1966     double bgdE1E5a;
1967     /**<   E1-E5a Broadcast group delay from F/Nav (E5A). \n
1968        - Type: double
1969        - Units: Seconds */
1970 
1971     double bgdE1E5b;
1972     /**<   E1-E5b Broadcast group delay from I/Nav (E1B or E5B). \n
1973        For E1B or E5B signal, both bgdE1E5a and bgdE1E5b are valid. \n
1974        For E5A signal, only bgdE1E5a is valid. \n
1975        Signal source identified using dataSignalSource. \n
1976        - Type: double
1977        - Units: Seconds */
1978 
1979     uint8_t svHealth;
1980     /**<   SV health status of signal identified by dataSourceSignal. \n
1981        - Type: uint8
1982        Valid Values: \n
1983        - 0 : Healthy
1984        - 1 : Unhealthy */
1985 } GalileoEphemeris;
1986 
1987 /** GPS Navigation model for each SV */
1988 typedef struct {
1989     uint16_t numOfEphemeris;
1990     GpsEphemeris gpsEphemerisData[GNSS_EPHEMERIS_LIST_MAX_SIZE_V02];
1991 } GpsEphemerisResponse;
1992 
1993 /** GLONASS Navigation model for each SV */
1994 typedef struct {
1995     uint16_t numOfEphemeris;
1996     GlonassEphemeris gloEphemerisData[GNSS_EPHEMERIS_LIST_MAX_SIZE_V02];
1997 } GlonassEphemerisResponse;
1998 
1999 /** BDS Navigation model for each SV */
2000 typedef struct {
2001     uint16_t numOfEphemeris;
2002     BdsEphemeris bdsEphemerisData[GNSS_EPHEMERIS_LIST_MAX_SIZE_V02];
2003 } BdsEphemerisResponse;
2004 
2005 /** GALILEO Navigation model for each SV */
2006 typedef struct {
2007     uint16_t numOfEphemeris;
2008     GalileoEphemeris galEphemerisData[GNSS_EPHEMERIS_LIST_MAX_SIZE_V02];
2009 } GalileoEphemerisResponse;
2010 
2011 /** QZSS Navigation model for each SV */
2012 typedef struct {
2013     uint16_t numOfEphemeris;
2014     GpsEphemeris qzssEphemerisData[GNSS_EPHEMERIS_LIST_MAX_SIZE_V02];
2015 } QzssEphemerisResponse;
2016 
2017 
2018 typedef struct {
2019     /** Indicates GNSS Constellation Type
2020         Mandatory field */
2021     Gnss_LocSvSystemEnumType gnssConstellation;
2022 
2023     /** GPS System Time of the ephemeris report */
2024     bool isSystemTimeValid;
2025     GnssSystemTimeStructType systemTime;
2026 
2027     union {
2028        /** GPS Ephemeris */
2029        GpsEphemerisResponse gpsEphemeris;
2030        /** GLONASS Ephemeris */
2031        GlonassEphemerisResponse glonassEphemeris;
2032        /** BDS Ephemeris */
2033        BdsEphemerisResponse bdsEphemeris;
2034        /** GALILEO Ephemeris */
2035        GalileoEphemerisResponse galileoEphemeris;
2036        /** QZSS Ephemeris */
2037        QzssEphemerisResponse qzssEphemeris;
2038     } ephInfo;
2039 } GnssSvEphemerisReport;
2040 
2041 typedef struct {
2042     /** GPS System Time of the iono model report */
2043     bool isSystemTimeValid;
2044     GnssSystemTimeStructType systemTime;
2045 
2046     /** Indicates GNSS Constellation Type */
2047     Gnss_LocSvSystemEnumType gnssConstellation;
2048 
2049     float alpha0;
2050     /**<   Klobuchar Model Parameter Alpha 0.
2051          - Type: float
2052          - Unit: Seconds
2053     */
2054 
2055     float alpha1;
2056     /**<   Klobuchar Model Parameter Alpha 1.
2057          - Type: float
2058          - Unit: Seconds / Semi-Circle
2059     */
2060 
2061     float alpha2;
2062     /**<   Klobuchar Model Parameter Alpha 2.
2063          - Type: float
2064          - Unit: Seconds / Semi-Circle^2
2065     */
2066 
2067     float alpha3;
2068     /**<   Klobuchar Model Parameter Alpha 3.
2069          - Type: float
2070          - Unit: Seconds / Semi-Circle^3
2071     */
2072 
2073     float beta0;
2074     /**<   Klobuchar Model Parameter Beta 0.
2075          - Type: float
2076          - Unit: Seconds
2077     */
2078 
2079     float beta1;
2080     /**<   Klobuchar Model Parameter Beta 1.
2081          - Type: float
2082          - Unit: Seconds / Semi-Circle
2083     */
2084 
2085     float beta2;
2086     /**<   Klobuchar Model Parameter Beta 2.
2087          - Type: float
2088          - Unit: Seconds / Semi-Circle^2
2089     */
2090 
2091     float beta3;
2092     /**<   Klobuchar Model Parameter Beta 3.
2093          - Type: float
2094          - Unit: Seconds / Semi-Circle^3
2095     */
2096 } GnssKlobucharIonoModel;
2097 
2098 typedef struct {
2099         /** GPS System Time of the report */
2100     bool isSystemTimeValid;
2101     GnssSystemTimeStructType systemTime;
2102 
2103     GnssAdditionalSystemInfoMask validityMask;
2104     double tauC;
2105     int8_t leapSec;
2106 } GnssAdditionalSystemInfo;
2107 
2108 /* Various Short Range Node Technology type*/
2109 typedef enum {
2110     SRN_AP_DATA_TECH_TYPE_NONE,
2111     SRN_AP_DATA_TECH_TYPE_BT,
2112     SRN_AP_DATA_TECH_TYPE_BTLE,
2113     SRN_AP_DATA_TECH_TYPE_NFC,
2114     SRN_AP_DATA_TECH_TYPE_MOBILE_CODE,
2115     SRN_AP_DATA_TECH_TYPE_OTHER
2116 } Gnss_SrnTech;
2117 
2118 /* Mac Address type requested by modem */
2119 typedef enum {
2120     SRN_AP_DATA_PUBLIC_MAC_ADDR_TYPE_INVALID, /* No valid mac address type send */
2121     SRN_AP_DATA_PUBLIC_MAC_ADDR_TYPE_PUBLIC, /* SRN AP MAC Address type PUBLIC  */
2122     SRN_AP_DATA_PUBLIC_MAC_ADDR_TYPE_PRIVATE, /* SRN AP MAC Address type PRIVATE  */
2123     SRN_AP_DATA_PUBLIC_MAC_ADDR_TYPE_OTHER, /* SRN AP MAC Address type OTHER  */
2124 }Gnss_Srn_MacAddr_Type;
2125 
2126 typedef struct
2127 {
2128     uint32_t                 size;
2129     Gnss_SrnTech           srnTechType; /* SRN Technology type in request */
2130     bool                   srnRequest; /* scan - start(true) or stop(false) */
2131     bool                   e911Mode; /* If in E911 emergency */
2132     Gnss_Srn_MacAddr_Type  macAddrType; /* SRN AP MAC Address type */
2133 } GnssSrnDataReq;
2134 
2135 /* Mask indicating enabled or disabled constellations */
2136 typedef uint64_t GnssSvTypesMask;
2137 typedef enum {
2138     GNSS_SV_TYPES_MASK_GLO_BIT    = (1<<0),
2139     GNSS_SV_TYPES_MASK_BDS_BIT    = (1<<1),
2140     GNSS_SV_TYPES_MASK_QZSS_BIT   = (1<<2),
2141     GNSS_SV_TYPES_MASK_GAL_BIT    = (1<<3),
2142     GNSS_SV_TYPES_MASK_NAVIC_BIT  = (1<<4),
2143 } GnssSvTypesMaskBits;
2144 
2145 /* This SV Type config is injected directly to GNSS Adapter
2146  * bypassing Location API */
2147 typedef struct {
2148     uint32_t size; // set to sizeof(GnssSvTypeConfig)
2149     // Enabled Constellations
2150     GnssSvTypesMask enabledSvTypesMask;
2151     // Disabled Constellations
2152     GnssSvTypesMask blacklistedSvTypesMask;
2153 } GnssSvTypeConfig;
2154 
2155 /* Provides the current GNSS SV Type configuration to the client.
2156  * This is fetched via direct call to GNSS Adapter bypassing
2157  * Location API */
2158 typedef std::function<void(
2159     const GnssSvTypeConfig& config
2160 )> GnssSvTypeConfigCallback;
2161 
2162 /*
2163  * Represents the status of AGNSS augmented to support IPv4.
2164  */
2165 struct AGnssExtStatusIpV4 {
2166     AGpsExtType         type;
2167     LocApnTypeMask      apnTypeMask;
2168     LocAGpsStatusValue  status;
2169     /*
2170      * 32-bit IPv4 address.
2171      */
2172     uint32_t            ipV4Addr;
2173 };
2174 
2175 /*
2176  * Represents the status of AGNSS augmented to support IPv6.
2177  */
2178 struct AGnssExtStatusIpV6 {
2179     AGpsExtType         type;
2180     LocApnTypeMask      apnTypeMask;
2181     LocAGpsStatusValue  status;
2182     /*
2183      * 128-bit IPv6 address.
2184      */
2185     uint8_t             ipV6Addr[16];
2186 };
2187 
2188 /*
2189 * Represents the the Nfw Notification structure
2190 */
2191 #define GNSS_MAX_NFW_APP_STRING_LEN 64
2192 #define GNSS_MAX_NFW_STRING_LEN  20
2193 
2194 typedef enum {
2195     GNSS_NFW_CTRL_PLANE = 0,
2196     GNSS_NFW_SUPL = 1,
2197     GNSS_NFW_IMS = 10,
2198     GNSS_NFW_SIM = 11,
2199     GNSS_NFW_OTHER_PROTOCOL_STACK = 100
2200 } GnssNfwProtocolStack;
2201 
2202 typedef enum {
2203     GNSS_NFW_CARRIER = 0,
2204     GNSS_NFW_OEM = 10,
2205     GNSS_NFW_MODEM_CHIPSET_VENDOR = 11,
2206     GNSS_NFW_GNSS_CHIPSET_VENDOR = 12,
2207     GNSS_NFW_OTHER_CHIPSET_VENDOR = 13,
2208     GNSS_NFW_AUTOMOBILE_CLIENT = 20,
2209     GNSS_NFW_OTHER_REQUESTOR = 100
2210 } GnssNfwRequestor;
2211 
2212 typedef enum {
2213     GNSS_NFW_REJECTED = 0,
2214     GNSS_NFW_ACCEPTED_NO_LOCATION_PROVIDED = 1,
2215     GNSS_NFW_ACCEPTED_LOCATION_PROVIDED = 2,
2216 } GnssNfwResponseType;
2217 
2218 typedef struct {
2219     char                    proxyAppPackageName[GNSS_MAX_NFW_APP_STRING_LEN];
2220     GnssNfwProtocolStack    protocolStack;
2221     char                    otherProtocolStackName[GNSS_MAX_NFW_STRING_LEN];
2222     GnssNfwRequestor        requestor;
2223     char                    requestorId[GNSS_MAX_NFW_STRING_LEN];
2224     GnssNfwResponseType     responseType;
2225     bool                    inEmergencyMode;
2226     bool                    isCachedLocation;
2227 } GnssNfwNotification;
2228 
2229 /* ODCPI Request Info */
2230 enum OdcpiRequestType {
2231     ODCPI_REQUEST_TYPE_START,
2232     ODCPI_REQUEST_TYPE_STOP
2233 };
2234 struct OdcpiRequestInfo {
2235     uint32_t size;
2236     OdcpiRequestType type;
2237     uint32_t tbfMillis;
2238     bool isEmergencyMode;
2239 };
2240 /* Callback to send ODCPI request to framework */
2241 typedef std::function<void(const OdcpiRequestInfo& request)> OdcpiRequestCallback;
2242 
2243 /*
2244  * Callback with AGNSS(IpV4) status information.
2245  *
2246  * @param status Will be of type AGnssExtStatusIpV4.
2247  */
2248 typedef void (*AgnssStatusIpV4Cb)(AGnssExtStatusIpV4 status);
2249 
2250 /*
2251 * Callback with NFW information.
2252 */
2253 typedef void(*NfwStatusCb)(GnssNfwNotification notification);
2254 typedef bool(*IsInEmergencySession)(void);
2255 
2256 /*
2257  * Callback with AGNSS(IpV6) status information.
2258  *
2259  * @param status Will be of type AGnssExtStatusIpV6.
2260  */
2261 typedef void (*AgnssStatusIpV6Cb)(AGnssExtStatusIpV6 status);
2262 
2263 /* Constructs for interaction with loc_net_iface library */
2264 typedef void (*LocAgpsOpenResultCb)(bool isSuccess, AGpsExtType agpsType, const char* apn,
2265         AGpsBearerType bearerType, void* userDataPtr);
2266 
2267 typedef void (*LocAgpsCloseResultCb)(bool isSuccess, AGpsExtType agpsType, void* userDataPtr);
2268 
2269 /* Shared resources of LocIpc */
2270 #define LOC_IPC_HAL                    "/dev/socket/location/socket_hal"
2271 #define LOC_IPC_XTRA                   "/dev/socket/location/xtra/socket_xtra"
2272 
2273 #define SOCKET_DIR_LOCATION            "/dev/socket/location/"
2274 #define SOCKET_DIR_EHUB                "/dev/socket/location/ehub/"
2275 #define SOCKET_TO_LOCATION_HAL_DAEMON  "/dev/socket/loc_client/hal_daemon"
2276 
2277 #define SOCKET_LOC_CLIENT_DIR          "/dev/socket/loc_client/"
2278 #define EAP_LOC_CLIENT_DIR             "/data/vendor/location/extap_locclient/"
2279 
2280 #define LOC_CLIENT_NAME_PREFIX         "toclient"
2281 
2282 typedef uint64_t NetworkHandle;
2283 #define NETWORK_HANDLE_UNKNOWN  ~0
2284 #define MAX_NETWORK_HANDLES 10
2285 
2286 #ifdef __cplusplus
2287 }
2288 #endif /* __cplusplus */
2289 
2290 #endif /* GPS_EXTENDED_C_H */
2291