blob: eb44d5cd94876385a5cffefc9317574bd3ebbb1b [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
42
destradaa9f7c3732014-04-29 10:50:22 -070043/** Maximum number of Measurements in gps_measurement_callback(). */
44#define GPS_MAX_MEASUREMENT 32
45
Mike Lockwoodb15879a2010-04-14 15:36:34 -040046/** Requested operational mode for GPS operation. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050047typedef uint32_t GpsPositionMode;
48// IMPORTANT: Note that the following values must match
49// constants in GpsLocationProvider.java.
50/** Mode for running GPS standalone (no assistance). */
51#define GPS_POSITION_MODE_STANDALONE 0
52/** AGPS MS-Based mode. */
53#define GPS_POSITION_MODE_MS_BASED 1
54/** AGPS MS-Assisted mode. */
55#define GPS_POSITION_MODE_MS_ASSISTED 2
56
Mike Lockwoodb15879a2010-04-14 15:36:34 -040057/** Requested recurrence mode for GPS operation. */
58typedef uint32_t GpsPositionRecurrence;
59// IMPORTANT: Note that the following values must match
60// constants in GpsLocationProvider.java.
61/** Receive GPS fixes on a recurring basis at a specified period. */
62#define GPS_POSITION_RECURRENCE_PERIODIC 0
63/** Request a single shot GPS fix. */
64#define GPS_POSITION_RECURRENCE_SINGLE 1
65
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050066/** GPS status event values. */
67typedef uint16_t GpsStatusValue;
68// IMPORTANT: Note that the following values must match
69// constants in GpsLocationProvider.java.
70/** GPS status unknown. */
71#define GPS_STATUS_NONE 0
72/** GPS has begun navigating. */
73#define GPS_STATUS_SESSION_BEGIN 1
74/** GPS has stopped navigating. */
75#define GPS_STATUS_SESSION_END 2
76/** GPS has powered on but is not navigating. */
77#define GPS_STATUS_ENGINE_ON 3
78/** GPS is powered off. */
79#define GPS_STATUS_ENGINE_OFF 4
80
81/** Flags to indicate which values are valid in a GpsLocation. */
82typedef uint16_t GpsLocationFlags;
83// IMPORTANT: Note that the following values must match
84// constants in GpsLocationProvider.java.
85/** GpsLocation has valid latitude and longitude. */
86#define GPS_LOCATION_HAS_LAT_LONG 0x0001
87/** GpsLocation has valid altitude. */
88#define GPS_LOCATION_HAS_ALTITUDE 0x0002
89/** GpsLocation has valid speed. */
90#define GPS_LOCATION_HAS_SPEED 0x0004
91/** GpsLocation has valid bearing. */
92#define GPS_LOCATION_HAS_BEARING 0x0008
93/** GpsLocation has valid accuracy. */
94#define GPS_LOCATION_HAS_ACCURACY 0x0010
95
Mike Lockwoodb15879a2010-04-14 15:36:34 -040096/** Flags for the gps_set_capabilities callback. */
97
98/** GPS HAL schedules fixes for GPS_POSITION_RECURRENCE_PERIODIC mode.
99 If this is not set, then the framework will use 1000ms for min_interval
100 and will start and call start() and stop() to schedule the GPS.
101 */
102#define GPS_CAPABILITY_SCHEDULING 0x0000001
103/** GPS supports MS-Based AGPS mode */
104#define GPS_CAPABILITY_MSB 0x0000002
105/** GPS supports MS-Assisted AGPS mode */
106#define GPS_CAPABILITY_MSA 0x0000004
107/** GPS supports single-shot fixes */
108#define GPS_CAPABILITY_SINGLE_SHOT 0x0000008
Mike Lockwood8aac5912011-06-29 15:10:36 -0400109/** GPS supports on demand time injection */
110#define GPS_CAPABILITY_ON_DEMAND_TIME 0x0000010
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800111/** GPS supports Geofencing */
112#define GPS_CAPABILITY_GEOFENCING 0x0000020
destradaa69d5ea52014-07-31 16:34:09 -0700113/** GPS supports Measurements */
114#define GPS_CAPABILITY_MEASUREMENTS 0x0000040
115/** GPS supports Navigation Messages */
116#define GPS_CAPABILITY_NAV_MESSAGES 0x0000080
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400117
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500118/** Flags used to specify which aiding data to delete
119 when calling delete_aiding_data(). */
120typedef uint16_t GpsAidingData;
121// IMPORTANT: Note that the following values must match
122// constants in GpsLocationProvider.java.
123#define GPS_DELETE_EPHEMERIS 0x0001
124#define GPS_DELETE_ALMANAC 0x0002
125#define GPS_DELETE_POSITION 0x0004
126#define GPS_DELETE_TIME 0x0008
127#define GPS_DELETE_IONO 0x0010
128#define GPS_DELETE_UTC 0x0020
129#define GPS_DELETE_HEALTH 0x0040
130#define GPS_DELETE_SVDIR 0x0080
131#define GPS_DELETE_SVSTEER 0x0100
132#define GPS_DELETE_SADATA 0x0200
133#define GPS_DELETE_RTI 0x0400
134#define GPS_DELETE_CELLDB_INFO 0x8000
135#define GPS_DELETE_ALL 0xFFFF
136
137/** AGPS type */
138typedef uint16_t AGpsType;
139#define AGPS_TYPE_SUPL 1
140#define AGPS_TYPE_C2K 2
141
Miguel Torroja5f404f52010-07-27 06:34:15 +0200142typedef uint16_t AGpsSetIDType;
143#define AGPS_SETID_TYPE_NONE 0
144#define AGPS_SETID_TYPE_IMSI 1
145#define AGPS_SETID_TYPE_MSISDN 2
146
destradaaf48cc672014-06-05 11:07:09 -0700147typedef uint16_t ApnIpType;
148#define APN_IP_INVALID 0
149#define APN_IP_IPV4 1
150#define APN_IP_IPV6 2
151#define APN_IP_IPV4V6 3
152
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500153/**
154 * String length constants
155 */
156#define GPS_NI_SHORT_STRING_MAXLEN 256
157#define GPS_NI_LONG_STRING_MAXLEN 2048
158
159/**
160 * GpsNiType constants
161 */
162typedef uint32_t GpsNiType;
163#define GPS_NI_TYPE_VOICE 1
164#define GPS_NI_TYPE_UMTS_SUPL 2
165#define GPS_NI_TYPE_UMTS_CTRL_PLANE 3
166
167/**
168 * GpsNiNotifyFlags constants
169 */
170typedef uint32_t GpsNiNotifyFlags;
171/** NI requires notification */
172#define GPS_NI_NEED_NOTIFY 0x0001
173/** NI requires verification */
174#define GPS_NI_NEED_VERIFY 0x0002
175/** NI requires privacy override, no notification/minimal trace */
176#define GPS_NI_PRIVACY_OVERRIDE 0x0004
177
178/**
179 * GPS NI responses, used to define the response in
180 * NI structures
181 */
182typedef int GpsUserResponseType;
183#define GPS_NI_RESPONSE_ACCEPT 1
184#define GPS_NI_RESPONSE_DENY 2
185#define GPS_NI_RESPONSE_NORESP 3
186
187/**
188 * NI data encoding scheme
189 */
190typedef int GpsNiEncodingType;
191#define GPS_ENC_NONE 0
192#define GPS_ENC_SUPL_GSM_DEFAULT 1
193#define GPS_ENC_SUPL_UTF8 2
194#define GPS_ENC_SUPL_UCS2 3
195#define GPS_ENC_UNKNOWN -1
196
197/** AGPS status event values. */
198typedef uint16_t AGpsStatusValue;
199/** GPS requests data connection for AGPS. */
200#define GPS_REQUEST_AGPS_DATA_CONN 1
201/** GPS releases the AGPS data connection. */
202#define GPS_RELEASE_AGPS_DATA_CONN 2
203/** AGPS data connection initiated */
204#define GPS_AGPS_DATA_CONNECTED 3
205/** AGPS data connection completed */
206#define GPS_AGPS_DATA_CONN_DONE 4
207/** AGPS data connection failed */
208#define GPS_AGPS_DATA_CONN_FAILED 5
209
Miguel Torroja5f404f52010-07-27 06:34:15 +0200210#define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1
211#define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2
212#define AGPS_REG_LOCATION_TYPE_MAC 3
213
Mike Lockwood455e83b2010-10-11 06:16:57 -0400214/** Network types for update_network_state "type" parameter */
215#define AGPS_RIL_NETWORK_TYPE_MOBILE 0
216#define AGPS_RIL_NETWORK_TYPE_WIFI 1
217#define AGPS_RIL_NETWORK_TYPE_MOBILE_MMS 2
218#define AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL 3
219#define AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN 4
220#define AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI 5
221#define AGPS_RIL_NETWORK_TTYPE_WIMAX 6
222
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500223/**
destradaa9f7c3732014-04-29 10:50:22 -0700224 * Flags to indicate what fields in GpsClock are valid.
225 */
226typedef uint16_t GpsClockFlags;
227/** A valid 'leap second' is stored in the data structure. */
228#define GPS_CLOCK_HAS_LEAP_SECOND (1<<0)
229/** A valid 'time uncertainty' is stored in the data structure. */
230#define GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1)
destradaa75843eb2014-07-17 14:04:50 -0700231/** A valid 'full bias' is stored in the data structure. */
232#define GPS_CLOCK_HAS_FULL_BIAS (1<<2)
destradaa9f7c3732014-04-29 10:50:22 -0700233/** A valid 'bias' is stored in the data structure. */
destradaa75843eb2014-07-17 14:04:50 -0700234#define GPS_CLOCK_HAS_BIAS (1<<3)
destradaa9f7c3732014-04-29 10:50:22 -0700235/** A valid 'bias uncertainty' is stored in the data structure. */
destradaa75843eb2014-07-17 14:04:50 -0700236#define GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4)
destradaa9f7c3732014-04-29 10:50:22 -0700237/** A valid 'drift' is stored in the data structure. */
destradaa75843eb2014-07-17 14:04:50 -0700238#define GPS_CLOCK_HAS_DRIFT (1<<5)
destradaa9f7c3732014-04-29 10:50:22 -0700239/** A valid 'drift uncertainty' is stored in the data structure. */
destradaa75843eb2014-07-17 14:04:50 -0700240#define GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6)
241
242/**
243 * Enumeration of the available values for the GPS Clock type.
244 */
245typedef uint8_t GpsClockType;
246/** The type is not available ot it is unknown. */
247#define GPS_CLOCK_TYPE_UNKNOWN 0
248/** The source of the time value reported by GPS clock is the local hardware clock. */
249#define GPS_CLOCK_TYPE_LOCAL_HW_TIME 1
250/**
251 * The source of the time value reported by GPS clock is the GPS time derived from satellites
252 * (epoch = Jan 6, 1980)
253 */
254#define GPS_CLOCK_TYPE_GPS_TIME 2
destradaa9f7c3732014-04-29 10:50:22 -0700255
256/**
257 * Flags to indicate what fields in GpsMeasurement are valid.
258 */
259typedef uint32_t GpsMeasurementFlags;
260/** A valid 'snr' is stored in the data structure. */
261#define GPS_MEASUREMENT_HAS_SNR (1<<0)
262/** A valid 'elevation' is stored in the data structure. */
263#define GPS_MEASUREMENT_HAS_ELEVATION (1<<1)
264/** A valid 'elevation uncertainty' is stored in the data structure. */
265#define GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2)
266/** A valid 'azimuth' is stored in the data structure. */
267#define GPS_MEASUREMENT_HAS_AZIMUTH (1<<3)
268/** A valid 'azimuth uncertainty' is stored in the data structure. */
269#define GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4)
270/** A valid 'pseudorange' is stored in the data structure. */
271#define GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5)
272/** A valid 'pseudorange uncertainty' is stored in the data structure. */
273#define GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6)
274/** A valid 'code phase' is stored in the data structure. */
275#define GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7)
276/** A valid 'code phase uncertainty' is stored in the data structure. */
277#define GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8)
278/** A valid 'carrier frequency' is stored in the data structure. */
279#define GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9)
280/** A valid 'carrier cycles' is stored in the data structure. */
281#define GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10)
282/** A valid 'carrier phase' is stored in the data structure. */
283#define GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11)
284/** A valid 'carrier phase uncertainty' is stored in the data structure. */
285#define GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12)
286/** A valid 'bit number' is stored in the data structure. */
287#define GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13)
288/** A valid 'time from last bit' is stored in the data structure. */
289#define GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14)
290/** A valid 'doppler shift' is stored in the data structure. */
291#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15)
292/** A valid 'doppler shift uncertainty' is stored in the data structure. */
293#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16)
294/** A valid 'used in fix' flag is stored in the data structure. */
295#define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17)
296
297/**
destradaa75843eb2014-07-17 14:04:50 -0700298 * Enumeration of the available values for the GPS Measurement's loss of lock.
destradaa9f7c3732014-04-29 10:50:22 -0700299 */
300typedef uint8_t GpsLossOfLock;
301/** The indicator is not available or it is unknown. */
302#define GPS_LOSS_OF_LOCK_UNKNOWN 0
303/** The measurement does not present any indication of loss of lock. */
304#define GPS_LOSS_OF_LOCK_OK 1
305/** Loss of lock between previous and current observation: cycle slip possible. */
306#define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2
307
308/**
destradaa75843eb2014-07-17 14:04:50 -0700309 * Enumeration of available values for the GPS Measurement's multipath indicator.
destradaa9f7c3732014-04-29 10:50:22 -0700310 */
311typedef uint8_t GpsMultipathIndicator;
312/** The indicator is not available or unknown. */
313#define GPS_MULTIPATH_INDICATOR_UNKNOWN 0
314/** The measurement has been indicated to use multipath. */
315#define GPS_MULTIPATH_INDICATOR_DETECTED 1
316/** The measurement has been indicated Not to use multipath. */
317#define GPS_MULTIPATH_INDICATOR_NOT_USED 2
318
319/**
destradaa75843eb2014-07-17 14:04:50 -0700320 * Flags indicating the GPS measurement state.
321 */
322typedef uint16_t GpsMeasurementState;
323#define GPS_MEASUREMENT_STATE_UNKNOWN 0
324#define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0)
325#define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1)
326#define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2)
327#define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3)
328
329/**
330 * Flags indicating the Accumulated Delta Range's states.
331 */
332typedef uint16_t GpsAccumulatedDeltaRangeState;
333#define GPS_ADR_STATE_UNKNOWN 0
334#define GPS_ADR_STATE_VALID (1<<0)
335#define GPS_ADR_STATE_RESET (1<<1)
336#define GPS_ADR_STATE_CYCLE_SLIP (1<<2)
337
338/**
339 * Enumeration of available values to indicate the available GPS Natigation message types.
destradaa9f7c3732014-04-29 10:50:22 -0700340 */
341typedef uint8_t GpsNavigationMessageType;
342/** The message type is unknown. */
343#define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0
344/** L1 C/A message contained in the structure. */
345#define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1
346/** L2-CNAV message contained in the structure. */
347#define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2
348/** L5-CNAV message contained in the structure. */
349#define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3
350/** CNAV-2 message contained in the structure. */
351#define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4
352
353
354/**
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500355 * Name for the GPS XTRA interface.
356 */
357#define GPS_XTRA_INTERFACE "gps-xtra"
358
359/**
360 * Name for the GPS DEBUG interface.
361 */
362#define GPS_DEBUG_INTERFACE "gps-debug"
363
364/**
365 * Name for the AGPS interface.
366 */
367#define AGPS_INTERFACE "agps"
368
369/**
destradaaa1f4c0a2013-09-13 15:45:03 -0700370 * Name of the Supl Certificate interface.
371 */
372#define SUPL_CERTIFICATE_INTERFACE "supl-certificate"
373
374/**
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500375 * Name for NI interface
376 */
377#define GPS_NI_INTERFACE "gps-ni"
378
Miguel Torroja5f404f52010-07-27 06:34:15 +0200379/**
380 * Name for the AGPS-RIL interface.
381 */
382#define AGPS_RIL_INTERFACE "agps_ril"
383
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800384/**
385 * Name for the GPS_Geofencing interface.
386 */
387#define GPS_GEOFENCING_INTERFACE "gps_geofencing"
388
destradaa9f7c3732014-04-29 10:50:22 -0700389/**
390 * Name of the GPS Measurements interface.
391 */
392#define GPS_MEASUREMENT_INTERFACE "gps_measurement"
393
394/**
395 * Name of the GPS navigation message interface.
396 */
397 #define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message"
398
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800399
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500400/** Represents a location. */
401typedef struct {
402 /** set to sizeof(GpsLocation) */
403 size_t size;
404 /** Contains GpsLocationFlags bits. */
405 uint16_t flags;
406 /** Represents latitude in degrees. */
407 double latitude;
408 /** Represents longitude in degrees. */
409 double longitude;
410 /** Represents altitude in meters above the WGS 84 reference
411 * ellipsoid. */
412 double altitude;
413 /** Represents speed in meters per second. */
414 float speed;
415 /** Represents heading in degrees. */
416 float bearing;
417 /** Represents expected accuracy in meters. */
418 float accuracy;
419 /** Timestamp for the location fix. */
420 GpsUtcTime timestamp;
421} GpsLocation;
422
423/** Represents the status. */
424typedef struct {
425 /** set to sizeof(GpsStatus) */
426 size_t size;
427 GpsStatusValue status;
428} GpsStatus;
429
430/** Represents SV information. */
431typedef struct {
432 /** set to sizeof(GpsSvInfo) */
433 size_t size;
434 /** Pseudo-random number for the SV. */
435 int prn;
436 /** Signal to noise ratio. */
437 float snr;
438 /** Elevation of SV in degrees. */
439 float elevation;
440 /** Azimuth of SV in degrees. */
441 float azimuth;
442} GpsSvInfo;
443
444/** Represents SV status. */
445typedef struct {
446 /** set to sizeof(GpsSvStatus) */
447 size_t size;
448
449 /** Number of SVs currently visible. */
450 int num_svs;
451
452 /** Contains an array of SV information. */
453 GpsSvInfo sv_list[GPS_MAX_SVS];
454
455 /** Represents a bit mask indicating which SVs
456 * have ephemeris data.
457 */
458 uint32_t ephemeris_mask;
459
460 /** Represents a bit mask indicating which SVs
461 * have almanac data.
462 */
463 uint32_t almanac_mask;
464
465 /**
466 * Represents a bit mask indicating which SVs
467 * were used for computing the most recent position fix.
468 */
469 uint32_t used_in_fix_mask;
470} GpsSvStatus;
471
destradaa9f7c3732014-04-29 10:50:22 -0700472
Miguel Torroja5f404f52010-07-27 06:34:15 +0200473/* 2G and 3G */
474/* In 3G lac is discarded */
475typedef struct {
476 uint16_t type;
477 uint16_t mcc;
478 uint16_t mnc;
479 uint16_t lac;
480 uint32_t cid;
481} AGpsRefLocationCellID;
482
483typedef struct {
484 uint8_t mac[6];
485} AGpsRefLocationMac;
486
487/** Represents ref locations */
488typedef struct {
489 uint16_t type;
490 union {
491 AGpsRefLocationCellID cellID;
492 AGpsRefLocationMac mac;
493 } u;
494} AGpsRefLocation;
495
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700496/** Callback with location information.
497 * Can only be called from a thread created by create_thread_cb.
498 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500499typedef void (* gps_location_callback)(GpsLocation* location);
500
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700501/** Callback with status information.
502 * Can only be called from a thread created by create_thread_cb.
503 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500504typedef void (* gps_status_callback)(GpsStatus* status);
505
destradaa9f7c3732014-04-29 10:50:22 -0700506/**
507 * Callback with SV status information.
508 * Can only be called from a thread created by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700509 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500510typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info);
511
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700512/** Callback for reporting NMEA sentences.
513 * Can only be called from a thread created by create_thread_cb.
514 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500515typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length);
516
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400517/** Callback to inform framework of the GPS engine's capabilities.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700518 * Capability parameter is a bit field of GPS_CAPABILITY_* flags.
519 */
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400520typedef void (* gps_set_capabilities)(uint32_t capabilities);
521
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400522/** Callback utility for acquiring the GPS wakelock.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700523 * This can be used to prevent the CPU from suspending while handling GPS events.
524 */
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400525typedef void (* gps_acquire_wakelock)();
526
527/** Callback utility for releasing the GPS wakelock. */
528typedef void (* gps_release_wakelock)();
529
Mike Lockwood8aac5912011-06-29 15:10:36 -0400530/** Callback for requesting NTP time */
531typedef void (* gps_request_utc_time)();
532
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700533/** Callback for creating a thread that can call into the Java framework code.
534 * This must be used to create any threads that report events up to the framework.
535 */
536typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg);
537
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500538/** GPS callback structure. */
539typedef struct {
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400540 /** set to sizeof(GpsCallbacks) */
541 size_t size;
542 gps_location_callback location_cb;
543 gps_status_callback status_cb;
544 gps_sv_status_callback sv_status_cb;
545 gps_nmea_callback nmea_cb;
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400546 gps_set_capabilities set_capabilities_cb;
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400547 gps_acquire_wakelock acquire_wakelock_cb;
548 gps_release_wakelock release_wakelock_cb;
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700549 gps_create_thread create_thread_cb;
Mike Lockwood8aac5912011-06-29 15:10:36 -0400550 gps_request_utc_time request_utc_time_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500551} GpsCallbacks;
552
553
554/** Represents the standard GPS interface. */
555typedef struct {
556 /** set to sizeof(GpsInterface) */
557 size_t size;
558 /**
559 * Opens the interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -0700560 * to the implementation of this interface.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500561 */
562 int (*init)( GpsCallbacks* callbacks );
563
564 /** Starts navigating. */
565 int (*start)( void );
566
567 /** Stops navigating. */
568 int (*stop)( void );
569
570 /** Closes the interface. */
571 void (*cleanup)( void );
572
573 /** Injects the current time. */
574 int (*inject_time)(GpsUtcTime time, int64_t timeReference,
575 int uncertainty);
576
577 /** Injects current location from another location provider
578 * (typically cell ID).
579 * latitude and longitude are measured in degrees
580 * expected accuracy is measured in meters
581 */
582 int (*inject_location)(double latitude, double longitude, float accuracy);
583
584 /**
585 * Specifies that the next call to start will not use the
586 * information defined in the flags. GPS_DELETE_ALL is passed for
587 * a cold start.
588 */
589 void (*delete_aiding_data)(GpsAidingData flags);
590
591 /**
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400592 * min_interval represents the time between fixes in milliseconds.
593 * preferred_accuracy represents the requested fix accuracy in meters.
594 * preferred_time represents the requested time to first fix in milliseconds.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500595 */
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400596 int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence,
597 uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time);
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500598
599 /** Get a pointer to extension information. */
600 const void* (*get_extension)(const char* name);
601} GpsInterface;
602
603/** Callback to request the client to download XTRA data.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700604 * The client should download XTRA data and inject it by calling inject_xtra_data().
605 * Can only be called from a thread created by create_thread_cb.
606 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500607typedef void (* gps_xtra_download_request)();
608
609/** Callback structure for the XTRA interface. */
610typedef struct {
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700611 gps_xtra_download_request download_request_cb;
612 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500613} GpsXtraCallbacks;
614
615/** Extended interface for XTRA support. */
616typedef struct {
617 /** set to sizeof(GpsXtraInterface) */
618 size_t size;
619 /**
620 * Opens the XTRA interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -0700621 * to the implementation of this interface.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500622 */
623 int (*init)( GpsXtraCallbacks* callbacks );
624 /** Injects XTRA data into the GPS. */
625 int (*inject_xtra_data)( char* data, int length );
626} GpsXtraInterface;
627
628/** Extended interface for DEBUG support. */
629typedef struct {
630 /** set to sizeof(GpsDebugInterface) */
631 size_t size;
632
633 /**
634 * This function should return any information that the native
635 * implementation wishes to include in a bugreport.
636 */
637 size_t (*get_internal_state)(char* buffer, size_t bufferSize);
638} GpsDebugInterface;
639
640/** Represents the status of AGPS. */
641typedef struct {
destradaaf48cc672014-06-05 11:07:09 -0700642 /** set to sizeof(AGpsStatus_v1) */
643 size_t size;
644
645 AGpsType type;
646 AGpsStatusValue status;
647} AGpsStatus_v1;
648
649/** Represents the status of AGPS augmented with a IPv4 address field. */
650typedef struct {
651 /** set to sizeof(AGpsStatus_v2) */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500652 size_t size;
653
654 AGpsType type;
655 AGpsStatusValue status;
Stephen Li9e48a972011-03-03 15:40:47 -0800656 uint32_t ipaddr;
destradaaf48cc672014-06-05 11:07:09 -0700657} AGpsStatus_v2;
658
659/* Represents the status of AGPS augmented to support IPv4 and IPv6. */
660typedef struct {
661 /** set to sizeof(AGpsStatus_v3) */
662 size_t size;
663
664 AGpsType type;
665 AGpsStatusValue status;
666
667 /**
668 * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4
669 * address, or set to INADDR_NONE otherwise.
670 */
671 uint32_t ipaddr;
672
673 /**
674 * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report.
675 * Any other value of addr.ss_family will be rejected.
676 * */
677 struct sockaddr_storage addr;
678} AGpsStatus_v3;
679
680typedef AGpsStatus_v3 AGpsStatus;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500681
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700682/** Callback with AGPS status information.
683 * Can only be called from a thread created by create_thread_cb.
684 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500685typedef void (* agps_status_callback)(AGpsStatus* status);
686
687/** Callback structure for the AGPS interface. */
688typedef struct {
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700689 agps_status_callback status_cb;
690 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500691} AGpsCallbacks;
692
693
694/** Extended interface for AGPS support. */
695typedef struct {
destradaaf48cc672014-06-05 11:07:09 -0700696 /** set to sizeof(AGpsInterface_v1) */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500697 size_t size;
698
699 /**
700 * Opens the AGPS interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -0700701 * to the implementation of this interface.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500702 */
703 void (*init)( AGpsCallbacks* callbacks );
704 /**
destradaaa1f4c0a2013-09-13 15:45:03 -0700705 * Notifies that a data connection is available and sets
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500706 * the name of the APN to be used for SUPL.
707 */
708 int (*data_conn_open)( const char* apn );
709 /**
710 * Notifies that the AGPS data connection has been closed.
711 */
712 int (*data_conn_closed)();
713 /**
destradaaa1f4c0a2013-09-13 15:45:03 -0700714 * Notifies that a data connection is not available for AGPS.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500715 */
716 int (*data_conn_failed)();
717 /**
718 * Sets the hostname and port for the AGPS server.
719 */
720 int (*set_server)( AGpsType type, const char* hostname, int port );
destradaaf48cc672014-06-05 11:07:09 -0700721} AGpsInterface_v1;
722
723/**
724 * Extended interface for AGPS support, it is augmented to enable to pass
725 * extra APN data.
726 */
727typedef struct {
728 /** set to sizeof(AGpsInterface_v2) */
729 size_t size;
730
731 /**
732 * Opens the AGPS interface and provides the callback routines to the
733 * implementation of this interface.
734 */
735 void (*init)(AGpsCallbacks* callbacks);
736 /**
737 * Deprecated.
738 * If the HAL supports AGpsInterface_v2 this API will not be used, see
739 * data_conn_open_with_apn_ip_type for more information.
740 */
741 int (*data_conn_open)(const char* apn);
742 /**
743 * Notifies that the AGPS data connection has been closed.
744 */
745 int (*data_conn_closed)();
746 /**
747 * Notifies that a data connection is not available for AGPS.
748 */
749 int (*data_conn_failed)();
750 /**
751 * Sets the hostname and port for the AGPS server.
752 */
753 int (*set_server)(AGpsType type, const char* hostname, int port);
754
755 /**
756 * Notifies that a data connection is available and sets the name of the
757 * APN, and its IP type, to be used for SUPL connections.
758 */
759 int (*data_conn_open_with_apn_ip_type)(
760 const char* apn,
761 ApnIpType apnIpType);
762} AGpsInterface_v2;
763
764typedef AGpsInterface_v2 AGpsInterface;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500765
destradaaa1f4c0a2013-09-13 15:45:03 -0700766/** Error codes associated with certificate operations */
767#define AGPS_CERTIFICATE_OPERATION_SUCCESS 0
768#define AGPS_CERTIFICATE_ERROR_GENERIC -100
769#define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101
770
771/** A data structure that represents an X.509 certificate using DER encoding */
772typedef struct {
773 size_t length;
774 u_char* data;
775} DerEncodedCertificate;
776
777/**
778 * A type definition for SHA1 Fingerprints used to identify X.509 Certificates
779 * The Fingerprint is a digest of the DER Certificate that uniquely identifies it.
780 */
781typedef struct {
782 u_char data[20];
783} Sha1CertificateFingerprint;
784
destradaa9f7c3732014-04-29 10:50:22 -0700785/** AGPS Interface to handle SUPL certificate operations */
destradaaa1f4c0a2013-09-13 15:45:03 -0700786typedef struct {
787 /** set to sizeof(SuplCertificateInterface) */
788 size_t size;
789
790 /**
791 * Installs a set of Certificates used for SUPL connections to the AGPS server.
792 * If needed the HAL should find out internally any certificates that need to be removed to
793 * accommodate the certificates to install.
794 * The certificates installed represent a full set of valid certificates needed to connect to
795 * AGPS SUPL servers.
796 * The list of certificates is required, and all must be available at the same time, when trying
797 * to establish a connection with the AGPS Server.
798 *
799 * Parameters:
800 * certificates - A pointer to an array of DER encoded certificates that are need to be
801 * installed in the HAL.
802 * length - The number of certificates to install.
803 * Returns:
804 * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully
805 * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of
806 * certificates attempted to be installed, the state of the certificates stored should
807 * remain the same as before on this error case.
808 *
809 * IMPORTANT:
810 * If needed the HAL should find out internally the set of certificates that need to be
811 * removed to accommodate the certificates to install.
812 */
813 int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length );
814
815 /**
816 * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is
817 * expected that the given set of certificates is removed from the internal store of the HAL.
818 *
819 * Parameters:
820 * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of
821 * certificates to revoke.
822 * length - The number of fingerprints provided.
823 * Returns:
824 * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully.
825 *
826 * IMPORTANT:
827 * If any of the certificates provided (through its fingerprint) is not known by the HAL,
828 * it should be ignored and continue revoking/deleting the rest of them.
829 */
830 int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length );
destradaa7ddd4d72013-11-07 13:47:59 -0800831} SuplCertificateInterface;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500832
833/** Represents an NI request */
834typedef struct {
835 /** set to sizeof(GpsNiNotification) */
836 size_t size;
837
838 /**
839 * An ID generated by HAL to associate NI notifications and UI
840 * responses
841 */
842 int notification_id;
843
844 /**
845 * An NI type used to distinguish different categories of NI
846 * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ...
847 */
848 GpsNiType ni_type;
849
850 /**
851 * Notification/verification options, combinations of GpsNiNotifyFlags constants
852 */
853 GpsNiNotifyFlags notify_flags;
854
855 /**
856 * Timeout period to wait for user response.
857 * Set to 0 for no time out limit.
858 */
859 int timeout;
860
861 /**
862 * Default response when time out.
863 */
864 GpsUserResponseType default_response;
865
866 /**
867 * Requestor ID
868 */
869 char requestor_id[GPS_NI_SHORT_STRING_MAXLEN];
870
871 /**
872 * Notification message. It can also be used to store client_id in some cases
873 */
874 char text[GPS_NI_LONG_STRING_MAXLEN];
875
876 /**
877 * Client name decoding scheme
878 */
879 GpsNiEncodingType requestor_id_encoding;
880
881 /**
882 * Client name decoding scheme
883 */
884 GpsNiEncodingType text_encoding;
885
886 /**
887 * A pointer to extra data. Format:
888 * key_1 = value_1
889 * key_2 = value_2
890 */
891 char extras[GPS_NI_LONG_STRING_MAXLEN];
892
893} GpsNiNotification;
894
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700895/** Callback with NI notification.
896 * Can only be called from a thread created by create_thread_cb.
897 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500898typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification);
899
900/** GPS NI callback structure. */
901typedef struct
902{
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700903 /**
904 * Sends the notification request from HAL to GPSLocationProvider.
905 */
906 gps_ni_notify_callback notify_cb;
907 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500908} GpsNiCallbacks;
909
910/**
911 * Extended interface for Network-initiated (NI) support.
912 */
913typedef struct
914{
915 /** set to sizeof(GpsNiInterface) */
916 size_t size;
917
918 /** Registers the callbacks for HAL to use. */
919 void (*init) (GpsNiCallbacks *callbacks);
920
921 /** Sends a response to HAL. */
922 void (*respond) (int notif_id, GpsUserResponseType user_response);
923} GpsNiInterface;
924
925struct gps_device_t {
926 struct hw_device_t common;
927
928 /**
929 * Set the provided lights to the provided values.
930 *
931 * Returns: 0 on succes, error code on failure.
932 */
933 const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev);
934};
935
Miguel Torroja5f404f52010-07-27 06:34:15 +0200936#define AGPS_RIL_REQUEST_SETID_IMSI (1<<0L)
937#define AGPS_RIL_REQUEST_SETID_MSISDN (1<<1L)
938
939#define AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L)
940#define AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L)
941
942typedef void (*agps_ril_request_set_id)(uint32_t flags);
943typedef void (*agps_ril_request_ref_loc)(uint32_t flags);
944
945typedef struct {
946 agps_ril_request_set_id request_setid;
947 agps_ril_request_ref_loc request_refloc;
948 gps_create_thread create_thread_cb;
949} AGpsRilCallbacks;
950
951/** Extended interface for AGPS_RIL support. */
952typedef struct {
953 /** set to sizeof(AGpsRilInterface) */
954 size_t size;
955 /**
956 * Opens the AGPS interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -0700957 * to the implementation of this interface.
Miguel Torroja5f404f52010-07-27 06:34:15 +0200958 */
959 void (*init)( AGpsRilCallbacks* callbacks );
960
961 /**
962 * Sets the reference location.
963 */
964 void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct);
965 /**
966 * Sets the set ID.
967 */
968 void (*set_set_id) (AGpsSetIDType type, const char* setid);
969
970 /**
971 * Send network initiated message.
972 */
973 void (*ni_message) (uint8_t *msg, size_t len);
Mike Lockwood455e83b2010-10-11 06:16:57 -0400974
975 /**
976 * Notify GPS of network status changes.
977 * These parameters match values in the android.net.NetworkInfo class.
978 */
979 void (*update_network_state) (int connected, int type, int roaming, const char* extra_info);
Kevin Tangb82c2db2011-04-13 17:15:55 -0700980
981 /**
982 * Notify GPS of network status changes.
983 * These parameters match values in the android.net.NetworkInfo class.
984 */
985 void (*update_network_availability) (int avaiable, const char* apn);
Miguel Torroja5f404f52010-07-27 06:34:15 +0200986} AGpsRilInterface;
987
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800988/**
989 * GPS Geofence.
990 * There are 3 states associated with a Geofence: Inside, Outside, Unknown.
991 * There are 3 transitions: ENTERED, EXITED, UNCERTAIN.
992 *
993 * An example state diagram with confidence level: 95% and Unknown time limit
994 * set as 30 secs is shown below. (confidence level and Unknown time limit are
995 * explained latter)
996 * ____________________________
997 * | Unknown (30 secs) |
998 * """"""""""""""""""""""""""""
999 * ^ | | ^
1000 * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN
1001 * | v v |
1002 * ________ EXITED _________
1003 * | Inside | -----------> | Outside |
1004 * | | <----------- | |
1005 * """""""" ENTERED """""""""
1006 *
1007 * Inside state: We are 95% confident that the user is inside the geofence.
1008 * Outside state: We are 95% confident that the user is outside the geofence
1009 * Unknown state: Rest of the time.
1010 *
1011 * The Unknown state is better explained with an example:
1012 *
1013 * __________
1014 * | c|
1015 * | ___ | _______
1016 * | |a| | | b |
1017 * | """ | """""""
1018 * | |
1019 * """"""""""
1020 * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy
1021 * circle reported by the GPS subsystem. Now with regard to "b", the system is
1022 * confident that the user is outside. But with regard to "a" is not confident
1023 * whether it is inside or outside the geofence. If the accuracy remains the
1024 * same for a sufficient period of time, the UNCERTAIN transition would be
1025 * triggered with the state set to Unknown. If the accuracy improves later, an
1026 * appropriate transition should be triggered. This "sufficient period of time"
1027 * is defined by the parameter in the add_geofence_area API.
1028 * In other words, Unknown state can be interpreted as a state in which the
1029 * GPS subsystem isn't confident enough that the user is either inside or
1030 * outside the Geofence. It moves to Unknown state only after the expiry of the
1031 * timeout.
1032 *
1033 * The geofence callback needs to be triggered for the ENTERED and EXITED
1034 * transitions, when the GPS system is confident that the user has entered
1035 * (Inside state) or exited (Outside state) the Geofence. An implementation
1036 * which uses a value of 95% as the confidence is recommended. The callback
1037 * should be triggered only for the transitions requested by the
1038 * add_geofence_area call.
1039 *
1040 * Even though the diagram and explanation talks about states and transitions,
1041 * the callee is only interested in the transistions. The states are mentioned
1042 * here for illustrative purposes.
1043 *
1044 * Startup Scenario: When the device boots up, if an application adds geofences,
1045 * and then we get an accurate GPS location fix, it needs to trigger the
1046 * appropriate (ENTERED or EXITED) transition for every Geofence it knows about.
1047 * By default, all the Geofences will be in the Unknown state.
1048 *
1049 * When the GPS system is unavailable, gps_geofence_status_callback should be
1050 * called to inform the upper layers of the same. Similarly, when it becomes
1051 * available the callback should be called. This is a global state while the
1052 * UNKNOWN transition described above is per geofence.
1053 *
1054 * An important aspect to note is that users of this API (framework), will use
1055 * other subsystems like wifi, sensors, cell to handle Unknown case and
1056 * hopefully provide a definitive state transition to the third party
1057 * application. GPS Geofence will just be a signal indicating what the GPS
1058 * subsystem knows about the Geofence.
1059 *
1060 */
1061#define GPS_GEOFENCE_ENTERED (1<<0L)
1062#define GPS_GEOFENCE_EXITED (1<<1L)
1063#define GPS_GEOFENCE_UNCERTAIN (1<<2L)
1064
1065#define GPS_GEOFENCE_UNAVAILABLE (1<<0L)
1066#define GPS_GEOFENCE_AVAILABLE (1<<1L)
1067
Jaikumar Ganesh5824b402013-02-25 11:43:33 -08001068#define GPS_GEOFENCE_OPERATION_SUCCESS 0
1069#define GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES -100
1070#define GPS_GEOFENCE_ERROR_ID_EXISTS -101
1071#define GPS_GEOFENCE_ERROR_ID_UNKNOWN -102
1072#define GPS_GEOFENCE_ERROR_INVALID_TRANSITION -103
1073#define GPS_GEOFENCE_ERROR_GENERIC -149
1074
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001075/**
1076 * The callback associated with the geofence.
1077 * Parameters:
1078 * geofence_id - The id associated with the add_geofence_area.
1079 * location - The current GPS location.
1080 * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED,
1081 * GPS_GEOFENCE_UNCERTAIN.
1082 * timestamp - Timestamp when the transition was detected.
1083 *
1084 * The callback should only be called when the caller is interested in that
1085 * particular transition. For instance, if the caller is interested only in
1086 * ENTERED transition, then the callback should NOT be called with the EXITED
1087 * transition.
1088 *
1089 * IMPORTANT: If a transition is triggered resulting in this callback, the GPS
1090 * subsystem will wake up the application processor, if its in suspend state.
1091 */
1092typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location,
1093 int32_t transition, GpsUtcTime timestamp);
1094
1095/**
destradaa9f7c3732014-04-29 10:50:22 -07001096 * The callback associated with the availability of the GPS system for geofencing
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001097 * monitoring. If the GPS system determines that it cannot monitor geofences
1098 * because of lack of reliability or unavailability of the GPS signals, it will
1099 * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter.
1100 *
1101 * Parameters:
1102 * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE.
1103 * last_location - Last known location.
1104 */
1105typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location);
1106
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001107/**
1108 * The callback associated with the add_geofence call.
1109 *
1110 * Parameter:
1111 * geofence_id - Id of the geofence.
1112 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1113 * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached.
1114 * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists
1115 * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an
1116 * invalid transition
1117 * GPS_GEOFENCE_ERROR_GENERIC - for other errors.
1118 */
1119typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status);
1120
1121/**
1122 * The callback associated with the remove_geofence call.
1123 *
1124 * Parameter:
1125 * geofence_id - Id of the geofence.
1126 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1127 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1128 * GPS_GEOFENCE_ERROR_GENERIC for others.
1129 */
1130typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status);
1131
1132
1133/**
1134 * The callback associated with the pause_geofence call.
1135 *
1136 * Parameter:
1137 * geofence_id - Id of the geofence.
1138 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1139 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1140 * GPS_GEOFENCE_ERROR_INVALID_TRANSITION -
1141 * when monitor_transitions is invalid
1142 * GPS_GEOFENCE_ERROR_GENERIC for others.
1143 */
1144typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status);
1145
1146/**
1147 * The callback associated with the resume_geofence call.
1148 *
1149 * Parameter:
1150 * geofence_id - Id of the geofence.
1151 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1152 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1153 * GPS_GEOFENCE_ERROR_GENERIC for others.
1154 */
1155typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status);
1156
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001157typedef struct {
1158 gps_geofence_transition_callback geofence_transition_callback;
1159 gps_geofence_status_callback geofence_status_callback;
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001160 gps_geofence_add_callback geofence_add_callback;
1161 gps_geofence_remove_callback geofence_remove_callback;
1162 gps_geofence_pause_callback geofence_pause_callback;
1163 gps_geofence_resume_callback geofence_resume_callback;
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001164 gps_create_thread create_thread_cb;
1165} GpsGeofenceCallbacks;
1166
1167/** Extended interface for GPS_Geofencing support */
1168typedef struct {
1169 /** set to sizeof(GpsGeofencingInterface) */
1170 size_t size;
1171
1172 /**
1173 * Opens the geofence interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -07001174 * to the implementation of this interface.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001175 */
1176 void (*init)( GpsGeofenceCallbacks* callbacks );
1177
1178 /**
1179 * Add a geofence area. This api currently supports circular geofences.
1180 * Parameters:
1181 * geofence_id - The id for the geofence. If a geofence with this id
Jaikumar Ganesh5824b402013-02-25 11:43:33 -08001182 * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS)
1183 * should be returned.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001184 * latitude, longtitude, radius_meters - The lat, long and radius
1185 * (in meters) for the geofence
1186 * last_transition - The current state of the geofence. For example, if
1187 * the system already knows that the user is inside the geofence,
1188 * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it
1189 * will be GPS_GEOFENCE_UNCERTAIN.
1190 * monitor_transition - Which transitions to monitor. Bitwise OR of
1191 * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
1192 * GPS_GEOFENCE_UNCERTAIN.
1193 * notification_responsiveness_ms - Defines the best-effort description
1194 * of how soon should the callback be called when the transition
1195 * associated with the Geofence is triggered. For instance, if set
1196 * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback
1197 * should be called 1000 milliseconds within entering the geofence.
1198 * This parameter is defined in milliseconds.
1199 * NOTE: This is not to be confused with the rate that the GPS is
1200 * polled at. It is acceptable to dynamically vary the rate of
1201 * sampling the GPS for power-saving reasons; thus the rate of
1202 * sampling may be faster or slower than this.
1203 * unknown_timer_ms - The time limit after which the UNCERTAIN transition
destradaa9f7c3732014-04-29 10:50:22 -07001204 * should be triggered. This parameter is defined in milliseconds.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001205 * See above for a detailed explanation.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001206 */
destradaa9f7c3732014-04-29 10:50:22 -07001207 void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude,
1208 double radius_meters, int last_transition, int monitor_transitions,
1209 int notification_responsiveness_ms, int unknown_timer_ms);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001210
1211 /**
1212 * Pause monitoring a particular geofence.
1213 * Parameters:
1214 * geofence_id - The id for the geofence.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001215 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001216 void (*pause_geofence) (int32_t geofence_id);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001217
1218 /**
1219 * Resume monitoring a particular geofence.
1220 * Parameters:
1221 * geofence_id - The id for the geofence.
1222 * monitor_transitions - Which transitions to monitor. Bitwise OR of
1223 * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
1224 * GPS_GEOFENCE_UNCERTAIN.
1225 * This supersedes the value associated provided in the
1226 * add_geofence_area call.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001227 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001228 void (*resume_geofence) (int32_t geofence_id, int monitor_transitions);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001229
1230 /**
1231 * Remove a geofence area. After the function returns, no notifications
1232 * should be sent.
1233 * Parameter:
1234 * geofence_id - The id for the geofence.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001235 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001236 void (*remove_geofence_area) (int32_t geofence_id);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001237} GpsGeofencingInterface;
destradaa9f7c3732014-04-29 10:50:22 -07001238
1239
1240/**
1241 * Represents an estimate of the GPS clock time.
1242 */
1243typedef struct {
1244 /** set to sizeof(GpsClock) */
1245 size_t size;
1246
1247 /** A set of flags indicating the validity of the fields in this data structure. */
1248 GpsClockFlags flags;
1249
1250 /**
1251 * Leap second data.
destradaa75843eb2014-07-17 14:04:50 -07001252 * The sign of the value is defined by the following equation:
1253 * utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second * 1,000,000,000
1254 *
destradaa9f7c3732014-04-29 10:50:22 -07001255 * If the data is available 'flags' must contain GPS_CLOCK_HAS_LEAP_SECOND.
1256 */
1257 int16_t leap_second;
1258
1259 /**
destradaa75843eb2014-07-17 14:04:50 -07001260 * Indicates the type of time reported by the 'time_ns' field.
1261 * This is a Mandatory field.
1262 */
1263 GpsClockType type;
1264
1265 /**
1266 * The GPS receiver internal clock value. This can be either the local hardware clock value
1267 * (GPS_CLOCK_TYPE_LOCAL_HW_TIME), or the current GPS time derived inside GPS receiver
1268 * (GPS_CLOCK_TYPE_GPS_TIME). The field 'type' defines the time reported.
destradaa9f7c3732014-04-29 10:50:22 -07001269 *
destradaa75843eb2014-07-17 14:04:50 -07001270 * For local hardware clock, this value is expected to be monotonically increasing during
1271 * the reporting session. The real GPS time can be derived by compensating the 'full bias'
1272 * (when it is available) from this value.
destradaa9f7c3732014-04-29 10:50:22 -07001273 *
destradaa75843eb2014-07-17 14:04:50 -07001274 * For GPS time, this value is expected to be the best estimation of current GPS time that GPS
1275 * receiver can achieve. Set the 'time uncertainty' appropriately when GPS time is specified.
1276 *
1277 * Sub-nanosecond accuracy can be provided by means of the 'bias' field.
destradaa9f7c3732014-04-29 10:50:22 -07001278 * The value contains the 'time uncertainty' in it.
destradaa75843eb2014-07-17 14:04:50 -07001279 *
destradaa9f7c3732014-04-29 10:50:22 -07001280 * This is a Mandatory field.
1281 */
1282 int64_t time_ns;
1283
1284 /**
1285 * 1-Sigma uncertainty associated with the clock's time in nanoseconds.
1286 * The uncertainty is represented as an absolute (single sided) value.
1287 *
destradaa75843eb2014-07-17 14:04:50 -07001288 * This value should be set if GPS_CLOCK_TYPE_GPS_TIME is set.
destradaa9f7c3732014-04-29 10:50:22 -07001289 * If the data is available 'flags' must contain GPS_CLOCK_HAS_TIME_UNCERTAINTY.
1290 */
1291 double time_uncertainty_ns;
1292
1293 /**
destradaa75843eb2014-07-17 14:04:50 -07001294 * The difference between hardware clock ('time' field) inside GPS receiver and the true GPS
1295 * time since 0000Z, January 6, 1980, in nanoseconds.
1296 * This value is used if and only if GPS_CLOCK_TYPE_LOCAL_HW_TIME is set, and GPS receiver
1297 * has solved the clock for GPS time.
1298 * The caller is responsible for using the 'bias uncertainty' field for quality check.
destradaa9f7c3732014-04-29 10:50:22 -07001299 *
destradaa75843eb2014-07-17 14:04:50 -07001300 * The sign of the value is defined by the following equation:
1301 * true time (GPS time) = time_ns + (full_bias_ns + bias_ns)
1302 *
1303 * This value contains the 'bias uncertainty' in it.
1304 * If the data is available 'flags' must contain GPS_CLOCK_HAS_FULL_BIAS.
1305
1306 */
1307 int64_t full_bias_ns;
1308
1309 /**
1310 * Sub-nanosecond bias.
destradaa9f7c3732014-04-29 10:50:22 -07001311 * The value contains the 'bias uncertainty' in it.
destradaa75843eb2014-07-17 14:04:50 -07001312 *
destradaa9f7c3732014-04-29 10:50:22 -07001313 * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS.
1314 */
1315 double bias_ns;
1316
1317 /**
1318 * 1-Sigma uncertainty associated with the clock's bias in nanoseconds.
1319 * The uncertainty is represented as an absolute (single sided) value.
1320 *
1321 * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS_UNCERTAINTY.
1322 */
1323 double bias_uncertainty_ns;
1324
1325 /**
1326 * The clock's drift in nanoseconds (per second).
1327 * A positive value means that the frequency is higher than the nominal frequency.
1328 *
1329 * The value contains the 'drift uncertainty' in it.
1330 * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT.
1331 */
1332 double drift_nsps;
1333
1334 /**
1335 * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second).
1336 * The uncertainty is represented as an absolute (single sided) value.
1337 *
1338 * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT_UNCERTAINTY.
1339 */
1340 double drift_uncertainty_nsps;
1341} GpsClock;
1342
1343/**
1344 * Represents a GPS Measurement, it contains raw and computed information.
1345 */
1346typedef struct {
1347 /** set to sizeof(GpsMeasurement) */
1348 size_t size;
1349
1350 /** A set of flags indicating the validity of the fields in this data structure. */
1351 GpsMeasurementFlags flags;
1352
1353 /**
1354 * Pseudo-random number in the range of [1, 32]
1355 * This is a Mandatory value.
1356 */
1357 int8_t prn;
1358
1359 /**
destradaa75843eb2014-07-17 14:04:50 -07001360 * Time offset at which the measurement was taken in nanoseconds.
1361 * The reference receiver's time is specified by GpsData::clock::time_ns and should be
1362 * interpreted in the same way as indicated by GpsClock::type.
1363 *
destradaa9f7c3732014-04-29 10:50:22 -07001364 * The sign of time_offset_ns is given by the following equation:
1365 * measurement time = GpsClock::time_ns + time_offset_ns
1366 *
1367 * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy.
1368 * This is a Mandatory value.
1369 */
destradaa75843eb2014-07-17 14:04:50 -07001370 double time_offset_ns;
destradaa9f7c3732014-04-29 10:50:22 -07001371
1372 /**
destradaa75843eb2014-07-17 14:04:50 -07001373 * Per satellite sync state. It represents the current sync state for the associated satellite.
1374 * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly.
destradaa9f7c3732014-04-29 10:50:22 -07001375 *
1376 * This is a Mandatory value.
1377 */
destradaa75843eb2014-07-17 14:04:50 -07001378 GpsMeasurementState state;
1379
1380 /**
1381 * Received GPS Time-of-Week at the measurement time, in nanoseconds.
1382 * The value is relative to the beginning of the current GPS week.
1383 *
1384 * Given the sync state of GPS receiver, per each satellite, valid range for this field can be:
1385 * Searching : [ 0 ] : GPS_MEASUREMENT_STATE_UNKNOWN
1386 * Ranging code lock : [ 0 1ms ] : GPS_MEASUREMENT_STATE_CODE_LOCK is set
1387 * Bit sync : [ 0 20ms ] : GPS_MEASUREMENT_STATE_BIT_SYNC is set
1388 * Subframe sync : [ 0 6ms ] : GPS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
1389 * TOW decoded : [ 0 1week ] : GPS_MEASUREMENT_STATE_TOW_DECODED is set
1390 */
destradaa9f7c3732014-04-29 10:50:22 -07001391 int64_t received_gps_tow_ns;
1392
1393 /**
destradaa941c9282014-07-21 18:13:42 -07001394 * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds.
1395 */
1396 int64_t received_gps_tow_uncertainty_ns;
1397
1398 /**
destradaa9f7c3732014-04-29 10:50:22 -07001399 * Carrier-to-noise density in dB-Hz, in the range [0, 63].
1400 * It contains the measured C/N0 value for the signal at the antenna input.
1401 *
1402 * This is a Mandatory value.
1403 */
1404 double c_n0_dbhz;
1405
1406 /**
1407 * Pseudorange rate at the timestamp in m/s.
1408 * The value also includes the effects of the receiver clock frequency and satellite clock
1409 * frequency errors.
1410 *
1411 * The value includes the 'pseudorange rate uncertainty' in it.
1412 * A positive value indicates that the pseudorange is getting larger.
1413 *
1414 * This is a Mandatory value.
1415 */
destradaa75843eb2014-07-17 14:04:50 -07001416 double pseudorange_rate_mps;
destradaa9f7c3732014-04-29 10:50:22 -07001417
1418 /**
1419 * 1-Sigma uncertainty of the pseudurange rate in m/s.
1420 * The uncertainty is represented as an absolute (single sided) value.
1421 *
1422 * This is a Mandatory value.
1423 */
destradaa75843eb2014-07-17 14:04:50 -07001424 double pseudorange_rate_uncertainty_mps;
1425
1426 /**
1427 * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip
1428 * (indicating loss of lock).
1429 *
1430 * This is a Mandatory value.
1431 */
1432 GpsAccumulatedDeltaRangeState accumulated_delta_range_state;
destradaa9f7c3732014-04-29 10:50:22 -07001433
1434 /**
1435 * Accumulated delta range since the last channel reset in meters.
destradaa75843eb2014-07-17 14:04:50 -07001436 * The data is available if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
destradaa9f7c3732014-04-29 10:50:22 -07001437 */
1438 double accumulated_delta_range_m;
1439
1440 /**
1441 * 1-Sigma uncertainty of the accumulated delta range in meters.
destradaa75843eb2014-07-17 14:04:50 -07001442 * The data is available if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
destradaa9f7c3732014-04-29 10:50:22 -07001443 */
1444 double accumulated_delta_range_uncertainty_m;
1445
1446 /**
1447 * Best derived Pseudorange by the chip-set, in meters.
1448 * The value contains the 'pseudorange uncertainty' in it.
1449 *
1450 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE.
1451 */
1452 double pseudorange_m;
1453
1454 /**
1455 * 1-Sigma uncertainty of the pseudorange in meters.
1456 * The value contains the 'pseudorange' and 'clock' uncertainty in it.
1457 * The uncertainty is represented as an absolute (single sided) value.
1458 *
1459 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY.
1460 */
1461 double pseudorange_uncertainty_m;
1462
1463 /**
1464 * A fraction of the current C/A code cycle, in the range [0.0, 1023.0]
1465 * This value contains the time (in Chip units) since the last C/A code cycle (GPS Msec epoch).
1466 *
1467 * The reference frequency is given by the field 'carrier_frequency_hz'.
1468 * The value contains the 'code-phase uncertainty' in it.
1469 *
1470 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE.
1471 */
1472 double code_phase_chips;
1473
1474 /**
1475 * 1-Sigma uncertainty of the code-phase, in a fraction of chips.
1476 * The uncertainty is represented as an absolute (single sided) value.
1477 *
1478 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY.
1479 */
1480 double code_phase_uncertainty_chips;
1481
1482 /**
1483 * Carrier frequency at which codes and messages are modulated, it can be L1 or L2.
1484 * If the field is not set, the carrier frequency is assumed to be L1.
1485 *
1486 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY.
1487 */
1488 float carrier_frequency_hz;
1489
1490 /**
1491 * The number of full carrier cycles between the satellite and the receiver.
1492 * The reference frequency is given by the field 'carrier_frequency_hz'.
1493 *
1494 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_CYCLES.
1495 */
1496 int64_t carrier_cycles;
1497
1498 /**
1499 * The RF phase detected by the receiver, in the range [0.0, 1.0].
1500 * This is usually the fractional part of the complete carrier phase measurement.
1501 *
1502 * The reference frequency is given by the field 'carrier_frequency_hz'.
1503 * The value contains the 'carrier-phase uncertainty' in it.
1504 *
1505 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE.
1506 */
1507 double carrier_phase;
1508
1509 /**
1510 * 1-Sigma uncertainty of the carrier-phase.
1511 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY.
1512 */
1513 double carrier_phase_uncertainty;
1514
1515 /**
1516 * An enumeration that indicates the 'loss of lock' state of the event.
1517 */
1518 GpsLossOfLock loss_of_lock;
1519
1520 /**
1521 * The number of GPS bits transmitted since Sat-Sun midnight (GPS week).
1522 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_BIT_NUMBER.
1523 */
1524 int16_t bit_number;
1525
1526 /**
destradaa75843eb2014-07-17 14:04:50 -07001527 * The elapsed time since the last received bit in milliseconds, in the range [0, 20]
destradaa9f7c3732014-04-29 10:50:22 -07001528 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT.
1529 */
destradaa75843eb2014-07-17 14:04:50 -07001530 int16_t time_from_last_bit_ms;
destradaa9f7c3732014-04-29 10:50:22 -07001531
1532 /**
1533 * Doppler shift in Hz.
1534 * A positive value indicates that the SV is moving toward the receiver.
1535 *
1536 * The reference frequency is given by the field 'carrier_frequency_hz'.
1537 * The value contains the 'doppler shift uncertainty' in it.
1538 *
1539 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT.
1540 */
1541 double doppler_shift_hz;
1542
1543 /**
1544 * 1-Sigma uncertainty of the doppler shift in Hz.
1545 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY.
1546 */
1547 double doppler_shift_uncertainty_hz;
1548
1549 /**
1550 * An enumeration that indicates the 'multipath' state of the event.
1551 */
1552 GpsMultipathIndicator multipath_indicator;
1553
1554 /**
1555 * Signal-to-noise ratio in dB.
1556 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_SNR.
1557 */
1558 double snr_db;
1559
1560 /**
1561 * Elevation in degrees, the valid range is [-90, 90].
1562 * The value contains the 'elevation uncertainty' in it.
1563 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION.
1564 */
1565 double elevation_deg;
1566
1567 /**
1568 * 1-Sigma uncertainty of the elevation in degrees, the valid range is [0, 90].
1569 * The uncertainty is represented as the absolute (single sided) value.
1570 *
1571 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY.
1572 */
1573 double elevation_uncertainty_deg;
1574
1575 /**
1576 * Azimuth in degrees, in the range [0, 360).
1577 * The value contains the 'azimuth uncertainty' in it.
1578 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH.
1579 * */
1580 double azimuth_deg;
1581
1582 /**
1583 * 1-Sigma uncertainty of the azimuth in degrees, the valid range is [0, 180].
1584 * The uncertainty is represented as an absolute (single sided) value.
1585 *
1586 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY.
1587 */
1588 double azimuth_uncertainty_deg;
1589
1590 /**
1591 * Whether the GPS represented by the measurement was used for computing the most recent fix.
1592 * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_USED_IN_FIX.
1593 */
1594 bool used_in_fix;
1595} GpsMeasurement;
1596
1597/** Represents a reading of GPS measurements. */
1598typedef struct {
1599 /** set to sizeof(GpsData) */
1600 size_t size;
1601
1602 /** Number of measurements. */
1603 size_t measurement_count;
1604
1605 /** The array of measurements. */
1606 GpsMeasurement measurements[GPS_MAX_MEASUREMENT];
1607
1608 /** The GPS clock time reading. */
1609 GpsClock clock;
1610} GpsData;
1611
1612/**
1613 * The callback for to report measurements from the HAL.
1614 *
1615 * Parameters:
1616 * data - A data structure containing the measurements.
1617 */
1618typedef void (*gps_measurement_callback) (GpsData* data);
1619
1620typedef struct {
1621 /** set to sizeof(GpsMeasurementCallbacks) */
1622 size_t size;
1623 gps_measurement_callback measurement_callback;
1624} GpsMeasurementCallbacks;
1625
1626#define GPS_MEASUREMENT_OPERATION_SUCCESS 0
1627#define GPS_MEASUREMENT_ERROR_ALREADY_INIT -100
1628#define GPS_MEASUREMENT_ERROR_GENERIC -101
1629
1630/**
1631 * Extended interface for GPS Measurements support.
1632 */
1633typedef struct {
1634 /** Set to sizeof(GpsMeasurementInterface) */
1635 size_t size;
1636
1637 /**
1638 * Initializes the interface and registers the callback routines with the HAL.
1639 * After a successful call to 'init' the HAL must begin to provide updates at its own phase.
1640 *
1641 * Status:
1642 * GPS_MEASUREMENT_OPERATION_SUCCESS
1643 * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a
1644 * corresponding call to 'close'
1645 * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL
1646 * will not generate any updates upon returning this error code.
1647 */
1648 int (*init) (GpsMeasurementCallbacks* callbacks);
1649
1650 /**
1651 * Stops updates from the HAL, and unregisters the callback routines.
1652 * After a call to stop, the previously registered callbacks must be considered invalid by the
1653 * HAL.
1654 * If stop is invoked without a previous 'init', this function should perform no work.
1655 */
1656 void (*close) ();
1657
1658} GpsMeasurementInterface;
1659
1660
1661/** Represents a GPS navigation message (or a fragment of it). */
1662typedef struct {
1663 /** set to sizeof(GpsNavigationMessage) */
1664 size_t size;
1665
1666 /**
1667 * Pseudo-random number in the range of [1, 32]
1668 * This is a Mandatory value.
1669 */
1670 int8_t prn;
1671
1672 /**
1673 * The type of message contained in the structure.
1674 * This is a Mandatory value.
1675 */
1676 GpsNavigationMessageType type;
1677
1678 /**
1679 * Message identifier.
destradaa75843eb2014-07-17 14:04:50 -07001680 * It provides an index so the complete Navigation Message can be assembled. i.e. fo L1 C/A
1681 * subframe 4 and 5, this value corresponds to the 'frame id' of the navigation message.
1682 * Subframe 1, 2, 3 does not contain a 'frame id' and this value can be set to -1.
destradaa9f7c3732014-04-29 10:50:22 -07001683 */
1684 int16_t message_id;
1685
1686 /**
1687 * Sub-message identifier.
1688 * If required by the message 'type', this value contains a sub-index within the current
1689 * message (or frame) that is being transmitted.
1690 * i.e. for L1 C/A the submessage id corresponds to the sub-frame id of the navigation message.
1691 */
1692 int16_t submessage_id;
1693
1694 /**
1695 * The length of the data (in bytes) contained in the current message.
1696 * If this value is different from zero, 'data' must point to an array of the same size.
destradaa69d5ea52014-07-31 16:34:09 -07001697 * 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 -07001698 *
1699 * This is a Mandatory value.
1700 */
1701 size_t data_length;
1702
1703 /**
1704 * The data of the reported GPS message.
1705 * The bytes (or words) specified using big endian format (MSB first).
destradaa69d5ea52014-07-31 16:34:09 -07001706 *
1707 * For L1 C/A, each subframe contains 10 30-bit GPS words. Each GPS word (30 bits) should be
1708 * fitted into the last 30 bits in a 4-byte word (skip B31 and B32), with MSB first.
destradaa9f7c3732014-04-29 10:50:22 -07001709 */
1710 uint8_t* data;
1711
1712} GpsNavigationMessage;
1713
1714/**
1715 * The callback to report an available fragment of a GPS navigation messages from the HAL.
1716 *
1717 * Parameters:
1718 * message - The GPS navigation submessage/subframe representation.
1719 */
1720typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message);
1721
1722typedef struct {
1723 /** set to sizeof(GpsNavigationMessageCallbacks) */
1724 size_t size;
1725 gps_navigation_message_callback navigation_message_callback;
1726} GpsNavigationMessageCallbacks;
1727
1728#define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS 0
1729#define GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT -100
1730#define GPS_NAVIGATION_MESSAGE_ERROR_GENERIC -101
1731
1732/**
1733 * Extended interface for GPS navigation message reporting support.
1734 */
1735typedef struct {
1736 /** Set to sizeof(GpsNavigationMessageInterface) */
1737 size_t size;
1738
1739 /**
1740 * Initializes the interface and registers the callback routines with the HAL.
1741 * After a successful call to 'init' the HAL must begin to provide updates as they become
1742 * available.
1743 *
1744 * Status:
1745 * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS
1746 * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered
1747 * without a corresponding call to 'close'.
1748 * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that
1749 * the HAL will not generate any updates upon returning this error code.
1750 */
1751 int (*init) (GpsNavigationMessageCallbacks* callbacks);
1752
1753 /**
1754 * Stops updates from the HAL, and unregisters the callback routines.
1755 * After a call to stop, the previously registered callbacks must be considered invalid by the
1756 * HAL.
1757 * If stop is invoked without a previous 'init', this function should perform no work.
1758 */
1759 void (*close) ();
1760
1761} GpsNavigationMessageInterface;
1762
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05001763__END_DECLS
1764
1765#endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */
1766