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