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