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