• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2018 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 LOCATIONDATATYPES_H
30 #define LOCATIONDATATYPES_H
31 
32 #include <vector>
33 #include <stdint.h>
34 #include <functional>
35 #include <list>
36 
37 #define GNSS_NI_REQUESTOR_MAX  (256)
38 #define GNSS_NI_MESSAGE_ID_MAX (2048)
39 #define GNSS_SV_MAX            (64)
40 #define GNSS_MEASUREMENTS_MAX  (64)
41 #define GNSS_UTC_TIME_OFFSET   (3657)
42 
43 #define GNSS_BUGREPORT_GPS_MIN  (1)
44 #define GNSS_BUGREPORT_SBAS_MIN (120)
45 #define GNSS_BUGREPORT_GLO_MIN  (1)
46 #define GNSS_BUGREPORT_QZSS_MIN (193)
47 #define GNSS_BUGREPORT_BDS_MIN  (1)
48 #define GNSS_BUGREPORT_GAL_MIN  (1)
49 
50 typedef enum {
51     LOCATION_ERROR_SUCCESS = 0,
52     LOCATION_ERROR_GENERAL_FAILURE,
53     LOCATION_ERROR_CALLBACK_MISSING,
54     LOCATION_ERROR_INVALID_PARAMETER,
55     LOCATION_ERROR_ID_EXISTS,
56     LOCATION_ERROR_ID_UNKNOWN,
57     LOCATION_ERROR_ALREADY_STARTED,
58     LOCATION_ERROR_GEOFENCES_AT_MAX,
59     LOCATION_ERROR_NOT_SUPPORTED
60 } LocationError;
61 
62 // Flags to indicate which values are valid in a Location
63 typedef uint16_t LocationFlagsMask;
64 typedef enum {
65     LOCATION_HAS_LAT_LONG_BIT          = (1<<0), // location has valid latitude and longitude
66     LOCATION_HAS_ALTITUDE_BIT          = (1<<1), // location has valid altitude
67     LOCATION_HAS_SPEED_BIT             = (1<<2), // location has valid speed
68     LOCATION_HAS_BEARING_BIT           = (1<<3), // location has valid bearing
69     LOCATION_HAS_ACCURACY_BIT          = (1<<4), // location has valid accuracy
70     LOCATION_HAS_VERTICAL_ACCURACY_BIT = (1<<5), // location has valid vertical accuracy
71     LOCATION_HAS_SPEED_ACCURACY_BIT    = (1<<6), // location has valid speed accuracy
72     LOCATION_HAS_BEARING_ACCURACY_BIT  = (1<<7), // location has valid bearing accuracy
73 } LocationFlagsBits;
74 
75 typedef uint16_t LocationTechnologyMask;
76 typedef enum {
77     LOCATION_TECHNOLOGY_GNSS_BIT     = (1<<0), // location was calculated using GNSS
78     LOCATION_TECHNOLOGY_CELL_BIT     = (1<<1), // location was calculated using Cell
79     LOCATION_TECHNOLOGY_WIFI_BIT     = (1<<2), // location was calculated using WiFi
80     LOCATION_TECHNOLOGY_SENSORS_BIT  = (1<<3), // location was calculated using Sensors
81 } LocationTechnologyBits;
82 
83 typedef enum {
84     LOCATION_RELIABILITY_NOT_SET = 0,
85     LOCATION_RELIABILITY_VERY_LOW,
86     LOCATION_RELIABILITY_LOW,
87     LOCATION_RELIABILITY_MEDIUM,
88     LOCATION_RELIABILITY_HIGH,
89 } LocationReliability;
90 
91 typedef uint32_t GnssLocationNavSolutionMask;
92 typedef enum {
93     LOCATION_SBAS_CORRECTION_IONO_BIT  = (1<<0), // SBAS ionospheric correction is used
94     LOCATION_SBAS_CORRECTION_FAST_BIT  = (1<<1), // SBAS fast correction is used
95     LOCATION_SBAS_CORRECTION_LONG_BIT  = (1<<2), // SBAS long-tem correction is used
96     LOCATION_SBAS_INTEGRITY_BIT        = (1<<3), // SBAS integrity information is used
97     LOCATION_NAV_CORRECTION_DGNSS_BIT  = (1<<4), // Position Report is DGNSS corrected
98     LOCATION_NAV_CORRECTION_RTK_BIT    = (1<<5), // Position Report is RTK corrected
99     LOCATION_NAV_CORRECTION_PPP_BIT    = (1<<6) // Position Report is PPP corrected
100 } GnssLocationNavSolutionBits;
101 
102 typedef uint32_t GnssLocationPosTechMask;
103 typedef enum {
104     LOCATION_POS_TECH_DEFAULT_BIT                  = 0,
105     LOCATION_POS_TECH_SATELLITE_BIT                = (1<<0),
106     LOCATION_POS_TECH_CELLID_BIT                   = (1<<1),
107     LOCATION_POS_TECH_WIFI_BIT                     = (1<<2),
108     LOCATION_POS_TECH_SENSORS_BIT                  = (1<<3),
109     LOCATION_POS_TECH_REFERENCE_LOCATION_BIT       = (1<<4),
110     LOCATION_POS_TECH_INJECTED_COARSE_POSITION_BIT = (1<<5),
111     LOCATION_POS_TECH_AFLT_BIT                     = (1<<6),
112     LOCATION_POS_TECH_HYBRID_BIT                   = (1<<7),
113     LOCATION_POS_TECH_PPE_BIT                      = (1<<8)
114 } GnssLocationPosTechBits;
115 
116 typedef uint32_t GnssLocationPosDataMask;
117 typedef enum {
118     LOCATION_NAV_DATA_HAS_LONG_ACCEL_BIT  = (1<<0), // Navigation data has Forward Acceleration
119     LOCATION_NAV_DATA_HAS_LAT_ACCEL_BIT   = (1<<1), // Navigation data has Sideward Acceleration
120     LOCATION_NAV_DATA_HAS_VERT_ACCEL_BIT  = (1<<2), // Navigation data has Vertical Acceleration
121     LOCATION_NAV_DATA_HAS_YAW_RATE_BIT    = (1<<3), // Navigation data has Heading Rate
122     LOCATION_NAV_DATA_HAS_PITCH_BIT       = (1<<4)  // Navigation data has Body pitch
123 } GnssLocationPosDataBits;
124 
125 typedef uint32_t GnssLocationInfoFlagMask;
126 typedef enum {
127     GNSS_LOCATION_INFO_ALTITUDE_MEAN_SEA_LEVEL_BIT      = (1<<0), // valid altitude mean sea level
128     GNSS_LOCATION_INFO_DOP_BIT                          = (1<<1), // valid pdop, hdop, and vdop
129     GNSS_LOCATION_INFO_MAGNETIC_DEVIATION_BIT           = (1<<2), // valid magnetic deviation
130     GNSS_LOCATION_INFO_HOR_RELIABILITY_BIT              = (1<<3), // valid horizontal reliability
131     GNSS_LOCATION_INFO_VER_RELIABILITY_BIT              = (1<<4), // valid vertical reliability
132     GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MAJOR_BIT = (1<<5), // valid elipsode semi major
133     GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MINOR_BIT = (1<<6), // valid elipsode semi minor
134     GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_AZIMUTH_BIT    = (1<<7), // valid accuracy elipsode azimuth
135     GNSS_LOCATION_INFO_GNSS_SV_USED_DATA_BIT            = (1<<8), // valid gnss sv used in pos data
136     GNSS_LOCATION_INFO_NAV_SOLUTION_MASK_BIT            = (1<<9), // valid navSolutionMask
137     GNSS_LOCATION_INFO_POS_TECH_MASK_BIT                = (1<<10),// valid LocPosTechMask
138     GNSS_LOCATION_INFO_SV_SOURCE_INFO_BIT               = (1<<11),// valid LocSvInfoSource
139     GNSS_LOCATION_INFO_POS_DYNAMICS_DATA_BIT            = (1<<12),// valid position dynamics data
140     GNSS_LOCATION_INFO_GPS_TIME_BIT                     = (1<<13),// valid GPS Time
141     GNSS_LOCATION_INFO_EXT_DOP_BIT                      = (1<<14) // valid gdop, tdop
142 } GnssLocationInfoFlagBits;
143 
144 typedef enum {
145     GEOFENCE_BREACH_ENTER = 0,
146     GEOFENCE_BREACH_EXIT,
147     GEOFENCE_BREACH_DWELL_IN,
148     GEOFENCE_BREACH_DWELL_OUT,
149     GEOFENCE_BREACH_UNKNOWN,
150 } GeofenceBreachType;
151 
152 typedef uint16_t GeofenceBreachTypeMask;
153 typedef enum {
154     GEOFENCE_BREACH_ENTER_BIT     = (1<<0),
155     GEOFENCE_BREACH_EXIT_BIT      = (1<<1),
156     GEOFENCE_BREACH_DWELL_IN_BIT  = (1<<2),
157     GEOFENCE_BREACH_DWELL_OUT_BIT = (1<<3),
158 } GeofenceBreachTypeBits;
159 
160 typedef enum {
161     GEOFENCE_STATUS_AVAILABILE_NO = 0,
162     GEOFENCE_STATUS_AVAILABILE_YES,
163 } GeofenceStatusAvailable;
164 
165 typedef uint32_t LocationCapabilitiesMask;
166 typedef enum {
167     // supports startTracking API with minInterval param
168     LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT           = (1<<0),
169     // supports startBatching API with minInterval param
170     LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT           = (1<<1),
171     // supports startTracking API with minDistance param
172     LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT       = (1<<2),
173     // supports startBatching API with minDistance param
174     LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT       = (1<<3),
175     // supports addGeofences API
176     LOCATION_CAPABILITIES_GEOFENCE_BIT                      = (1<<4),
177     // supports GnssMeasurementsCallback
178     LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT             = (1<<5),
179     // supports startTracking/startBatching API with LocationOptions.mode of MSB (Ms Based)
180     LOCATION_CAPABILITIES_GNSS_MSB_BIT                      = (1<<6),
181     // supports startTracking/startBatching API with LocationOptions.mode of MSA (MS Assisted)
182     LOCATION_CAPABILITIES_GNSS_MSA_BIT                      = (1<<7),
183     // supports debug nmea sentences in the debugNmeaCallback
184     LOCATION_CAPABILITIES_DEBUG_NMEA_BIT                    = (1<<8),
185     // support outdoor trip batching
186     LOCATION_CAPABILITIES_OUTDOOR_TRIP_BATCHING_BIT         = (1<<9),
187     // support constellation enablement
188     LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT      = (1<<10),
189     // support agpm
190     LOCATION_CAPABILITIES_AGPM_BIT                          = (1<<11),
191 } LocationCapabilitiesBits;
192 
193 typedef enum {
194     LOCATION_TECHNOLOGY_TYPE_GNSS = 0,
195 } LocationTechnologyType;
196 
197 // Configures how GPS is locked when GPS is disabled (through GnssDisable)
198 typedef enum {
199     GNSS_CONFIG_GPS_LOCK_NONE = 0, // gps is not locked when GPS is disabled (GnssDisable)
200     GNSS_CONFIG_GPS_LOCK_MO,       // gps mobile originated (MO) is locked when GPS is disabled
201     GNSS_CONFIG_GPS_LOCK_NI,       // gps network initiated (NI) is locked when GPS is disabled
202     GNSS_CONFIG_GPS_LOCK_MO_AND_NI,// gps MO and NI is locked when GPS is disabled
203 } GnssConfigGpsLock;
204 
205 // SUPL version
206 typedef enum {
207     GNSS_CONFIG_SUPL_VERSION_1_0_0 = 1,
208     GNSS_CONFIG_SUPL_VERSION_2_0_0,
209     GNSS_CONFIG_SUPL_VERSION_2_0_2,
210 } GnssConfigSuplVersion;
211 
212 // LTE Positioning Profile
213 typedef enum {
214     GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE = 0,              // RRLP on LTE (Default)
215     GNSS_CONFIG_LPP_PROFILE_USER_PLANE,                   // LPP User Plane (UP) on LTE
216     GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE,                // LPP_Control_Plane (CP)
217     GNSS_CONFIG_LPP_PROFILE_USER_PLANE_AND_CONTROL_PLANE, // Both LPP UP and CP
218 } GnssConfigLppProfile;
219 
220 // Technology for LPPe Control Plane
221 typedef uint16_t GnssConfigLppeControlPlaneMask;
222 typedef enum {
223     GNSS_CONFIG_LPPE_CONTROL_PLANE_DBH_BIT                  = (1<<0), // DBH
224     GNSS_CONFIG_LPPE_CONTROL_PLANE_WLAN_AP_MEASUREMENTS_BIT = (1<<1), // WLAN_AP_MEASUREMENTS
225     GNSS_CONFIG_LPPE_CONTROL_PLANE_SRN_AP_MEASUREMENTS_BIT = (1<<2), // SRN_AP_MEASUREMENTS
226     GNSS_CONFIG_LPPE_CONTROL_PLANE_SENSOR_BARO_MEASUREMENTS_BIT = (1<<3),
227                                                              // SENSOR_BARO_MEASUREMENTS
228 } GnssConfigLppeControlPlaneBits;
229 
230 // Technology for LPPe User Plane
231 typedef uint16_t GnssConfigLppeUserPlaneMask;
232 typedef enum {
233     GNSS_CONFIG_LPPE_USER_PLANE_DBH_BIT                  = (1<<0), // DBH
234     GNSS_CONFIG_LPPE_USER_PLANE_WLAN_AP_MEASUREMENTS_BIT = (1<<1), // WLAN_AP_MEASUREMENTS
235     GNSS_CONFIG_LPPE_USER_PLANE_SRN_AP_MEASUREMENTS_BIT = (1<<2), // SRN_AP_MEASUREMENTS
236     GNSS_CONFIG_LPPE_USER_PLANE_SENSOR_BARO_MEASUREMENTS_BIT = (1<<3),
237                                                             // SENSOR_BARO_MEASUREMENTS
238 } GnssConfigLppeUserPlaneBits;
239 
240 // Positioning Protocol on A-GLONASS system
241 typedef uint16_t GnssConfigAGlonassPositionProtocolMask;
242 typedef enum {
243     GNSS_CONFIG_RRC_CONTROL_PLANE_BIT = (1<<0),  // RRC Control Plane
244     GNSS_CONFIG_RRLP_USER_PLANE_BIT   = (1<<1),  // RRLP User Plane
245     GNSS_CONFIG_LLP_USER_PLANE_BIT    = (1<<2),  // LPP User Plane
246     GNSS_CONFIG_LLP_CONTROL_PLANE_BIT = (1<<3),  // LPP Control Plane
247 } GnssConfigAGlonassPositionProtocolBits;
248 
249 typedef enum {
250     GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_NO = 0,
251     GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_YES,
252 } GnssConfigEmergencyPdnForEmergencySupl;
253 
254 typedef enum {
255     GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO = 0,
256     GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_YES,
257 } GnssConfigSuplEmergencyServices;
258 
259 typedef uint16_t GnssConfigSuplModeMask;
260 typedef enum {
261     GNSS_CONFIG_SUPL_MODE_MSB_BIT = (1<<0),
262     GNSS_CONFIG_SUPL_MODE_MSA_BIT = (1<<1),
263 } GnssConfigSuplModeBits;
264 
265 typedef uint32_t GnssConfigFlagsMask;
266 typedef enum {
267     GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT                   = (1<<0),
268     GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT               = (1<<1),
269     GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT        = (1<<2),
270     GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT                = (1<<3),
271     GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT         = (1<<4),
272     GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT            = (1<<5),
273     GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT = (1<<6),
274     GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT         = (1<<7),
275     GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT                 = (1<<8),
276     GNSS_CONFIG_FLAGS_SUPL_MODE_BIT                        = (1<<9),
277     GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT               = (1<<10)
278 } GnssConfigFlagsBits;
279 
280 typedef enum {
281     GNSS_NI_ENCODING_TYPE_NONE = 0,
282     GNSS_NI_ENCODING_TYPE_GSM_DEFAULT,
283     GNSS_NI_ENCODING_TYPE_UTF8,
284     GNSS_NI_ENCODING_TYPE_UCS2,
285 } GnssNiEncodingType;
286 
287 typedef enum {
288     GNSS_NI_TYPE_VOICE = 0,
289     GNSS_NI_TYPE_SUPL,
290     GNSS_NI_TYPE_CONTROL_PLANE,
291     GNSS_NI_TYPE_EMERGENCY_SUPL
292 } GnssNiType;
293 
294 typedef uint16_t GnssNiOptionsMask;
295 typedef enum {
296     GNSS_NI_OPTIONS_NOTIFICATION_BIT     = (1<<0),
297     GNSS_NI_OPTIONS_VERIFICATION_BIT     = (1<<1),
298     GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT = (1<<2),
299 } GnssNiOptionsBits;
300 
301 typedef enum {
302     GNSS_NI_RESPONSE_ACCEPT = 1,
303     GNSS_NI_RESPONSE_DENY,
304     GNSS_NI_RESPONSE_NO_RESPONSE,
305     GNSS_NI_RESPONSE_IGNORE,
306 } GnssNiResponse;
307 
308 typedef enum {
309     GNSS_SV_TYPE_UNKNOWN = 0,
310     GNSS_SV_TYPE_GPS,
311     GNSS_SV_TYPE_SBAS,
312     GNSS_SV_TYPE_GLONASS,
313     GNSS_SV_TYPE_QZSS,
314     GNSS_SV_TYPE_BEIDOU,
315     GNSS_SV_TYPE_GALILEO,
316 } GnssSvType;
317 
318 typedef enum {
319     GNSS_EPH_TYPE_UNKNOWN = 0,
320     GNSS_EPH_TYPE_EPHEMERIS,
321     GNSS_EPH_TYPE_ALMANAC,
322 } GnssEphemerisType;
323 
324 typedef enum {
325     GNSS_EPH_SOURCE_UNKNOWN = 0,
326     GNSS_EPH_SOURCE_DEMODULATED,
327     GNSS_EPH_SOURCE_SUPL_PROVIDED,
328     GNSS_EPH_SOURCE_OTHER_SERVER_PROVIDED,
329     GNSS_EPH_SOURCE_LOCAL,
330 } GnssEphemerisSource;
331 
332 typedef enum {
333     GNSS_EPH_HEALTH_UNKNOWN = 0,
334     GNSS_EPH_HEALTH_GOOD,
335     GNSS_EPH_HEALTH_BAD,
336 } GnssEphemerisHealth;
337 
338 typedef uint16_t GnssSvOptionsMask;
339 typedef enum {
340     GNSS_SV_OPTIONS_HAS_EPHEMER_BIT = (1<<0),
341     GNSS_SV_OPTIONS_HAS_ALMANAC_BIT = (1<<1),
342     GNSS_SV_OPTIONS_USED_IN_FIX_BIT = (1<<2),
343     GNSS_SV_OPTIONS_HAS_CARRIER_FREQUENCY_BIT = (1<<3),
344 } GnssSvOptionsBits;
345 
346 typedef enum {
347     GNSS_ASSISTANCE_TYPE_SUPL = 0,
348     GNSS_ASSISTANCE_TYPE_C2K,
349 } GnssAssistanceType;
350 
351 typedef enum {
352     GNSS_SUPL_MODE_STANDALONE = 0,
353     GNSS_SUPL_MODE_MSB,
354     GNSS_SUPL_MODE_MSA,
355 } GnssSuplMode;
356 
357 typedef enum {
358     BATCHING_MODE_ROUTINE = 0,   // positions are reported when batched positions memory is full
359     BATCHING_MODE_TRIP,          // positions are reported when a certain distance is covered
360     BATCHING_MODE_NO_AUTO_REPORT // no report of positions automatically, instead queried on demand
361 } BatchingMode;
362 
363 typedef enum {
364     BATCHING_STATUS_TRIP_COMPLETED = 0,
365     BATCHING_STATUS_POSITION_AVAILABE,
366     BATCHING_STATUS_POSITION_UNAVAILABLE
367 } BatchingStatus;
368 
369 typedef uint16_t GnssMeasurementsAdrStateMask;
370 typedef enum {
371     GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_UNKNOWN         = 0,
372     GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT       = (1<<0),
373     GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT       = (1<<1),
374     GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT  = (1<<2),
375 } GnssMeasurementsAdrStateBits;
376 
377 typedef uint32_t GnssMeasurementsDataFlagsMask;
378 typedef enum {
379     GNSS_MEASUREMENTS_DATA_SV_ID_BIT                        = (1<<0),
380     GNSS_MEASUREMENTS_DATA_SV_TYPE_BIT                      = (1<<1),
381     GNSS_MEASUREMENTS_DATA_STATE_BIT                        = (1<<2),
382     GNSS_MEASUREMENTS_DATA_RECEIVED_SV_TIME_BIT             = (1<<3),
383     GNSS_MEASUREMENTS_DATA_RECEIVED_SV_TIME_UNCERTAINTY_BIT = (1<<4),
384     GNSS_MEASUREMENTS_DATA_CARRIER_TO_NOISE_BIT             = (1<<5),
385     GNSS_MEASUREMENTS_DATA_PSEUDORANGE_RATE_BIT             = (1<<6),
386     GNSS_MEASUREMENTS_DATA_PSEUDORANGE_RATE_UNCERTAINTY_BIT = (1<<7),
387     GNSS_MEASUREMENTS_DATA_ADR_STATE_BIT                    = (1<<8),
388     GNSS_MEASUREMENTS_DATA_ADR_BIT                          = (1<<9),
389     GNSS_MEASUREMENTS_DATA_ADR_UNCERTAINTY_BIT              = (1<<10),
390     GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT            = (1<<11),
391     GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT               = (1<<12),
392     GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT                = (1<<13),
393     GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT    = (1<<14),
394     GNSS_MEASUREMENTS_DATA_MULTIPATH_INDICATOR_BIT          = (1<<15),
395     GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT        = (1<<16),
396     GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT       = (1<<17),
397 } GnssMeasurementsDataFlagsBits;
398 
399 typedef uint32_t GnssMeasurementsStateMask;
400 typedef enum {
401     GNSS_MEASUREMENTS_STATE_UNKNOWN_BIT               = 0,
402     GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT             = (1<<0),
403     GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT              = (1<<1),
404     GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT         = (1<<2),
405     GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT           = (1<<3),
406     GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT        = (1<<4),
407     GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT           = (1<<5),
408     GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT       = (1<<6),
409     GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT       = (1<<7),
410     GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT       = (1<<8),
411     GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT  = (1<<9),
412     GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT    = (1<<10),
413     GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT = (1<<11),
414     GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT     = (1<<12),
415     GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT             = (1<<13),
416 } GnssMeasurementsStateBits;
417 
418 typedef enum {
419     GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_UNKNOWN = 0,
420     GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_PRESENT,
421     GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_NOT_PRESENT,
422 } GnssMeasurementsMultipathIndicator;
423 
424 typedef uint32_t GnssMeasurementsClockFlagsMask;
425 typedef enum {
426     GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT                  = (1<<0),
427     GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_BIT                         = (1<<1),
428     GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT             = (1<<2),
429     GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT                    = (1<<3),
430     GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT                         = (1<<4),
431     GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT             = (1<<5),
432     GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_BIT                        = (1<<6),
433     GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_UNCERTAINTY_BIT            = (1<<7),
434     GNSS_MEASUREMENTS_CLOCK_FLAGS_HW_CLOCK_DISCONTINUITY_COUNT_BIT = (1<<8),
435 } GnssMeasurementsClockFlagsBits;
436 
437 typedef uint32_t GnssAidingDataSvMask;
438 typedef enum {
439     GNSS_AIDING_DATA_SV_EPHEMERIS_BIT    = (1<<0), // ephemeris
440     GNSS_AIDING_DATA_SV_ALMANAC_BIT      = (1<<1), // almanac
441     GNSS_AIDING_DATA_SV_HEALTH_BIT       = (1<<2), // health
442     GNSS_AIDING_DATA_SV_DIRECTION_BIT    = (1<<3), // direction
443     GNSS_AIDING_DATA_SV_STEER_BIT        = (1<<4), // steer
444     GNSS_AIDING_DATA_SV_ALMANAC_CORR_BIT = (1<<5), // almanac correction
445     GNSS_AIDING_DATA_SV_BLACKLIST_BIT    = (1<<6), // blacklist SVs
446     GNSS_AIDING_DATA_SV_SA_DATA_BIT      = (1<<7), // sensitivity assistance data
447     GNSS_AIDING_DATA_SV_NO_EXIST_BIT     = (1<<8), // SV does not exist
448     GNSS_AIDING_DATA_SV_IONOSPHERE_BIT   = (1<<9), // ionosphere correction
449     GNSS_AIDING_DATA_SV_TIME_BIT         = (1<<10),// reset satellite time
450 } GnssAidingDataSvBits;
451 
452 typedef uint32_t GnssAidingDataSvTypeMask;
453 typedef enum {
454     GNSS_AIDING_DATA_SV_TYPE_GPS_BIT      = (1<<0),
455     GNSS_AIDING_DATA_SV_TYPE_GLONASS_BIT  = (1<<1),
456     GNSS_AIDING_DATA_SV_TYPE_QZSS_BIT     = (1<<2),
457     GNSS_AIDING_DATA_SV_TYPE_BEIDOU_BIT   = (1<<3),
458     GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT  = (1<<4),
459 } GnssAidingDataSvTypeBits;
460 
461 typedef enum
462 {
463     GNSS_LOC_SV_SYSTEM_GPS                    = 1,
464     /**< GPS satellite. */
465     GNSS_LOC_SV_SYSTEM_GALILEO                = 2,
466     /**< GALILEO satellite. */
467     GNSS_LOC_SV_SYSTEM_SBAS                   = 3,
468     /**< SBAS satellite. */
469     GNSS_LOC_SV_SYSTEM_COMPASS                = 4,
470     /**< COMPASS satellite. */
471     GNSS_LOC_SV_SYSTEM_GLONASS                = 5,
472     /**< GLONASS satellite. */
473     GNSS_LOC_SV_SYSTEM_BDS                    = 6,
474     /**< BDS satellite. */
475     GNSS_LOC_SV_SYSTEM_QZSS                   = 7
476     /**< QZSS satellite. */
477 } Gnss_LocSvSystemEnumType;
478 
479 typedef uint32_t GnssSystemTimeStructTypeFlags;
480 typedef enum {
481     GNSS_SYSTEM_TIME_WEEK_VALID             = (1 << 0),
482     GNSS_SYSTEM_TIME_WEEK_MS_VALID          = (1 << 1),
483     GNSS_SYSTEM_CLK_TIME_BIAS_VALID         = (1 << 2),
484     GNSS_SYSTEM_CLK_TIME_BIAS_UNC_VALID     = (1 << 3),
485     GNSS_SYSTEM_REF_FCOUNT_VALID            = (1 << 4),
486     GNSS_SYSTEM_NUM_CLOCK_RESETS_VALID      = (1 << 5)
487 } GnssSystemTimeTypeBits;
488 
489 typedef uint32_t GnssGloTimeStructTypeFlags;
490 typedef enum {
491     GNSS_CLO_DAYS_VALID                     = (1 << 0),
492     GNSS_GLOS_MSEC_VALID                    = (1 << 1),
493     GNSS_GLO_CLK_TIME_BIAS_VALID            = (1 << 2),
494     GNSS_GLO_CLK_TIME_BIAS_UNC_VALID        = (1 << 3),
495     GNSS_GLO_REF_FCOUNT_VALID               = (1 << 4),
496     GNSS_GLO_NUM_CLOCK_RESETS_VALID         = (1 << 5),
497     GNSS_GLO_FOUR_YEAR_VALID                = (1 << 6)
498 } GnssGloTimeTypeBits;
499 
500 typedef struct {
501     GnssAidingDataSvMask svMask;         // bitwise OR of GnssAidingDataSvBits
502     GnssAidingDataSvTypeMask svTypeMask; // bitwise OR of GnssAidingDataSvTypeBits
503 } GnssAidingDataSv;
504 
505 typedef uint32_t GnssAidingDataCommonMask;
506 typedef enum {
507     GNSS_AIDING_DATA_COMMON_POSITION_BIT      = (1<<0), // position estimate
508     GNSS_AIDING_DATA_COMMON_TIME_BIT          = (1<<1), // reset all clock values
509     GNSS_AIDING_DATA_COMMON_UTC_BIT           = (1<<2), // UTC estimate
510     GNSS_AIDING_DATA_COMMON_RTI_BIT           = (1<<3), // RTI
511     GNSS_AIDING_DATA_COMMON_FREQ_BIAS_EST_BIT = (1<<4), // frequency bias estimate
512     GNSS_AIDING_DATA_COMMON_CELLDB_BIT        = (1<<5), // all celldb info
513 } GnssAidingDataCommonBits;
514 
515 typedef struct {
516     GnssAidingDataCommonMask mask; // bitwise OR of GnssAidingDataCommonBits
517 } GnssAidingDataCommon;
518 
519 typedef struct {
520     bool deleteAll;              // if true, delete all aiding data and ignore other params
521     GnssAidingDataSv sv;         // SV specific aiding data
522     GnssAidingDataCommon common; // common aiding data
523 } GnssAidingData;
524 
525 typedef struct {
526     size_t size;             // set to sizeof(Location)
527     LocationFlagsMask flags; // bitwise OR of LocationFlagsBits to mark which params are valid
528     uint64_t timestamp;      // UTC timestamp for location fix, milliseconds since January 1, 1970
529     double latitude;         // in degrees
530     double longitude;        // in degrees
531     double altitude;         // in meters above the WGS 84 reference ellipsoid
532     float speed;             // in meters per second
533     float bearing;           // in degrees; range [0, 360)
534     float accuracy;          // in meters
535     float verticalAccuracy;  // in meters
536     float speedAccuracy;     // in meters/second
537     float bearingAccuracy;   // in degrees (0 to 359.999)
538     LocationTechnologyMask techMask;
539 } Location;
540 
541 struct LocationOptions {
542     size_t size;          // set to sizeof(LocationOptions)
543     uint32_t minInterval; // in milliseconds
544     uint32_t minDistance; // in meters. if minDistance > 0, gnssSvCallback/gnssNmeaCallback/
545                           // gnssMeasurementsCallback may not be called
546     GnssSuplMode mode;    // Standalone/MS-Based/MS-Assisted
547 
LocationOptionsLocationOptions548     inline LocationOptions() :
549             size(0), minInterval(0), minDistance(0), mode(GNSS_SUPL_MODE_STANDALONE) {}
550 };
551 
552 typedef enum {
553     GNSS_POWER_MODE_INVALID = 0,
554     GNSS_POWER_MODE_M1,  /* Improved Accuracy Mode */
555     GNSS_POWER_MODE_M2,  /* Normal Mode */
556     GNSS_POWER_MODE_M3,  /* Background Mode */
557     GNSS_POWER_MODE_M4,  /* Background Mode */
558     GNSS_POWER_MODE_M5   /* Background Mode */
559 } GnssPowerMode;
560 
561 struct TrackingOptions : LocationOptions {
562     GnssPowerMode powerMode; /* Power Mode to be used for time based tracking
563                                 sessions */
564     uint32_t tbm;  /* Time interval between measurements.
565                       Applicable to background power modes */
566 
TrackingOptionsTrackingOptions567     inline TrackingOptions() :
568             LocationOptions(), powerMode(GNSS_POWER_MODE_INVALID), tbm(0) {}
TrackingOptionsTrackingOptions569     inline TrackingOptions(size_t s, GnssPowerMode m, uint32_t t) :
570             LocationOptions(), powerMode(m), tbm(t) { LocationOptions::size = s; }
TrackingOptionsTrackingOptions571     inline TrackingOptions(const LocationOptions& options) :
572             LocationOptions(options), powerMode(GNSS_POWER_MODE_INVALID), tbm(0) {}
setLocationOptionsTrackingOptions573     inline void setLocationOptions(const LocationOptions& options) {
574         minInterval = options.minInterval;
575         minDistance = options.minDistance;
576         mode = options.mode;
577     }
578 };
579 
580 struct BatchingOptions : LocationOptions {
581     BatchingMode batchingMode;
582 
BatchingOptionsBatchingOptions583     inline BatchingOptions() :
584             LocationOptions(), batchingMode(BATCHING_MODE_ROUTINE) {}
BatchingOptionsBatchingOptions585     inline BatchingOptions(size_t s, BatchingMode m) :
586             LocationOptions(), batchingMode(m) { LocationOptions::size = s; }
BatchingOptionsBatchingOptions587     inline BatchingOptions(const LocationOptions& options) :
588             LocationOptions(options), batchingMode(BATCHING_MODE_ROUTINE) {}
setLocationOptionsBatchingOptions589     inline void setLocationOptions(const LocationOptions& options) {
590         minInterval = options.minInterval;
591         minDistance = options.minDistance;
592         mode = options.mode;
593     }
594 };
595 
596 typedef struct {
597     size_t size;
598     BatchingStatus batchingStatus;
599 } BatchingStatusInfo;
600 
601 typedef struct {
602     size_t size;                            // set to sizeof(GeofenceOption)
603     GeofenceBreachTypeMask breachTypeMask;  // bitwise OR of GeofenceBreachTypeBits
604     uint32_t responsiveness;                // in milliseconds
605     uint32_t dwellTime;                     // in seconds
606 } GeofenceOption;
607 
608 typedef struct {
609     size_t size;      // set to sizeof(GeofenceInfo)
610     double latitude;  // in degrees
611     double longitude; // in degrees
612     double radius;    // in meters
613 } GeofenceInfo;
614 
615 typedef struct {
616     size_t size;             // set to sizeof(GeofenceBreachNotification)
617     size_t count;            // number of ids in array
618     uint32_t* ids;           // array of ids that have breached
619     Location location;       // location associated with breach
620     GeofenceBreachType type; // type of breach
621     uint64_t timestamp;      // timestamp of breach
622 } GeofenceBreachNotification;
623 
624 typedef struct {
625     size_t size;                       // set to sizeof(GeofenceBreachNotification)
626     GeofenceStatusAvailable available; // GEOFENCE_STATUS_AVAILABILE_NO/_YES
627     LocationTechnologyType techType;   // GNSS
628 } GeofenceStatusNotification;
629 
630 typedef struct {
631     uint64_t gpsSvUsedIdsMask;
632     uint64_t gloSvUsedIdsMask;
633     uint64_t galSvUsedIdsMask;
634     uint64_t bdsSvUsedIdsMask;
635     uint64_t qzssSvUsedIdsMask;
636 } GnssLocationSvUsedInPosition;
637 
638 /** @struct
639     Body Frame parameters
640 */
641 typedef struct {
642     GnssLocationPosDataMask bodyFrameDataMask; // Contains Body frame LocPosDataMask bits
643     float longAccel;                           // Forward Acceleration in body frame (m/s2)
644     float latAccel;                            // Sideward Acceleration in body frame (m/s2)
645     float vertAccel;                           // Vertical Acceleration in body frame (m/s2)
646     float yawRate;                             // Heading Rate (Radians/second)
647     float pitch;                               // Body pitch (Radians)
648 } GnssLocationPositionDynamics;
649 
650 typedef struct {
651     /** Validity mask for below fields */
652     GnssSystemTimeStructTypeFlags validityMask;
653     /** Extended week number at reference tick.
654     Unit: Week.
655     Set to 65535 if week number is unknown.
656     For GPS:
657       Calculated from midnight, Jan. 6, 1980.
658       OTA decoded 10 bit GPS week is extended to map between:
659       [NV6264 to (NV6264 + 1023)].
660       NV6264: Minimum GPS week number configuration.
661       Default value of NV6264: 1738
662     For BDS:
663       Calculated from 00:00:00 on January 1, 2006 of Coordinated Universal Time (UTC).
664     For GAL:
665       Calculated from 00:00 UT on Sunday August 22, 1999 (midnight between August 21 and August 22).
666    */
667     uint16_t systemWeek;
668     /** Time in to the current week at reference tick.
669        Unit: Millisecond. Range: 0 to 604799999.
670        Check for systemClkTimeUncMs before use */
671     uint32_t systemMsec;
672     /** System clock time bias (sub-millisecond)
673         Units: Millisecond
674         Note: System time (TOW Millisecond) = systemMsec - systemClkTimeBias.
675         Check for systemClkTimeUncMs before use. */
676     float systemClkTimeBias;
677     /** Single sided maximum time bias uncertainty
678         Units: Millisecond */
679     float systemClkTimeUncMs;
680     /** FCount (free running HW timer) value. Don't use for relative time purpose
681          due to possible discontinuities.
682          Unit: Millisecond */
683     uint32_t refFCount;
684     /** Number of clock resets/discontinuities detected, affecting the local hardware counter value. */
685     uint32_t numClockResets;
686 } GnssSystemTimeStructType;
687 
688 typedef struct {
689     /** GLONASS day number in four years. Refer to GLONASS ICD.
690         Applicable only for GLONASS and shall be ignored for other constellations.
691         If unknown shall be set to 65535 */
692     uint16_t gloDays;
693     /** Validity mask for below fields */
694     GnssGloTimeStructTypeFlags validityMask;
695     /** GLONASS time of day in Millisecond. Refer to GLONASS ICD.
696         Units: Millisecond
697         Check for gloClkTimeUncMs before use */
698     uint32_t gloMsec;
699     /** GLONASS clock time bias (sub-millisecond)
700         Units: Millisecond
701         Note: GLO time (TOD Millisecond) = gloMsec - gloClkTimeBias.
702         Check for gloClkTimeUncMs before use. */
703     float gloClkTimeBias;
704     /** Single sided maximum time bias uncertainty
705         Units: Millisecond */
706     float gloClkTimeUncMs;
707     /** FCount (free running HW timer) value. Don't use for relative time purpose
708         due to possible discontinuities.
709         Unit: Millisecond */
710     uint32_t  refFCount;
711     /** Number of clock resets/discontinuities detected, affecting the local hardware counter value. */
712     uint32_t numClockResets;
713     /** GLONASS four year number from 1996. Refer to GLONASS ICD.
714         Applicable only for GLONASS and shall be ignored for other constellations.
715         If unknown shall be set to 255 */
716     uint8_t gloFourYear;
717 } GnssGloTimeStructType;
718 
719 typedef union {
720     GnssSystemTimeStructType gpsSystemTime;
721     GnssSystemTimeStructType galSystemTime;
722     GnssSystemTimeStructType bdsSystemTime;
723     GnssSystemTimeStructType qzssSystemTime;
724     GnssGloTimeStructType gloSytemTime;
725 } SystemTimeStructUnion;
726     /** Time applicability of PVT report */
727 typedef struct {
728     /** Specifies GNSS system time reported. Mandatory field */
729     Gnss_LocSvSystemEnumType gnssSystemTimeSrc;
730     /** Reporting of GPS system time is recommended.
731       If GPS time is unknown & other satellite system time is known,
732       it should be reported.
733       Mandatory field
734      */
735     SystemTimeStructUnion u;
736 } GnssSystemTime;
737 
738 typedef struct {
739     size_t size;                        // set to sizeof(GnssLocationInfo)
740     GnssLocationInfoFlagMask flags;     // bitwise OR of GnssLocationInfoBits for param validity
741     float altitudeMeanSeaLevel;         // altitude wrt mean sea level
742     float pdop;                         // position dilusion of precision
743     float hdop;                         // horizontal dilusion of precision
744     float vdop;                         // vertical dilusion of precision
745     float gdop;                         // geometric  dilution of precision
746     float tdop;                         // time dilution of precision
747     float magneticDeviation;            // magnetic deviation
748     LocationReliability horReliability; // horizontal reliability
749     LocationReliability verReliability; // vertical reliability
750     float horUncEllipseSemiMajor;       // horizontal elliptical accuracy semi-major axis
751     float horUncEllipseSemiMinor;       // horizontal elliptical accuracy semi-minor axis
752     float horUncEllipseOrientAzimuth;   // horizontal elliptical accuracy azimuth
753     float northVelocity;                // North Velocity.Unit: Meters/sec
754     float eastVelocity;                 // East Velocity
755     float upVelocity;
756     float northVelocityStdDeviation;
757     float eastVelocityStdDeviation;
758     float upVelocityStdDeviation;
759     GnssLocationSvUsedInPosition svUsedInPosition;// Gnss sv used in position data
760     GnssLocationNavSolutionMask navSolutionMask;  // Nav solution mask to indicate sbas corrections
761     GnssLocationPosTechMask posTechMask;          // Position technology used in computing this fix
762     GnssLocationPositionDynamics bodyFrameData;   // Body Frame Dynamics: 4wayAcceleration and
763                                                   // pitch set with validity
764     GnssSystemTime gnssSystemTime;            // GNSS System Time
765     Location location;
766 } GnssLocationInfoNotification;
767 
768 typedef struct {
769     size_t size;                           // set to sizeof(GnssNiNotification)
770     GnssNiType type;                       // type of NI (Voice, SUPL, Control Plane)
771     GnssNiOptionsMask options;             // bitwise OR of GnssNiOptionsBits
772     uint32_t timeout;                      // time (seconds) to wait for user input
773     GnssNiResponse timeoutResponse;        // the response that should be sent when timeout expires
774     char requestor[GNSS_NI_REQUESTOR_MAX]; // the requestor that is making the request
775     GnssNiEncodingType requestorEncoding;  // the encoding type for requestor
776     char message[GNSS_NI_MESSAGE_ID_MAX];  // the message to show user
777     GnssNiEncodingType messageEncoding;    // the encoding type for message
778     char extras[GNSS_NI_MESSAGE_ID_MAX];
779 } GnssNiNotification;
780 
781 typedef struct {
782     size_t size;       // set to sizeof(GnssSv)
783     uint16_t svId;     // Unique Identifier
784     GnssSvType type;   // type of SV (GPS, SBAS, GLONASS, QZSS, BEIDOU, GALILEO)
785     float cN0Dbhz;     // signal strength
786     float elevation;   // elevation of SV (in degrees)
787     float azimuth;     // azimuth of SV (in degrees)
788     GnssSvOptionsMask gnssSvOptionsMask; // Bitwise OR of GnssSvOptionsBits
789     float carrierFrequencyHz; // carrier frequency of the signal tracked
790 } GnssSv;
791 
792 struct GnssConfigSetAssistanceServer {
793     size_t size;             // set to sizeof(GnssConfigSetAssistanceServer)
794     GnssAssistanceType type; // SUPL or C2K
795     const char* hostName;    // null terminated string
796     uint32_t port;           // port of server
797 
equalsGnssConfigSetAssistanceServer798     inline bool equals(const GnssConfigSetAssistanceServer& config) {
799         if (config.type == type && config.port == port &&
800                ((NULL == config.hostName && NULL == hostName) ||
801                 (NULL != config.hostName && NULL != hostName &&
802                      0 == strcmp(config.hostName, hostName)))) {
803             return true;
804         }
805         return false;
806     }
807 };
808 
809 typedef struct {
810     size_t size;                               // set to sizeof(GnssMeasurementsData)
811     GnssMeasurementsDataFlagsMask flags;       // bitwise OR of GnssMeasurementsDataFlagsBits
812     int16_t svId;
813     GnssSvType svType;
814     double timeOffsetNs;
815     GnssMeasurementsStateMask stateMask;       // bitwise OR of GnssMeasurementsStateBits
816     int64_t receivedSvTimeNs;
817     int64_t receivedSvTimeUncertaintyNs;
818     double carrierToNoiseDbHz;
819     double pseudorangeRateMps;
820     double pseudorangeRateUncertaintyMps;
821     GnssMeasurementsAdrStateMask adrStateMask; // bitwise OR of GnssMeasurementsAdrStateBits
822     double adrMeters;
823     double adrUncertaintyMeters;
824     float carrierFrequencyHz;
825     int64_t carrierCycles;
826     double carrierPhase;
827     double carrierPhaseUncertainty;
828     GnssMeasurementsMultipathIndicator multipathIndicator;
829     double signalToNoiseRatioDb;
830     double agcLevelDb;
831 } GnssMeasurementsData;
832 
833 typedef struct {
834     size_t size;                          // set to sizeof(GnssMeasurementsClock)
835     GnssMeasurementsClockFlagsMask flags; // bitwise OR of GnssMeasurementsClockFlagsBits
836     int16_t leapSecond;
837     int64_t timeNs;
838     double timeUncertaintyNs;
839     int64_t fullBiasNs;
840     double biasNs;
841     double biasUncertaintyNs;
842     double driftNsps;
843     double driftUncertaintyNsps;
844     uint32_t hwClockDiscontinuityCount;
845 } GnssMeasurementsClock;
846 
847 typedef struct {
848     size_t size;                 // set to sizeof(GnssSvNotification)
849     size_t count;                // number of SVs in the GnssSv array
850     GnssSv gnssSvs[GNSS_SV_MAX]; // information on a number of SVs
851 } GnssSvNotification;
852 
853 typedef struct {
854     size_t size;         // set to sizeof(GnssNmeaNotification)
855     uint64_t timestamp;  // timestamp
856     const char* nmea;    // nmea text
857     size_t length;       // length of the nmea text
858 } GnssNmeaNotification;
859 
860 typedef struct {
861     size_t size;         // set to sizeof(GnssMeasurementsNotification)
862     size_t count;        // number of items in GnssMeasurements array
863     GnssMeasurementsData measurements[GNSS_MEASUREMENTS_MAX];
864     GnssMeasurementsClock clock; // clock
865 } GnssMeasurementsNotification;
866 
867 typedef uint32_t GnssSvId;
868 
869 struct GnssSvIdSource{
870     size_t size;                 // set to sizeof(GnssSvIdSource)
871     GnssSvType constellation;    // constellation for the sv to blacklist
872     GnssSvId svId;           // sv id to blacklist
873 };
874 inline bool operator ==(GnssSvIdSource const& left, GnssSvIdSource const& right) {
875     return left.size == right.size &&
876             left.constellation == right.constellation && left.svId == right.svId;
877 }
878 
879 #define GNSS_SV_CONFIG_ALL_BITS_ENABLED_MASK ((uint64_t)0xFFFFFFFFFFFFFFFF)
880 typedef struct {
881     size_t size; // set to sizeof(GnssSvIdConfig)
882 
883     // GLONASS - SV 65 maps to bit 0
884 #define GNSS_SV_CONFIG_GLO_INITIAL_SV_ID 65
885 #define GNSS_SV_CONFIG_GLO_LAST_SV_ID 88
886     uint64_t gloBlacklistSvMask;
887 
888     // BEIDOU - SV 201 maps to bit 0
889 #define GNSS_SV_CONFIG_BDS_INITIAL_SV_ID 201
890 #define GNSS_SV_CONFIG_BDS_LAST_SV_ID 237
891     uint64_t bdsBlacklistSvMask;
892 
893     // QZSS - SV 193 maps to bit 0
894 #define GNSS_SV_CONFIG_QZSS_INITIAL_SV_ID 193
895 #define GNSS_SV_CONFIG_QZSS_LAST_SV_ID 200
896     uint64_t qzssBlacklistSvMask;
897 
898     // GAL - SV 301 maps to bit 0
899 #define GNSS_SV_CONFIG_GAL_INITIAL_SV_ID 301
900 #define GNSS_SV_CONFIG_GAL_LAST_SV_ID 336
901     uint64_t galBlacklistSvMask;
902 } GnssSvIdConfig;
903 
904 struct GnssConfig{
905     size_t size;  // set to sizeof(GnssConfig)
906     GnssConfigFlagsMask flags; // bitwise OR of GnssConfigFlagsBits to mark which params are valid
907     GnssConfigGpsLock gpsLock;
908     GnssConfigSuplVersion suplVersion;
909     GnssConfigSetAssistanceServer assistanceServer;
910     GnssConfigLppProfile lppProfile;
911     GnssConfigLppeControlPlaneMask lppeControlPlaneMask;
912     GnssConfigLppeUserPlaneMask lppeUserPlaneMask;
913     GnssConfigAGlonassPositionProtocolMask aGlonassPositionProtocolMask;
914     GnssConfigEmergencyPdnForEmergencySupl emergencyPdnForEmergencySupl;
915     GnssConfigSuplEmergencyServices suplEmergencyServices;
916     GnssConfigSuplModeMask suplModeMask; //bitwise OR of GnssConfigSuplModeBits
917     std::vector<GnssSvIdSource> blacklistedSvIds;
918 
equalsGnssConfig919     inline bool equals(const GnssConfig& config) {
920         if (flags == config.flags &&
921                 gpsLock == config.gpsLock &&
922                 suplVersion == config.suplVersion &&
923                 assistanceServer.equals(config.assistanceServer) &&
924                 lppProfile == config.lppProfile &&
925                 lppeControlPlaneMask == config.lppeControlPlaneMask &&
926                 lppeUserPlaneMask == config.lppeUserPlaneMask &&
927                 aGlonassPositionProtocolMask == config.aGlonassPositionProtocolMask &&
928                 emergencyPdnForEmergencySupl == config.emergencyPdnForEmergencySupl &&
929                 suplEmergencyServices == config.suplEmergencyServices &&
930                 suplModeMask == config.suplModeMask  &&
931                 blacklistedSvIds == config.blacklistedSvIds) {
932             return true;
933         }
934         return false;
935     }
936 };
937 
938 typedef struct {
939     size_t size;                        // set to sizeof
940     bool                                mValid;
941     Location                            mLocation;
942     double                              verticalAccuracyMeters;
943     double                              speedAccuracyMetersPerSecond;
944     double                              bearingAccuracyDegrees;
945     timespec                            mUtcReported;
946 } GnssDebugLocation;
947 
948 typedef struct {
949     size_t size;                        // set to sizeof
950     bool                                mValid;
951     int64_t                             timeEstimate;
952     float                               timeUncertaintyNs;
953     float                               frequencyUncertaintyNsPerSec;
954 } GnssDebugTime;
955 
956 typedef struct {
957     size_t size;                        // set to sizeof
958     uint32_t                            svid;
959     GnssSvType                          constellation;
960     GnssEphemerisType                   mEphemerisType;
961     GnssEphemerisSource                 mEphemerisSource;
962     GnssEphemerisHealth                 mEphemerisHealth;
963     float                               ephemerisAgeSeconds;
964     bool                                serverPredictionIsAvailable;
965     float                               serverPredictionAgeSeconds;
966 } GnssDebugSatelliteInfo;
967 
968 typedef struct {
969     size_t size;                        // set to sizeof
970     GnssDebugLocation                   mLocation;
971     GnssDebugTime                       mTime;
972     std::vector<GnssDebugSatelliteInfo> mSatelliteInfo;
973 } GnssDebugReport;
974 
975 /* Provides the capabilities of the system
976    capabilities callback is called once soon after createInstance is called */
977 typedef std::function<void(
978     LocationCapabilitiesMask capabilitiesMask // bitwise OR of LocationCapabilitiesBits
979 )> capabilitiesCallback;
980 
981 /* Used by tracking, batching, and miscellanous APIs
982    responseCallback is called for every Tracking, Batching API, and Miscellanous API */
983 typedef std::function<void(
984     LocationError err, // if not SUCCESS, then id is not valid
985     uint32_t id        // id to be associated to the request
986 )> responseCallback;
987 
988 /* Used by APIs that gets more than one LocationError in it's response
989    collectiveResponseCallback is called for every geofence API call.
990    ids array and LocationError array are only valid until collectiveResponseCallback returns. */
991 typedef std::function<void(
992     size_t count, // number of locations in arrays
993     LocationError* errs, // array of LocationError associated to the request
994     uint32_t* ids // array of ids to be associated to the request
995 )> collectiveResponseCallback;
996 
997 /* Used for startTracking API, optional can be NULL
998    trackingCallback is called when delivering a location in a tracking session
999    broadcasted to all clients, no matter if a session has started by client */
1000 typedef std::function<void(
1001     Location location
1002 )> trackingCallback;
1003 
1004 /* Used for startBatching API, optional can be NULL
1005    batchingCallback is called when delivering locations in a batching session.
1006    broadcasted to all clients, no matter if a session has started by client */
1007 typedef std::function<void(
1008     size_t count,      // number of locations in array
1009     Location* location, // array of locations
1010     BatchingOptions batchingOptions // Batching options
1011 )> batchingCallback;
1012 
1013 typedef std::function<void(
1014     BatchingStatusInfo batchingStatus, // batch status
1015     std::list<uint32_t> & listOfCompletedTrips
1016 )> batchingStatusCallback;
1017 
1018 /* Gives GNSS Location information, optional can be NULL
1019     gnssLocationInfoCallback is called only during a tracking session
1020     broadcasted to all clients, no matter if a session has started by client */
1021 typedef std::function<void(
1022     GnssLocationInfoNotification gnssLocationInfoNotification
1023 )> gnssLocationInfoCallback;
1024 
1025 /* Used for addGeofences API, optional can be NULL
1026    geofenceBreachCallback is called when any number of geofences have a state change */
1027 typedef std::function<void(
1028     GeofenceBreachNotification geofenceBreachNotification
1029 )> geofenceBreachCallback;
1030 
1031 /* Used for addGeofences API, optional can be NULL
1032        geofenceStatusCallback is called when any number of geofences have a status change */
1033 typedef std::function<void(
1034     GeofenceStatusNotification geofenceStatusNotification
1035 )> geofenceStatusCallback;
1036 
1037 /* Network Initiated request, optional can be NULL
1038    This callback should be responded to by calling gnssNiResponse */
1039 typedef std::function<void(
1040     uint32_t id, // id that should be used to respond by calling gnssNiResponse
1041     GnssNiNotification gnssNiNotification
1042 )> gnssNiCallback;
1043 
1044 /* Gives GNSS SV information, optional can be NULL
1045     gnssSvCallback is called only during a tracking session
1046     broadcasted to all clients, no matter if a session has started by client */
1047 typedef std::function<void(
1048     GnssSvNotification gnssSvNotification
1049 )> gnssSvCallback;
1050 
1051 /* Gives GNSS NMEA data, optional can be NULL
1052     gnssNmeaCallback is called only during a tracking session
1053     broadcasted to all clients, no matter if a session has started by client */
1054 typedef std::function<void(
1055     GnssNmeaNotification gnssNmeaNotification
1056 )> gnssNmeaCallback;
1057 
1058 /* Gives GNSS Measurements information, optional can be NULL
1059     gnssMeasurementsCallback is called only during a tracking session
1060     broadcasted to all clients, no matter if a session has started by client */
1061 typedef std::function<void(
1062     GnssMeasurementsNotification gnssMeasurementsNotification
1063 )> gnssMeasurementsCallback;
1064 
1065 /* Provides the current GNSS configuration to the client */
1066 typedef std::function<void(
1067     GnssConfig& config
1068 )> gnssConfigCallback;
1069 
1070 typedef struct {
1071     size_t size; // set to sizeof(LocationCallbacks)
1072     capabilitiesCallback capabilitiesCb;             // mandatory
1073     responseCallback responseCb;                     // mandatory
1074     collectiveResponseCallback collectiveResponseCb; // mandatory
1075     trackingCallback trackingCb;                     // optional
1076     batchingCallback batchingCb;                     // optional
1077     geofenceBreachCallback geofenceBreachCb;         // optional
1078     geofenceStatusCallback geofenceStatusCb;         // optional
1079     gnssLocationInfoCallback gnssLocationInfoCb;     // optional
1080     gnssNiCallback gnssNiCb;                         // optional
1081     gnssSvCallback gnssSvCb;                         // optional
1082     gnssNmeaCallback gnssNmeaCb;                     // optional
1083     gnssMeasurementsCallback gnssMeasurementsCb;     // optional
1084     batchingStatusCallback batchingStatusCb;         // optional
1085 } LocationCallbacks;
1086 
1087 #endif /* LOCATIONDATATYPES_H */
1088