blob: a54948cb8b901d1e97bbd6fd7a55a8b590abc95f [file] [log] [blame]
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_INCLUDE_HARDWARE_GPS_H
18#define ANDROID_INCLUDE_HARDWARE_GPS_H
19
20#include <stdint.h>
21#include <sys/cdefs.h>
22#include <sys/types.h>
Mike Lockwood4453b5b2010-06-20 14:23:10 -070023#include <pthread.h>
destradaaf48cc672014-06-05 11:07:09 -070024#include <sys/socket.h>
destradaa9f7c3732014-04-29 10:50:22 -070025#include <stdbool.h>
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050026
27#include <hardware/hardware.h>
28
29__BEGIN_DECLS
30
31/**
32 * The id of this module
33 */
34#define GPS_HARDWARE_MODULE_ID "gps"
35
36
37/** Milliseconds since January 1, 1970 */
38typedef int64_t GpsUtcTime;
39
40/** Maximum number of SVs for gps_sv_status_callback(). */
41#define GPS_MAX_SVS 32
Lifu Tang7e33bb22016-02-07 18:09:30 -080042/** Maximum number of SVs for gps_sv_status_callback(). */
43#define GNSS_MAX_SVS 64
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050044
destradaa9f7c3732014-04-29 10:50:22 -070045/** Maximum number of Measurements in gps_measurement_callback(). */
46#define GPS_MAX_MEASUREMENT 32
47
Lifu Tang7e33bb22016-02-07 18:09:30 -080048/** Maximum number of Measurements in gnss_measurement_callback(). */
49#define GNSS_MAX_MEASUREMENT 64
50
Mike Lockwoodb15879a2010-04-14 15:36:34 -040051/** Requested operational mode for GPS operation. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050052typedef uint32_t GpsPositionMode;
Lifu Tanga1ca5742016-02-16 17:42:13 -080053/* IMPORTANT: Note that the following values must match
54 * constants in GpsLocationProvider.java. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050055/** Mode for running GPS standalone (no assistance). */
56#define GPS_POSITION_MODE_STANDALONE 0
57/** AGPS MS-Based mode. */
58#define GPS_POSITION_MODE_MS_BASED 1
destradaa81534882015-04-28 13:10:56 -070059/**
60 * AGPS MS-Assisted mode. This mode is not maintained by the platform anymore.
Lifu Tangdf0fcf72015-10-27 14:58:25 -070061 * It is strongly recommended to use GPS_POSITION_MODE_MS_BASED instead.
destradaa81534882015-04-28 13:10:56 -070062 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050063#define GPS_POSITION_MODE_MS_ASSISTED 2
64
Mike Lockwoodb15879a2010-04-14 15:36:34 -040065/** Requested recurrence mode for GPS operation. */
66typedef uint32_t GpsPositionRecurrence;
Lifu Tanga1ca5742016-02-16 17:42:13 -080067/* IMPORTANT: Note that the following values must match
68 * constants in GpsLocationProvider.java. */
Mike Lockwoodb15879a2010-04-14 15:36:34 -040069/** Receive GPS fixes on a recurring basis at a specified period. */
70#define GPS_POSITION_RECURRENCE_PERIODIC 0
71/** Request a single shot GPS fix. */
72#define GPS_POSITION_RECURRENCE_SINGLE 1
73
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050074/** GPS status event values. */
75typedef uint16_t GpsStatusValue;
Lifu Tanga1ca5742016-02-16 17:42:13 -080076/* IMPORTANT: Note that the following values must match
77 * constants in GpsLocationProvider.java. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050078/** GPS status unknown. */
79#define GPS_STATUS_NONE 0
80/** GPS has begun navigating. */
81#define GPS_STATUS_SESSION_BEGIN 1
82/** GPS has stopped navigating. */
83#define GPS_STATUS_SESSION_END 2
84/** GPS has powered on but is not navigating. */
85#define GPS_STATUS_ENGINE_ON 3
86/** GPS is powered off. */
87#define GPS_STATUS_ENGINE_OFF 4
88
89/** Flags to indicate which values are valid in a GpsLocation. */
90typedef uint16_t GpsLocationFlags;
Lifu Tanga1ca5742016-02-16 17:42:13 -080091/* IMPORTANT: Note that the following values must match
92 * constants in GpsLocationProvider.java. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050093/** GpsLocation has valid latitude and longitude. */
94#define GPS_LOCATION_HAS_LAT_LONG 0x0001
95/** GpsLocation has valid altitude. */
96#define GPS_LOCATION_HAS_ALTITUDE 0x0002
97/** GpsLocation has valid speed. */
98#define GPS_LOCATION_HAS_SPEED 0x0004
99/** GpsLocation has valid bearing. */
100#define GPS_LOCATION_HAS_BEARING 0x0008
101/** GpsLocation has valid accuracy. */
102#define GPS_LOCATION_HAS_ACCURACY 0x0010
103
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400104/** Flags for the gps_set_capabilities callback. */
105
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700106/**
107 * GPS HAL schedules fixes for GPS_POSITION_RECURRENCE_PERIODIC mode. If this is
108 * not set, then the framework will use 1000ms for min_interval and will start
109 * and call start() and stop() to schedule the GPS.
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400110 */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700111#define GPS_CAPABILITY_SCHEDULING (1 << 0)
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400112/** GPS supports MS-Based AGPS mode */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700113#define GPS_CAPABILITY_MSB (1 << 1)
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400114/** GPS supports MS-Assisted AGPS mode */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700115#define GPS_CAPABILITY_MSA (1 << 2)
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400116/** GPS supports single-shot fixes */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700117#define GPS_CAPABILITY_SINGLE_SHOT (1 << 3)
Mike Lockwood8aac5912011-06-29 15:10:36 -0400118/** GPS supports on demand time injection */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700119#define GPS_CAPABILITY_ON_DEMAND_TIME (1 << 4)
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800120/** GPS supports Geofencing */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700121#define GPS_CAPABILITY_GEOFENCING (1 << 5)
Lifu Tang1d4183c2016-02-24 13:50:19 -0800122/** GPS supports Measurements. */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700123#define GPS_CAPABILITY_MEASUREMENTS (1 << 6)
destradaa69d5ea52014-07-31 16:34:09 -0700124/** GPS supports Navigation Messages */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700125#define GPS_CAPABILITY_NAV_MESSAGES (1 << 7)
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400126
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700127/**
128 * Flags used to specify which aiding data to delete when calling
129 * delete_aiding_data().
130 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500131typedef uint16_t GpsAidingData;
Lifu Tanga1ca5742016-02-16 17:42:13 -0800132/* IMPORTANT: Note that the following values must match
133 * constants in GpsLocationProvider.java. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500134#define GPS_DELETE_EPHEMERIS 0x0001
135#define GPS_DELETE_ALMANAC 0x0002
136#define GPS_DELETE_POSITION 0x0004
137#define GPS_DELETE_TIME 0x0008
138#define GPS_DELETE_IONO 0x0010
139#define GPS_DELETE_UTC 0x0020
140#define GPS_DELETE_HEALTH 0x0040
141#define GPS_DELETE_SVDIR 0x0080
142#define GPS_DELETE_SVSTEER 0x0100
143#define GPS_DELETE_SADATA 0x0200
144#define GPS_DELETE_RTI 0x0400
145#define GPS_DELETE_CELLDB_INFO 0x8000
146#define GPS_DELETE_ALL 0xFFFF
147
148/** AGPS type */
149typedef uint16_t AGpsType;
150#define AGPS_TYPE_SUPL 1
151#define AGPS_TYPE_C2K 2
152
Miguel Torroja5f404f52010-07-27 06:34:15 +0200153typedef uint16_t AGpsSetIDType;
154#define AGPS_SETID_TYPE_NONE 0
155#define AGPS_SETID_TYPE_IMSI 1
156#define AGPS_SETID_TYPE_MSISDN 2
157
destradaaf48cc672014-06-05 11:07:09 -0700158typedef uint16_t ApnIpType;
159#define APN_IP_INVALID 0
160#define APN_IP_IPV4 1
161#define APN_IP_IPV6 2
162#define APN_IP_IPV4V6 3
163
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500164/**
165 * String length constants
166 */
167#define GPS_NI_SHORT_STRING_MAXLEN 256
168#define GPS_NI_LONG_STRING_MAXLEN 2048
169
170/**
171 * GpsNiType constants
172 */
173typedef uint32_t GpsNiType;
174#define GPS_NI_TYPE_VOICE 1
175#define GPS_NI_TYPE_UMTS_SUPL 2
176#define GPS_NI_TYPE_UMTS_CTRL_PLANE 3
177
178/**
179 * GpsNiNotifyFlags constants
180 */
181typedef uint32_t GpsNiNotifyFlags;
182/** NI requires notification */
183#define GPS_NI_NEED_NOTIFY 0x0001
184/** NI requires verification */
185#define GPS_NI_NEED_VERIFY 0x0002
186/** NI requires privacy override, no notification/minimal trace */
187#define GPS_NI_PRIVACY_OVERRIDE 0x0004
188
189/**
190 * GPS NI responses, used to define the response in
191 * NI structures
192 */
193typedef int GpsUserResponseType;
194#define GPS_NI_RESPONSE_ACCEPT 1
195#define GPS_NI_RESPONSE_DENY 2
196#define GPS_NI_RESPONSE_NORESP 3
197
198/**
199 * NI data encoding scheme
200 */
201typedef int GpsNiEncodingType;
202#define GPS_ENC_NONE 0
203#define GPS_ENC_SUPL_GSM_DEFAULT 1
204#define GPS_ENC_SUPL_UTF8 2
205#define GPS_ENC_SUPL_UCS2 3
206#define GPS_ENC_UNKNOWN -1
207
208/** AGPS status event values. */
209typedef uint16_t AGpsStatusValue;
210/** GPS requests data connection for AGPS. */
211#define GPS_REQUEST_AGPS_DATA_CONN 1
212/** GPS releases the AGPS data connection. */
213#define GPS_RELEASE_AGPS_DATA_CONN 2
214/** AGPS data connection initiated */
215#define GPS_AGPS_DATA_CONNECTED 3
216/** AGPS data connection completed */
217#define GPS_AGPS_DATA_CONN_DONE 4
218/** AGPS data connection failed */
219#define GPS_AGPS_DATA_CONN_FAILED 5
220
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700221typedef uint16_t AGpsRefLocationType;
Miguel Torroja5f404f52010-07-27 06:34:15 +0200222#define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1
223#define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2
Lifu Tang3fc3bc82016-03-13 22:58:33 -0700224#define AGPS_REF_LOCATION_TYPE_MAC 3
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700225#define AGPS_REF_LOCATION_TYPE_LTE_CELLID 4
Miguel Torroja5f404f52010-07-27 06:34:15 +0200226
Lifu Tang3fc3bc82016-03-13 22:58:33 -0700227/* Deprecated, to be removed in the next Android release. */
228#define AGPS_REG_LOCATION_TYPE_MAC 3
229
Mike Lockwood455e83b2010-10-11 06:16:57 -0400230/** Network types for update_network_state "type" parameter */
231#define AGPS_RIL_NETWORK_TYPE_MOBILE 0
232#define AGPS_RIL_NETWORK_TYPE_WIFI 1
233#define AGPS_RIL_NETWORK_TYPE_MOBILE_MMS 2
234#define AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL 3
235#define AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN 4
236#define AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI 5
237#define AGPS_RIL_NETWORK_TTYPE_WIMAX 6
238
Lifu Tanga1ca5742016-02-16 17:42:13 -0800239/* The following typedef together with its constants below are deprecated, and
240 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700241typedef uint16_t GpsClockFlags;
destradaa9f7c3732014-04-29 10:50:22 -0700242#define GPS_CLOCK_HAS_LEAP_SECOND (1<<0)
destradaa9f7c3732014-04-29 10:50:22 -0700243#define GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1)
destradaa75843eb2014-07-17 14:04:50 -0700244#define GPS_CLOCK_HAS_FULL_BIAS (1<<2)
destradaa75843eb2014-07-17 14:04:50 -0700245#define GPS_CLOCK_HAS_BIAS (1<<3)
destradaa75843eb2014-07-17 14:04:50 -0700246#define GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4)
destradaa75843eb2014-07-17 14:04:50 -0700247#define GPS_CLOCK_HAS_DRIFT (1<<5)
destradaa75843eb2014-07-17 14:04:50 -0700248#define GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6)
249
250/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800251 * Flags to indicate what fields in GnssClock are valid.
destradaa75843eb2014-07-17 14:04:50 -0700252 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800253typedef uint16_t GnssClockFlags;
254/** A valid 'leap second' is stored in the data structure. */
255#define GNSS_CLOCK_HAS_LEAP_SECOND (1<<0)
256/** A valid 'time uncertainty' is stored in the data structure. */
257#define GNSS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1)
258/** A valid 'full bias' is stored in the data structure. */
259#define GNSS_CLOCK_HAS_FULL_BIAS (1<<2)
260/** A valid 'bias' is stored in the data structure. */
261#define GNSS_CLOCK_HAS_BIAS (1<<3)
262/** A valid 'bias uncertainty' is stored in the data structure. */
263#define GNSS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4)
264/** A valid 'drift' is stored in the data structure. */
265#define GNSS_CLOCK_HAS_DRIFT (1<<5)
266/** A valid 'drift uncertainty' is stored in the data structure. */
267#define GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6)
268
269/* The following typedef together with its constants below are deprecated, and
270 * will be removed in the next release. */
destradaa75843eb2014-07-17 14:04:50 -0700271typedef uint8_t GpsClockType;
destradaa75843eb2014-07-17 14:04:50 -0700272#define GPS_CLOCK_TYPE_UNKNOWN 0
destradaa75843eb2014-07-17 14:04:50 -0700273#define GPS_CLOCK_TYPE_LOCAL_HW_TIME 1
destradaa75843eb2014-07-17 14:04:50 -0700274#define GPS_CLOCK_TYPE_GPS_TIME 2
destradaa9f7c3732014-04-29 10:50:22 -0700275
Lifu Tanga1ca5742016-02-16 17:42:13 -0800276/* The following typedef together with its constants below are deprecated, and
277 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700278typedef uint32_t GpsMeasurementFlags;
destradaa9f7c3732014-04-29 10:50:22 -0700279#define GPS_MEASUREMENT_HAS_SNR (1<<0)
destradaa9f7c3732014-04-29 10:50:22 -0700280#define GPS_MEASUREMENT_HAS_ELEVATION (1<<1)
destradaa9f7c3732014-04-29 10:50:22 -0700281#define GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2)
destradaa9f7c3732014-04-29 10:50:22 -0700282#define GPS_MEASUREMENT_HAS_AZIMUTH (1<<3)
destradaa9f7c3732014-04-29 10:50:22 -0700283#define GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4)
destradaa9f7c3732014-04-29 10:50:22 -0700284#define GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5)
destradaa9f7c3732014-04-29 10:50:22 -0700285#define GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6)
destradaa9f7c3732014-04-29 10:50:22 -0700286#define GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7)
destradaa9f7c3732014-04-29 10:50:22 -0700287#define GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8)
destradaa9f7c3732014-04-29 10:50:22 -0700288#define GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9)
destradaa9f7c3732014-04-29 10:50:22 -0700289#define GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10)
destradaa9f7c3732014-04-29 10:50:22 -0700290#define GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11)
destradaa9f7c3732014-04-29 10:50:22 -0700291#define GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12)
destradaa9f7c3732014-04-29 10:50:22 -0700292#define GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13)
destradaa9f7c3732014-04-29 10:50:22 -0700293#define GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14)
destradaa9f7c3732014-04-29 10:50:22 -0700294#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15)
destradaa9f7c3732014-04-29 10:50:22 -0700295#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16)
destradaa9f7c3732014-04-29 10:50:22 -0700296#define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17)
destradaa00caa892015-04-09 18:41:46 -0700297#define GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE (1<<18)
destradaa9f7c3732014-04-29 10:50:22 -0700298
299/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800300 * Flags to indicate what fields in GnssMeasurement are valid.
destradaa9f7c3732014-04-29 10:50:22 -0700301 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800302typedef uint32_t GnssMeasurementFlags;
303/** A valid 'snr' is stored in the data structure. */
304#define GNSS_MEASUREMENT_HAS_SNR (1<<0)
Lifu Tanga1ca5742016-02-16 17:42:13 -0800305/** A valid 'carrier frequency' is stored in the data structure. */
306#define GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9)
307/** A valid 'carrier cycles' is stored in the data structure. */
308#define GNSS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10)
309/** A valid 'carrier phase' is stored in the data structure. */
310#define GNSS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11)
311/** A valid 'carrier phase uncertainty' is stored in the data structure. */
312#define GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12)
Lifu Tanga1ca5742016-02-16 17:42:13 -0800313
314/* The following typedef together with its constants below are deprecated, and
315 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700316typedef uint8_t GpsLossOfLock;
destradaa9f7c3732014-04-29 10:50:22 -0700317#define GPS_LOSS_OF_LOCK_UNKNOWN 0
destradaa9f7c3732014-04-29 10:50:22 -0700318#define GPS_LOSS_OF_LOCK_OK 1
destradaa9f7c3732014-04-29 10:50:22 -0700319#define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2
320
Lifu Tanga1ca5742016-02-16 17:42:13 -0800321/* The following typedef together with its constants below are deprecated, and
Lifu Tang1d4183c2016-02-24 13:50:19 -0800322 * will be removed in the next release. Use GnssMultipathIndicator instead.
323 */
destradaa9f7c3732014-04-29 10:50:22 -0700324typedef uint8_t GpsMultipathIndicator;
destradaa9f7c3732014-04-29 10:50:22 -0700325#define GPS_MULTIPATH_INDICATOR_UNKNOWN 0
destradaa9f7c3732014-04-29 10:50:22 -0700326#define GPS_MULTIPATH_INDICATOR_DETECTED 1
destradaa9f7c3732014-04-29 10:50:22 -0700327#define GPS_MULTIPATH_INDICATOR_NOT_USED 2
328
329/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800330 * Enumeration of available values for the GNSS Measurement's multipath
331 * indicator.
destradaa75843eb2014-07-17 14:04:50 -0700332 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800333typedef uint8_t GnssMultipathIndicator;
334/** The indicator is not available or unknown. */
335#define GNSS_MULTIPATH_INDICATOR_UNKNOWN 0
336/** The measurement is indicated to be affected by multipath. */
Lifu Tang1d4183c2016-02-24 13:50:19 -0800337#define GNSS_MULTIPATH_INDICATOR_PRESENT 1
Lifu Tanga1ca5742016-02-16 17:42:13 -0800338/** The measurement is indicated to be not affected by multipath. */
Lifu Tang1d4183c2016-02-24 13:50:19 -0800339#define GNSS_MULTIPATH_INDICATOR_NOT_PRESENT 2
Lifu Tanga1ca5742016-02-16 17:42:13 -0800340
341/* The following typedef together with its constants below are deprecated, and
342 * will be removed in the next release. */
destradaa75843eb2014-07-17 14:04:50 -0700343typedef uint16_t GpsMeasurementState;
344#define GPS_MEASUREMENT_STATE_UNKNOWN 0
345#define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0)
346#define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1)
347#define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2)
348#define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3)
Tsuwei Chena90cf192014-10-23 12:49:12 -0700349#define GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4)
destradaa75843eb2014-07-17 14:04:50 -0700350
351/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800352 * Flags indicating the GNSS measurement state.
353 *
354 * The expected behavior here is for GPS HAL to set all the flags that applies.
355 * For example, if the state for a satellite is only C/A code locked and bit
356 * synchronized, and there is still millisecond ambiguity, the state should be
357 * set as:
358 *
359 * GNSS_MEASUREMENT_STATE_CODE_LOCK | GNSS_MEASUREMENT_STATE_BIT_SYNC |
360 * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS
361 *
362 * If GNSS is still searching for a satellite, the corresponding state should be
363 * set to GNSS_MEASUREMENT_STATE_UNKNOWN(0).
destradaa75843eb2014-07-17 14:04:50 -0700364 */
Lifu Tang3fc3bc82016-03-13 22:58:33 -0700365typedef uint32_t GnssMeasurementState;
Lifu Tanga1ca5742016-02-16 17:42:13 -0800366#define GNSS_MEASUREMENT_STATE_UNKNOWN 0
367#define GNSS_MEASUREMENT_STATE_CODE_LOCK (1<<0)
368#define GNSS_MEASUREMENT_STATE_BIT_SYNC (1<<1)
369#define GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2)
370#define GNSS_MEASUREMENT_STATE_TOW_DECODED (1<<3)
371#define GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4)
Lifu Tang1d4183c2016-02-24 13:50:19 -0800372#define GNSS_MEASUREMENT_STATE_SYMBOL_SYNC (1<<5)
Lifu Tang3fc3bc82016-03-13 22:58:33 -0700373#define GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC (1<<6)
374#define GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED (1<<7)
375#define GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC (1<<8)
376#define GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC (1<<9)
377#define GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK (1<<10)
378#define GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK (1<<11)
379#define GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC (1<<12)
380#define GNSS_MEASUREMENT_STATE_SBAS_SYNC (1<<13)
Lifu Tanga1ca5742016-02-16 17:42:13 -0800381
382/* The following typedef together with its constants below are deprecated, and
383 * will be removed in the next release. */
destradaa75843eb2014-07-17 14:04:50 -0700384typedef uint16_t GpsAccumulatedDeltaRangeState;
385#define GPS_ADR_STATE_UNKNOWN 0
386#define GPS_ADR_STATE_VALID (1<<0)
387#define GPS_ADR_STATE_RESET (1<<1)
388#define GPS_ADR_STATE_CYCLE_SLIP (1<<2)
389
390/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800391 * Flags indicating the Accumulated Delta Range's states.
destradaa9f7c3732014-04-29 10:50:22 -0700392 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800393typedef uint16_t GnssAccumulatedDeltaRangeState;
394#define GNSS_ADR_STATE_UNKNOWN 0
395#define GNSS_ADR_STATE_VALID (1<<0)
396#define GNSS_ADR_STATE_RESET (1<<1)
397#define GNSS_ADR_STATE_CYCLE_SLIP (1<<2)
398
399/* The following typedef together with its constants below are deprecated, and
400 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700401typedef uint8_t GpsNavigationMessageType;
destradaa9f7c3732014-04-29 10:50:22 -0700402#define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0
destradaa9f7c3732014-04-29 10:50:22 -0700403#define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1
destradaa9f7c3732014-04-29 10:50:22 -0700404#define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2
destradaa9f7c3732014-04-29 10:50:22 -0700405#define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3
destradaa9f7c3732014-04-29 10:50:22 -0700406#define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4
407
Tsuwei Chena90cf192014-10-23 12:49:12 -0700408/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800409 * Enumeration of available values to indicate the GNSS Navigation message
410 * types.
411 *
412 * For convenience, first byte is the GnssConstellationType on which that signal
413 * is typically transmitted
414 */
415typedef int16_t GnssNavigationMessageType;
416
417#define GNSS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0
418/** GPS L1 C/A message contained in the structure. */
419#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L1CA 0x0101
420/** GPS L2-CNAV message contained in the structure. */
421#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L2CNAV 0x0102
422/** GPS L5-CNAV message contained in the structure. */
423#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L5CNAV 0x0103
424/** GPS CNAV-2 message contained in the structure. */
425#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_CNAV2 0x0104
426/** Glonass L1 CA message contained in the structure. */
427#define GNSS_NAVIGATION_MESSAGE_TYPE_GLO_L1CA 0x0301
428/** Beidou D1 message contained in the structure. */
429#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D1 0x0501
430/** Beidou D2 message contained in the structure. */
431#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D2 0x0502
432/** Galileo I/NAV message contained in the structure. */
433#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_I 0x0601
434/** Galileo F/NAV message contained in the structure. */
435#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_F 0x0602
436
437/**
Tsuwei Chena90cf192014-10-23 12:49:12 -0700438 * Status of Navigation Message
439 * When a message is received properly without any parity error in its navigation words, the
440 * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received
441 * with words that failed parity check, but GPS is able to correct those words, the status
442 * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT.
443 * No need to send any navigation message that contains words with parity error and cannot be
444 * corrected.
445 */
446typedef uint16_t NavigationMessageStatus;
Lifu Tang1d4183c2016-02-24 13:50:19 -0800447#define NAV_MESSAGE_STATUS_UNKNOWN 0
Tsuwei Chena90cf192014-10-23 12:49:12 -0700448#define NAV_MESSAGE_STATUS_PARITY_PASSED (1<<0)
449#define NAV_MESSAGE_STATUS_PARITY_REBUILT (1<<1)
destradaa9f7c3732014-04-29 10:50:22 -0700450
Lifu Tang1d4183c2016-02-24 13:50:19 -0800451/* This constant is deprecated, and will be removed in the next release. */
452#define NAV_MESSAGE_STATUS_UNKONW 0
453
destradaa9f7c3732014-04-29 10:50:22 -0700454/**
Lifu Tang1d4183c2016-02-24 13:50:19 -0800455 * Flags that indicate information about the satellite
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700456 */
457typedef uint8_t GnssSvFlags;
458#define GNSS_SV_FLAGS_NONE 0
459#define GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA (1 << 0)
460#define GNSS_SV_FLAGS_HAS_ALMANAC_DATA (1 << 1)
461#define GNSS_SV_FLAGS_USED_IN_FIX (1 << 2)
462
463/**
464 * Constellation type of GnssSvInfo
465 */
466typedef uint8_t GnssConstellationType;
467#define GNSS_CONSTELLATION_UNKNOWN 0
468#define GNSS_CONSTELLATION_GPS 1
469#define GNSS_CONSTELLATION_SBAS 2
470#define GNSS_CONSTELLATION_GLONASS 3
471#define GNSS_CONSTELLATION_QZSS 4
472#define GNSS_CONSTELLATION_BEIDOU 5
473#define GNSS_CONSTELLATION_GALILEO 6
474
475/**
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500476 * Name for the GPS XTRA interface.
477 */
478#define GPS_XTRA_INTERFACE "gps-xtra"
479
480/**
481 * Name for the GPS DEBUG interface.
482 */
483#define GPS_DEBUG_INTERFACE "gps-debug"
484
485/**
486 * Name for the AGPS interface.
487 */
488#define AGPS_INTERFACE "agps"
489
490/**
destradaaa1f4c0a2013-09-13 15:45:03 -0700491 * Name of the Supl Certificate interface.
492 */
493#define SUPL_CERTIFICATE_INTERFACE "supl-certificate"
494
495/**
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500496 * Name for NI interface
497 */
498#define GPS_NI_INTERFACE "gps-ni"
499
Miguel Torroja5f404f52010-07-27 06:34:15 +0200500/**
501 * Name for the AGPS-RIL interface.
502 */
503#define AGPS_RIL_INTERFACE "agps_ril"
504
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800505/**
506 * Name for the GPS_Geofencing interface.
507 */
508#define GPS_GEOFENCING_INTERFACE "gps_geofencing"
509
destradaa9f7c3732014-04-29 10:50:22 -0700510/**
511 * Name of the GPS Measurements interface.
512 */
513#define GPS_MEASUREMENT_INTERFACE "gps_measurement"
514
515/**
516 * Name of the GPS navigation message interface.
517 */
Tsuwei Chen167d31f2014-08-26 16:34:19 -0700518#define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message"
519
520/**
521 * Name of the GNSS/GPS configuration interface.
522 */
523#define GNSS_CONFIGURATION_INTERFACE "gnss_configuration"
destradaa9f7c3732014-04-29 10:50:22 -0700524
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800525
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500526/** Represents a location. */
527typedef struct {
528 /** set to sizeof(GpsLocation) */
529 size_t size;
530 /** Contains GpsLocationFlags bits. */
531 uint16_t flags;
532 /** Represents latitude in degrees. */
533 double latitude;
534 /** Represents longitude in degrees. */
535 double longitude;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700536 /**
537 * Represents altitude in meters above the WGS 84 reference ellipsoid.
538 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500539 double altitude;
540 /** Represents speed in meters per second. */
541 float speed;
542 /** Represents heading in degrees. */
543 float bearing;
544 /** Represents expected accuracy in meters. */
545 float accuracy;
546 /** Timestamp for the location fix. */
547 GpsUtcTime timestamp;
548} GpsLocation;
549
550/** Represents the status. */
551typedef struct {
552 /** set to sizeof(GpsStatus) */
553 size_t size;
554 GpsStatusValue status;
555} GpsStatus;
556
Lifu Tanga1ca5742016-02-16 17:42:13 -0800557/**
558 * Legacy struct to represents SV information.
559 * Deprecated, to be removed in the next Android release.
560 * Use GnssSvInfo instead.
561 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500562typedef struct {
563 /** set to sizeof(GpsSvInfo) */
564 size_t size;
565 /** Pseudo-random number for the SV. */
566 int prn;
567 /** Signal to noise ratio. */
568 float snr;
569 /** Elevation of SV in degrees. */
570 float elevation;
571 /** Azimuth of SV in degrees. */
572 float azimuth;
573} GpsSvInfo;
574
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500575typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700576 /** set to sizeof(GnssSvInfo) */
577 size_t size;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500578
579 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -0800580 * Pseudo-random number for the SV, or FCN/OSN number for Glonass. The
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700581 * distinction is made by looking at constellation field. Values should be
582 * in the range of:
583 *
584 * - GPS: 1-32
585 * - SBAS: 120-151, 183-192
Lifu Tang1d4183c2016-02-24 13:50:19 -0800586 * - GLONASS: Set the upper 8 bits, signed, to the frequency channel number
587 * (FCN) in the range from -7 to +6, if known, and -127, if
588 * unknown
589 * Set the lower 8 bits, signed, to the orbital slot number (OSN)
590 * in the range from 1-24, if known, or -127 if unknown
591 * At least one of the two (FCN & OSN) must be set to a known
592 * value
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700593 * - QZSS: 193-200
Lifu Tang1d4183c2016-02-24 13:50:19 -0800594 * - Galileo: 1-36
595 * - Beidou: 1-37
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500596 */
Lifu Tang7e33bb22016-02-07 18:09:30 -0800597 int16_t svid;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700598
Lifu Tanga1ca5742016-02-16 17:42:13 -0800599 /**
600 * Defines the constellation of the given SV. Value should be one of those
601 * GNSS_CONSTELLATION_* constants
602 */
603 GnssConstellationType constellation;
604
Lifu Tang1d4183c2016-02-24 13:50:19 -0800605 /**
606 * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
607 * It contains the measured C/N0 value for the signal at the antenna port.
608 *
609 * This is a mandatory value.
610 */
611 float c_n0_dbhz;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700612
613 /** Elevation of SV in degrees. */
614 float elevation;
615
616 /** Azimuth of SV in degrees. */
617 float azimuth;
618
619 /**
620 * Contains additional data about the given SV. Value should be one of those
621 * GNSS_SV_FLAGS_* constants
622 */
623 GnssSvFlags flags;
624
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700625} GnssSvInfo;
626
627/**
Lifu Tang7e33bb22016-02-07 18:09:30 -0800628 * Legacy struct to represents SV status.
629 * Deprecated, to be removed in the next Android release.
630 * Use GnssSvStatus instead.
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700631 */
632typedef struct {
633 /** set to sizeof(GpsSvStatus) */
634 size_t size;
Lifu Tang7e33bb22016-02-07 18:09:30 -0800635 int num_svs;
636 GpsSvInfo sv_list[GPS_MAX_SVS];
637 uint32_t ephemeris_mask;
638 uint32_t almanac_mask;
639 uint32_t used_in_fix_mask;
640} GpsSvStatus;
641
642/**
643 * Represents SV status.
644 */
645typedef struct {
646 /** set to sizeof(GnssSvStatus) */
647 size_t size;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700648
649 /** Number of GPS SVs currently visible, refers to the SVs stored in sv_list */
650 int num_svs;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700651 /**
652 * Pointer to an array of SVs information for all GNSS constellations,
653 * except GPS, which is reported using sv_list
654 */
Lifu Tang7e33bb22016-02-07 18:09:30 -0800655 GnssSvInfo gnss_sv_list[GNSS_MAX_SVS];
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700656
Lifu Tang7e33bb22016-02-07 18:09:30 -0800657} GnssSvStatus;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500658
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700659/* CellID for 2G, 3G and LTE, used in AGPS. */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200660typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700661 AGpsRefLocationType type;
662 /** Mobile Country Code. */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200663 uint16_t mcc;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700664 /** Mobile Network Code .*/
Miguel Torroja5f404f52010-07-27 06:34:15 +0200665 uint16_t mnc;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700666 /** Location Area Code in 2G, 3G and LTE. In 3G lac is discarded. In LTE,
667 * lac is populated with tac, to ensure that we don't break old clients that
668 * might rely in the old (wrong) behavior.
669 */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200670 uint16_t lac;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700671 /** Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200672 uint32_t cid;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700673 /** Tracking Area Code in LTE. */
674 uint16_t tac;
675 /** Physical Cell id in LTE (not used in 2G and 3G) */
676 uint16_t pcid;
Miguel Torroja5f404f52010-07-27 06:34:15 +0200677} AGpsRefLocationCellID;
678
679typedef struct {
680 uint8_t mac[6];
681} AGpsRefLocationMac;
682
683/** Represents ref locations */
684typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700685 AGpsRefLocationType type;
Miguel Torroja5f404f52010-07-27 06:34:15 +0200686 union {
687 AGpsRefLocationCellID cellID;
688 AGpsRefLocationMac mac;
689 } u;
690} AGpsRefLocation;
691
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700692/**
693 * Callback with location information. Can only be called from a thread created
694 * by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700695 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500696typedef void (* gps_location_callback)(GpsLocation* location);
697
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700698/**
699 * Callback with status information. Can only be called from a thread created by
700 * create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700701 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500702typedef void (* gps_status_callback)(GpsStatus* status);
703
destradaa9f7c3732014-04-29 10:50:22 -0700704/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800705 * Legacy callback with SV status information.
destradaa9f7c3732014-04-29 10:50:22 -0700706 * Can only be called from a thread created by create_thread_cb.
Lifu Tanga1ca5742016-02-16 17:42:13 -0800707 *
708 * This callback is deprecated, and will be removed in the next release. Use
709 * gnss_sv_status_callback() instead.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700710 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500711typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info);
712
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700713/**
Lifu Tang7e33bb22016-02-07 18:09:30 -0800714 * Callback with SV status information.
715 * Can only be called from a thread created by create_thread_cb.
716 */
717typedef void (* gnss_sv_status_callback)(GnssSvStatus* sv_info);
718
719/**
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700720 * Callback for reporting NMEA sentences. Can only be called from a thread
721 * created by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700722 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500723typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length);
724
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700725/**
726 * Callback to inform framework of the GPS engine's capabilities. Capability
727 * parameter is a bit field of GPS_CAPABILITY_* flags.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700728 */
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400729typedef void (* gps_set_capabilities)(uint32_t capabilities);
730
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700731/**
732 * Callback utility for acquiring the GPS wakelock. This can be used to prevent
733 * the CPU from suspending while handling GPS events.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700734 */
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400735typedef void (* gps_acquire_wakelock)();
736
737/** Callback utility for releasing the GPS wakelock. */
738typedef void (* gps_release_wakelock)();
739
Mike Lockwood8aac5912011-06-29 15:10:36 -0400740/** Callback for requesting NTP time */
741typedef void (* gps_request_utc_time)();
742
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700743/**
744 * Callback for creating a thread that can call into the Java framework code.
745 * This must be used to create any threads that report events up to the
746 * framework.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700747 */
748typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg);
749
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700750/**
751 * Provides information about how new the underlying GPS/GNSS hardware and
752 * software is.
753 *
754 * This information will be available for Android Test Applications. If a GPS
755 * HAL does not provide this information, it will be considered "2015 or
756 * earlier".
757 *
758 * If a GPS HAL does provide this information, then newer years will need to
759 * meet newer CTS standards. E.g. if the date are 2016 or above, then N+ level
760 * GpsMeasurement support will be verified.
761 */
762typedef struct {
Lifu Tanga1ca5742016-02-16 17:42:13 -0800763 /** Set to sizeof(GnssSystemInfo) */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700764 size_t size;
765 /* year in which the last update was made to the underlying hardware/firmware
766 * used to capture GNSS signals, e.g. 2016 */
767 uint16_t year_of_hw;
Lifu Tanga1ca5742016-02-16 17:42:13 -0800768} GnssSystemInfo;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700769
770/**
771 * Callback to inform framework of the engine's hardware version information.
772 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800773typedef void (*gnss_set_system_info)(const GnssSystemInfo* info);
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700774
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700775/** New GPS callback structure. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500776typedef struct {
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400777 /** set to sizeof(GpsCallbacks) */
778 size_t size;
779 gps_location_callback location_cb;
780 gps_status_callback status_cb;
781 gps_sv_status_callback sv_status_cb;
782 gps_nmea_callback nmea_cb;
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400783 gps_set_capabilities set_capabilities_cb;
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400784 gps_acquire_wakelock acquire_wakelock_cb;
785 gps_release_wakelock release_wakelock_cb;
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700786 gps_create_thread create_thread_cb;
Mike Lockwood8aac5912011-06-29 15:10:36 -0400787 gps_request_utc_time request_utc_time_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500788
Lifu Tanga1ca5742016-02-16 17:42:13 -0800789 gnss_set_system_info set_system_info_cb;
Lifu Tang7e33bb22016-02-07 18:09:30 -0800790 gnss_sv_status_callback gnss_sv_status_cb;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700791} GpsCallbacks;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500792
793/** Represents the standard GPS interface. */
794typedef struct {
795 /** set to sizeof(GpsInterface) */
796 size_t size;
797 /**
798 * Opens the interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -0700799 * to the implementation of this interface.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500800 */
801 int (*init)( GpsCallbacks* callbacks );
802
803 /** Starts navigating. */
804 int (*start)( void );
805
806 /** Stops navigating. */
807 int (*stop)( void );
808
809 /** Closes the interface. */
810 void (*cleanup)( void );
811
812 /** Injects the current time. */
813 int (*inject_time)(GpsUtcTime time, int64_t timeReference,
814 int uncertainty);
815
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700816 /**
817 * Injects current location from another location provider (typically cell
818 * ID). Latitude and longitude are measured in degrees expected accuracy is
819 * measured in meters
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500820 */
821 int (*inject_location)(double latitude, double longitude, float accuracy);
822
823 /**
824 * Specifies that the next call to start will not use the
825 * information defined in the flags. GPS_DELETE_ALL is passed for
826 * a cold start.
827 */
828 void (*delete_aiding_data)(GpsAidingData flags);
829
830 /**
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400831 * min_interval represents the time between fixes in milliseconds.
832 * preferred_accuracy represents the requested fix accuracy in meters.
833 * preferred_time represents the requested time to first fix in milliseconds.
destradaa81534882015-04-28 13:10:56 -0700834 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700835 * 'mode' parameter should be one of GPS_POSITION_MODE_MS_BASED
destradaa81534882015-04-28 13:10:56 -0700836 * or GPS_POSITION_MODE_STANDALONE.
837 * It is allowed by the platform (and it is recommended) to fallback to
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700838 * GPS_POSITION_MODE_MS_BASED if GPS_POSITION_MODE_MS_ASSISTED is passed in, and
destradaa81534882015-04-28 13:10:56 -0700839 * GPS_POSITION_MODE_MS_BASED is supported.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500840 */
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400841 int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence,
842 uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time);
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500843
844 /** Get a pointer to extension information. */
845 const void* (*get_extension)(const char* name);
846} GpsInterface;
847
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700848/**
849 * Callback to request the client to download XTRA data. The client should
850 * download XTRA data and inject it by calling inject_xtra_data(). Can only be
851 * called from a thread created by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700852 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500853typedef void (* gps_xtra_download_request)();
854
855/** Callback structure for the XTRA interface. */
856typedef struct {
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700857 gps_xtra_download_request download_request_cb;
858 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500859} GpsXtraCallbacks;
860
861/** Extended interface for XTRA support. */
862typedef struct {
863 /** set to sizeof(GpsXtraInterface) */
864 size_t size;
865 /**
866 * Opens the XTRA interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -0700867 * to the implementation of this interface.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500868 */
869 int (*init)( GpsXtraCallbacks* callbacks );
870 /** Injects XTRA data into the GPS. */
871 int (*inject_xtra_data)( char* data, int length );
872} GpsXtraInterface;
873
874/** Extended interface for DEBUG support. */
875typedef struct {
876 /** set to sizeof(GpsDebugInterface) */
877 size_t size;
878
879 /**
880 * This function should return any information that the native
881 * implementation wishes to include in a bugreport.
882 */
883 size_t (*get_internal_state)(char* buffer, size_t bufferSize);
884} GpsDebugInterface;
885
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700886/*
887 * Represents the status of AGPS augmented to support IPv4 and IPv6.
888 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500889typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700890 /** set to sizeof(AGpsStatus) */
destradaaf48cc672014-06-05 11:07:09 -0700891 size_t size;
892
893 AGpsType type;
894 AGpsStatusValue status;
895
896 /**
897 * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4
898 * address, or set to INADDR_NONE otherwise.
899 */
900 uint32_t ipaddr;
901
902 /**
903 * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report.
904 * Any other value of addr.ss_family will be rejected.
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700905 */
destradaaf48cc672014-06-05 11:07:09 -0700906 struct sockaddr_storage addr;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700907} AGpsStatus;
destradaaf48cc672014-06-05 11:07:09 -0700908
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700909/**
910 * Callback with AGPS status information. Can only be called from a thread
911 * created by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700912 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500913typedef void (* agps_status_callback)(AGpsStatus* status);
914
915/** Callback structure for the AGPS interface. */
916typedef struct {
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700917 agps_status_callback status_cb;
918 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500919} AGpsCallbacks;
920
destradaaf48cc672014-06-05 11:07:09 -0700921/**
922 * Extended interface for AGPS support, it is augmented to enable to pass
923 * extra APN data.
924 */
925typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700926 /** set to sizeof(AGpsInterface) */
destradaaf48cc672014-06-05 11:07:09 -0700927 size_t size;
928
929 /**
930 * Opens the AGPS interface and provides the callback routines to the
931 * implementation of this interface.
932 */
933 void (*init)(AGpsCallbacks* callbacks);
934 /**
935 * Deprecated.
936 * If the HAL supports AGpsInterface_v2 this API will not be used, see
937 * data_conn_open_with_apn_ip_type for more information.
938 */
939 int (*data_conn_open)(const char* apn);
940 /**
941 * Notifies that the AGPS data connection has been closed.
942 */
943 int (*data_conn_closed)();
944 /**
945 * Notifies that a data connection is not available for AGPS.
946 */
947 int (*data_conn_failed)();
948 /**
949 * Sets the hostname and port for the AGPS server.
950 */
951 int (*set_server)(AGpsType type, const char* hostname, int port);
952
953 /**
954 * Notifies that a data connection is available and sets the name of the
955 * APN, and its IP type, to be used for SUPL connections.
956 */
957 int (*data_conn_open_with_apn_ip_type)(
958 const char* apn,
959 ApnIpType apnIpType);
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700960} AGpsInterface;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500961
destradaaa1f4c0a2013-09-13 15:45:03 -0700962/** Error codes associated with certificate operations */
963#define AGPS_CERTIFICATE_OPERATION_SUCCESS 0
964#define AGPS_CERTIFICATE_ERROR_GENERIC -100
965#define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101
966
967/** A data structure that represents an X.509 certificate using DER encoding */
968typedef struct {
969 size_t length;
970 u_char* data;
971} DerEncodedCertificate;
972
973/**
974 * A type definition for SHA1 Fingerprints used to identify X.509 Certificates
975 * The Fingerprint is a digest of the DER Certificate that uniquely identifies it.
976 */
977typedef struct {
978 u_char data[20];
979} Sha1CertificateFingerprint;
980
destradaa9f7c3732014-04-29 10:50:22 -0700981/** AGPS Interface to handle SUPL certificate operations */
destradaaa1f4c0a2013-09-13 15:45:03 -0700982typedef struct {
983 /** set to sizeof(SuplCertificateInterface) */
984 size_t size;
985
986 /**
987 * Installs a set of Certificates used for SUPL connections to the AGPS server.
988 * If needed the HAL should find out internally any certificates that need to be removed to
989 * accommodate the certificates to install.
990 * The certificates installed represent a full set of valid certificates needed to connect to
991 * AGPS SUPL servers.
992 * The list of certificates is required, and all must be available at the same time, when trying
993 * to establish a connection with the AGPS Server.
994 *
995 * Parameters:
996 * certificates - A pointer to an array of DER encoded certificates that are need to be
997 * installed in the HAL.
998 * length - The number of certificates to install.
999 * Returns:
1000 * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully
1001 * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of
1002 * certificates attempted to be installed, the state of the certificates stored should
1003 * remain the same as before on this error case.
1004 *
1005 * IMPORTANT:
1006 * If needed the HAL should find out internally the set of certificates that need to be
1007 * removed to accommodate the certificates to install.
1008 */
1009 int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length );
1010
1011 /**
1012 * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is
1013 * expected that the given set of certificates is removed from the internal store of the HAL.
1014 *
1015 * Parameters:
1016 * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of
1017 * certificates to revoke.
1018 * length - The number of fingerprints provided.
1019 * Returns:
1020 * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully.
1021 *
1022 * IMPORTANT:
1023 * If any of the certificates provided (through its fingerprint) is not known by the HAL,
1024 * it should be ignored and continue revoking/deleting the rest of them.
1025 */
1026 int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length );
destradaa7ddd4d72013-11-07 13:47:59 -08001027} SuplCertificateInterface;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05001028
1029/** Represents an NI request */
1030typedef struct {
1031 /** set to sizeof(GpsNiNotification) */
1032 size_t size;
1033
1034 /**
1035 * An ID generated by HAL to associate NI notifications and UI
1036 * responses
1037 */
1038 int notification_id;
1039
1040 /**
1041 * An NI type used to distinguish different categories of NI
1042 * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ...
1043 */
1044 GpsNiType ni_type;
1045
1046 /**
1047 * Notification/verification options, combinations of GpsNiNotifyFlags constants
1048 */
1049 GpsNiNotifyFlags notify_flags;
1050
1051 /**
1052 * Timeout period to wait for user response.
1053 * Set to 0 for no time out limit.
1054 */
1055 int timeout;
1056
1057 /**
1058 * Default response when time out.
1059 */
1060 GpsUserResponseType default_response;
1061
1062 /**
1063 * Requestor ID
1064 */
1065 char requestor_id[GPS_NI_SHORT_STRING_MAXLEN];
1066
1067 /**
1068 * Notification message. It can also be used to store client_id in some cases
1069 */
1070 char text[GPS_NI_LONG_STRING_MAXLEN];
1071
1072 /**
1073 * Client name decoding scheme
1074 */
1075 GpsNiEncodingType requestor_id_encoding;
1076
1077 /**
1078 * Client name decoding scheme
1079 */
1080 GpsNiEncodingType text_encoding;
1081
1082 /**
1083 * A pointer to extra data. Format:
1084 * key_1 = value_1
1085 * key_2 = value_2
1086 */
1087 char extras[GPS_NI_LONG_STRING_MAXLEN];
1088
1089} GpsNiNotification;
1090
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001091/**
1092 * Callback with NI notification. Can only be called from a thread created by
1093 * create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -07001094 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05001095typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification);
1096
1097/** GPS NI callback structure. */
1098typedef struct
1099{
Mike Lockwood4453b5b2010-06-20 14:23:10 -07001100 /**
1101 * Sends the notification request from HAL to GPSLocationProvider.
1102 */
1103 gps_ni_notify_callback notify_cb;
1104 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05001105} GpsNiCallbacks;
1106
1107/**
1108 * Extended interface for Network-initiated (NI) support.
1109 */
1110typedef struct
1111{
1112 /** set to sizeof(GpsNiInterface) */
1113 size_t size;
1114
1115 /** Registers the callbacks for HAL to use. */
1116 void (*init) (GpsNiCallbacks *callbacks);
1117
1118 /** Sends a response to HAL. */
1119 void (*respond) (int notif_id, GpsUserResponseType user_response);
1120} GpsNiInterface;
1121
1122struct gps_device_t {
1123 struct hw_device_t common;
1124
1125 /**
1126 * Set the provided lights to the provided values.
1127 *
1128 * Returns: 0 on succes, error code on failure.
1129 */
1130 const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev);
1131};
1132
Miguel Torroja5f404f52010-07-27 06:34:15 +02001133#define AGPS_RIL_REQUEST_SETID_IMSI (1<<0L)
1134#define AGPS_RIL_REQUEST_SETID_MSISDN (1<<1L)
1135
1136#define AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L)
1137#define AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L)
1138
1139typedef void (*agps_ril_request_set_id)(uint32_t flags);
1140typedef void (*agps_ril_request_ref_loc)(uint32_t flags);
1141
1142typedef struct {
1143 agps_ril_request_set_id request_setid;
1144 agps_ril_request_ref_loc request_refloc;
1145 gps_create_thread create_thread_cb;
1146} AGpsRilCallbacks;
1147
1148/** Extended interface for AGPS_RIL support. */
1149typedef struct {
1150 /** set to sizeof(AGpsRilInterface) */
1151 size_t size;
1152 /**
1153 * Opens the AGPS interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -07001154 * to the implementation of this interface.
Miguel Torroja5f404f52010-07-27 06:34:15 +02001155 */
1156 void (*init)( AGpsRilCallbacks* callbacks );
1157
1158 /**
1159 * Sets the reference location.
1160 */
1161 void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct);
1162 /**
1163 * Sets the set ID.
1164 */
1165 void (*set_set_id) (AGpsSetIDType type, const char* setid);
1166
1167 /**
1168 * Send network initiated message.
1169 */
1170 void (*ni_message) (uint8_t *msg, size_t len);
Mike Lockwood455e83b2010-10-11 06:16:57 -04001171
1172 /**
1173 * Notify GPS of network status changes.
1174 * These parameters match values in the android.net.NetworkInfo class.
1175 */
1176 void (*update_network_state) (int connected, int type, int roaming, const char* extra_info);
Kevin Tangb82c2db2011-04-13 17:15:55 -07001177
1178 /**
1179 * Notify GPS of network status changes.
1180 * These parameters match values in the android.net.NetworkInfo class.
1181 */
1182 void (*update_network_availability) (int avaiable, const char* apn);
Miguel Torroja5f404f52010-07-27 06:34:15 +02001183} AGpsRilInterface;
1184
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001185/**
1186 * GPS Geofence.
1187 * There are 3 states associated with a Geofence: Inside, Outside, Unknown.
1188 * There are 3 transitions: ENTERED, EXITED, UNCERTAIN.
1189 *
1190 * An example state diagram with confidence level: 95% and Unknown time limit
1191 * set as 30 secs is shown below. (confidence level and Unknown time limit are
1192 * explained latter)
1193 * ____________________________
1194 * | Unknown (30 secs) |
1195 * """"""""""""""""""""""""""""
1196 * ^ | | ^
1197 * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN
1198 * | v v |
1199 * ________ EXITED _________
1200 * | Inside | -----------> | Outside |
1201 * | | <----------- | |
1202 * """""""" ENTERED """""""""
1203 *
1204 * Inside state: We are 95% confident that the user is inside the geofence.
1205 * Outside state: We are 95% confident that the user is outside the geofence
1206 * Unknown state: Rest of the time.
1207 *
1208 * The Unknown state is better explained with an example:
1209 *
1210 * __________
1211 * | c|
1212 * | ___ | _______
1213 * | |a| | | b |
1214 * | """ | """""""
1215 * | |
1216 * """"""""""
1217 * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy
1218 * circle reported by the GPS subsystem. Now with regard to "b", the system is
1219 * confident that the user is outside. But with regard to "a" is not confident
1220 * whether it is inside or outside the geofence. If the accuracy remains the
1221 * same for a sufficient period of time, the UNCERTAIN transition would be
1222 * triggered with the state set to Unknown. If the accuracy improves later, an
1223 * appropriate transition should be triggered. This "sufficient period of time"
1224 * is defined by the parameter in the add_geofence_area API.
1225 * In other words, Unknown state can be interpreted as a state in which the
1226 * GPS subsystem isn't confident enough that the user is either inside or
1227 * outside the Geofence. It moves to Unknown state only after the expiry of the
1228 * timeout.
1229 *
1230 * The geofence callback needs to be triggered for the ENTERED and EXITED
1231 * transitions, when the GPS system is confident that the user has entered
1232 * (Inside state) or exited (Outside state) the Geofence. An implementation
1233 * which uses a value of 95% as the confidence is recommended. The callback
1234 * should be triggered only for the transitions requested by the
1235 * add_geofence_area call.
1236 *
1237 * Even though the diagram and explanation talks about states and transitions,
1238 * the callee is only interested in the transistions. The states are mentioned
1239 * here for illustrative purposes.
1240 *
1241 * Startup Scenario: When the device boots up, if an application adds geofences,
1242 * and then we get an accurate GPS location fix, it needs to trigger the
1243 * appropriate (ENTERED or EXITED) transition for every Geofence it knows about.
1244 * By default, all the Geofences will be in the Unknown state.
1245 *
1246 * When the GPS system is unavailable, gps_geofence_status_callback should be
1247 * called to inform the upper layers of the same. Similarly, when it becomes
1248 * available the callback should be called. This is a global state while the
1249 * UNKNOWN transition described above is per geofence.
1250 *
1251 * An important aspect to note is that users of this API (framework), will use
1252 * other subsystems like wifi, sensors, cell to handle Unknown case and
1253 * hopefully provide a definitive state transition to the third party
1254 * application. GPS Geofence will just be a signal indicating what the GPS
1255 * subsystem knows about the Geofence.
1256 *
1257 */
1258#define GPS_GEOFENCE_ENTERED (1<<0L)
1259#define GPS_GEOFENCE_EXITED (1<<1L)
1260#define GPS_GEOFENCE_UNCERTAIN (1<<2L)
1261
1262#define GPS_GEOFENCE_UNAVAILABLE (1<<0L)
1263#define GPS_GEOFENCE_AVAILABLE (1<<1L)
1264
Jaikumar Ganesh5824b402013-02-25 11:43:33 -08001265#define GPS_GEOFENCE_OPERATION_SUCCESS 0
1266#define GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES -100
1267#define GPS_GEOFENCE_ERROR_ID_EXISTS -101
1268#define GPS_GEOFENCE_ERROR_ID_UNKNOWN -102
1269#define GPS_GEOFENCE_ERROR_INVALID_TRANSITION -103
1270#define GPS_GEOFENCE_ERROR_GENERIC -149
1271
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001272/**
1273 * The callback associated with the geofence.
1274 * Parameters:
1275 * geofence_id - The id associated with the add_geofence_area.
1276 * location - The current GPS location.
1277 * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED,
1278 * GPS_GEOFENCE_UNCERTAIN.
1279 * timestamp - Timestamp when the transition was detected.
1280 *
1281 * The callback should only be called when the caller is interested in that
1282 * particular transition. For instance, if the caller is interested only in
1283 * ENTERED transition, then the callback should NOT be called with the EXITED
1284 * transition.
1285 *
1286 * IMPORTANT: If a transition is triggered resulting in this callback, the GPS
1287 * subsystem will wake up the application processor, if its in suspend state.
1288 */
1289typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location,
1290 int32_t transition, GpsUtcTime timestamp);
1291
1292/**
destradaa9f7c3732014-04-29 10:50:22 -07001293 * The callback associated with the availability of the GPS system for geofencing
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001294 * monitoring. If the GPS system determines that it cannot monitor geofences
1295 * because of lack of reliability or unavailability of the GPS signals, it will
1296 * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter.
1297 *
1298 * Parameters:
1299 * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE.
1300 * last_location - Last known location.
1301 */
1302typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location);
1303
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001304/**
1305 * The callback associated with the add_geofence call.
1306 *
1307 * Parameter:
1308 * geofence_id - Id of the geofence.
1309 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1310 * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached.
1311 * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists
1312 * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an
1313 * invalid transition
1314 * GPS_GEOFENCE_ERROR_GENERIC - for other errors.
1315 */
1316typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status);
1317
1318/**
1319 * The callback associated with the remove_geofence call.
1320 *
1321 * Parameter:
1322 * geofence_id - Id of the geofence.
1323 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1324 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1325 * GPS_GEOFENCE_ERROR_GENERIC for others.
1326 */
1327typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status);
1328
1329
1330/**
1331 * The callback associated with the pause_geofence call.
1332 *
1333 * Parameter:
1334 * geofence_id - Id of the geofence.
1335 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1336 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1337 * GPS_GEOFENCE_ERROR_INVALID_TRANSITION -
1338 * when monitor_transitions is invalid
1339 * GPS_GEOFENCE_ERROR_GENERIC for others.
1340 */
1341typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status);
1342
1343/**
1344 * The callback associated with the resume_geofence call.
1345 *
1346 * Parameter:
1347 * geofence_id - Id of the geofence.
1348 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1349 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1350 * GPS_GEOFENCE_ERROR_GENERIC for others.
1351 */
1352typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status);
1353
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001354typedef struct {
1355 gps_geofence_transition_callback geofence_transition_callback;
1356 gps_geofence_status_callback geofence_status_callback;
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001357 gps_geofence_add_callback geofence_add_callback;
1358 gps_geofence_remove_callback geofence_remove_callback;
1359 gps_geofence_pause_callback geofence_pause_callback;
1360 gps_geofence_resume_callback geofence_resume_callback;
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001361 gps_create_thread create_thread_cb;
1362} GpsGeofenceCallbacks;
1363
1364/** Extended interface for GPS_Geofencing support */
1365typedef struct {
1366 /** set to sizeof(GpsGeofencingInterface) */
1367 size_t size;
1368
1369 /**
1370 * Opens the geofence interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -07001371 * to the implementation of this interface.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001372 */
1373 void (*init)( GpsGeofenceCallbacks* callbacks );
1374
1375 /**
1376 * Add a geofence area. This api currently supports circular geofences.
1377 * Parameters:
1378 * geofence_id - The id for the geofence. If a geofence with this id
Jaikumar Ganesh5824b402013-02-25 11:43:33 -08001379 * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS)
1380 * should be returned.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001381 * latitude, longtitude, radius_meters - The lat, long and radius
1382 * (in meters) for the geofence
1383 * last_transition - The current state of the geofence. For example, if
1384 * the system already knows that the user is inside the geofence,
1385 * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it
1386 * will be GPS_GEOFENCE_UNCERTAIN.
1387 * monitor_transition - Which transitions to monitor. Bitwise OR of
1388 * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
1389 * GPS_GEOFENCE_UNCERTAIN.
1390 * notification_responsiveness_ms - Defines the best-effort description
1391 * of how soon should the callback be called when the transition
1392 * associated with the Geofence is triggered. For instance, if set
1393 * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback
1394 * should be called 1000 milliseconds within entering the geofence.
1395 * This parameter is defined in milliseconds.
1396 * NOTE: This is not to be confused with the rate that the GPS is
1397 * polled at. It is acceptable to dynamically vary the rate of
1398 * sampling the GPS for power-saving reasons; thus the rate of
1399 * sampling may be faster or slower than this.
1400 * unknown_timer_ms - The time limit after which the UNCERTAIN transition
destradaa9f7c3732014-04-29 10:50:22 -07001401 * should be triggered. This parameter is defined in milliseconds.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001402 * See above for a detailed explanation.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001403 */
destradaa9f7c3732014-04-29 10:50:22 -07001404 void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude,
1405 double radius_meters, int last_transition, int monitor_transitions,
1406 int notification_responsiveness_ms, int unknown_timer_ms);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001407
1408 /**
1409 * Pause monitoring a particular geofence.
1410 * Parameters:
1411 * geofence_id - The id for the geofence.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001412 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001413 void (*pause_geofence) (int32_t geofence_id);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001414
1415 /**
1416 * Resume monitoring a particular geofence.
1417 * Parameters:
1418 * geofence_id - The id for the geofence.
1419 * monitor_transitions - Which transitions to monitor. Bitwise OR of
1420 * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
1421 * GPS_GEOFENCE_UNCERTAIN.
1422 * This supersedes the value associated provided in the
1423 * add_geofence_area call.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001424 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001425 void (*resume_geofence) (int32_t geofence_id, int monitor_transitions);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001426
1427 /**
1428 * Remove a geofence area. After the function returns, no notifications
1429 * should be sent.
1430 * Parameter:
1431 * geofence_id - The id for the geofence.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001432 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001433 void (*remove_geofence_area) (int32_t geofence_id);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001434} GpsGeofencingInterface;
destradaa9f7c3732014-04-29 10:50:22 -07001435
destradaa9f7c3732014-04-29 10:50:22 -07001436/**
Lifu Tang7e33bb22016-02-07 18:09:30 -08001437 * Legacy struct to represent an estimate of the GPS clock time.
1438 * Deprecated, to be removed in the next Android release.
1439 * Use GnssClock instead.
destradaa9f7c3732014-04-29 10:50:22 -07001440 */
1441typedef struct {
1442 /** set to sizeof(GpsClock) */
1443 size_t size;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001444 GpsClockFlags flags;
1445 int16_t leap_second;
1446 GpsClockType type;
1447 int64_t time_ns;
1448 double time_uncertainty_ns;
1449 int64_t full_bias_ns;
1450 double bias_ns;
1451 double bias_uncertainty_ns;
1452 double drift_nsps;
1453 double drift_uncertainty_nsps;
1454} GpsClock;
1455
1456/**
1457 * Represents an estimate of the GPS clock time.
1458 */
1459typedef struct {
1460 /** set to sizeof(GnssClock) */
1461 size_t size;
destradaa9f7c3732014-04-29 10:50:22 -07001462
Lifu Tanga1ca5742016-02-16 17:42:13 -08001463 /**
1464 * A set of flags indicating the validity of the fields in this data
1465 * structure.
1466 */
1467 GnssClockFlags flags;
destradaa9f7c3732014-04-29 10:50:22 -07001468
1469 /**
1470 * Leap second data.
destradaa75843eb2014-07-17 14:04:50 -07001471 * The sign of the value is defined by the following equation:
Lifu Tanga1ca5742016-02-16 17:42:13 -08001472 * utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second *
1473 * 1,000,000,000
destradaa75843eb2014-07-17 14:04:50 -07001474 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001475 * If the data is available 'flags' must contain GNSS_CLOCK_HAS_LEAP_SECOND.
destradaa9f7c3732014-04-29 10:50:22 -07001476 */
1477 int16_t leap_second;
1478
1479 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001480 * The GNSS receiver internal clock value. This is the local hardware clock
1481 * value.
destradaa9f7c3732014-04-29 10:50:22 -07001482 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001483 * For local hardware clock, this value is expected to be monotonically
1484 * increasing while the hardware clock remains power on. (For the case of a
1485 * HW clock that is not continuously on, see the
1486 * hw_clock_discontinuity_count field). The real GPS time can be derived by
1487 * adding the 'full_bias_ns + bias_ns' (when it is available) to this value.
destradaa9f7c3732014-04-29 10:50:22 -07001488 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001489 * This GPS time is expected to be the best estimate of current GPS time
1490 * that GNSS receiver can achieve.
destradaa75843eb2014-07-17 14:04:50 -07001491 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001492 * Sub-nanosecond accuracy can be provided by means of the 'bias_ns' field.
destradaa9f7c3732014-04-29 10:50:22 -07001493 * The value contains the 'time uncertainty' in it.
destradaa75843eb2014-07-17 14:04:50 -07001494 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001495 * This field is mandatory.
destradaa9f7c3732014-04-29 10:50:22 -07001496 */
1497 int64_t time_ns;
1498
1499 /**
1500 * 1-Sigma uncertainty associated with the clock's time in nanoseconds.
1501 * The uncertainty is represented as an absolute (single sided) value.
1502 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001503 * If the data is available, 'flags' must contain
Lifu Tanga1ca5742016-02-16 17:42:13 -08001504 * GNSS_CLOCK_HAS_TIME_UNCERTAINTY. This value is effectively zero (it is
1505 * the reference local clock, by which all other times and time
1506 * uncertainties are measured.) (And thus this field can be not provided,
1507 * per GNSS_CLOCK_HAS_TIME_UNCERTAINTY flag, or provided & set to 0.)
destradaa9f7c3732014-04-29 10:50:22 -07001508 */
1509 double time_uncertainty_ns;
1510
1511 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001512 * The difference between hardware clock ('time' field) inside GPS receiver
1513 * and the true GPS time since 0000Z, January 6, 1980, in nanoseconds.
destradaa9f7c3732014-04-29 10:50:22 -07001514 *
destradaa75843eb2014-07-17 14:04:50 -07001515 * The sign of the value is defined by the following equation:
Lifu Tanga1ca5742016-02-16 17:42:13 -08001516 * local estimate of GPS time = time_ns + (full_bias_ns + bias_ns)
destradaa75843eb2014-07-17 14:04:50 -07001517 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001518 * This value is mandatory if the receiver has estimated GPS time. If the
1519 * computed time is for a non-GPS constellation, the time offset of that
1520 * constellation to GPS has to be applied to fill this value. The value
1521 * contains the 'bias uncertainty' in it, and the caller is responsible of
1522 * using the uncertainty. If the data is available 'flags' must contain
1523 * GNSS_CLOCK_HAS_FULL_BIAS.
destradaa75843eb2014-07-17 14:04:50 -07001524 */
1525 int64_t full_bias_ns;
1526
1527 /**
1528 * Sub-nanosecond bias.
destradaa9f7c3732014-04-29 10:50:22 -07001529 * The value contains the 'bias uncertainty' in it.
destradaa75843eb2014-07-17 14:04:50 -07001530 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001531 * If the data is available 'flags' must contain GNSS_CLOCK_HAS_BIAS. If GPS
1532 * has computed a position fix. This value is mandatory if the receiver has
1533 * estimated GPS time.
destradaa9f7c3732014-04-29 10:50:22 -07001534 */
1535 double bias_ns;
1536
1537 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001538 * 1-Sigma uncertainty associated with the local estimate of GPS time (clock
1539 * bias) in nanoseconds. The uncertainty is represented as an absolute
1540 * (single sided) value.
destradaa9f7c3732014-04-29 10:50:22 -07001541 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001542 * If the data is available 'flags' must contain
Lifu Tanga1ca5742016-02-16 17:42:13 -08001543 * GNSS_CLOCK_HAS_BIAS_UNCERTAINTY. This value is mandatory if the receiver
1544 * has estimated GPS time.
destradaa9f7c3732014-04-29 10:50:22 -07001545 */
1546 double bias_uncertainty_ns;
1547
1548 /**
1549 * The clock's drift in nanoseconds (per second).
Lifu Tanga1ca5742016-02-16 17:42:13 -08001550 *
1551 * A positive value means that the frequency is higher than the nominal
1552 * frequency.
destradaa9f7c3732014-04-29 10:50:22 -07001553 *
1554 * The value contains the 'drift uncertainty' in it.
Lifu Tanga1ca5742016-02-16 17:42:13 -08001555 * If the data is available 'flags' must contain GNSS_CLOCK_HAS_DRIFT.
destradaa00caa892015-04-09 18:41:46 -07001556 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001557 * This value is mandatory if the receiver has estimated GNSS time
destradaa9f7c3732014-04-29 10:50:22 -07001558 */
1559 double drift_nsps;
1560
1561 /**
1562 * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second).
1563 * The uncertainty is represented as an absolute (single sided) value.
1564 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001565 * If the data is available 'flags' must contain
Lifu Tanga1ca5742016-02-16 17:42:13 -08001566 * GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY. If GPS has computed a position fix this
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001567 * field is mandatory and must be populated.
destradaa9f7c3732014-04-29 10:50:22 -07001568 */
1569 double drift_uncertainty_nsps;
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001570
1571 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001572 * When there are any discontinuities in the HW clock, this field is
1573 * mandatory.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001574 *
1575 * A "discontinuity" is meant to cover the case of a switch from one source
1576 * of clock to another. A single free-running crystal oscillator (XO)
Lifu Tanga1ca5742016-02-16 17:42:13 -08001577 * should generally not have any discontinuities, and this can be set and
1578 * left at 0.
1579 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001580 * If, however, the time_ns value (HW clock) is derived from a composite of
Lifu Tanga1ca5742016-02-16 17:42:13 -08001581 * sources, that is not as smooth as a typical XO, or is otherwise stopped &
1582 * restarted, then this value shall be incremented each time a discontinuity
1583 * occurs. (E.g. this value may start at zero at device boot-up and
1584 * increment each time there is a change in clock continuity. In the
1585 * unlikely event that this value reaches full scale, rollover (not
1586 * clamping) is required, such that this value continues to change, during
1587 * subsequent discontinuity events.)
1588 *
1589 * While this number stays the same, between GnssClock reports, it can be
1590 * safely assumed that the time_ns value has been running continuously, e.g.
1591 * derived from a single, high quality clock (XO like, or better, that's
1592 * typically used during continuous GNSS signal sampling.)
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001593 *
1594 * It is expected, esp. during periods where there are few GNSS signals
1595 * available, that the HW clock be discontinuity-free as long as possible,
Lifu Tanga1ca5742016-02-16 17:42:13 -08001596 * as this avoids the need to use (waste) a GNSS measurement to fully
1597 * re-solve for the GPS clock bias and drift, when using the accompanying
1598 * measurements, from consecutive GnssData reports.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001599 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001600 uint32_t hw_clock_discontinuity_count;
1601
Lifu Tang7e33bb22016-02-07 18:09:30 -08001602} GnssClock;
destradaa9f7c3732014-04-29 10:50:22 -07001603
1604/**
Lifu Tang7e33bb22016-02-07 18:09:30 -08001605 * Legacy struct to represent a GPS Measurement, it contains raw and computed
1606 * information.
1607 * Deprecated, to be removed in the next Android release.
1608 * Use GnssMeasurement instead.
1609 */
1610typedef struct {
1611 /** set to sizeof(GpsMeasurement) */
1612 size_t size;
1613 GpsMeasurementFlags flags;
1614 int8_t prn;
1615 double time_offset_ns;
1616 GpsMeasurementState state;
1617 int64_t received_gps_tow_ns;
1618 int64_t received_gps_tow_uncertainty_ns;
1619 double c_n0_dbhz;
1620 double pseudorange_rate_mps;
1621 double pseudorange_rate_uncertainty_mps;
1622 GpsAccumulatedDeltaRangeState accumulated_delta_range_state;
1623 double accumulated_delta_range_m;
1624 double accumulated_delta_range_uncertainty_m;
1625 double pseudorange_m;
1626 double pseudorange_uncertainty_m;
1627 double code_phase_chips;
1628 double code_phase_uncertainty_chips;
1629 float carrier_frequency_hz;
1630 int64_t carrier_cycles;
1631 double carrier_phase;
1632 double carrier_phase_uncertainty;
1633 GpsLossOfLock loss_of_lock;
1634 int32_t bit_number;
1635 int16_t time_from_last_bit_ms;
1636 double doppler_shift_hz;
1637 double doppler_shift_uncertainty_hz;
1638 GpsMultipathIndicator multipath_indicator;
1639 double snr_db;
1640 double elevation_deg;
1641 double elevation_uncertainty_deg;
1642 double azimuth_deg;
1643 double azimuth_uncertainty_deg;
1644 bool used_in_fix;
1645} GpsMeasurement;
1646
1647/**
1648 * Represents a GNSS Measurement, it contains raw and computed information.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001649 *
1650 * Independence - All signal measurement information (e.g. sv_time,
1651 * pseudorange_rate, multipath_indicator) reported in this struct should be
1652 * based on GNSS signal measurements only. You may not synthesize measurements
1653 * by calculating or reporting expected measurements based on known or estimated
1654 * position, velocity, or time.
destradaa9f7c3732014-04-29 10:50:22 -07001655 */
1656typedef struct {
1657 /** set to sizeof(GpsMeasurement) */
1658 size_t size;
1659
1660 /** A set of flags indicating the validity of the fields in this data structure. */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001661 GnssMeasurementFlags flags;
destradaa9f7c3732014-04-29 10:50:22 -07001662
1663 /**
Lifu Tang7e33bb22016-02-07 18:09:30 -08001664 * Satellite vehicle ID number, as defined in GnssSvInfo::svid
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001665 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001666 */
Lifu Tang7e33bb22016-02-07 18:09:30 -08001667 int16_t svid;
destradaa9f7c3732014-04-29 10:50:22 -07001668
1669 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001670 * Defines the constellation of the given SV. Value should be one of those
1671 * GNSS_CONSTELLATION_* constants
1672 */
1673 GnssConstellationType constellation;
1674
1675 /**
destradaa75843eb2014-07-17 14:04:50 -07001676 * Time offset at which the measurement was taken in nanoseconds.
1677 * The reference receiver's time is specified by GpsData::clock::time_ns and should be
1678 * interpreted in the same way as indicated by GpsClock::type.
1679 *
destradaa9f7c3732014-04-29 10:50:22 -07001680 * The sign of time_offset_ns is given by the following equation:
1681 * measurement time = GpsClock::time_ns + time_offset_ns
1682 *
1683 * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001684 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001685 */
destradaa75843eb2014-07-17 14:04:50 -07001686 double time_offset_ns;
destradaa9f7c3732014-04-29 10:50:22 -07001687
1688 /**
destradaa75843eb2014-07-17 14:04:50 -07001689 * Per satellite sync state. It represents the current sync state for the associated satellite.
1690 * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly.
destradaa9f7c3732014-04-29 10:50:22 -07001691 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001692 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001693 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001694 GnssMeasurementState state;
destradaa75843eb2014-07-17 14:04:50 -07001695
1696 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001697 * The received GNSS Time-of-Week at the measurement time, in nanoseconds.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001698 * Ensure that this field is independent (see comment at top of
1699 * GnssMeasurement struct.)
destradaa75843eb2014-07-17 14:04:50 -07001700 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001701 * For GPS & QZSS, this is:
1702 * Received GPS Time-of-Week at the measurement time, in nanoseconds.
1703 * The value is relative to the beginning of the current GPS week.
Tsuwei Chena90cf192014-10-23 12:49:12 -07001704 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001705 * Given the highest sync state that can be achieved, per each satellite, valid range
1706 * for this field can be:
1707 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1708 * C/A code lock : [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1709 * Bit sync : [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set
1710 * Subframe sync : [ 0 6s ] : GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
1711 * TOW decoded : [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set
destradaa00caa892015-04-09 18:41:46 -07001712 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001713 * Note well: if there is any ambiguity in integer millisecond,
1714 * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field.
1715 *
1716 * This value must be populated if 'state' != GNSS_MEASUREMENT_STATE_UNKNOWN.
1717 *
1718 * For Glonass, this is:
1719 * Received Glonass time of day, at the measurement time in nanoseconds.
1720 *
1721 * Given the highest sync state that can be achieved, per each satellite, valid range for
1722 * this field can be:
1723 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1724 * C/A code lock : [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001725 * Symbol sync : [ 0 10ms ] : GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set
1726 * Bit sync : [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set
1727 * String sync : [ 0 2s ] : GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC is set
1728 * Time of day : [ 0 1day ] : GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED is set
Lifu Tanga1ca5742016-02-16 17:42:13 -08001729 *
1730 * For Beidou, this is:
1731 * Received Beidou time of week, at the measurement time in nanoseconds.
1732 *
1733 * Given the highest sync state that can be achieved, per each satellite, valid range for
1734 * this field can be:
1735 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1736 * C/A code lock: [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1737 * Bit sync (D2): [ 0 2ms ] : GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC is set
1738 * Bit sync (D1): [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set
1739 * Subframe (D2): [ 0 0.6s ] : GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC is set
1740 * Subframe (D1): [ 0 6s ] : GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
1741 * Time of week : [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set
1742 *
1743 * For Galileo, this is:
1744 * Received Galileo time of week, at the measurement time in nanoseconds.
1745 *
1746 * E1BC code lock : [ 0 4ms ] : GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK is set
1747 * E1C 2nd code lock: [ 0 100ms ] :
1748 * GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK is set
1749 *
1750 * E1B page : [ 0 2s ] : GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC is set
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001751 * Time of week: [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set
Lifu Tanga1ca5742016-02-16 17:42:13 -08001752 *
1753 * For SBAS, this is:
1754 * Received SBAS time, at the measurement time in nanoseconds.
1755 *
1756 * Given the highest sync state that can be achieved, per each satellite,
1757 * valid range for this field can be:
1758 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1759 * C/A code lock: [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1760 * Symbol sync : [ 0 2ms ] : GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set
1761 * Message : [ 0 1s ] : GNSS_MEASUREMENT_STATE_SBAS_SYNC is set
1762 */
1763 int64_t received_sv_time_in_ns;
destradaa9f7c3732014-04-29 10:50:22 -07001764
1765 /**
destradaa941c9282014-07-21 18:13:42 -07001766 * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds.
destradaa00caa892015-04-09 18:41:46 -07001767 *
1768 * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN.
destradaa941c9282014-07-21 18:13:42 -07001769 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001770 int64_t received_sv_time_uncertainty_in_ns;
destradaa941c9282014-07-21 18:13:42 -07001771
1772 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -08001773 * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
1774 * It contains the measured C/N0 value for the signal at the antenna port.
destradaa9f7c3732014-04-29 10:50:22 -07001775 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001776 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001777 */
1778 double c_n0_dbhz;
1779
1780 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -08001781 * Pseudorange rate at the timestamp in m/s. The correction of a given
1782 * Pseudorange Rate value includes corrections for receiver and satellite
1783 * clock frequency errors. Ensure that this field is independent (see
1784 * comment at top of GnssMeasurement struct.)
destradaa00caa892015-04-09 18:41:46 -07001785 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001786 * It is mandatory to provide the 'uncorrected' 'pseudorange rate', and provide GpsClock's
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001787 * 'drift' field as well (When providing the uncorrected pseudorange rate, do not apply the
Lifu Tanga1ca5742016-02-16 17:42:13 -08001788 * corrections described above.)
destradaa9f7c3732014-04-29 10:50:22 -07001789 *
1790 * The value includes the 'pseudorange rate uncertainty' in it.
destradaa00caa892015-04-09 18:41:46 -07001791 * A positive 'uncorrected' value indicates that the SV is moving away from the receiver.
1792 *
destradaa357e6222015-04-14 16:30:21 -07001793 * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler
destradaa00caa892015-04-09 18:41:46 -07001794 * shift' is given by the equation:
destradaa357e6222015-04-14 16:30:21 -07001795 * pseudorange rate = -k * doppler shift (where k is a constant)
destradaa9f7c3732014-04-29 10:50:22 -07001796 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001797 * This should be the most accurate pseudorange rate available, based on
1798 * fresh signal measurements from this channel.
1799 *
1800 * It is mandatory that this value be provided at typical carrier phase PRR
1801 * quality (few cm/sec per second of uncertainty, or better) - when signals
1802 * are sufficiently strong & stable, e.g. signals from a GPS simulator at >=
1803 * 35 dB-Hz.
destradaa9f7c3732014-04-29 10:50:22 -07001804 */
destradaa75843eb2014-07-17 14:04:50 -07001805 double pseudorange_rate_mps;
destradaa9f7c3732014-04-29 10:50:22 -07001806
1807 /**
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001808 * 1-Sigma uncertainty of the pseudorange_rate_mps.
destradaa9f7c3732014-04-29 10:50:22 -07001809 * The uncertainty is represented as an absolute (single sided) value.
1810 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001811 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001812 */
destradaa75843eb2014-07-17 14:04:50 -07001813 double pseudorange_rate_uncertainty_mps;
1814
1815 /**
1816 * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip
1817 * (indicating loss of lock).
1818 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001819 * This is a mandatory value.
destradaa75843eb2014-07-17 14:04:50 -07001820 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001821 GnssAccumulatedDeltaRangeState accumulated_delta_range_state;
destradaa9f7c3732014-04-29 10:50:22 -07001822
1823 /**
1824 * Accumulated delta range since the last channel reset in meters.
destradaa357e6222015-04-14 16:30:21 -07001825 * A positive value indicates that the SV is moving away from the receiver.
destradaa00caa892015-04-09 18:41:46 -07001826 *
destradaa357e6222015-04-14 16:30:21 -07001827 * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase'
destradaa00caa892015-04-09 18:41:46 -07001828 * is given by the equation:
destradaa357e6222015-04-14 16:30:21 -07001829 * accumulated delta range = -k * carrier phase (where k is a constant)
destradaa00caa892015-04-09 18:41:46 -07001830 *
1831 * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
1832 * However, it is expected that the data is only accurate when:
1833 * 'accumulated delta range state' == GPS_ADR_STATE_VALID.
destradaa9f7c3732014-04-29 10:50:22 -07001834 */
1835 double accumulated_delta_range_m;
1836
1837 /**
1838 * 1-Sigma uncertainty of the accumulated delta range in meters.
destradaa00caa892015-04-09 18:41:46 -07001839 * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
destradaa9f7c3732014-04-29 10:50:22 -07001840 */
1841 double accumulated_delta_range_uncertainty_m;
1842
1843 /**
destradaa9f7c3732014-04-29 10:50:22 -07001844 * Carrier frequency at which codes and messages are modulated, it can be L1 or L2.
1845 * If the field is not set, the carrier frequency is assumed to be L1.
1846 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001847 * If the data is available, 'flags' must contain
1848 * GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY.
destradaa9f7c3732014-04-29 10:50:22 -07001849 */
1850 float carrier_frequency_hz;
1851
1852 /**
1853 * The number of full carrier cycles between the satellite and the receiver.
1854 * The reference frequency is given by the field 'carrier_frequency_hz'.
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001855 * Indications of possible cycle slips and resets in the accumulation of
1856 * this value can be inferred from the accumulated_delta_range_state flags.
destradaa9f7c3732014-04-29 10:50:22 -07001857 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001858 * If the data is available, 'flags' must contain
1859 * GNSS_MEASUREMENT_HAS_CARRIER_CYCLES.
destradaa9f7c3732014-04-29 10:50:22 -07001860 */
1861 int64_t carrier_cycles;
1862
1863 /**
1864 * The RF phase detected by the receiver, in the range [0.0, 1.0].
1865 * This is usually the fractional part of the complete carrier phase measurement.
1866 *
1867 * The reference frequency is given by the field 'carrier_frequency_hz'.
1868 * The value contains the 'carrier-phase uncertainty' in it.
1869 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001870 * If the data is available, 'flags' must contain
1871 * GNSS_MEASUREMENT_HAS_CARRIER_PHASE.
destradaa9f7c3732014-04-29 10:50:22 -07001872 */
1873 double carrier_phase;
1874
1875 /**
1876 * 1-Sigma uncertainty of the carrier-phase.
Lifu Tanga1ca5742016-02-16 17:42:13 -08001877 * If the data is available, 'flags' must contain
1878 * GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY.
destradaa9f7c3732014-04-29 10:50:22 -07001879 */
1880 double carrier_phase_uncertainty;
1881
1882 /**
destradaa9f7c3732014-04-29 10:50:22 -07001883 * An enumeration that indicates the 'multipath' state of the event.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001884 *
1885 * The multipath Indicator is intended to report the presence of overlapping
1886 * signals that manifest as distorted correlation peaks.
1887 *
1888 * - if there is a distorted correlation peak shape, report that multipath
1889 * is GNSS_MULTIPATH_INDICATOR_PRESENT.
1890 * - if there is not a distorted correlation peak shape, report
1891 * GNSS_MULTIPATH_INDICATOR_NOT_PRESENT
1892 * - if signals are too weak to discern this information, report
1893 * GNSS_MULTIPATH_INDICATOR_UNKNOWN
1894 *
1895 * Example: when doing the standardized overlapping Multipath Performance
1896 * test (3GPP TS 34.171) the Multipath indicator should report
1897 * GNSS_MULTIPATH_INDICATOR_PRESENT for those signals that are tracked, and
1898 * contain multipath, and GNSS_MULTIPATH_INDICATOR_NOT_PRESENT for those
1899 * signals that are tracked and do not contain multipath.
destradaa9f7c3732014-04-29 10:50:22 -07001900 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001901 GnssMultipathIndicator multipath_indicator;
destradaa9f7c3732014-04-29 10:50:22 -07001902
1903 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -08001904 * Signal-to-noise ratio at correlator output in dB.
Lifu Tanga1ca5742016-02-16 17:42:13 -08001905 * If the data is available, 'flags' must contain GNSS_MEASUREMENT_HAS_SNR.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001906 * This is the power ratio of the "correlation peak height above the
1907 * observed noise floor" to "the noise RMS".
destradaa9f7c3732014-04-29 10:50:22 -07001908 */
1909 double snr_db;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001910} GnssMeasurement;
1911
1912/**
1913 * Legacy struct to represents a reading of GPS measurements.
1914 * Deprecated, to be removed in the next Android release.
1915 * Use GnssData instead.
1916 */
1917typedef struct {
1918 /** set to sizeof(GpsData) */
1919 size_t size;
1920 size_t measurement_count;
1921 GpsMeasurement measurements[GPS_MAX_MEASUREMENT];
1922
1923 /** The GPS clock time reading. */
1924 GpsClock clock;
1925} GpsData;
destradaa9f7c3732014-04-29 10:50:22 -07001926
Lifu Tanga1ca5742016-02-16 17:42:13 -08001927/**
1928 * Represents a reading of GNSS measurements. For devices where GnssSystemInfo's
1929 * year_of_hw is set to 2016+, it is mandatory that these be provided, on
1930 * request, when the GNSS receiver is searching/tracking signals.
1931 *
1932 * - Reporting of GPS constellation measurements is mandatory.
1933 * - Reporting of all tracked constellations are encouraged.
1934 */
destradaa9f7c3732014-04-29 10:50:22 -07001935typedef struct {
Lifu Tang7e33bb22016-02-07 18:09:30 -08001936 /** set to sizeof(GnssData) */
destradaa9f7c3732014-04-29 10:50:22 -07001937 size_t size;
1938
1939 /** Number of measurements. */
1940 size_t measurement_count;
1941
1942 /** The array of measurements. */
Lifu Tang7e33bb22016-02-07 18:09:30 -08001943 GnssMeasurement measurements[GNSS_MAX_MEASUREMENT];
destradaa9f7c3732014-04-29 10:50:22 -07001944
1945 /** The GPS clock time reading. */
Lifu Tang7e33bb22016-02-07 18:09:30 -08001946 GnssClock clock;
1947} GnssData;
destradaa9f7c3732014-04-29 10:50:22 -07001948
1949/**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001950 * The legacy callback for to report measurements from the HAL.
1951 *
1952 * This callback is deprecated, and will be removed in the next release. Use
1953 * gnss_measurement_callback() instead.
destradaa9f7c3732014-04-29 10:50:22 -07001954 *
1955 * Parameters:
1956 * data - A data structure containing the measurements.
1957 */
1958typedef void (*gps_measurement_callback) (GpsData* data);
1959
Lifu Tang7e33bb22016-02-07 18:09:30 -08001960/**
1961 * The callback for to report measurements from the HAL.
1962 *
1963 * Parameters:
1964 * data - A data structure containing the measurements.
1965 */
1966typedef void (*gnss_measurement_callback) (GnssData* data);
1967
destradaa9f7c3732014-04-29 10:50:22 -07001968typedef struct {
1969 /** set to sizeof(GpsMeasurementCallbacks) */
1970 size_t size;
1971 gps_measurement_callback measurement_callback;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001972 gnss_measurement_callback gnss_measurement_callback;
destradaa9f7c3732014-04-29 10:50:22 -07001973} GpsMeasurementCallbacks;
1974
1975#define GPS_MEASUREMENT_OPERATION_SUCCESS 0
1976#define GPS_MEASUREMENT_ERROR_ALREADY_INIT -100
1977#define GPS_MEASUREMENT_ERROR_GENERIC -101
1978
1979/**
1980 * Extended interface for GPS Measurements support.
1981 */
1982typedef struct {
1983 /** Set to sizeof(GpsMeasurementInterface) */
1984 size_t size;
1985
1986 /**
1987 * Initializes the interface and registers the callback routines with the HAL.
1988 * After a successful call to 'init' the HAL must begin to provide updates at its own phase.
1989 *
1990 * Status:
1991 * GPS_MEASUREMENT_OPERATION_SUCCESS
1992 * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a
1993 * corresponding call to 'close'
1994 * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL
1995 * will not generate any updates upon returning this error code.
1996 */
1997 int (*init) (GpsMeasurementCallbacks* callbacks);
1998
1999 /**
2000 * Stops updates from the HAL, and unregisters the callback routines.
2001 * After a call to stop, the previously registered callbacks must be considered invalid by the
2002 * HAL.
2003 * If stop is invoked without a previous 'init', this function should perform no work.
2004 */
2005 void (*close) ();
2006
2007} GpsMeasurementInterface;
2008
Lifu Tang7e33bb22016-02-07 18:09:30 -08002009/**
2010 * Legacy struct to represents a GPS navigation message (or a fragment of it).
2011 * Deprecated, to be removed in the next Android release.
2012 * Use GnssNavigationMessage instead.
2013 */
destradaa9f7c3732014-04-29 10:50:22 -07002014typedef struct {
2015 /** set to sizeof(GpsNavigationMessage) */
2016 size_t size;
Lifu Tang7e33bb22016-02-07 18:09:30 -08002017 int8_t prn;
2018 GpsNavigationMessageType type;
2019 NavigationMessageStatus status;
2020 int16_t message_id;
2021 int16_t submessage_id;
2022 size_t data_length;
2023 uint8_t* data;
2024} GpsNavigationMessage;
2025
2026/** Represents a GPS navigation message (or a fragment of it). */
2027typedef struct {
2028 /** set to sizeof(GnssNavigationMessage) */
2029 size_t size;
destradaa9f7c3732014-04-29 10:50:22 -07002030
2031 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002032 * Satellite vehicle ID number, as defined in GnssSvInfo::svid
Lifu Tangdf0fcf72015-10-27 14:58:25 -07002033 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07002034 */
Lifu Tang7e33bb22016-02-07 18:09:30 -08002035 int16_t svid;
destradaa9f7c3732014-04-29 10:50:22 -07002036
2037 /**
2038 * The type of message contained in the structure.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07002039 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07002040 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08002041 GnssNavigationMessageType type;
destradaa9f7c3732014-04-29 10:50:22 -07002042
2043 /**
Tsuwei Chena90cf192014-10-23 12:49:12 -07002044 * The status of the received navigation message.
2045 * No need to send any navigation message that contains words with parity error and cannot be
2046 * corrected.
2047 */
2048 NavigationMessageStatus status;
2049
2050 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002051 * Message identifier. It provides an index so the complete Navigation
2052 * Message can be assembled.
2053 *
2054 * - For GPS L1 C/A subframe 4 and 5, this value corresponds to the 'frame
2055 * id' of the navigation message, in the range of 1-25 (Subframe 1, 2, 3
2056 * does not contain a 'frame id' and this value can be set to -1.)
2057 *
2058 * - For Glonass L1 C/A, this refers to the frame ID, in the range of 1-5.
2059 *
2060 * - For BeiDou D1, this refers to the frame number in the range of 1-24
2061 *
2062 * - For Beidou D2, this refers to the frame number, in the range of 1-120
2063 *
Lifu Tang3fc3bc82016-03-13 22:58:33 -07002064 * - For Galileo F/NAV nominal frame structure, this refers to the subframe
2065 * number, in the range of 1-12
Lifu Tanga1ca5742016-02-16 17:42:13 -08002066 *
Lifu Tang3fc3bc82016-03-13 22:58:33 -07002067 * - For Galileo I/NAV nominal frame structure, this refers to the subframe
2068 * number in the range of 1-24
destradaa9f7c3732014-04-29 10:50:22 -07002069 */
2070 int16_t message_id;
2071
2072 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002073 * Sub-message identifier. If required by the message 'type', this value
2074 * contains a sub-index within the current message (or frame) that is being
2075 * transmitted.
2076 *
2077 * - For GPS L1 C/A, BeiDou D1 & BeiDou D2, the submessage id corresponds to
2078 * the subframe number of the navigation message, in the range of 1-5.
2079 *
2080 * - For Glonass L1 C/A, this refers to the String number, in the range from
2081 * 1-15
2082 *
Lifu Tang3fc3bc82016-03-13 22:58:33 -07002083 * - For Galileo F/NAV, this refers to the page type in the range 1-6
Lifu Tanga1ca5742016-02-16 17:42:13 -08002084 *
Lifu Tang3fc3bc82016-03-13 22:58:33 -07002085 * - For Galileo I/NAV, this refers to the word type in the range 1-10+
destradaa9f7c3732014-04-29 10:50:22 -07002086 */
2087 int16_t submessage_id;
2088
2089 /**
2090 * The length of the data (in bytes) contained in the current message.
2091 * If this value is different from zero, 'data' must point to an array of the same size.
destradaa69d5ea52014-07-31 16:34:09 -07002092 * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word).
destradaa9f7c3732014-04-29 10:50:22 -07002093 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07002094 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07002095 */
2096 size_t data_length;
2097
2098 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002099 * The data of the reported GPS message. The bytes (or words) specified
2100 * using big endian format (MSB first).
destradaa69d5ea52014-07-31 16:34:09 -07002101 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08002102 * - For GPS L1 C/A, Beidou D1 & Beidou D2, each subframe contains 10 30-bit
2103 * words. Each word (30 bits) should be fit into the last 30 bits in a
2104 * 4-byte word (skip B31 and B32), with MSB first, for a total of 40
2105 * bytes, covering a time period of 6, 6, and 0.6 seconds, respectively.
2106 *
2107 * - For Glonass L1 C/A, each string contains 85 data bits, including the
2108 * checksum. These bits should be fit into 11 bytes, with MSB first (skip
2109 * B86-B88), covering a time period of 2 seconds.
2110 *
Lifu Tang3fc3bc82016-03-13 22:58:33 -07002111 * - For Galileo F/NAV, each word consists of 238-bit (sync & tail symbols
2112 * excluded). Each word should be fit into 30-bytes, with MSB first (skip
2113 * B239, B240), covering a time period of 10 seconds.
Lifu Tanga1ca5742016-02-16 17:42:13 -08002114 *
Lifu Tang3fc3bc82016-03-13 22:58:33 -07002115 * - For Galileo I/NAV, each page contains 2 page parts, even and odd, with
2116 * a total of 2x114 = 228 bits, (sync & tail excluded) that should be fit
2117 * into 29 bytes, with MSB first (skip B229-B232).
destradaa9f7c3732014-04-29 10:50:22 -07002118 */
2119 uint8_t* data;
2120
Lifu Tang7e33bb22016-02-07 18:09:30 -08002121} GnssNavigationMessage;
destradaa9f7c3732014-04-29 10:50:22 -07002122
2123/**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002124 * The legacy callback to report an available fragment of a GPS navigation
2125 * messages from the HAL.
2126 *
2127 * This callback is deprecated, and will be removed in the next release. Use
2128 * gnss_navigation_message_callback() instead.
destradaa9f7c3732014-04-29 10:50:22 -07002129 *
2130 * Parameters:
2131 * message - The GPS navigation submessage/subframe representation.
2132 */
2133typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message);
2134
Lifu Tang7e33bb22016-02-07 18:09:30 -08002135/**
2136 * The callback to report an available fragment of a GPS navigation messages from the HAL.
2137 *
2138 * Parameters:
2139 * message - The GPS navigation submessage/subframe representation.
2140 */
2141typedef void (*gnss_navigation_message_callback) (GnssNavigationMessage* message);
2142
destradaa9f7c3732014-04-29 10:50:22 -07002143typedef struct {
2144 /** set to sizeof(GpsNavigationMessageCallbacks) */
2145 size_t size;
2146 gps_navigation_message_callback navigation_message_callback;
Lifu Tang7e33bb22016-02-07 18:09:30 -08002147 gnss_navigation_message_callback gnss_navigation_message_callback;
destradaa9f7c3732014-04-29 10:50:22 -07002148} GpsNavigationMessageCallbacks;
2149
2150#define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS 0
2151#define GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT -100
2152#define GPS_NAVIGATION_MESSAGE_ERROR_GENERIC -101
2153
2154/**
2155 * Extended interface for GPS navigation message reporting support.
2156 */
2157typedef struct {
2158 /** Set to sizeof(GpsNavigationMessageInterface) */
2159 size_t size;
2160
2161 /**
2162 * Initializes the interface and registers the callback routines with the HAL.
2163 * After a successful call to 'init' the HAL must begin to provide updates as they become
2164 * available.
2165 *
2166 * Status:
2167 * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS
2168 * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered
2169 * without a corresponding call to 'close'.
2170 * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that
2171 * the HAL will not generate any updates upon returning this error code.
2172 */
2173 int (*init) (GpsNavigationMessageCallbacks* callbacks);
2174
2175 /**
2176 * Stops updates from the HAL, and unregisters the callback routines.
2177 * After a call to stop, the previously registered callbacks must be considered invalid by the
2178 * HAL.
2179 * If stop is invoked without a previous 'init', this function should perform no work.
2180 */
2181 void (*close) ();
2182
2183} GpsNavigationMessageInterface;
2184
Tsuwei Chen167d31f2014-08-26 16:34:19 -07002185/**
2186 * Interface for passing GNSS configuration contents from platform to HAL.
2187 */
2188typedef struct {
2189 /** Set to sizeof(GnssConfigurationInterface) */
2190 size_t size;
2191
2192 /**
2193 * Deliver GNSS configuration contents to HAL.
2194 * Parameters:
2195 * config_data - a pointer to a char array which holds what usually is expected from
2196 file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'.
2197 * length - total number of UTF8 characters in configuraiton data.
2198 *
2199 * IMPORTANT:
2200 * GPS HAL should expect this function can be called multiple times. And it may be
2201 * called even when GpsLocationProvider is already constructed and enabled. GPS HAL
2202 * should maintain the existing requests for various callback regardless the change
2203 * in configuration data.
2204 */
2205 void (*configuration_update) (const char* config_data, int32_t length);
2206} GnssConfigurationInterface;
2207
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05002208__END_DECLS
2209
2210#endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */
2211