Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 1 | /* |
| 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 Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 23 | #include <pthread.h> |
destradaa | f48cc67 | 2014-06-05 11:07:09 -0700 | [diff] [blame] | 24 | #include <sys/socket.h> |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 25 | #include <stdbool.h> |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 26 | |
| 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 */ |
| 38 | typedef int64_t GpsUtcTime; |
| 39 | |
| 40 | /** Maximum number of SVs for gps_sv_status_callback(). */ |
| 41 | #define GPS_MAX_SVS 32 |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 42 | /** Maximum number of SVs for gps_sv_status_callback(). */ |
| 43 | #define GNSS_MAX_SVS 64 |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 44 | |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 45 | /** Maximum number of Measurements in gps_measurement_callback(). */ |
| 46 | #define GPS_MAX_MEASUREMENT 32 |
| 47 | |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 48 | /** Maximum number of Measurements in gnss_measurement_callback(). */ |
| 49 | #define GNSS_MAX_MEASUREMENT 64 |
| 50 | |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 51 | /** Requested operational mode for GPS operation. */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 52 | typedef uint32_t GpsPositionMode; |
| 53 | // IMPORTANT: Note that the following values must match |
| 54 | // constants in GpsLocationProvider.java. |
| 55 | /** 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 |
destradaa | 8153488 | 2015-04-28 13:10:56 -0700 | [diff] [blame] | 59 | /** |
| 60 | * AGPS MS-Assisted mode. This mode is not maintained by the platform anymore. |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 61 | * It is strongly recommended to use GPS_POSITION_MODE_MS_BASED instead. |
destradaa | 8153488 | 2015-04-28 13:10:56 -0700 | [diff] [blame] | 62 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 63 | #define GPS_POSITION_MODE_MS_ASSISTED 2 |
| 64 | |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 65 | /** Requested recurrence mode for GPS operation. */ |
| 66 | typedef uint32_t GpsPositionRecurrence; |
| 67 | // IMPORTANT: Note that the following values must match |
| 68 | // constants in GpsLocationProvider.java. |
| 69 | /** 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 Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 74 | /** GPS status event values. */ |
| 75 | typedef uint16_t GpsStatusValue; |
| 76 | // IMPORTANT: Note that the following values must match |
| 77 | // constants in GpsLocationProvider.java. |
| 78 | /** 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. */ |
| 90 | typedef uint16_t GpsLocationFlags; |
| 91 | // IMPORTANT: Note that the following values must match |
| 92 | // constants in GpsLocationProvider.java. |
| 93 | /** 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 Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 104 | /** Flags for the gps_set_capabilities callback. */ |
| 105 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 106 | /** |
| 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 Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 110 | */ |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 111 | #define GPS_CAPABILITY_SCHEDULING (1 << 0) |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 112 | /** GPS supports MS-Based AGPS mode */ |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 113 | #define GPS_CAPABILITY_MSB (1 << 1) |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 114 | /** GPS supports MS-Assisted AGPS mode */ |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 115 | #define GPS_CAPABILITY_MSA (1 << 2) |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 116 | /** GPS supports single-shot fixes */ |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 117 | #define GPS_CAPABILITY_SINGLE_SHOT (1 << 3) |
Mike Lockwood | 8aac591 | 2011-06-29 15:10:36 -0400 | [diff] [blame] | 118 | /** GPS supports on demand time injection */ |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 119 | #define GPS_CAPABILITY_ON_DEMAND_TIME (1 << 4) |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 120 | /** GPS supports Geofencing */ |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 121 | #define GPS_CAPABILITY_GEOFENCING (1 << 5) |
destradaa | 69d5ea5 | 2014-07-31 16:34:09 -0700 | [diff] [blame] | 122 | /** GPS supports Measurements */ |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 123 | #define GPS_CAPABILITY_MEASUREMENTS (1 << 6) |
destradaa | 69d5ea5 | 2014-07-31 16:34:09 -0700 | [diff] [blame] | 124 | /** GPS supports Navigation Messages */ |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 125 | #define GPS_CAPABILITY_NAV_MESSAGES (1 << 7) |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 126 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 127 | /** |
| 128 | * Flags used to specify which aiding data to delete when calling |
| 129 | * delete_aiding_data(). |
| 130 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 131 | typedef uint16_t GpsAidingData; |
| 132 | // IMPORTANT: Note that the following values must match |
| 133 | // constants in GpsLocationProvider.java. |
| 134 | #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 */ |
| 149 | typedef uint16_t AGpsType; |
| 150 | #define AGPS_TYPE_SUPL 1 |
| 151 | #define AGPS_TYPE_C2K 2 |
| 152 | |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 153 | typedef 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 | |
destradaa | f48cc67 | 2014-06-05 11:07:09 -0700 | [diff] [blame] | 158 | typedef 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 Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 164 | /** |
| 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 | */ |
| 173 | typedef 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 | */ |
| 181 | typedef 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 | */ |
| 193 | typedef 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 | */ |
| 201 | typedef 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. */ |
| 209 | typedef 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 Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 221 | typedef uint16_t AGpsRefLocationType; |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 222 | #define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1 |
| 223 | #define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2 |
| 224 | #define AGPS_REG_LOCATION_TYPE_MAC 3 |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 225 | #define AGPS_REF_LOCATION_TYPE_LTE_CELLID 4 |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 226 | |
Mike Lockwood | 455e83b | 2010-10-11 06:16:57 -0400 | [diff] [blame] | 227 | /** Network types for update_network_state "type" parameter */ |
| 228 | #define AGPS_RIL_NETWORK_TYPE_MOBILE 0 |
| 229 | #define AGPS_RIL_NETWORK_TYPE_WIFI 1 |
| 230 | #define AGPS_RIL_NETWORK_TYPE_MOBILE_MMS 2 |
| 231 | #define AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL 3 |
| 232 | #define AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN 4 |
| 233 | #define AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI 5 |
| 234 | #define AGPS_RIL_NETWORK_TTYPE_WIMAX 6 |
| 235 | |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 236 | /** |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 237 | * Flags to indicate what fields in GpsClock are valid. |
| 238 | */ |
| 239 | typedef uint16_t GpsClockFlags; |
| 240 | /** A valid 'leap second' is stored in the data structure. */ |
| 241 | #define GPS_CLOCK_HAS_LEAP_SECOND (1<<0) |
| 242 | /** A valid 'time uncertainty' is stored in the data structure. */ |
| 243 | #define GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1) |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 244 | /** A valid 'full bias' is stored in the data structure. */ |
| 245 | #define GPS_CLOCK_HAS_FULL_BIAS (1<<2) |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 246 | /** A valid 'bias' is stored in the data structure. */ |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 247 | #define GPS_CLOCK_HAS_BIAS (1<<3) |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 248 | /** A valid 'bias uncertainty' is stored in the data structure. */ |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 249 | #define GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4) |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 250 | /** A valid 'drift' is stored in the data structure. */ |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 251 | #define GPS_CLOCK_HAS_DRIFT (1<<5) |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 252 | /** A valid 'drift uncertainty' is stored in the data structure. */ |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 253 | #define GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6) |
| 254 | |
| 255 | /** |
| 256 | * Enumeration of the available values for the GPS Clock type. |
| 257 | */ |
| 258 | typedef uint8_t GpsClockType; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 259 | /** The type is not available or it is unknown. */ |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 260 | #define GPS_CLOCK_TYPE_UNKNOWN 0 |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 261 | /** |
| 262 | * The source of the time value reported by GPS clock is the local hardware |
| 263 | * clock. This is a mandatory flag. When the GpsSystemInfo's year_of_hw is 2016 |
| 264 | * or higher, it is mandatory that 'time' is populated with the local hardware |
| 265 | * clock value, and this flag must always be set. |
| 266 | */ |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 267 | #define GPS_CLOCK_TYPE_LOCAL_HW_TIME 1 |
| 268 | /** |
| 269 | * The source of the time value reported by GPS clock is the GPS time derived from satellites |
| 270 | * (epoch = Jan 6, 1980) |
| 271 | */ |
| 272 | #define GPS_CLOCK_TYPE_GPS_TIME 2 |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 273 | |
| 274 | /** |
| 275 | * Flags to indicate what fields in GpsMeasurement are valid. |
| 276 | */ |
| 277 | typedef uint32_t GpsMeasurementFlags; |
| 278 | /** A valid 'snr' is stored in the data structure. */ |
| 279 | #define GPS_MEASUREMENT_HAS_SNR (1<<0) |
| 280 | /** A valid 'elevation' is stored in the data structure. */ |
| 281 | #define GPS_MEASUREMENT_HAS_ELEVATION (1<<1) |
| 282 | /** A valid 'elevation uncertainty' is stored in the data structure. */ |
| 283 | #define GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2) |
| 284 | /** A valid 'azimuth' is stored in the data structure. */ |
| 285 | #define GPS_MEASUREMENT_HAS_AZIMUTH (1<<3) |
| 286 | /** A valid 'azimuth uncertainty' is stored in the data structure. */ |
| 287 | #define GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4) |
| 288 | /** A valid 'pseudorange' is stored in the data structure. */ |
| 289 | #define GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5) |
| 290 | /** A valid 'pseudorange uncertainty' is stored in the data structure. */ |
| 291 | #define GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6) |
| 292 | /** A valid 'code phase' is stored in the data structure. */ |
| 293 | #define GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7) |
| 294 | /** A valid 'code phase uncertainty' is stored in the data structure. */ |
| 295 | #define GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8) |
| 296 | /** A valid 'carrier frequency' is stored in the data structure. */ |
| 297 | #define GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9) |
| 298 | /** A valid 'carrier cycles' is stored in the data structure. */ |
| 299 | #define GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10) |
| 300 | /** A valid 'carrier phase' is stored in the data structure. */ |
| 301 | #define GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11) |
| 302 | /** A valid 'carrier phase uncertainty' is stored in the data structure. */ |
| 303 | #define GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12) |
| 304 | /** A valid 'bit number' is stored in the data structure. */ |
| 305 | #define GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13) |
| 306 | /** A valid 'time from last bit' is stored in the data structure. */ |
| 307 | #define GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14) |
| 308 | /** A valid 'doppler shift' is stored in the data structure. */ |
| 309 | #define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15) |
| 310 | /** A valid 'doppler shift uncertainty' is stored in the data structure. */ |
| 311 | #define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16) |
| 312 | /** A valid 'used in fix' flag is stored in the data structure. */ |
| 313 | #define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17) |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 314 | /** |
| 315 | * The value of 'pseudorange rate' is uncorrected. |
| 316 | * This is a mandatory flag. It is mandatory that 'pseudorange rate' is |
| 317 | * populated with the uncorrected value, and this flag must always be set. |
| 318 | * See comments of GpsMeasurement::pseudorange_rate_mps for more details. |
| 319 | */ |
destradaa | 00caa89 | 2015-04-09 18:41:46 -0700 | [diff] [blame] | 320 | #define GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE (1<<18) |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 321 | |
| 322 | /** |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 323 | * Enumeration of the available values for the GPS Measurement's loss of lock. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 324 | */ |
| 325 | typedef uint8_t GpsLossOfLock; |
| 326 | /** The indicator is not available or it is unknown. */ |
| 327 | #define GPS_LOSS_OF_LOCK_UNKNOWN 0 |
| 328 | /** The measurement does not present any indication of loss of lock. */ |
| 329 | #define GPS_LOSS_OF_LOCK_OK 1 |
| 330 | /** Loss of lock between previous and current observation: cycle slip possible. */ |
| 331 | #define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2 |
| 332 | |
| 333 | /** |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 334 | * Enumeration of available values for the GPS Measurement's multipath indicator. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 335 | */ |
| 336 | typedef uint8_t GpsMultipathIndicator; |
| 337 | /** The indicator is not available or unknown. */ |
| 338 | #define GPS_MULTIPATH_INDICATOR_UNKNOWN 0 |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 339 | /** The measurement is indicated to be affected by multipath. */ |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 340 | #define GPS_MULTIPATH_INDICATOR_DETECTED 1 |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 341 | /** The measurement is indicated to be not affected by multipath. */ |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 342 | #define GPS_MULTIPATH_INDICATOR_NOT_USED 2 |
| 343 | |
| 344 | /** |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 345 | * Flags indicating the GPS measurement state. |
Tsuwei Chen | a90cf19 | 2014-10-23 12:49:12 -0700 | [diff] [blame] | 346 | * The expected behavior here is for GPS HAL to set all the flags that applies. For |
| 347 | * example, if the state for a satellite is only C/A code locked and bit synchronized, |
| 348 | * and there is still millisecond ambiguity, the state should be set as: |
| 349 | * GPS_MEASUREMENT_STATE_CODE_LOCK|GPS_MEASUREMENT_STATE_BIT_SYNC|GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS |
| 350 | * If GPS is still searching for a satellite, the corresponding state should be set to |
| 351 | * GPS_MEASUREMENT_STATE_UNKNOWN(0). |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 352 | */ |
| 353 | typedef uint16_t GpsMeasurementState; |
| 354 | #define GPS_MEASUREMENT_STATE_UNKNOWN 0 |
| 355 | #define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0) |
| 356 | #define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1) |
| 357 | #define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2) |
| 358 | #define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3) |
Tsuwei Chen | a90cf19 | 2014-10-23 12:49:12 -0700 | [diff] [blame] | 359 | #define GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4) |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 360 | |
| 361 | /** |
| 362 | * Flags indicating the Accumulated Delta Range's states. |
| 363 | */ |
| 364 | typedef uint16_t GpsAccumulatedDeltaRangeState; |
| 365 | #define GPS_ADR_STATE_UNKNOWN 0 |
| 366 | #define GPS_ADR_STATE_VALID (1<<0) |
| 367 | #define GPS_ADR_STATE_RESET (1<<1) |
| 368 | #define GPS_ADR_STATE_CYCLE_SLIP (1<<2) |
| 369 | |
| 370 | /** |
Tsuwei Chen | a90cf19 | 2014-10-23 12:49:12 -0700 | [diff] [blame] | 371 | * Enumeration of available values to indicate the available GPS Navigation message types. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 372 | */ |
| 373 | typedef uint8_t GpsNavigationMessageType; |
| 374 | /** The message type is unknown. */ |
| 375 | #define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0 |
| 376 | /** L1 C/A message contained in the structure. */ |
| 377 | #define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1 |
| 378 | /** L2-CNAV message contained in the structure. */ |
| 379 | #define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2 |
| 380 | /** L5-CNAV message contained in the structure. */ |
| 381 | #define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3 |
| 382 | /** CNAV-2 message contained in the structure. */ |
| 383 | #define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4 |
| 384 | |
Tsuwei Chen | a90cf19 | 2014-10-23 12:49:12 -0700 | [diff] [blame] | 385 | /** |
| 386 | * Status of Navigation Message |
| 387 | * When a message is received properly without any parity error in its navigation words, the |
| 388 | * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received |
| 389 | * with words that failed parity check, but GPS is able to correct those words, the status |
| 390 | * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT. |
| 391 | * No need to send any navigation message that contains words with parity error and cannot be |
| 392 | * corrected. |
| 393 | */ |
| 394 | typedef uint16_t NavigationMessageStatus; |
| 395 | #define NAV_MESSAGE_STATUS_UNKONW 0 |
| 396 | #define NAV_MESSAGE_STATUS_PARITY_PASSED (1<<0) |
| 397 | #define NAV_MESSAGE_STATUS_PARITY_REBUILT (1<<1) |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 398 | |
| 399 | /** |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 400 | * Flag that indicates which extra data GnssSvInfo includes. |
| 401 | */ |
| 402 | typedef uint8_t GnssSvFlags; |
| 403 | #define GNSS_SV_FLAGS_NONE 0 |
| 404 | #define GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA (1 << 0) |
| 405 | #define GNSS_SV_FLAGS_HAS_ALMANAC_DATA (1 << 1) |
| 406 | #define GNSS_SV_FLAGS_USED_IN_FIX (1 << 2) |
| 407 | |
| 408 | /** |
| 409 | * Constellation type of GnssSvInfo |
| 410 | */ |
| 411 | typedef uint8_t GnssConstellationType; |
| 412 | #define GNSS_CONSTELLATION_UNKNOWN 0 |
| 413 | #define GNSS_CONSTELLATION_GPS 1 |
| 414 | #define GNSS_CONSTELLATION_SBAS 2 |
| 415 | #define GNSS_CONSTELLATION_GLONASS 3 |
| 416 | #define GNSS_CONSTELLATION_QZSS 4 |
| 417 | #define GNSS_CONSTELLATION_BEIDOU 5 |
| 418 | #define GNSS_CONSTELLATION_GALILEO 6 |
| 419 | |
| 420 | /** |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 421 | * Name for the GPS XTRA interface. |
| 422 | */ |
| 423 | #define GPS_XTRA_INTERFACE "gps-xtra" |
| 424 | |
| 425 | /** |
| 426 | * Name for the GPS DEBUG interface. |
| 427 | */ |
| 428 | #define GPS_DEBUG_INTERFACE "gps-debug" |
| 429 | |
| 430 | /** |
| 431 | * Name for the AGPS interface. |
| 432 | */ |
| 433 | #define AGPS_INTERFACE "agps" |
| 434 | |
| 435 | /** |
destradaa | a1f4c0a | 2013-09-13 15:45:03 -0700 | [diff] [blame] | 436 | * Name of the Supl Certificate interface. |
| 437 | */ |
| 438 | #define SUPL_CERTIFICATE_INTERFACE "supl-certificate" |
| 439 | |
| 440 | /** |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 441 | * Name for NI interface |
| 442 | */ |
| 443 | #define GPS_NI_INTERFACE "gps-ni" |
| 444 | |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 445 | /** |
| 446 | * Name for the AGPS-RIL interface. |
| 447 | */ |
| 448 | #define AGPS_RIL_INTERFACE "agps_ril" |
| 449 | |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 450 | /** |
| 451 | * Name for the GPS_Geofencing interface. |
| 452 | */ |
| 453 | #define GPS_GEOFENCING_INTERFACE "gps_geofencing" |
| 454 | |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 455 | /** |
| 456 | * Name of the GPS Measurements interface. |
| 457 | */ |
| 458 | #define GPS_MEASUREMENT_INTERFACE "gps_measurement" |
| 459 | |
| 460 | /** |
| 461 | * Name of the GPS navigation message interface. |
| 462 | */ |
Tsuwei Chen | 167d31f | 2014-08-26 16:34:19 -0700 | [diff] [blame] | 463 | #define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message" |
| 464 | |
| 465 | /** |
| 466 | * Name of the GNSS/GPS configuration interface. |
| 467 | */ |
| 468 | #define GNSS_CONFIGURATION_INTERFACE "gnss_configuration" |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 469 | |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 470 | |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 471 | /** Represents a location. */ |
| 472 | typedef struct { |
| 473 | /** set to sizeof(GpsLocation) */ |
| 474 | size_t size; |
| 475 | /** Contains GpsLocationFlags bits. */ |
| 476 | uint16_t flags; |
| 477 | /** Represents latitude in degrees. */ |
| 478 | double latitude; |
| 479 | /** Represents longitude in degrees. */ |
| 480 | double longitude; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 481 | /** |
| 482 | * Represents altitude in meters above the WGS 84 reference ellipsoid. |
| 483 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 484 | double altitude; |
| 485 | /** Represents speed in meters per second. */ |
| 486 | float speed; |
| 487 | /** Represents heading in degrees. */ |
| 488 | float bearing; |
| 489 | /** Represents expected accuracy in meters. */ |
| 490 | float accuracy; |
| 491 | /** Timestamp for the location fix. */ |
| 492 | GpsUtcTime timestamp; |
| 493 | } GpsLocation; |
| 494 | |
| 495 | /** Represents the status. */ |
| 496 | typedef struct { |
| 497 | /** set to sizeof(GpsStatus) */ |
| 498 | size_t size; |
| 499 | GpsStatusValue status; |
| 500 | } GpsStatus; |
| 501 | |
| 502 | /** Represents SV information. */ |
| 503 | typedef struct { |
| 504 | /** set to sizeof(GpsSvInfo) */ |
| 505 | size_t size; |
| 506 | /** Pseudo-random number for the SV. */ |
| 507 | int prn; |
| 508 | /** Signal to noise ratio. */ |
| 509 | float snr; |
| 510 | /** Elevation of SV in degrees. */ |
| 511 | float elevation; |
| 512 | /** Azimuth of SV in degrees. */ |
| 513 | float azimuth; |
| 514 | } GpsSvInfo; |
| 515 | |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 516 | typedef struct { |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 517 | /** set to sizeof(GnssSvInfo) */ |
| 518 | size_t size; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 519 | |
| 520 | /** |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 521 | * Pseudo-random number for the SV, or Amanac/slot number for Glonass. The |
| 522 | * distinction is made by looking at constellation field. Values should be |
| 523 | * in the range of: |
| 524 | * |
| 525 | * - GPS: 1-32 |
| 526 | * - SBAS: 120-151, 183-192 |
| 527 | * - GLONASS: 1-24 (slot number) |
| 528 | * - QZSS: 193-200 |
| 529 | * - Galileo: 1-25 |
| 530 | * - Beidou: 1-35 |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 531 | */ |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 532 | int16_t svid; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 533 | |
| 534 | /** Signal to noise ratio. */ |
| 535 | float snr; |
| 536 | |
| 537 | /** Elevation of SV in degrees. */ |
| 538 | float elevation; |
| 539 | |
| 540 | /** Azimuth of SV in degrees. */ |
| 541 | float azimuth; |
| 542 | |
| 543 | /** |
| 544 | * Contains additional data about the given SV. Value should be one of those |
| 545 | * GNSS_SV_FLAGS_* constants |
| 546 | */ |
| 547 | GnssSvFlags flags; |
| 548 | |
| 549 | /** |
| 550 | * Defines the constellation of the given SV. Value should be one of those |
| 551 | * GNSS_CONSTELLATION_* constants |
| 552 | */ |
| 553 | GnssConstellationType constellation; |
| 554 | |
| 555 | } GnssSvInfo; |
| 556 | |
| 557 | /** |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 558 | * Legacy struct to represents SV status. |
| 559 | * Deprecated, to be removed in the next Android release. |
| 560 | * Use GnssSvStatus instead. |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 561 | */ |
| 562 | typedef struct { |
| 563 | /** set to sizeof(GpsSvStatus) */ |
| 564 | size_t size; |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 565 | int num_svs; |
| 566 | GpsSvInfo sv_list[GPS_MAX_SVS]; |
| 567 | uint32_t ephemeris_mask; |
| 568 | uint32_t almanac_mask; |
| 569 | uint32_t used_in_fix_mask; |
| 570 | } GpsSvStatus; |
| 571 | |
| 572 | /** |
| 573 | * Represents SV status. |
| 574 | */ |
| 575 | typedef struct { |
| 576 | /** set to sizeof(GnssSvStatus) */ |
| 577 | size_t size; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 578 | |
| 579 | /** Number of GPS SVs currently visible, refers to the SVs stored in sv_list */ |
| 580 | int num_svs; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 581 | /** |
| 582 | * Pointer to an array of SVs information for all GNSS constellations, |
| 583 | * except GPS, which is reported using sv_list |
| 584 | */ |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 585 | GnssSvInfo gnss_sv_list[GNSS_MAX_SVS]; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 586 | |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 587 | } GnssSvStatus; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 588 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 589 | /* CellID for 2G, 3G and LTE, used in AGPS. */ |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 590 | typedef struct { |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 591 | AGpsRefLocationType type; |
| 592 | /** Mobile Country Code. */ |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 593 | uint16_t mcc; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 594 | /** Mobile Network Code .*/ |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 595 | uint16_t mnc; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 596 | /** Location Area Code in 2G, 3G and LTE. In 3G lac is discarded. In LTE, |
| 597 | * lac is populated with tac, to ensure that we don't break old clients that |
| 598 | * might rely in the old (wrong) behavior. |
| 599 | */ |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 600 | uint16_t lac; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 601 | /** Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */ |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 602 | uint32_t cid; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 603 | /** Tracking Area Code in LTE. */ |
| 604 | uint16_t tac; |
| 605 | /** Physical Cell id in LTE (not used in 2G and 3G) */ |
| 606 | uint16_t pcid; |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 607 | } AGpsRefLocationCellID; |
| 608 | |
| 609 | typedef struct { |
| 610 | uint8_t mac[6]; |
| 611 | } AGpsRefLocationMac; |
| 612 | |
| 613 | /** Represents ref locations */ |
| 614 | typedef struct { |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 615 | AGpsRefLocationType type; |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 616 | union { |
| 617 | AGpsRefLocationCellID cellID; |
| 618 | AGpsRefLocationMac mac; |
| 619 | } u; |
| 620 | } AGpsRefLocation; |
| 621 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 622 | /** |
| 623 | * Callback with location information. Can only be called from a thread created |
| 624 | * by create_thread_cb. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 625 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 626 | typedef void (* gps_location_callback)(GpsLocation* location); |
| 627 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 628 | /** |
| 629 | * Callback with status information. Can only be called from a thread created by |
| 630 | * create_thread_cb. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 631 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 632 | typedef void (* gps_status_callback)(GpsStatus* status); |
| 633 | |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 634 | /** |
| 635 | * Callback with SV status information. |
| 636 | * Can only be called from a thread created by create_thread_cb. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 637 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 638 | typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); |
| 639 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 640 | /** |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 641 | * Callback with SV status information. |
| 642 | * Can only be called from a thread created by create_thread_cb. |
| 643 | */ |
| 644 | typedef void (* gnss_sv_status_callback)(GnssSvStatus* sv_info); |
| 645 | |
| 646 | /** |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 647 | * Callback for reporting NMEA sentences. Can only be called from a thread |
| 648 | * created by create_thread_cb. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 649 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 650 | typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length); |
| 651 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 652 | /** |
| 653 | * Callback to inform framework of the GPS engine's capabilities. Capability |
| 654 | * parameter is a bit field of GPS_CAPABILITY_* flags. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 655 | */ |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 656 | typedef void (* gps_set_capabilities)(uint32_t capabilities); |
| 657 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 658 | /** |
| 659 | * Callback utility for acquiring the GPS wakelock. This can be used to prevent |
| 660 | * the CPU from suspending while handling GPS events. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 661 | */ |
Mike Lockwood | d20bbae | 2010-04-07 09:04:25 -0400 | [diff] [blame] | 662 | typedef void (* gps_acquire_wakelock)(); |
| 663 | |
| 664 | /** Callback utility for releasing the GPS wakelock. */ |
| 665 | typedef void (* gps_release_wakelock)(); |
| 666 | |
Mike Lockwood | 8aac591 | 2011-06-29 15:10:36 -0400 | [diff] [blame] | 667 | /** Callback for requesting NTP time */ |
| 668 | typedef void (* gps_request_utc_time)(); |
| 669 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 670 | /** |
| 671 | * Callback for creating a thread that can call into the Java framework code. |
| 672 | * This must be used to create any threads that report events up to the |
| 673 | * framework. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 674 | */ |
| 675 | typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg); |
| 676 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 677 | /** |
| 678 | * Provides information about how new the underlying GPS/GNSS hardware and |
| 679 | * software is. |
| 680 | * |
| 681 | * This information will be available for Android Test Applications. If a GPS |
| 682 | * HAL does not provide this information, it will be considered "2015 or |
| 683 | * earlier". |
| 684 | * |
| 685 | * If a GPS HAL does provide this information, then newer years will need to |
| 686 | * meet newer CTS standards. E.g. if the date are 2016 or above, then N+ level |
| 687 | * GpsMeasurement support will be verified. |
| 688 | */ |
| 689 | typedef struct { |
| 690 | /** Set to sizeof(GpsSystemInfo) */ |
| 691 | size_t size; |
| 692 | /* year in which the last update was made to the underlying hardware/firmware |
| 693 | * used to capture GNSS signals, e.g. 2016 */ |
| 694 | uint16_t year_of_hw; |
| 695 | } GpsSystemInfo; |
| 696 | |
| 697 | /** |
| 698 | * Callback to inform framework of the engine's hardware version information. |
| 699 | */ |
| 700 | typedef void (*gps_set_system_info)(const GpsSystemInfo* info); |
| 701 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 702 | /** New GPS callback structure. */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 703 | typedef struct { |
Mike Lockwood | d20bbae | 2010-04-07 09:04:25 -0400 | [diff] [blame] | 704 | /** set to sizeof(GpsCallbacks) */ |
| 705 | size_t size; |
| 706 | gps_location_callback location_cb; |
| 707 | gps_status_callback status_cb; |
| 708 | gps_sv_status_callback sv_status_cb; |
| 709 | gps_nmea_callback nmea_cb; |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 710 | gps_set_capabilities set_capabilities_cb; |
Mike Lockwood | d20bbae | 2010-04-07 09:04:25 -0400 | [diff] [blame] | 711 | gps_acquire_wakelock acquire_wakelock_cb; |
| 712 | gps_release_wakelock release_wakelock_cb; |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 713 | gps_create_thread create_thread_cb; |
Mike Lockwood | 8aac591 | 2011-06-29 15:10:36 -0400 | [diff] [blame] | 714 | gps_request_utc_time request_utc_time_cb; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 715 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 716 | gps_set_system_info set_system_info_cb; |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 717 | gnss_sv_status_callback gnss_sv_status_cb; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 718 | } GpsCallbacks; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 719 | |
| 720 | /** Represents the standard GPS interface. */ |
| 721 | typedef struct { |
| 722 | /** set to sizeof(GpsInterface) */ |
| 723 | size_t size; |
| 724 | /** |
| 725 | * Opens the interface and provides the callback routines |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 726 | * to the implementation of this interface. |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 727 | */ |
| 728 | int (*init)( GpsCallbacks* callbacks ); |
| 729 | |
| 730 | /** Starts navigating. */ |
| 731 | int (*start)( void ); |
| 732 | |
| 733 | /** Stops navigating. */ |
| 734 | int (*stop)( void ); |
| 735 | |
| 736 | /** Closes the interface. */ |
| 737 | void (*cleanup)( void ); |
| 738 | |
| 739 | /** Injects the current time. */ |
| 740 | int (*inject_time)(GpsUtcTime time, int64_t timeReference, |
| 741 | int uncertainty); |
| 742 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 743 | /** |
| 744 | * Injects current location from another location provider (typically cell |
| 745 | * ID). Latitude and longitude are measured in degrees expected accuracy is |
| 746 | * measured in meters |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 747 | */ |
| 748 | int (*inject_location)(double latitude, double longitude, float accuracy); |
| 749 | |
| 750 | /** |
| 751 | * Specifies that the next call to start will not use the |
| 752 | * information defined in the flags. GPS_DELETE_ALL is passed for |
| 753 | * a cold start. |
| 754 | */ |
| 755 | void (*delete_aiding_data)(GpsAidingData flags); |
| 756 | |
| 757 | /** |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 758 | * min_interval represents the time between fixes in milliseconds. |
| 759 | * preferred_accuracy represents the requested fix accuracy in meters. |
| 760 | * preferred_time represents the requested time to first fix in milliseconds. |
destradaa | 8153488 | 2015-04-28 13:10:56 -0700 | [diff] [blame] | 761 | * |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 762 | * 'mode' parameter should be one of GPS_POSITION_MODE_MS_BASED |
destradaa | 8153488 | 2015-04-28 13:10:56 -0700 | [diff] [blame] | 763 | * or GPS_POSITION_MODE_STANDALONE. |
| 764 | * It is allowed by the platform (and it is recommended) to fallback to |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 765 | * GPS_POSITION_MODE_MS_BASED if GPS_POSITION_MODE_MS_ASSISTED is passed in, and |
destradaa | 8153488 | 2015-04-28 13:10:56 -0700 | [diff] [blame] | 766 | * GPS_POSITION_MODE_MS_BASED is supported. |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 767 | */ |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 768 | int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence, |
| 769 | uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 770 | |
| 771 | /** Get a pointer to extension information. */ |
| 772 | const void* (*get_extension)(const char* name); |
| 773 | } GpsInterface; |
| 774 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 775 | /** |
| 776 | * Callback to request the client to download XTRA data. The client should |
| 777 | * download XTRA data and inject it by calling inject_xtra_data(). Can only be |
| 778 | * called from a thread created by create_thread_cb. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 779 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 780 | typedef void (* gps_xtra_download_request)(); |
| 781 | |
| 782 | /** Callback structure for the XTRA interface. */ |
| 783 | typedef struct { |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 784 | gps_xtra_download_request download_request_cb; |
| 785 | gps_create_thread create_thread_cb; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 786 | } GpsXtraCallbacks; |
| 787 | |
| 788 | /** Extended interface for XTRA support. */ |
| 789 | typedef struct { |
| 790 | /** set to sizeof(GpsXtraInterface) */ |
| 791 | size_t size; |
| 792 | /** |
| 793 | * Opens the XTRA interface and provides the callback routines |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 794 | * to the implementation of this interface. |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 795 | */ |
| 796 | int (*init)( GpsXtraCallbacks* callbacks ); |
| 797 | /** Injects XTRA data into the GPS. */ |
| 798 | int (*inject_xtra_data)( char* data, int length ); |
| 799 | } GpsXtraInterface; |
| 800 | |
| 801 | /** Extended interface for DEBUG support. */ |
| 802 | typedef struct { |
| 803 | /** set to sizeof(GpsDebugInterface) */ |
| 804 | size_t size; |
| 805 | |
| 806 | /** |
| 807 | * This function should return any information that the native |
| 808 | * implementation wishes to include in a bugreport. |
| 809 | */ |
| 810 | size_t (*get_internal_state)(char* buffer, size_t bufferSize); |
| 811 | } GpsDebugInterface; |
| 812 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 813 | /* |
| 814 | * Represents the status of AGPS augmented to support IPv4 and IPv6. |
| 815 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 816 | typedef struct { |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 817 | /** set to sizeof(AGpsStatus) */ |
destradaa | f48cc67 | 2014-06-05 11:07:09 -0700 | [diff] [blame] | 818 | size_t size; |
| 819 | |
| 820 | AGpsType type; |
| 821 | AGpsStatusValue status; |
| 822 | |
| 823 | /** |
| 824 | * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4 |
| 825 | * address, or set to INADDR_NONE otherwise. |
| 826 | */ |
| 827 | uint32_t ipaddr; |
| 828 | |
| 829 | /** |
| 830 | * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report. |
| 831 | * Any other value of addr.ss_family will be rejected. |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 832 | */ |
destradaa | f48cc67 | 2014-06-05 11:07:09 -0700 | [diff] [blame] | 833 | struct sockaddr_storage addr; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 834 | } AGpsStatus; |
destradaa | f48cc67 | 2014-06-05 11:07:09 -0700 | [diff] [blame] | 835 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 836 | /** |
| 837 | * Callback with AGPS status information. Can only be called from a thread |
| 838 | * created by create_thread_cb. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 839 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 840 | typedef void (* agps_status_callback)(AGpsStatus* status); |
| 841 | |
| 842 | /** Callback structure for the AGPS interface. */ |
| 843 | typedef struct { |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 844 | agps_status_callback status_cb; |
| 845 | gps_create_thread create_thread_cb; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 846 | } AGpsCallbacks; |
| 847 | |
destradaa | f48cc67 | 2014-06-05 11:07:09 -0700 | [diff] [blame] | 848 | /** |
| 849 | * Extended interface for AGPS support, it is augmented to enable to pass |
| 850 | * extra APN data. |
| 851 | */ |
| 852 | typedef struct { |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 853 | /** set to sizeof(AGpsInterface) */ |
destradaa | f48cc67 | 2014-06-05 11:07:09 -0700 | [diff] [blame] | 854 | size_t size; |
| 855 | |
| 856 | /** |
| 857 | * Opens the AGPS interface and provides the callback routines to the |
| 858 | * implementation of this interface. |
| 859 | */ |
| 860 | void (*init)(AGpsCallbacks* callbacks); |
| 861 | /** |
| 862 | * Deprecated. |
| 863 | * If the HAL supports AGpsInterface_v2 this API will not be used, see |
| 864 | * data_conn_open_with_apn_ip_type for more information. |
| 865 | */ |
| 866 | int (*data_conn_open)(const char* apn); |
| 867 | /** |
| 868 | * Notifies that the AGPS data connection has been closed. |
| 869 | */ |
| 870 | int (*data_conn_closed)(); |
| 871 | /** |
| 872 | * Notifies that a data connection is not available for AGPS. |
| 873 | */ |
| 874 | int (*data_conn_failed)(); |
| 875 | /** |
| 876 | * Sets the hostname and port for the AGPS server. |
| 877 | */ |
| 878 | int (*set_server)(AGpsType type, const char* hostname, int port); |
| 879 | |
| 880 | /** |
| 881 | * Notifies that a data connection is available and sets the name of the |
| 882 | * APN, and its IP type, to be used for SUPL connections. |
| 883 | */ |
| 884 | int (*data_conn_open_with_apn_ip_type)( |
| 885 | const char* apn, |
| 886 | ApnIpType apnIpType); |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 887 | } AGpsInterface; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 888 | |
destradaa | a1f4c0a | 2013-09-13 15:45:03 -0700 | [diff] [blame] | 889 | /** Error codes associated with certificate operations */ |
| 890 | #define AGPS_CERTIFICATE_OPERATION_SUCCESS 0 |
| 891 | #define AGPS_CERTIFICATE_ERROR_GENERIC -100 |
| 892 | #define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101 |
| 893 | |
| 894 | /** A data structure that represents an X.509 certificate using DER encoding */ |
| 895 | typedef struct { |
| 896 | size_t length; |
| 897 | u_char* data; |
| 898 | } DerEncodedCertificate; |
| 899 | |
| 900 | /** |
| 901 | * A type definition for SHA1 Fingerprints used to identify X.509 Certificates |
| 902 | * The Fingerprint is a digest of the DER Certificate that uniquely identifies it. |
| 903 | */ |
| 904 | typedef struct { |
| 905 | u_char data[20]; |
| 906 | } Sha1CertificateFingerprint; |
| 907 | |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 908 | /** AGPS Interface to handle SUPL certificate operations */ |
destradaa | a1f4c0a | 2013-09-13 15:45:03 -0700 | [diff] [blame] | 909 | typedef struct { |
| 910 | /** set to sizeof(SuplCertificateInterface) */ |
| 911 | size_t size; |
| 912 | |
| 913 | /** |
| 914 | * Installs a set of Certificates used for SUPL connections to the AGPS server. |
| 915 | * If needed the HAL should find out internally any certificates that need to be removed to |
| 916 | * accommodate the certificates to install. |
| 917 | * The certificates installed represent a full set of valid certificates needed to connect to |
| 918 | * AGPS SUPL servers. |
| 919 | * The list of certificates is required, and all must be available at the same time, when trying |
| 920 | * to establish a connection with the AGPS Server. |
| 921 | * |
| 922 | * Parameters: |
| 923 | * certificates - A pointer to an array of DER encoded certificates that are need to be |
| 924 | * installed in the HAL. |
| 925 | * length - The number of certificates to install. |
| 926 | * Returns: |
| 927 | * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully |
| 928 | * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of |
| 929 | * certificates attempted to be installed, the state of the certificates stored should |
| 930 | * remain the same as before on this error case. |
| 931 | * |
| 932 | * IMPORTANT: |
| 933 | * If needed the HAL should find out internally the set of certificates that need to be |
| 934 | * removed to accommodate the certificates to install. |
| 935 | */ |
| 936 | int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length ); |
| 937 | |
| 938 | /** |
| 939 | * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is |
| 940 | * expected that the given set of certificates is removed from the internal store of the HAL. |
| 941 | * |
| 942 | * Parameters: |
| 943 | * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of |
| 944 | * certificates to revoke. |
| 945 | * length - The number of fingerprints provided. |
| 946 | * Returns: |
| 947 | * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully. |
| 948 | * |
| 949 | * IMPORTANT: |
| 950 | * If any of the certificates provided (through its fingerprint) is not known by the HAL, |
| 951 | * it should be ignored and continue revoking/deleting the rest of them. |
| 952 | */ |
| 953 | int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length ); |
destradaa | 7ddd4d7 | 2013-11-07 13:47:59 -0800 | [diff] [blame] | 954 | } SuplCertificateInterface; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 955 | |
| 956 | /** Represents an NI request */ |
| 957 | typedef struct { |
| 958 | /** set to sizeof(GpsNiNotification) */ |
| 959 | size_t size; |
| 960 | |
| 961 | /** |
| 962 | * An ID generated by HAL to associate NI notifications and UI |
| 963 | * responses |
| 964 | */ |
| 965 | int notification_id; |
| 966 | |
| 967 | /** |
| 968 | * An NI type used to distinguish different categories of NI |
| 969 | * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ... |
| 970 | */ |
| 971 | GpsNiType ni_type; |
| 972 | |
| 973 | /** |
| 974 | * Notification/verification options, combinations of GpsNiNotifyFlags constants |
| 975 | */ |
| 976 | GpsNiNotifyFlags notify_flags; |
| 977 | |
| 978 | /** |
| 979 | * Timeout period to wait for user response. |
| 980 | * Set to 0 for no time out limit. |
| 981 | */ |
| 982 | int timeout; |
| 983 | |
| 984 | /** |
| 985 | * Default response when time out. |
| 986 | */ |
| 987 | GpsUserResponseType default_response; |
| 988 | |
| 989 | /** |
| 990 | * Requestor ID |
| 991 | */ |
| 992 | char requestor_id[GPS_NI_SHORT_STRING_MAXLEN]; |
| 993 | |
| 994 | /** |
| 995 | * Notification message. It can also be used to store client_id in some cases |
| 996 | */ |
| 997 | char text[GPS_NI_LONG_STRING_MAXLEN]; |
| 998 | |
| 999 | /** |
| 1000 | * Client name decoding scheme |
| 1001 | */ |
| 1002 | GpsNiEncodingType requestor_id_encoding; |
| 1003 | |
| 1004 | /** |
| 1005 | * Client name decoding scheme |
| 1006 | */ |
| 1007 | GpsNiEncodingType text_encoding; |
| 1008 | |
| 1009 | /** |
| 1010 | * A pointer to extra data. Format: |
| 1011 | * key_1 = value_1 |
| 1012 | * key_2 = value_2 |
| 1013 | */ |
| 1014 | char extras[GPS_NI_LONG_STRING_MAXLEN]; |
| 1015 | |
| 1016 | } GpsNiNotification; |
| 1017 | |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1018 | /** |
| 1019 | * Callback with NI notification. Can only be called from a thread created by |
| 1020 | * create_thread_cb. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 1021 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 1022 | typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification); |
| 1023 | |
| 1024 | /** GPS NI callback structure. */ |
| 1025 | typedef struct |
| 1026 | { |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 1027 | /** |
| 1028 | * Sends the notification request from HAL to GPSLocationProvider. |
| 1029 | */ |
| 1030 | gps_ni_notify_callback notify_cb; |
| 1031 | gps_create_thread create_thread_cb; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 1032 | } GpsNiCallbacks; |
| 1033 | |
| 1034 | /** |
| 1035 | * Extended interface for Network-initiated (NI) support. |
| 1036 | */ |
| 1037 | typedef struct |
| 1038 | { |
| 1039 | /** set to sizeof(GpsNiInterface) */ |
| 1040 | size_t size; |
| 1041 | |
| 1042 | /** Registers the callbacks for HAL to use. */ |
| 1043 | void (*init) (GpsNiCallbacks *callbacks); |
| 1044 | |
| 1045 | /** Sends a response to HAL. */ |
| 1046 | void (*respond) (int notif_id, GpsUserResponseType user_response); |
| 1047 | } GpsNiInterface; |
| 1048 | |
| 1049 | struct gps_device_t { |
| 1050 | struct hw_device_t common; |
| 1051 | |
| 1052 | /** |
| 1053 | * Set the provided lights to the provided values. |
| 1054 | * |
| 1055 | * Returns: 0 on succes, error code on failure. |
| 1056 | */ |
| 1057 | const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev); |
| 1058 | }; |
| 1059 | |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 1060 | #define AGPS_RIL_REQUEST_SETID_IMSI (1<<0L) |
| 1061 | #define AGPS_RIL_REQUEST_SETID_MSISDN (1<<1L) |
| 1062 | |
| 1063 | #define AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L) |
| 1064 | #define AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L) |
| 1065 | |
| 1066 | typedef void (*agps_ril_request_set_id)(uint32_t flags); |
| 1067 | typedef void (*agps_ril_request_ref_loc)(uint32_t flags); |
| 1068 | |
| 1069 | typedef struct { |
| 1070 | agps_ril_request_set_id request_setid; |
| 1071 | agps_ril_request_ref_loc request_refloc; |
| 1072 | gps_create_thread create_thread_cb; |
| 1073 | } AGpsRilCallbacks; |
| 1074 | |
| 1075 | /** Extended interface for AGPS_RIL support. */ |
| 1076 | typedef struct { |
| 1077 | /** set to sizeof(AGpsRilInterface) */ |
| 1078 | size_t size; |
| 1079 | /** |
| 1080 | * Opens the AGPS interface and provides the callback routines |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1081 | * to the implementation of this interface. |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 1082 | */ |
| 1083 | void (*init)( AGpsRilCallbacks* callbacks ); |
| 1084 | |
| 1085 | /** |
| 1086 | * Sets the reference location. |
| 1087 | */ |
| 1088 | void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct); |
| 1089 | /** |
| 1090 | * Sets the set ID. |
| 1091 | */ |
| 1092 | void (*set_set_id) (AGpsSetIDType type, const char* setid); |
| 1093 | |
| 1094 | /** |
| 1095 | * Send network initiated message. |
| 1096 | */ |
| 1097 | void (*ni_message) (uint8_t *msg, size_t len); |
Mike Lockwood | 455e83b | 2010-10-11 06:16:57 -0400 | [diff] [blame] | 1098 | |
| 1099 | /** |
| 1100 | * Notify GPS of network status changes. |
| 1101 | * These parameters match values in the android.net.NetworkInfo class. |
| 1102 | */ |
| 1103 | void (*update_network_state) (int connected, int type, int roaming, const char* extra_info); |
Kevin Tang | b82c2db | 2011-04-13 17:15:55 -0700 | [diff] [blame] | 1104 | |
| 1105 | /** |
| 1106 | * Notify GPS of network status changes. |
| 1107 | * These parameters match values in the android.net.NetworkInfo class. |
| 1108 | */ |
| 1109 | void (*update_network_availability) (int avaiable, const char* apn); |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame] | 1110 | } AGpsRilInterface; |
| 1111 | |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1112 | /** |
| 1113 | * GPS Geofence. |
| 1114 | * There are 3 states associated with a Geofence: Inside, Outside, Unknown. |
| 1115 | * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. |
| 1116 | * |
| 1117 | * An example state diagram with confidence level: 95% and Unknown time limit |
| 1118 | * set as 30 secs is shown below. (confidence level and Unknown time limit are |
| 1119 | * explained latter) |
| 1120 | * ____________________________ |
| 1121 | * | Unknown (30 secs) | |
| 1122 | * """""""""""""""""""""""""""" |
| 1123 | * ^ | | ^ |
| 1124 | * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN |
| 1125 | * | v v | |
| 1126 | * ________ EXITED _________ |
| 1127 | * | Inside | -----------> | Outside | |
| 1128 | * | | <----------- | | |
| 1129 | * """""""" ENTERED """"""""" |
| 1130 | * |
| 1131 | * Inside state: We are 95% confident that the user is inside the geofence. |
| 1132 | * Outside state: We are 95% confident that the user is outside the geofence |
| 1133 | * Unknown state: Rest of the time. |
| 1134 | * |
| 1135 | * The Unknown state is better explained with an example: |
| 1136 | * |
| 1137 | * __________ |
| 1138 | * | c| |
| 1139 | * | ___ | _______ |
| 1140 | * | |a| | | b | |
| 1141 | * | """ | """"""" |
| 1142 | * | | |
| 1143 | * """""""""" |
| 1144 | * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy |
| 1145 | * circle reported by the GPS subsystem. Now with regard to "b", the system is |
| 1146 | * confident that the user is outside. But with regard to "a" is not confident |
| 1147 | * whether it is inside or outside the geofence. If the accuracy remains the |
| 1148 | * same for a sufficient period of time, the UNCERTAIN transition would be |
| 1149 | * triggered with the state set to Unknown. If the accuracy improves later, an |
| 1150 | * appropriate transition should be triggered. This "sufficient period of time" |
| 1151 | * is defined by the parameter in the add_geofence_area API. |
| 1152 | * In other words, Unknown state can be interpreted as a state in which the |
| 1153 | * GPS subsystem isn't confident enough that the user is either inside or |
| 1154 | * outside the Geofence. It moves to Unknown state only after the expiry of the |
| 1155 | * timeout. |
| 1156 | * |
| 1157 | * The geofence callback needs to be triggered for the ENTERED and EXITED |
| 1158 | * transitions, when the GPS system is confident that the user has entered |
| 1159 | * (Inside state) or exited (Outside state) the Geofence. An implementation |
| 1160 | * which uses a value of 95% as the confidence is recommended. The callback |
| 1161 | * should be triggered only for the transitions requested by the |
| 1162 | * add_geofence_area call. |
| 1163 | * |
| 1164 | * Even though the diagram and explanation talks about states and transitions, |
| 1165 | * the callee is only interested in the transistions. The states are mentioned |
| 1166 | * here for illustrative purposes. |
| 1167 | * |
| 1168 | * Startup Scenario: When the device boots up, if an application adds geofences, |
| 1169 | * and then we get an accurate GPS location fix, it needs to trigger the |
| 1170 | * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. |
| 1171 | * By default, all the Geofences will be in the Unknown state. |
| 1172 | * |
| 1173 | * When the GPS system is unavailable, gps_geofence_status_callback should be |
| 1174 | * called to inform the upper layers of the same. Similarly, when it becomes |
| 1175 | * available the callback should be called. This is a global state while the |
| 1176 | * UNKNOWN transition described above is per geofence. |
| 1177 | * |
| 1178 | * An important aspect to note is that users of this API (framework), will use |
| 1179 | * other subsystems like wifi, sensors, cell to handle Unknown case and |
| 1180 | * hopefully provide a definitive state transition to the third party |
| 1181 | * application. GPS Geofence will just be a signal indicating what the GPS |
| 1182 | * subsystem knows about the Geofence. |
| 1183 | * |
| 1184 | */ |
| 1185 | #define GPS_GEOFENCE_ENTERED (1<<0L) |
| 1186 | #define GPS_GEOFENCE_EXITED (1<<1L) |
| 1187 | #define GPS_GEOFENCE_UNCERTAIN (1<<2L) |
| 1188 | |
| 1189 | #define GPS_GEOFENCE_UNAVAILABLE (1<<0L) |
| 1190 | #define GPS_GEOFENCE_AVAILABLE (1<<1L) |
| 1191 | |
Jaikumar Ganesh | 5824b40 | 2013-02-25 11:43:33 -0800 | [diff] [blame] | 1192 | #define GPS_GEOFENCE_OPERATION_SUCCESS 0 |
| 1193 | #define GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES -100 |
| 1194 | #define GPS_GEOFENCE_ERROR_ID_EXISTS -101 |
| 1195 | #define GPS_GEOFENCE_ERROR_ID_UNKNOWN -102 |
| 1196 | #define GPS_GEOFENCE_ERROR_INVALID_TRANSITION -103 |
| 1197 | #define GPS_GEOFENCE_ERROR_GENERIC -149 |
| 1198 | |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1199 | /** |
| 1200 | * The callback associated with the geofence. |
| 1201 | * Parameters: |
| 1202 | * geofence_id - The id associated with the add_geofence_area. |
| 1203 | * location - The current GPS location. |
| 1204 | * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED, |
| 1205 | * GPS_GEOFENCE_UNCERTAIN. |
| 1206 | * timestamp - Timestamp when the transition was detected. |
| 1207 | * |
| 1208 | * The callback should only be called when the caller is interested in that |
| 1209 | * particular transition. For instance, if the caller is interested only in |
| 1210 | * ENTERED transition, then the callback should NOT be called with the EXITED |
| 1211 | * transition. |
| 1212 | * |
| 1213 | * IMPORTANT: If a transition is triggered resulting in this callback, the GPS |
| 1214 | * subsystem will wake up the application processor, if its in suspend state. |
| 1215 | */ |
| 1216 | typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location, |
| 1217 | int32_t transition, GpsUtcTime timestamp); |
| 1218 | |
| 1219 | /** |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1220 | * The callback associated with the availability of the GPS system for geofencing |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1221 | * monitoring. If the GPS system determines that it cannot monitor geofences |
| 1222 | * because of lack of reliability or unavailability of the GPS signals, it will |
| 1223 | * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter. |
| 1224 | * |
| 1225 | * Parameters: |
| 1226 | * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE. |
| 1227 | * last_location - Last known location. |
| 1228 | */ |
| 1229 | typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location); |
| 1230 | |
Jaikumar Ganesh | 3e39c49 | 2013-03-29 11:56:36 -0700 | [diff] [blame] | 1231 | /** |
| 1232 | * The callback associated with the add_geofence call. |
| 1233 | * |
| 1234 | * Parameter: |
| 1235 | * geofence_id - Id of the geofence. |
| 1236 | * status - GPS_GEOFENCE_OPERATION_SUCCESS |
| 1237 | * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. |
| 1238 | * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists |
| 1239 | * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an |
| 1240 | * invalid transition |
| 1241 | * GPS_GEOFENCE_ERROR_GENERIC - for other errors. |
| 1242 | */ |
| 1243 | typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status); |
| 1244 | |
| 1245 | /** |
| 1246 | * The callback associated with the remove_geofence call. |
| 1247 | * |
| 1248 | * Parameter: |
| 1249 | * geofence_id - Id of the geofence. |
| 1250 | * status - GPS_GEOFENCE_OPERATION_SUCCESS |
| 1251 | * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id |
| 1252 | * GPS_GEOFENCE_ERROR_GENERIC for others. |
| 1253 | */ |
| 1254 | typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status); |
| 1255 | |
| 1256 | |
| 1257 | /** |
| 1258 | * The callback associated with the pause_geofence call. |
| 1259 | * |
| 1260 | * Parameter: |
| 1261 | * geofence_id - Id of the geofence. |
| 1262 | * status - GPS_GEOFENCE_OPERATION_SUCCESS |
| 1263 | * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id |
| 1264 | * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - |
| 1265 | * when monitor_transitions is invalid |
| 1266 | * GPS_GEOFENCE_ERROR_GENERIC for others. |
| 1267 | */ |
| 1268 | typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status); |
| 1269 | |
| 1270 | /** |
| 1271 | * The callback associated with the resume_geofence call. |
| 1272 | * |
| 1273 | * Parameter: |
| 1274 | * geofence_id - Id of the geofence. |
| 1275 | * status - GPS_GEOFENCE_OPERATION_SUCCESS |
| 1276 | * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id |
| 1277 | * GPS_GEOFENCE_ERROR_GENERIC for others. |
| 1278 | */ |
| 1279 | typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status); |
| 1280 | |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1281 | typedef struct { |
| 1282 | gps_geofence_transition_callback geofence_transition_callback; |
| 1283 | gps_geofence_status_callback geofence_status_callback; |
Jaikumar Ganesh | 3e39c49 | 2013-03-29 11:56:36 -0700 | [diff] [blame] | 1284 | gps_geofence_add_callback geofence_add_callback; |
| 1285 | gps_geofence_remove_callback geofence_remove_callback; |
| 1286 | gps_geofence_pause_callback geofence_pause_callback; |
| 1287 | gps_geofence_resume_callback geofence_resume_callback; |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1288 | gps_create_thread create_thread_cb; |
| 1289 | } GpsGeofenceCallbacks; |
| 1290 | |
| 1291 | /** Extended interface for GPS_Geofencing support */ |
| 1292 | typedef struct { |
| 1293 | /** set to sizeof(GpsGeofencingInterface) */ |
| 1294 | size_t size; |
| 1295 | |
| 1296 | /** |
| 1297 | * Opens the geofence interface and provides the callback routines |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1298 | * to the implementation of this interface. |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1299 | */ |
| 1300 | void (*init)( GpsGeofenceCallbacks* callbacks ); |
| 1301 | |
| 1302 | /** |
| 1303 | * Add a geofence area. This api currently supports circular geofences. |
| 1304 | * Parameters: |
| 1305 | * geofence_id - The id for the geofence. If a geofence with this id |
Jaikumar Ganesh | 5824b40 | 2013-02-25 11:43:33 -0800 | [diff] [blame] | 1306 | * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS) |
| 1307 | * should be returned. |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1308 | * latitude, longtitude, radius_meters - The lat, long and radius |
| 1309 | * (in meters) for the geofence |
| 1310 | * last_transition - The current state of the geofence. For example, if |
| 1311 | * the system already knows that the user is inside the geofence, |
| 1312 | * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it |
| 1313 | * will be GPS_GEOFENCE_UNCERTAIN. |
| 1314 | * monitor_transition - Which transitions to monitor. Bitwise OR of |
| 1315 | * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and |
| 1316 | * GPS_GEOFENCE_UNCERTAIN. |
| 1317 | * notification_responsiveness_ms - Defines the best-effort description |
| 1318 | * of how soon should the callback be called when the transition |
| 1319 | * associated with the Geofence is triggered. For instance, if set |
| 1320 | * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback |
| 1321 | * should be called 1000 milliseconds within entering the geofence. |
| 1322 | * This parameter is defined in milliseconds. |
| 1323 | * NOTE: This is not to be confused with the rate that the GPS is |
| 1324 | * polled at. It is acceptable to dynamically vary the rate of |
| 1325 | * sampling the GPS for power-saving reasons; thus the rate of |
| 1326 | * sampling may be faster or slower than this. |
| 1327 | * unknown_timer_ms - The time limit after which the UNCERTAIN transition |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1328 | * should be triggered. This parameter is defined in milliseconds. |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1329 | * See above for a detailed explanation. |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1330 | */ |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1331 | void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude, |
| 1332 | double radius_meters, int last_transition, int monitor_transitions, |
| 1333 | int notification_responsiveness_ms, int unknown_timer_ms); |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1334 | |
| 1335 | /** |
| 1336 | * Pause monitoring a particular geofence. |
| 1337 | * Parameters: |
| 1338 | * geofence_id - The id for the geofence. |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1339 | */ |
Jaikumar Ganesh | 3e39c49 | 2013-03-29 11:56:36 -0700 | [diff] [blame] | 1340 | void (*pause_geofence) (int32_t geofence_id); |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1341 | |
| 1342 | /** |
| 1343 | * Resume monitoring a particular geofence. |
| 1344 | * Parameters: |
| 1345 | * geofence_id - The id for the geofence. |
| 1346 | * monitor_transitions - Which transitions to monitor. Bitwise OR of |
| 1347 | * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and |
| 1348 | * GPS_GEOFENCE_UNCERTAIN. |
| 1349 | * This supersedes the value associated provided in the |
| 1350 | * add_geofence_area call. |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1351 | */ |
Jaikumar Ganesh | 3e39c49 | 2013-03-29 11:56:36 -0700 | [diff] [blame] | 1352 | void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1353 | |
| 1354 | /** |
| 1355 | * Remove a geofence area. After the function returns, no notifications |
| 1356 | * should be sent. |
| 1357 | * Parameter: |
| 1358 | * geofence_id - The id for the geofence. |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1359 | */ |
Jaikumar Ganesh | 3e39c49 | 2013-03-29 11:56:36 -0700 | [diff] [blame] | 1360 | void (*remove_geofence_area) (int32_t geofence_id); |
Jaikumar Ganesh | 052a20a | 2013-02-04 17:22:04 -0800 | [diff] [blame] | 1361 | } GpsGeofencingInterface; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1362 | |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1363 | /** |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1364 | * Legacy struct to represent an estimate of the GPS clock time. |
| 1365 | * Deprecated, to be removed in the next Android release. |
| 1366 | * Use GnssClock instead. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1367 | */ |
| 1368 | typedef struct { |
| 1369 | /** set to sizeof(GpsClock) */ |
| 1370 | size_t size; |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1371 | GpsClockFlags flags; |
| 1372 | int16_t leap_second; |
| 1373 | GpsClockType type; |
| 1374 | int64_t time_ns; |
| 1375 | double time_uncertainty_ns; |
| 1376 | int64_t full_bias_ns; |
| 1377 | double bias_ns; |
| 1378 | double bias_uncertainty_ns; |
| 1379 | double drift_nsps; |
| 1380 | double drift_uncertainty_nsps; |
| 1381 | } GpsClock; |
| 1382 | |
| 1383 | /** |
| 1384 | * Represents an estimate of the GPS clock time. |
| 1385 | */ |
| 1386 | typedef struct { |
| 1387 | /** set to sizeof(GnssClock) */ |
| 1388 | size_t size; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1389 | |
| 1390 | /** A set of flags indicating the validity of the fields in this data structure. */ |
| 1391 | GpsClockFlags flags; |
| 1392 | |
| 1393 | /** |
| 1394 | * Leap second data. |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1395 | * The sign of the value is defined by the following equation: |
| 1396 | * utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second * 1,000,000,000 |
| 1397 | * |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1398 | * If the data is available 'flags' must contain GPS_CLOCK_HAS_LEAP_SECOND. |
| 1399 | */ |
| 1400 | int16_t leap_second; |
| 1401 | |
| 1402 | /** |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1403 | * Indicates the type of time reported by the 'time_ns' field. |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1404 | * This is a mandatory field. |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1405 | */ |
| 1406 | GpsClockType type; |
| 1407 | |
| 1408 | /** |
| 1409 | * The GPS receiver internal clock value. This can be either the local hardware clock value |
| 1410 | * (GPS_CLOCK_TYPE_LOCAL_HW_TIME), or the current GPS time derived inside GPS receiver |
| 1411 | * (GPS_CLOCK_TYPE_GPS_TIME). The field 'type' defines the time reported. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1412 | * |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1413 | * For local hardware clock, this value is expected to be monotonically increasing during |
| 1414 | * the reporting session. The real GPS time can be derived by compensating the 'full bias' |
| 1415 | * (when it is available) from this value. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1416 | * |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1417 | * For GPS time, this value is expected to be the best estimation of current GPS time that GPS |
| 1418 | * receiver can achieve. Set the 'time uncertainty' appropriately when GPS time is specified. |
| 1419 | * |
| 1420 | * Sub-nanosecond accuracy can be provided by means of the 'bias' field. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1421 | * The value contains the 'time uncertainty' in it. |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1422 | * |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1423 | * This field is mandatory. |
| 1424 | * |
| 1425 | * For devices where GpsSystemInfo's year_of_hw is set to 2016+, it is |
| 1426 | * mandatory that it contains the value from the 'local hardware clock, and |
| 1427 | * thus GPS_CLOCK_TYPE_LOCAL_HW_TIME must be set in 'type' field. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1428 | */ |
| 1429 | int64_t time_ns; |
| 1430 | |
| 1431 | /** |
| 1432 | * 1-Sigma uncertainty associated with the clock's time in nanoseconds. |
| 1433 | * The uncertainty is represented as an absolute (single sided) value. |
| 1434 | * |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1435 | * If the data is available, 'flags' must contain |
| 1436 | * GPS_CLOCK_HAS_TIME_UNCERTAINTY. If GPS has computed a position fix, this |
| 1437 | * field is mandatory and must be populated. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1438 | */ |
| 1439 | double time_uncertainty_ns; |
| 1440 | |
| 1441 | /** |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1442 | * The difference between hardware clock ('time' field) inside GPS receiver and the true GPS |
| 1443 | * time since 0000Z, January 6, 1980, in nanoseconds. |
| 1444 | * This value is used if and only if GPS_CLOCK_TYPE_LOCAL_HW_TIME is set, and GPS receiver |
| 1445 | * has solved the clock for GPS time. |
| 1446 | * The caller is responsible for using the 'bias uncertainty' field for quality check. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1447 | * |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1448 | * The sign of the value is defined by the following equation: |
| 1449 | * true time (GPS time) = time_ns + (full_bias_ns + bias_ns) |
| 1450 | * |
| 1451 | * This value contains the 'bias uncertainty' in it. |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1452 | * If GPS has computed a position fix this field is mandatory and must be |
| 1453 | * populated. If the data is available 'flags' must contain |
| 1454 | * GPS_CLOCK_HAS_FULL_BIAS. |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1455 | */ |
| 1456 | int64_t full_bias_ns; |
| 1457 | |
| 1458 | /** |
| 1459 | * Sub-nanosecond bias. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1460 | * The value contains the 'bias uncertainty' in it. |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1461 | * |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1462 | * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS. If GPS |
| 1463 | * has computed a position fix, this field is mandatory and must be |
| 1464 | * populated. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1465 | */ |
| 1466 | double bias_ns; |
| 1467 | |
| 1468 | /** |
| 1469 | * 1-Sigma uncertainty associated with the clock's bias in nanoseconds. |
| 1470 | * The uncertainty is represented as an absolute (single sided) value. |
| 1471 | * |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1472 | * If the data is available 'flags' must contain |
| 1473 | * GPS_CLOCK_HAS_BIAS_UNCERTAINTY. If GPS has computed a position fix this |
| 1474 | * field is mandatory and must be populated. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1475 | */ |
| 1476 | double bias_uncertainty_ns; |
| 1477 | |
| 1478 | /** |
| 1479 | * The clock's drift in nanoseconds (per second). |
| 1480 | * A positive value means that the frequency is higher than the nominal frequency. |
| 1481 | * |
| 1482 | * The value contains the 'drift uncertainty' in it. |
| 1483 | * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT. |
destradaa | 00caa89 | 2015-04-09 18:41:46 -0700 | [diff] [blame] | 1484 | * |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1485 | * If GpsMeasurement's 'flags' field contains |
| 1486 | * GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE, it is encouraged that |
| 1487 | * this field is also provided. If GPS has computed a position fix this |
| 1488 | * field is mandatory and must be populated. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1489 | */ |
| 1490 | double drift_nsps; |
| 1491 | |
| 1492 | /** |
| 1493 | * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second). |
| 1494 | * The uncertainty is represented as an absolute (single sided) value. |
| 1495 | * |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1496 | * If the data is available 'flags' must contain |
| 1497 | * GPS_CLOCK_HAS_DRIFT_UNCERTAINTY. If GPS has computed a position fix this |
| 1498 | * field is mandatory and must be populated. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1499 | */ |
| 1500 | double drift_uncertainty_nsps; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1501 | |
| 1502 | /** |
| 1503 | * When the GPS_CLOCK_TYPE_LOCAL_HW_TIME is set, this field is mandatory. |
| 1504 | * |
| 1505 | * A "discontinuity" is meant to cover the case of a switch from one source |
| 1506 | * of clock to another. A single free-running crystal oscillator (XO) |
| 1507 | * should generally not have any discontinuities, and this can be set to 0. |
| 1508 | * If, however, the time_ns value (HW clock) is derived from a composite of |
| 1509 | * sources, that is not as smooth as a typical XO, then this value shall be |
| 1510 | * set to the time_ns value since which the time_ns has been derived from a |
| 1511 | * single, high quality clock (XO like, or better, that's typically used |
| 1512 | * during continuous GPS signal sampling.) |
| 1513 | * |
| 1514 | * It is expected, esp. during periods where there are few GNSS signals |
| 1515 | * available, that the HW clock be discontinuity-free as long as possible, |
| 1516 | * as this avoids the need to use (waste) a GPS measurement to fully |
| 1517 | * re-solve for the clock bias and drift. |
| 1518 | */ |
| 1519 | int64_t time_of_last_hw_clock_discontinuity_ns; |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1520 | } GnssClock; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1521 | |
| 1522 | /** |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1523 | * Legacy struct to represent a GPS Measurement, it contains raw and computed |
| 1524 | * information. |
| 1525 | * Deprecated, to be removed in the next Android release. |
| 1526 | * Use GnssMeasurement instead. |
| 1527 | */ |
| 1528 | typedef struct { |
| 1529 | /** set to sizeof(GpsMeasurement) */ |
| 1530 | size_t size; |
| 1531 | GpsMeasurementFlags flags; |
| 1532 | int8_t prn; |
| 1533 | double time_offset_ns; |
| 1534 | GpsMeasurementState state; |
| 1535 | int64_t received_gps_tow_ns; |
| 1536 | int64_t received_gps_tow_uncertainty_ns; |
| 1537 | double c_n0_dbhz; |
| 1538 | double pseudorange_rate_mps; |
| 1539 | double pseudorange_rate_uncertainty_mps; |
| 1540 | GpsAccumulatedDeltaRangeState accumulated_delta_range_state; |
| 1541 | double accumulated_delta_range_m; |
| 1542 | double accumulated_delta_range_uncertainty_m; |
| 1543 | double pseudorange_m; |
| 1544 | double pseudorange_uncertainty_m; |
| 1545 | double code_phase_chips; |
| 1546 | double code_phase_uncertainty_chips; |
| 1547 | float carrier_frequency_hz; |
| 1548 | int64_t carrier_cycles; |
| 1549 | double carrier_phase; |
| 1550 | double carrier_phase_uncertainty; |
| 1551 | GpsLossOfLock loss_of_lock; |
| 1552 | int32_t bit_number; |
| 1553 | int16_t time_from_last_bit_ms; |
| 1554 | double doppler_shift_hz; |
| 1555 | double doppler_shift_uncertainty_hz; |
| 1556 | GpsMultipathIndicator multipath_indicator; |
| 1557 | double snr_db; |
| 1558 | double elevation_deg; |
| 1559 | double elevation_uncertainty_deg; |
| 1560 | double azimuth_deg; |
| 1561 | double azimuth_uncertainty_deg; |
| 1562 | bool used_in_fix; |
| 1563 | } GpsMeasurement; |
| 1564 | |
| 1565 | /** |
| 1566 | * Represents a GNSS Measurement, it contains raw and computed information. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1567 | */ |
| 1568 | typedef struct { |
| 1569 | /** set to sizeof(GpsMeasurement) */ |
| 1570 | size_t size; |
| 1571 | |
| 1572 | /** A set of flags indicating the validity of the fields in this data structure. */ |
| 1573 | GpsMeasurementFlags flags; |
| 1574 | |
| 1575 | /** |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1576 | * Satellite vehicle ID number, as defined in GnssSvInfo::svid |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1577 | * This is a mandatory value. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1578 | */ |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1579 | int16_t svid; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1580 | |
| 1581 | /** |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1582 | * Time offset at which the measurement was taken in nanoseconds. |
| 1583 | * The reference receiver's time is specified by GpsData::clock::time_ns and should be |
| 1584 | * interpreted in the same way as indicated by GpsClock::type. |
| 1585 | * |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1586 | * The sign of time_offset_ns is given by the following equation: |
| 1587 | * measurement time = GpsClock::time_ns + time_offset_ns |
| 1588 | * |
| 1589 | * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy. |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1590 | * This is a mandatory value. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1591 | */ |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1592 | double time_offset_ns; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1593 | |
| 1594 | /** |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1595 | * Per satellite sync state. It represents the current sync state for the associated satellite. |
| 1596 | * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1597 | * |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1598 | * This is a mandatory value. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1599 | */ |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1600 | GpsMeasurementState state; |
| 1601 | |
| 1602 | /** |
| 1603 | * Received GPS Time-of-Week at the measurement time, in nanoseconds. |
| 1604 | * The value is relative to the beginning of the current GPS week. |
| 1605 | * |
Tsuwei Chen | a90cf19 | 2014-10-23 12:49:12 -0700 | [diff] [blame] | 1606 | * Given the highest sync state that can be achieved, per each satellite, valid range for |
| 1607 | * this field can be: |
| 1608 | * Searching : [ 0 ] : GPS_MEASUREMENT_STATE_UNKNOWN |
| 1609 | * C/A code lock : [ 0 1ms ] : GPS_MEASUREMENT_STATE_CODE_LOCK is set |
| 1610 | * Bit sync : [ 0 20ms ] : GPS_MEASUREMENT_STATE_BIT_SYNC is set |
| 1611 | * Subframe sync : [ 0 6s ] : GPS_MEASUREMENT_STATE_SUBFRAME_SYNC is set |
| 1612 | * TOW decoded : [ 0 1week ] : GPS_MEASUREMENT_STATE_TOW_DECODED is set |
| 1613 | * |
| 1614 | * However, if there is any ambiguity in integer millisecond, |
| 1615 | * GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field. |
destradaa | 00caa89 | 2015-04-09 18:41:46 -0700 | [diff] [blame] | 1616 | * |
| 1617 | * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN. |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1618 | */ |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1619 | int64_t received_gps_tow_ns; |
| 1620 | |
| 1621 | /** |
destradaa | 941c928 | 2014-07-21 18:13:42 -0700 | [diff] [blame] | 1622 | * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds. |
destradaa | 00caa89 | 2015-04-09 18:41:46 -0700 | [diff] [blame] | 1623 | * |
| 1624 | * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN. |
destradaa | 941c928 | 2014-07-21 18:13:42 -0700 | [diff] [blame] | 1625 | */ |
| 1626 | int64_t received_gps_tow_uncertainty_ns; |
| 1627 | |
| 1628 | /** |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1629 | * Carrier-to-noise density in dB-Hz, in the range [0, 63]. |
| 1630 | * It contains the measured C/N0 value for the signal at the antenna input. |
| 1631 | * |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1632 | * This is a mandatory value. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1633 | */ |
| 1634 | double c_n0_dbhz; |
| 1635 | |
| 1636 | /** |
| 1637 | * Pseudorange rate at the timestamp in m/s. |
destradaa | 357e622 | 2015-04-14 16:30:21 -0700 | [diff] [blame] | 1638 | * The correction of a given Pseudorange Rate value includes corrections for receiver and |
| 1639 | * satellite clock frequency errors. |
destradaa | 00caa89 | 2015-04-09 18:41:46 -0700 | [diff] [blame] | 1640 | * |
destradaa | 00caa89 | 2015-04-09 18:41:46 -0700 | [diff] [blame] | 1641 | * It is encouraged to provide the 'uncorrected' 'pseudorange rate', and provide GpsClock's |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1642 | * 'drift' field as well. When providing the uncorrected pseudorange rate, |
| 1643 | * do not apply the corrections described above. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1644 | * |
| 1645 | * The value includes the 'pseudorange rate uncertainty' in it. |
destradaa | 00caa89 | 2015-04-09 18:41:46 -0700 | [diff] [blame] | 1646 | * A positive 'uncorrected' value indicates that the SV is moving away from the receiver. |
| 1647 | * |
destradaa | 357e622 | 2015-04-14 16:30:21 -0700 | [diff] [blame] | 1648 | * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler |
destradaa | 00caa89 | 2015-04-09 18:41:46 -0700 | [diff] [blame] | 1649 | * shift' is given by the equation: |
destradaa | 357e622 | 2015-04-14 16:30:21 -0700 | [diff] [blame] | 1650 | * pseudorange rate = -k * doppler shift (where k is a constant) |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1651 | * |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1652 | * This field should be based on the signal energy doppler measurement. (See |
| 1653 | * also pseudorate_rate_carrier_mps for a similar field, based on carrier |
| 1654 | * phase changes.) |
| 1655 | * |
| 1656 | * This is a mandatory value. It is mandatory (and expected) that it |
| 1657 | * contains the 'uncorrected' reading, and |
| 1658 | * GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE must be set in 'flags' |
| 1659 | * field. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1660 | */ |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1661 | double pseudorange_rate_mps; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1662 | |
| 1663 | /** |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1664 | * 1-Sigma uncertainty of the pseudorange_rate_mps. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1665 | * The uncertainty is represented as an absolute (single sided) value. |
| 1666 | * |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1667 | * This is a mandatory value. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1668 | */ |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1669 | double pseudorange_rate_uncertainty_mps; |
| 1670 | |
| 1671 | /** |
| 1672 | * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip |
| 1673 | * (indicating loss of lock). |
| 1674 | * |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1675 | * This is a mandatory value. |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1676 | */ |
| 1677 | GpsAccumulatedDeltaRangeState accumulated_delta_range_state; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1678 | |
| 1679 | /** |
| 1680 | * Accumulated delta range since the last channel reset in meters. |
destradaa | 357e622 | 2015-04-14 16:30:21 -0700 | [diff] [blame] | 1681 | * A positive value indicates that the SV is moving away from the receiver. |
destradaa | 00caa89 | 2015-04-09 18:41:46 -0700 | [diff] [blame] | 1682 | * |
destradaa | 357e622 | 2015-04-14 16:30:21 -0700 | [diff] [blame] | 1683 | * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase' |
destradaa | 00caa89 | 2015-04-09 18:41:46 -0700 | [diff] [blame] | 1684 | * is given by the equation: |
destradaa | 357e622 | 2015-04-14 16:30:21 -0700 | [diff] [blame] | 1685 | * accumulated delta range = -k * carrier phase (where k is a constant) |
destradaa | 00caa89 | 2015-04-09 18:41:46 -0700 | [diff] [blame] | 1686 | * |
| 1687 | * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. |
| 1688 | * However, it is expected that the data is only accurate when: |
| 1689 | * 'accumulated delta range state' == GPS_ADR_STATE_VALID. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1690 | */ |
| 1691 | double accumulated_delta_range_m; |
| 1692 | |
| 1693 | /** |
| 1694 | * 1-Sigma uncertainty of the accumulated delta range in meters. |
destradaa | 00caa89 | 2015-04-09 18:41:46 -0700 | [diff] [blame] | 1695 | * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1696 | */ |
| 1697 | double accumulated_delta_range_uncertainty_m; |
| 1698 | |
| 1699 | /** |
| 1700 | * Best derived Pseudorange by the chip-set, in meters. |
| 1701 | * The value contains the 'pseudorange uncertainty' in it. |
| 1702 | * |
| 1703 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE. |
| 1704 | */ |
| 1705 | double pseudorange_m; |
| 1706 | |
| 1707 | /** |
| 1708 | * 1-Sigma uncertainty of the pseudorange in meters. |
| 1709 | * The value contains the 'pseudorange' and 'clock' uncertainty in it. |
| 1710 | * The uncertainty is represented as an absolute (single sided) value. |
| 1711 | * |
| 1712 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY. |
| 1713 | */ |
| 1714 | double pseudorange_uncertainty_m; |
| 1715 | |
| 1716 | /** |
| 1717 | * A fraction of the current C/A code cycle, in the range [0.0, 1023.0] |
| 1718 | * This value contains the time (in Chip units) since the last C/A code cycle (GPS Msec epoch). |
| 1719 | * |
| 1720 | * The reference frequency is given by the field 'carrier_frequency_hz'. |
| 1721 | * The value contains the 'code-phase uncertainty' in it. |
| 1722 | * |
| 1723 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE. |
| 1724 | */ |
| 1725 | double code_phase_chips; |
| 1726 | |
| 1727 | /** |
| 1728 | * 1-Sigma uncertainty of the code-phase, in a fraction of chips. |
| 1729 | * The uncertainty is represented as an absolute (single sided) value. |
| 1730 | * |
| 1731 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY. |
| 1732 | */ |
| 1733 | double code_phase_uncertainty_chips; |
| 1734 | |
| 1735 | /** |
| 1736 | * Carrier frequency at which codes and messages are modulated, it can be L1 or L2. |
| 1737 | * If the field is not set, the carrier frequency is assumed to be L1. |
| 1738 | * |
| 1739 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY. |
| 1740 | */ |
| 1741 | float carrier_frequency_hz; |
| 1742 | |
| 1743 | /** |
| 1744 | * The number of full carrier cycles between the satellite and the receiver. |
| 1745 | * The reference frequency is given by the field 'carrier_frequency_hz'. |
| 1746 | * |
| 1747 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_CYCLES. |
| 1748 | */ |
| 1749 | int64_t carrier_cycles; |
| 1750 | |
| 1751 | /** |
| 1752 | * The RF phase detected by the receiver, in the range [0.0, 1.0]. |
| 1753 | * This is usually the fractional part of the complete carrier phase measurement. |
| 1754 | * |
| 1755 | * The reference frequency is given by the field 'carrier_frequency_hz'. |
| 1756 | * The value contains the 'carrier-phase uncertainty' in it. |
| 1757 | * |
| 1758 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE. |
| 1759 | */ |
| 1760 | double carrier_phase; |
| 1761 | |
| 1762 | /** |
| 1763 | * 1-Sigma uncertainty of the carrier-phase. |
| 1764 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY. |
| 1765 | */ |
| 1766 | double carrier_phase_uncertainty; |
| 1767 | |
| 1768 | /** |
| 1769 | * An enumeration that indicates the 'loss of lock' state of the event. |
| 1770 | */ |
| 1771 | GpsLossOfLock loss_of_lock; |
| 1772 | |
| 1773 | /** |
| 1774 | * The number of GPS bits transmitted since Sat-Sun midnight (GPS week). |
| 1775 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_BIT_NUMBER. |
| 1776 | */ |
Tsuwei Chen | 167d31f | 2014-08-26 16:34:19 -0700 | [diff] [blame] | 1777 | int32_t bit_number; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1778 | |
| 1779 | /** |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1780 | * The elapsed time since the last received bit in milliseconds, in the range [0, 20] |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1781 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT. |
| 1782 | */ |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 1783 | int16_t time_from_last_bit_ms; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1784 | |
| 1785 | /** |
| 1786 | * Doppler shift in Hz. |
| 1787 | * A positive value indicates that the SV is moving toward the receiver. |
| 1788 | * |
| 1789 | * The reference frequency is given by the field 'carrier_frequency_hz'. |
| 1790 | * The value contains the 'doppler shift uncertainty' in it. |
| 1791 | * |
| 1792 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT. |
| 1793 | */ |
| 1794 | double doppler_shift_hz; |
| 1795 | |
| 1796 | /** |
| 1797 | * 1-Sigma uncertainty of the doppler shift in Hz. |
| 1798 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY. |
| 1799 | */ |
| 1800 | double doppler_shift_uncertainty_hz; |
| 1801 | |
| 1802 | /** |
| 1803 | * An enumeration that indicates the 'multipath' state of the event. |
| 1804 | */ |
| 1805 | GpsMultipathIndicator multipath_indicator; |
| 1806 | |
| 1807 | /** |
| 1808 | * Signal-to-noise ratio in dB. |
| 1809 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_SNR. |
| 1810 | */ |
| 1811 | double snr_db; |
| 1812 | |
| 1813 | /** |
| 1814 | * Elevation in degrees, the valid range is [-90, 90]. |
| 1815 | * The value contains the 'elevation uncertainty' in it. |
| 1816 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION. |
| 1817 | */ |
| 1818 | double elevation_deg; |
| 1819 | |
| 1820 | /** |
| 1821 | * 1-Sigma uncertainty of the elevation in degrees, the valid range is [0, 90]. |
| 1822 | * The uncertainty is represented as the absolute (single sided) value. |
| 1823 | * |
| 1824 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY. |
| 1825 | */ |
| 1826 | double elevation_uncertainty_deg; |
| 1827 | |
| 1828 | /** |
| 1829 | * Azimuth in degrees, in the range [0, 360). |
| 1830 | * The value contains the 'azimuth uncertainty' in it. |
| 1831 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH. |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1832 | */ |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1833 | double azimuth_deg; |
| 1834 | |
| 1835 | /** |
| 1836 | * 1-Sigma uncertainty of the azimuth in degrees, the valid range is [0, 180]. |
| 1837 | * The uncertainty is represented as an absolute (single sided) value. |
| 1838 | * |
| 1839 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY. |
| 1840 | */ |
| 1841 | double azimuth_uncertainty_deg; |
| 1842 | |
| 1843 | /** |
| 1844 | * Whether the GPS represented by the measurement was used for computing the most recent fix. |
| 1845 | * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_USED_IN_FIX. |
| 1846 | */ |
| 1847 | bool used_in_fix; |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1848 | |
| 1849 | /** |
| 1850 | * Pseudorange rate (based on carrier phase changes) at the timestamp in m/s. |
| 1851 | * |
| 1852 | * The correction of a given Pseudorange Rate value includes corrections for |
| 1853 | * receiver and satellite clock frequency errors. |
| 1854 | * |
| 1855 | * It is mandatory to provide the 'uncorrected' 'pseudorange rate' in this |
| 1856 | * field. (Do not apply the corrections described above.) |
| 1857 | * |
| 1858 | * The value includes the 'pseudorange rate (carrier) uncertainty' in it. A |
| 1859 | * positive 'uncorrected' value indicates that the SV is moving away from |
| 1860 | * the receiver. |
| 1861 | * |
| 1862 | * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the |
| 1863 | * sign of 'doppler shift' is given by the equation: |
| 1864 | * |
| 1865 | * pseudorange rate = -k * doppler shift (where k is a constant) |
| 1866 | * |
| 1867 | * This field must be based on changes in the carrier phase measurement. |
| 1868 | * (See pseudorange_rate_mps for a similar field, based on signal energy |
| 1869 | * doppler.) |
| 1870 | * |
| 1871 | * It is mandatory that this value be provided, when signals are |
| 1872 | * sufficiently strong, e.g. signals from a GPS simulator at >= 30 dB-Hz. |
| 1873 | */ |
| 1874 | double pseudorange_rate_carrier_mps; |
| 1875 | /** |
| 1876 | * 1-Sigma uncertainty of the pseudorange_rate_carrier_mps. |
| 1877 | * The uncertainty is represented as an absolute (single sided) value. |
| 1878 | * |
| 1879 | * This is a mandatory value when pseudorange_rate_carrier_mps is provided. |
| 1880 | */ |
| 1881 | double pseudorange_rate_carrier_uncertainty_mps; |
| 1882 | |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1883 | } GnssMeasurement; |
| 1884 | |
| 1885 | /** |
| 1886 | * Legacy struct to represents a reading of GPS measurements. |
| 1887 | * Deprecated, to be removed in the next Android release. |
| 1888 | * Use GnssData instead. |
| 1889 | */ |
| 1890 | typedef struct { |
| 1891 | /** set to sizeof(GpsData) */ |
| 1892 | size_t size; |
| 1893 | size_t measurement_count; |
| 1894 | GpsMeasurement measurements[GPS_MAX_MEASUREMENT]; |
| 1895 | |
| 1896 | /** The GPS clock time reading. */ |
| 1897 | GpsClock clock; |
| 1898 | } GpsData; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1899 | |
| 1900 | /** Represents a reading of GPS measurements. */ |
| 1901 | typedef struct { |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1902 | /** set to sizeof(GnssData) */ |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1903 | size_t size; |
| 1904 | |
| 1905 | /** Number of measurements. */ |
| 1906 | size_t measurement_count; |
| 1907 | |
| 1908 | /** The array of measurements. */ |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1909 | GnssMeasurement measurements[GNSS_MAX_MEASUREMENT]; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1910 | |
| 1911 | /** The GPS clock time reading. */ |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1912 | GnssClock clock; |
| 1913 | } GnssData; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1914 | |
| 1915 | /** |
| 1916 | * The callback for to report measurements from the HAL. |
| 1917 | * |
| 1918 | * Parameters: |
| 1919 | * data - A data structure containing the measurements. |
| 1920 | */ |
| 1921 | typedef void (*gps_measurement_callback) (GpsData* data); |
| 1922 | |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1923 | /** |
| 1924 | * The callback for to report measurements from the HAL. |
| 1925 | * |
| 1926 | * Parameters: |
| 1927 | * data - A data structure containing the measurements. |
| 1928 | */ |
| 1929 | typedef void (*gnss_measurement_callback) (GnssData* data); |
| 1930 | |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1931 | typedef struct { |
| 1932 | /** set to sizeof(GpsMeasurementCallbacks) */ |
| 1933 | size_t size; |
| 1934 | gps_measurement_callback measurement_callback; |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1935 | gnss_measurement_callback gnss_measurement_callback; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1936 | } GpsMeasurementCallbacks; |
| 1937 | |
| 1938 | #define GPS_MEASUREMENT_OPERATION_SUCCESS 0 |
| 1939 | #define GPS_MEASUREMENT_ERROR_ALREADY_INIT -100 |
| 1940 | #define GPS_MEASUREMENT_ERROR_GENERIC -101 |
| 1941 | |
| 1942 | /** |
| 1943 | * Extended interface for GPS Measurements support. |
| 1944 | */ |
| 1945 | typedef struct { |
| 1946 | /** Set to sizeof(GpsMeasurementInterface) */ |
| 1947 | size_t size; |
| 1948 | |
| 1949 | /** |
| 1950 | * Initializes the interface and registers the callback routines with the HAL. |
| 1951 | * After a successful call to 'init' the HAL must begin to provide updates at its own phase. |
| 1952 | * |
| 1953 | * Status: |
| 1954 | * GPS_MEASUREMENT_OPERATION_SUCCESS |
| 1955 | * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a |
| 1956 | * corresponding call to 'close' |
| 1957 | * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL |
| 1958 | * will not generate any updates upon returning this error code. |
| 1959 | */ |
| 1960 | int (*init) (GpsMeasurementCallbacks* callbacks); |
| 1961 | |
| 1962 | /** |
| 1963 | * Stops updates from the HAL, and unregisters the callback routines. |
| 1964 | * After a call to stop, the previously registered callbacks must be considered invalid by the |
| 1965 | * HAL. |
| 1966 | * If stop is invoked without a previous 'init', this function should perform no work. |
| 1967 | */ |
| 1968 | void (*close) (); |
| 1969 | |
| 1970 | } GpsMeasurementInterface; |
| 1971 | |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1972 | /** |
| 1973 | * Legacy struct to represents a GPS navigation message (or a fragment of it). |
| 1974 | * Deprecated, to be removed in the next Android release. |
| 1975 | * Use GnssNavigationMessage instead. |
| 1976 | */ |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1977 | typedef struct { |
| 1978 | /** set to sizeof(GpsNavigationMessage) */ |
| 1979 | size_t size; |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1980 | int8_t prn; |
| 1981 | GpsNavigationMessageType type; |
| 1982 | NavigationMessageStatus status; |
| 1983 | int16_t message_id; |
| 1984 | int16_t submessage_id; |
| 1985 | size_t data_length; |
| 1986 | uint8_t* data; |
| 1987 | } GpsNavigationMessage; |
| 1988 | |
| 1989 | /** Represents a GPS navigation message (or a fragment of it). */ |
| 1990 | typedef struct { |
| 1991 | /** set to sizeof(GnssNavigationMessage) */ |
| 1992 | size_t size; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1993 | |
| 1994 | /** |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 1995 | * This is a mandatory value. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1996 | */ |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 1997 | int16_t svid; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 1998 | |
| 1999 | /** |
| 2000 | * The type of message contained in the structure. |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 2001 | * This is a mandatory value. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 2002 | */ |
| 2003 | GpsNavigationMessageType type; |
| 2004 | |
| 2005 | /** |
Tsuwei Chen | a90cf19 | 2014-10-23 12:49:12 -0700 | [diff] [blame] | 2006 | * The status of the received navigation message. |
| 2007 | * No need to send any navigation message that contains words with parity error and cannot be |
| 2008 | * corrected. |
| 2009 | */ |
| 2010 | NavigationMessageStatus status; |
| 2011 | |
| 2012 | /** |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 2013 | * Message identifier. |
destradaa | 75843eb | 2014-07-17 14:04:50 -0700 | [diff] [blame] | 2014 | * It provides an index so the complete Navigation Message can be assembled. i.e. fo L1 C/A |
| 2015 | * subframe 4 and 5, this value corresponds to the 'frame id' of the navigation message. |
| 2016 | * Subframe 1, 2, 3 does not contain a 'frame id' and this value can be set to -1. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 2017 | */ |
| 2018 | int16_t message_id; |
| 2019 | |
| 2020 | /** |
| 2021 | * Sub-message identifier. |
| 2022 | * If required by the message 'type', this value contains a sub-index within the current |
| 2023 | * message (or frame) that is being transmitted. |
| 2024 | * i.e. for L1 C/A the submessage id corresponds to the sub-frame id of the navigation message. |
| 2025 | */ |
| 2026 | int16_t submessage_id; |
| 2027 | |
| 2028 | /** |
| 2029 | * The length of the data (in bytes) contained in the current message. |
| 2030 | * If this value is different from zero, 'data' must point to an array of the same size. |
destradaa | 69d5ea5 | 2014-07-31 16:34:09 -0700 | [diff] [blame] | 2031 | * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word). |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 2032 | * |
Lifu Tang | df0fcf7 | 2015-10-27 14:58:25 -0700 | [diff] [blame] | 2033 | * This is a mandatory value. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 2034 | */ |
| 2035 | size_t data_length; |
| 2036 | |
| 2037 | /** |
| 2038 | * The data of the reported GPS message. |
| 2039 | * The bytes (or words) specified using big endian format (MSB first). |
destradaa | 69d5ea5 | 2014-07-31 16:34:09 -0700 | [diff] [blame] | 2040 | * |
| 2041 | * For L1 C/A, each subframe contains 10 30-bit GPS words. Each GPS word (30 bits) should be |
| 2042 | * fitted into the last 30 bits in a 4-byte word (skip B31 and B32), with MSB first. |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 2043 | */ |
| 2044 | uint8_t* data; |
| 2045 | |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 2046 | } GnssNavigationMessage; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 2047 | |
| 2048 | /** |
| 2049 | * The callback to report an available fragment of a GPS navigation messages from the HAL. |
| 2050 | * |
| 2051 | * Parameters: |
| 2052 | * message - The GPS navigation submessage/subframe representation. |
| 2053 | */ |
| 2054 | typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message); |
| 2055 | |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 2056 | /** |
| 2057 | * The callback to report an available fragment of a GPS navigation messages from the HAL. |
| 2058 | * |
| 2059 | * Parameters: |
| 2060 | * message - The GPS navigation submessage/subframe representation. |
| 2061 | */ |
| 2062 | typedef void (*gnss_navigation_message_callback) (GnssNavigationMessage* message); |
| 2063 | |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 2064 | typedef struct { |
| 2065 | /** set to sizeof(GpsNavigationMessageCallbacks) */ |
| 2066 | size_t size; |
| 2067 | gps_navigation_message_callback navigation_message_callback; |
Lifu Tang | 7e33bb2 | 2016-02-07 18:09:30 -0800 | [diff] [blame^] | 2068 | gnss_navigation_message_callback gnss_navigation_message_callback; |
destradaa | 9f7c373 | 2014-04-29 10:50:22 -0700 | [diff] [blame] | 2069 | } GpsNavigationMessageCallbacks; |
| 2070 | |
| 2071 | #define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS 0 |
| 2072 | #define GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT -100 |
| 2073 | #define GPS_NAVIGATION_MESSAGE_ERROR_GENERIC -101 |
| 2074 | |
| 2075 | /** |
| 2076 | * Extended interface for GPS navigation message reporting support. |
| 2077 | */ |
| 2078 | typedef struct { |
| 2079 | /** Set to sizeof(GpsNavigationMessageInterface) */ |
| 2080 | size_t size; |
| 2081 | |
| 2082 | /** |
| 2083 | * Initializes the interface and registers the callback routines with the HAL. |
| 2084 | * After a successful call to 'init' the HAL must begin to provide updates as they become |
| 2085 | * available. |
| 2086 | * |
| 2087 | * Status: |
| 2088 | * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS |
| 2089 | * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered |
| 2090 | * without a corresponding call to 'close'. |
| 2091 | * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that |
| 2092 | * the HAL will not generate any updates upon returning this error code. |
| 2093 | */ |
| 2094 | int (*init) (GpsNavigationMessageCallbacks* callbacks); |
| 2095 | |
| 2096 | /** |
| 2097 | * Stops updates from the HAL, and unregisters the callback routines. |
| 2098 | * After a call to stop, the previously registered callbacks must be considered invalid by the |
| 2099 | * HAL. |
| 2100 | * If stop is invoked without a previous 'init', this function should perform no work. |
| 2101 | */ |
| 2102 | void (*close) (); |
| 2103 | |
| 2104 | } GpsNavigationMessageInterface; |
| 2105 | |
Tsuwei Chen | 167d31f | 2014-08-26 16:34:19 -0700 | [diff] [blame] | 2106 | /** |
| 2107 | * Interface for passing GNSS configuration contents from platform to HAL. |
| 2108 | */ |
| 2109 | typedef struct { |
| 2110 | /** Set to sizeof(GnssConfigurationInterface) */ |
| 2111 | size_t size; |
| 2112 | |
| 2113 | /** |
| 2114 | * Deliver GNSS configuration contents to HAL. |
| 2115 | * Parameters: |
| 2116 | * config_data - a pointer to a char array which holds what usually is expected from |
| 2117 | file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'. |
| 2118 | * length - total number of UTF8 characters in configuraiton data. |
| 2119 | * |
| 2120 | * IMPORTANT: |
| 2121 | * GPS HAL should expect this function can be called multiple times. And it may be |
| 2122 | * called even when GpsLocationProvider is already constructed and enabled. GPS HAL |
| 2123 | * should maintain the existing requests for various callback regardless the change |
| 2124 | * in configuration data. |
| 2125 | */ |
| 2126 | void (*configuration_update) (const char* config_data, int32_t length); |
| 2127 | } GnssConfigurationInterface; |
| 2128 | |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 2129 | __END_DECLS |
| 2130 | |
| 2131 | #endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */ |
| 2132 | |