Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | package android.hardware.gnss@1.0; |
| 18 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 19 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 20 | * The interface is required for the HAL to communicate certain information |
| 21 | * like status and location info back to the platform, the platform implements |
| 22 | * the interfaces and passes a handle to the HAL. |
| 23 | */ |
| 24 | interface IGnssCallback { |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 25 | /** Flags for the gnssSetCapabilities callback. */ |
Hridya Valsaraju | 529331c | 2016-11-22 08:17:23 -0800 | [diff] [blame] | 26 | @export(name="", value_prefix="GPS_CAPABILITY_") |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 27 | enum Capabilities : uint32_t { |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 28 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 29 | * GNSS HAL schedules fixes for RECURRENCE_PERIODIC mode. |
| 30 | * If this is not set, then the framework will use 1000ms for |
| 31 | * minInterval and will call start() and stop() to schedule the GNSS. |
| 32 | */ |
gomo | c3d9278 | 2017-01-11 14:04:21 -0800 | [diff] [blame] | 33 | SCHEDULING = 1 << 0, |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 34 | /** GNSS supports MS-Based AGNSS mode */ |
gomo | c3d9278 | 2017-01-11 14:04:21 -0800 | [diff] [blame] | 35 | MSB = 1 << 1, |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 36 | /** GNSS supports MS-Assisted AGNSS mode */ |
gomo | c3d9278 | 2017-01-11 14:04:21 -0800 | [diff] [blame] | 37 | MSA = 1 << 2, |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 38 | /** GNSS supports single-shot fixes */ |
gomo | c3d9278 | 2017-01-11 14:04:21 -0800 | [diff] [blame] | 39 | SINGLE_SHOT = 1 << 3, |
Neil Fuller | 379ee87 | 2023-01-19 13:52:00 +0000 | [diff] [blame] | 40 | /** |
| 41 | * The platform periodically injects time to GNSS in addition to |
| 42 | * on-demand and occasional time updates. |
| 43 | * |
| 44 | * Note: The naming of "on demand" should be "periodic" instead. This |
| 45 | * is the result of a historic implementation bug, b/73893222. |
| 46 | */ |
gomo | c3d9278 | 2017-01-11 14:04:21 -0800 | [diff] [blame] | 47 | ON_DEMAND_TIME = 1 << 4, |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 48 | /** GNSS supports Geofencing */ |
gomo | c3d9278 | 2017-01-11 14:04:21 -0800 | [diff] [blame] | 49 | GEOFENCING = 1 << 5, |
| 50 | /** GNSS supports Measurements for at least GPS. */ |
| 51 | MEASUREMENTS = 1 << 6, |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 52 | /** GNSS supports Navigation Messages */ |
gomo | c3d9278 | 2017-01-11 14:04:21 -0800 | [diff] [blame] | 53 | NAV_MESSAGES = 1 << 7 |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 56 | /** GNSS status event values. */ |
Hridya Valsaraju | 529331c | 2016-11-22 08:17:23 -0800 | [diff] [blame] | 57 | @export(name="", value_prefix="GPS_STATUS_") |
Hridya Valsaraju | 97ecaa0 | 2016-11-02 10:20:07 -0700 | [diff] [blame] | 58 | enum GnssStatusValue : uint8_t { |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 59 | /** GNSS status unknown. */ |
Hridya Valsaraju | 97ecaa0 | 2016-11-02 10:20:07 -0700 | [diff] [blame] | 60 | NONE = 0, |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 61 | /** GNSS has begun navigating. */ |
| 62 | SESSION_BEGIN = 1, |
| 63 | /** GNSS has stopped navigating. */ |
| 64 | SESSION_END = 2, |
| 65 | /** GNSS has powered on but is not navigating. */ |
| 66 | ENGINE_ON = 3, |
| 67 | /** GNSS is powered off. */ |
| 68 | ENGINE_OFF = 4 |
| 69 | }; |
| 70 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 71 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 72 | * Flags that indicate information about the satellite |
| 73 | */ |
Hridya Valsaraju | 529331c | 2016-11-22 08:17:23 -0800 | [diff] [blame] | 74 | @export(name="", value_prefix="GNSS_SV_FLAGS_") |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 75 | enum GnssSvFlags : uint8_t { |
gomo | c3d9278 | 2017-01-11 14:04:21 -0800 | [diff] [blame] | 76 | NONE = 0, |
| 77 | HAS_EPHEMERIS_DATA = 1 << 0, |
| 78 | HAS_ALMANAC_DATA = 1 << 1, |
| 79 | USED_IN_FIX = 1 << 2, |
| 80 | HAS_CARRIER_FREQUENCY = 1 << 3 |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | struct GnssSvInfo { |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 84 | /** |
Wyatt Riley | 0093415 | 2017-10-19 10:59:24 -0700 | [diff] [blame] | 85 | * Pseudo-random or satellite ID number for the satellite, a.k.a. Space Vehicle (SV), or |
| 86 | * FCN/OSN number for Glonass. The distinction is made by looking at constellation field. |
| 87 | * Values must be in the range of: |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 88 | * |
| 89 | * - GNSS: 1-32 |
| 90 | * - SBAS: 120-151, 183-192 |
| 91 | * - GLONASS: 1-24, the orbital slot number (OSN), if known. Or, if not: |
| 92 | * 93-106, the frequency channel number (FCN) (-7 to +6) offset by |
| 93 | * + 100 |
| 94 | * i.e. report an FCN of -7 as 93, FCN of 0 as 100, and FCN of +6 |
| 95 | * as 106. |
| 96 | * - QZSS: 193-200 |
| 97 | * - Galileo: 1-36 |
| 98 | * - Beidou: 1-37 |
Yu-Han Yang | 200f881 | 2020-01-14 11:04:48 -0800 | [diff] [blame] | 99 | * - IRNSS: 1-14 |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 100 | */ |
| 101 | int16_t svid; |
| 102 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 103 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 104 | * Defines the constellation of the given SV. |
| 105 | */ |
| 106 | GnssConstellationType constellation; |
| 107 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 108 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 109 | * Carrier-to-noise density in dB-Hz, typically in the range [0, 63]. |
| 110 | * It contains the measured C/N0 value for the signal at the antenna port. |
| 111 | * |
| 112 | * This is a mandatory value. |
| 113 | */ |
| 114 | float cN0Dbhz; |
| 115 | |
| 116 | /** Elevation of SV in degrees. */ |
| 117 | float elevationDegrees; |
| 118 | |
| 119 | /** Azimuth of SV in degrees. */ |
| 120 | float azimuthDegrees; |
| 121 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 122 | /** |
gomo | c3d9278 | 2017-01-11 14:04:21 -0800 | [diff] [blame] | 123 | * Carrier frequency of the signal tracked, for example it can be the |
gomo | d567a99 | 2017-01-20 00:00:42 -0800 | [diff] [blame] | 124 | * GPS central frequency for L1 = 1575.45 MHz, or L2 = 1227.60 MHz, L5 = |
Yu-Han Yang | 2cf6611 | 2018-11-06 11:20:59 -0800 | [diff] [blame] | 125 | * 1176.45 MHz, varying GLO channels, etc. If the field is zero, it is |
| 126 | * the primary common use central frequency, e.g. L1 = 1575.45 MHz for |
| 127 | * GPS. |
gomo | d567a99 | 2017-01-20 00:00:42 -0800 | [diff] [blame] | 128 | * |
| 129 | * For an L1, L5 receiver tracking a satellite on L1 and L5 at the same |
| 130 | * time, two GnssSvInfo structs must be reported for this same |
| 131 | * satellite, in one of the structs, all the values related |
| 132 | * to L1 must be filled, and in the other all of the values related to |
| 133 | * L5 must be filled. |
gomo | c3d9278 | 2017-01-11 14:04:21 -0800 | [diff] [blame] | 134 | * |
Yu-Han Yang | 2cf6611 | 2018-11-06 11:20:59 -0800 | [diff] [blame] | 135 | * If the data is available, svFlag must contain HAS_CARRIER_FREQUENCY. |
gomo | c3d9278 | 2017-01-11 14:04:21 -0800 | [diff] [blame] | 136 | */ |
| 137 | float carrierFrequencyHz; |
| 138 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 139 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 140 | * Contains additional data about the given SV. |
| 141 | */ |
Yifan Hong | 35e2aac | 2016-12-05 12:35:05 -0800 | [diff] [blame] | 142 | bitfield<GnssSvFlags> svFlag; |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 143 | }; |
| 144 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 145 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 146 | * Represents SV status. |
| 147 | */ |
| 148 | struct GnssSvStatus { |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 149 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 150 | * Number of GNSS SVs currently visible, refers to the SVs stored in sv_list |
| 151 | */ |
Hridya Valsaraju | 97ecaa0 | 2016-11-02 10:20:07 -0700 | [diff] [blame] | 152 | uint32_t numSvs; |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 153 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 154 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 155 | * Pointer to an array of SVs information for all GNSS constellations, |
| 156 | * except GNSS, which is reported using svList |
| 157 | */ |
Hridya Valsaraju | 97ecaa0 | 2016-11-02 10:20:07 -0700 | [diff] [blame] | 158 | GnssSvInfo[GnssMax:SVS_COUNT] gnssSvList; |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 159 | |
| 160 | }; |
| 161 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 162 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 163 | * Called when a GNSS location is available. |
| 164 | * |
| 165 | * @param location Location information from HAL. |
| 166 | */ |
| 167 | gnssLocationCb(GnssLocation location); |
| 168 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 169 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 170 | * Called to communicate the status of the GNSS engine. |
| 171 | * |
| 172 | * @param status Status information from HAL. |
| 173 | */ |
| 174 | gnssStatusCb(GnssStatusValue status); |
| 175 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 176 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 177 | * @param svInfo SV status information from HAL. |
| 178 | */ |
| 179 | gnssSvStatusCb(GnssSvStatus svInfo); |
| 180 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 181 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 182 | * Called when NMEA data is available. |
| 183 | * Callback for reporting NMEA sentences. |
| 184 | * |
| 185 | * @param timestamp Marks the instance of reporting. |
| 186 | * @param nmea Follows standard NMEA 0183. Each sentence begins with a '$' |
| 187 | * and ends with a carriage return/line feed sequence and can be no longer |
| 188 | * than 80 characters of visible text (plus the line terminators). The data |
| 189 | * is contained within this single line with data items separated by commas. |
| 190 | * The data itself is just ascii text and may extend over multiple sentences |
| 191 | * in certain specialized instances but is normally fully contained in one |
| 192 | * variable length sentence. The data may vary in the amount of precision |
| 193 | * contained in the message. For example time might be indicated to decimal |
| 194 | * parts of a second or location may be shown with 3 or even 4 digits after |
| 195 | * the decimal point. Programs that read the data must only use the commas |
| 196 | * to determine the field boundaries and not depend on column positions. |
| 197 | * There is a provision for a checksum at the end of each sentence which may |
| 198 | * or may not be checked by the unit that reads the data. The checksum field |
| 199 | * consists of a '*' and two hex digits representing an 8 bit exclusive OR |
| 200 | * of all characters between, but not including, the '$' and '*'. |
| 201 | */ |
| 202 | gnssNmeaCb(GnssUtcTime timestamp, string nmea); |
| 203 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 204 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 205 | * Callback to inform framework of the GNSS engine's capabilities. |
| 206 | * |
| 207 | * @param capabilities Capability parameter is a bit field of |
| 208 | * the Capabilities enum. |
| 209 | */ |
Yifan Hong | 7037fdb | 2016-12-05 17:16:09 -0800 | [diff] [blame] | 210 | gnssSetCapabilitesCb(bitfield<Capabilities> capabilities); |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 211 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 212 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 213 | * Callback utility for acquiring the GNSS wakelock. This can be used to prevent |
| 214 | * the CPU from suspending while handling GNSS events. |
| 215 | */ |
| 216 | gnssAcquireWakelockCb(); |
| 217 | |
| 218 | /** Callback utility for releasing the GNSS wakelock. */ |
| 219 | gnssReleaseWakelockCb(); |
| 220 | |
| 221 | /** Callback for requesting NTP time */ |
| 222 | gnssRequestTimeCb(); |
| 223 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 224 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 225 | * Provides information about how new the underlying GPS/GNSS hardware and |
| 226 | * software is. |
| 227 | * |
| 228 | * This information will be available for Android Test Applications. If a GNSS |
| 229 | * HAL does not provide this information, it will be considered "2015 or |
| 230 | * earlier". |
| 231 | * |
| 232 | * If a GNSS HAL does provide this information, then newer years will need to |
| 233 | * meet newer CTS standards. E.g. if the date are 2016 or above, then N+ level |
| 234 | * GnssMeasurement support will be verified. |
| 235 | */ |
| 236 | struct GnssSystemInfo{ |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 237 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 238 | * year in which the last update was made to the underlying hardware/firmware |
| 239 | * used to capture GNSS signals, e.g. 2016 |
| 240 | */ |
| 241 | uint16_t yearOfHw; |
| 242 | }; |
| 243 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 244 | /** |
Hridya Valsaraju | e596a71 | 2016-09-22 14:07:22 -0700 | [diff] [blame] | 245 | * Callback to inform framework of the engine's hardware version information. |
| 246 | * |
| 247 | * @param info GnssSystemInfo about the GPS/GNSS hardware. |
| 248 | */ |
| 249 | gnssSetSystemInfoCb(GnssSystemInfo info); |
| 250 | }; |