blob: 54b50a5f029067224afb751b8e87958f0e06ad2d [file] [log] [blame]
The Android Open Source Projectd6054a32008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2008 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 _HARDWARE_GPS_H
18#define _HARDWARE_GPS_H
19
20#include <stdint.h>
21
22#if __cplusplus
23extern "C" {
24#endif
25
26/** milliseconds since January 1, 1970 */
27typedef int64_t GpsUtcTime;
28
29/** maximum number of Space Vehicles for gps_sv_status_callback */
30#define GPS_MAX_SVS 32
31
32
33typedef uint16_t GpsPositionMode;
34#define GPS_POSITION_MODE_STANDALONE 0
35#define GPS_POSITION_MODE_MS_BASED 1
36#define GPS_POSITION_MODE_MS_ASSISTED 2
37
38typedef uint16_t GpsStatusValue;
39// IMPORTANT - these symbols here must match constants in GpsLocationProvider.java
40#define GPS_STATUS_NONE 0
41#define GPS_STATUS_SESSION_BEGIN 1
42#define GPS_STATUS_SESSION_END 2
43#define GPS_STATUS_ENGINE_ON 3
44#define GPS_STATUS_ENGINE_OFF 4
45
46typedef uint16_t GpsLocationFlags;
47// IMPORTANT - these symbols here must match constants in GpsLocationProvider.java
48#define GPS_LOCATION_HAS_LAT_LONG 0x0001
49#define GPS_LOCATION_HAS_ALTITUDE 0x0002
50#define GPS_LOCATION_HAS_SPEED 0x0004
51#define GPS_LOCATION_HAS_BEARING 0x0008
52#define GPS_LOCATION_HAS_ACCURACY 0x0010
53
54typedef uint16_t GpsAidingData;
55// IMPORTANT - these symbols here must match constants in GpsLocationProvider.java
56#define GPS_DELETE_EPHEMERIS 0x0001
57#define GPS_DELETE_ALMANAC 0x0002
58#define GPS_DELETE_POSITION 0x0004
59#define GPS_DELETE_TIME 0x0008
60#define GPS_DELETE_IONO 0x0010
61#define GPS_DELETE_UTC 0x0020
62#define GPS_DELETE_HEALTH 0x0040
63#define GPS_DELETE_SVDIR 0x0080
64#define GPS_DELETE_SVSTEER 0x0100
65#define GPS_DELETE_SADATA 0x0200
66#define GPS_DELETE_RTI 0x0400
67#define GPS_DELETE_CELLDB_INFO 0x8000
68#define GPS_DELETE_ALL 0xFFFF
69
70/**
71 * names for GPS XTRA interface
72 */
73#define GPS_XTRA_INTERFACE "gps-xtra"
74
75/**
76 * names for GPS supplemental interface
77 * TODO: Remove not used.
78 */
79#define GPS_SUPL_INTERFACE "gps-supl"
80
81/** The location */
82typedef struct {
83 /** contains GpsLocationFlags bits */
84 uint16_t flags;
85 double latitude;
86 double longitude;
87 double altitude;
88 float speed;
89 float bearing;
90 float accuracy;
91 GpsUtcTime timestamp;
92} GpsLocation;
93
94/** The status */
95typedef struct {
96 GpsStatusValue status;
97} GpsStatus;
98
99/** Space Vehicle info */
100typedef struct {
101 int prn;
102 float snr;
103 float elevation;
104 float azimuth;
105} GpsSvInfo;
106
107/** Space Vehicle status */
108typedef struct {
109 /** number of SVs currently visible */
110 int num_svs;
111
112 /** Array of space vehicle info */
113 GpsSvInfo sv_list[GPS_MAX_SVS];
114
115 /** bit mask indicating which SVs have ephemeris data */
116 uint32_t ephemeris_mask;
117
118 /** bit mask indicating which SVs have almanac data */
119 uint32_t almanac_mask;
120
121 /**
122 * bit mask indicating which SVs were used for
123 * computing the most recent position fix
124 */
125 uint32_t used_in_fix_mask;
126} GpsSvStatus;
127
128/** Callback with location information */
129typedef void (* gps_location_callback)(GpsLocation* location);
130
131/** Callback with the status information */
132typedef void (* gps_status_callback)(GpsStatus* status);
133
134/** Callback with the space vehicle status information */
135typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info);
136
137/** GPS call back structure */
138typedef struct {
139 gps_location_callback location_cb;
140 gps_status_callback status_cb;
141 gps_sv_status_callback sv_status_cb;
142} GpsCallbacks;
143
144
145/** Standard GPS interface */
146typedef struct {
147 /**
148 * Open the interface and provide the callback routines
149 * to the implemenation of this interface.
150 */
151 int (*init)( GpsCallbacks* callbacks );
152
153 /** Start navigating */
154 int (*start)( void );
155
156 /** Stop navigating */
157 int (*stop)( void );
158
159 /** Set requested frequency of fixes in seconds */
160 void (*set_fix_frequency)( int frequency );
161
162 /** Close the interface */
163 void (*cleanup)( void );
164
165 /** Inject the current time */
166 int (*inject_time)(GpsUtcTime time, int64_t timeReference,
167 int uncertainty);
168
169 /**
170 * The next call to start will not use the information
171 * defined in the flags. GPS_DELETE_ALL is passed for
172 * a cold start.
173 */
174 void (*delete_aiding_data)(GpsAidingData flags);
175
176 /**
177 * fix_frequency is time between fixes in seconds.
178 * set fix_frequency to zero for a single shot fix.
179 */
180 int (*set_position_mode)(GpsPositionMode mode, int fix_frequency);
181
182 /** Get a pointer to extension information. */
183 const void* (*get_extension)(const char* name);
184} GpsInterface;
185
186/** The download request callback routine. */
187typedef void (* gps_xtra_download_request)();
188
189/** The download request callback structure. */
190typedef struct {
191 gps_xtra_download_request download_request_cb;
192} GpsXtraCallbacks;
193
194/** Extended interface for XTRA support. */
195typedef struct {
196 int (*init)( GpsXtraCallbacks* callbacks );
197 int (*inject_xtra_data)( char* data, int length );
198} GpsXtraInterface;
199
200/** returns the hardware GPS interface. */
201const GpsInterface* gps_get_hardware_interface();
202
203/**
204 * returns the qemu hardware interface GPS interface.
205 */
206const GpsInterface* gps_get_qemu_interface();
207
208/**
209 * returns the default GPS interface,
210 * implemented in lib/hardware/gps.cpp.
211 */
212const GpsInterface* gps_get_interface();
213
214#if __cplusplus
215} // extern "C"
216#endif
217
218#endif // _HARDWARE_GPS_H