blob: 9685942b143d556cef06617ef34895a504e3ea05 [file] [log] [blame]
Hridya Valsarajue596a712016-09-22 14:07:22 -07001/*
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
17package android.hardware.gnss@1.0;
18
19/* The callback interface to report measurements from the HAL. */
20interface IGnssMeasurementCallback {
21 /*
22 * Flags to indicate what fields in GnssClock are valid.
23 */
24 enum GnssClockFlags : uint16_t {
25 /** A valid 'leap second' is stored in the data structure. */
26 HAS_LEAP_SECOND = 1 << 0,
27 /** A valid 'time uncertainty' is stored in the data structure. */
28 HAS_TIME_UNCERTAINTY = 1 << 1,
29 /** A valid 'full bias' is stored in the data structure. */
30 HAS_FULL_BIAS = 1 << 2,
31 /** A valid 'bias' is stored in the data structure. */
32 HAS_BIAS = 1 << 3,
33 /** A valid 'bias uncertainty' is stored in the data structure. */
34 HAS_BIAS_UNCERTAINTY = 1 << 4,
35 /** A valid 'drift' is stored in the data structure. */
36 HAS_DRIFT = 1 << 5,
37 /** A valid 'drift uncertainty' is stored in the data structure. */
38 HAS_DRIFT_UNCERTAINTY = 1 << 6
39 };
40
41 /*
42 * Flags to indicate what fields in GnssMeasurement are valid.
43 */
44 enum GnssMeasurementFlags : uint32_t {
45 /** A valid 'snr' is stored in the data structure. */
46 HAS_SNR = 1 << 0,
47 /** A valid 'carrier frequency' is stored in the data structure. */
48 HAS_CARRIER_FREQUENCY = 1 << 9,
49 /** A valid 'carrier cycles' is stored in the data structure. */
50 HAS_CARRIER_CYCLES = 1 << 10,
51 /** A valid 'carrier phase' is stored in the data structure. */
52 HAS_CARRIER_PHASE = 1 << 11,
53 /** A valid 'carrier phase uncertainty' is stored in the data structure. */
54 HAS_CARRIER_PHASE_UNCERTAINTY = 1 << 12
55 };
56
57 /*
58 * Enumeration of available values for the GNSS Measurement's multipath
59 * indicator.
60 */
61 enum GnssMultipathIndicator : uint8_t {
62 /** The indicator is not available or unknown. */
63 INDICATOR_UNKNOWN = 0,
64 /** The measurement is indicated to be affected by multipath. */
65 INDICATOR_PRESENT = 1,
66 /** The measurement is indicated to be not affected by multipath. */
67 INDICATIOR_NOT_PRESENT = 2
68 };
69
70 /*
71 * Flags indicating the GNSS measurement state.
72 *
73 * The expected behavior here is for GNSS HAL to set all the flags that applies.
74 * For example, if the state for a satellite is only C/A code locked and bit
75 * synchronized, and there is still millisecond ambiguity, the state must be
76 * set as:
77 *
78 * STATE_CODE_LOCK | STATE_BIT_SYNC | STATE_MSEC_AMBIGUOUS
79 *
80 * If GNSS is still searching for a satellite, the corresponding state must be
81 * set to STATE_UNKNOWN(0).
82 */
83 enum GnssMeasurementState : uint32_t {
84 STATE_UNKNOWN = 0,
85 STATE_CODE_LOCK = 1 << 0,
86 STATE_BIT_SYNC = 1 << 1,
87 STATE_SUBFRAME_SYNC = 1 << 2,
88 STATE_TOW_DECODED = 1 << 3,
89 STATE_MSEC_AMBIGUOUS = 1 << 4,
90 STATE_SYMBOL_SYNC = 1 << 5,
91 STATE_GLO_STRING_SYNC = 1 << 6,
92 STATE_GLO_TOD_DECODED = 1 << 7,
93 STATE_BDS_D2_BIT_SYNC = 1 << 8,
94 STATE_BDS_D2_SUBFRAME_SYNC = 1 << 9,
95 STATE_GAL_E1BC_CODE_LOCK = 1 << 10,
96 STATE_GAL_E1C_2ND_CODE_LOCK = 1 << 11,
97 STATE_GAL_E1B_PAGE_SYNC = 1 << 12,
98 STATE_SBAS_SYNC = 1 << 13
99 };
100
101 /*
102 * Flags indicating the Accumulated Delta Range's states.
103 */
104 enum GnssAccumulatedDeltaRangeState : uint16_t {
105 ADR_STATE_UNKNOWN = 0,
106 ADR_STATE_VALID = 1 << 0,
107 ADR_STATE_RESET = 1 << 1,
108 ADR_STATE_CYCLE_SLIP = 1 << 2,
109 };
110
111 /*
112 * Represents an estimate of the GNSS clock time.
113 */
114 struct GnssClock {
115 /*
116 * A set of flags indicating the validity of the fields in this data
117 * structure.
118 */
Yifan Hong7037fdb2016-12-05 17:16:09 -0800119 bitfield<GnssClockFlags> gnssClockFlags;
Hridya Valsarajue596a712016-09-22 14:07:22 -0700120
121 /*
122 * Leap second data.
123 * The sign of the value is defined by the following equation:
124 * utcTimeNs = timeNs - (fullBiasNs + biasNs) - leapSecond *
125 * 1,000,000,000
126 *
127 * If this data is available, gnssClockFlags must contain
128 * HAS_LEAP_SECOND.
129 */
130 int16_t leapSecond;
131
132 /*
133 * The GNSS receiver internal clock value. This is the local hardware clock
134 * value.
135 *
136 * For local hardware clock, this value is expected to be monotonically
137 * increasing while the hardware clock remains powered on. (For the case of a
138 * HW clock that is not continuously on, see the
139 * hwClockDiscontinuityCount field). The receiver's estimate of GNSS time
140 * can be derived by subtracting the sum of fullBiasNs and biasNs (when
141 * available) from this value.
142 *
143 * This GNSS time must be the best estimate of current GNSS time
144 * that GNSS receiver can achieve.
145 *
146 * Sub-nanosecond accuracy can be provided by means of the 'biasNs' field.
147 * The value contains the timeUncertaintyNs in it.
148 *
149 * This field is mandatory.
150 */
151 int64_t timeNs;
152
153 /*
154 * 1-Sigma uncertainty associated with the clock's time in nanoseconds.
155 * The uncertainty is represented as an absolute (single sided) value.
156 *
157 * If the data is available, gnssClockFlags must contain
158 * HAS_TIME_UNCERTAINTY. Ths value is ideally zero, as the time
159 * 'latched' by timeNs is defined as the reference clock vs. which all
160 * other times (and corresponding uncertainties) are measured.
161 */
162 double timeUncertaintyNs;
163
164 /*
165 * The difference between hardware clock ('time' field) inside GNSS receiver
166 * and the true GNSS time since 0000Z, January 6, 1980, in nanoseconds.
167 *
168 * The sign of the value is defined by the following equation:
169 * local estimate of GNSS time = timeNs - (fullBiasNs + biasNs)
170 *
171 * This value is mandatory if the receiver has estimated GNSS time. If the
172 * computed time is for a non-GNSS constellation, the time offset of that
173 * constellation to GNSS has to be applied to fill this value. The error
174 * estimate for the sum of this and the biasNs is the biasUncertaintyNs,
175 * and the caller is responsible for using this uncertainty (it can be very
176 * large before the GNSS time has been solved for.) If the data is available
177 * gnssClockFlags must contain HAS_FULL_BIAS.
178 */
179 int64_t fullBiasNs;
180
181 /*
182 * Sub-nanosecond bias.
183 * The error estimate for the sum of this and the fullBiasNs is the
184 * biasUncertaintyNs.
185 *
186 * If the data is available gnssClockFlags must contain HAS_BIAS. If GNSS
187 * has computed a position fix. This value is mandatory if the receiver has
188 * estimated GNSS time.
189 */
190 double biasNs;
191
192 /*
193 * 1-Sigma uncertainty associated with the local estimate of GNSS time (clock
194 * bias) in nanoseconds. The uncertainty is represented as an absolute
195 * (single sided) value.
196 *
197 * If the data is available gnssClockFlags must contain
198 * HAS_BIAS_UNCERTAINTY. This value is mandatory if the receiver
199 * has estimated GNSS time.
200 */
201 double biasUncertaintyNs;
202
203 /*
204 * The clock's drift in nanoseconds (per second).
205 *
206 * A positive value means that the frequency is higher than the nominal
207 * frequency, and that the (fullBiasNs + biasNs) is growing more positive
208 * over time.
209 *
210 * The value contains the 'drift uncertainty' in it.
211 * If the data is available gnssClockFlags must contain HAS_DRIFT.
212 *
213 * This value is mandatory if the receiver has estimated GNSS time.
214 */
215 double driftNsps;
216
217 /*
218 * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per
219 * second).
220 * The uncertainty is represented as an absolute (single sided) value.
221 *
222 * If the data is available gnssClockFlags must contain
223 * HAS_DRIFT_UNCERTAINTY. If GNSS has computed a position fix this
224 * field is mandatory and must be populated.
225 */
226 double driftUncertaintyNsps;
227
228 /*
229 * When there are any discontinuities in the HW clock, this field is
230 * mandatory.
231 *
232 * A "discontinuity" is meant to cover the case of a switch from one source
233 * of clock to another. A single free-running crystal oscillator (XO)
234 * will generally not have any discontinuities, and this can be set and
235 * left at 0.
236 *
237 * If, however, the timeNs value (HW clock) is derived from a composite of
238 * sources, that is not as smooth as a typical XO, or is otherwise stopped &
239 * restarted, then this value shall be incremented each time a discontinuity
240 * occurs. (E.g. this value can start at zero at device boot-up and
241 * increment each time there is a change in clock continuity. In the
242 * unlikely event that this value reaches full scale, rollover (not
243 * clamping) is required, such that this value continues to change, during
244 * subsequent discontinuity events.)
245 *
246 * While this number stays the same, between GnssClock reports, it can be
247 * safely assumed that the timeNs value has been running continuously, e.g.
248 * derived from a single, high quality clock (XO like, or better, that is
249 * typically used during continuous GNSS signal sampling.)
250 *
251 * It is expected, esp. during periods where there are few GNSS signals
252 * available, that the HW clock be discontinuity-free as long as possible,
253 * as this avoids the need to use (waste) a GNSS measurement to fully
254 * re-solve for the GNSS clock bias and drift, when using the accompanying
255 * measurements, from consecutive GnssData reports.
256 */
257 uint32_t hwClockDiscontinuityCount;
258
259 };
260
261 /*
262 * Represents a GNSS Measurement, it contains raw and computed information.
263 *
264 * All signal measurement information (e.g. svTime,
265 * pseudorangeRate, multipathIndicator) reported in this struct must be
266 * based on GNSS signal measurements only. You must not synthesize measurements
267 * by calculating or reporting expected measurements based on known or estimated
268 * position, velocity, or time.
269 */
270 struct GnssMeasurement{
271 /*
272 * A set of flags indicating the validity of the fields in this data
273 * structure.
274 */
Yifan Hong7037fdb2016-12-05 17:16:09 -0800275 bitfield<GnssMeasurementFlags> flags;
Hridya Valsarajue596a712016-09-22 14:07:22 -0700276
277 /*
278 * Satellite vehicle ID number, as defined in GnssSvInfo::svid
279 * This is a mandatory value.
280 */
281 int16_t svid;
282
283 /*
284 * Defines the constellation of the given SV.
285 */
286 GnssConstellationType constellation;
287
288 /*
289 * Time offset at which the measurement was taken in nanoseconds.
290 * The reference receiver's time is specified by GnssData::clock::timeNs.
291 *
292 * The sign of timeOffsetNs is given by the following equation:
293 * measurement time = GnssClock::timeNs + timeOffsetNs
294 *
295 * It provides an individual time-stamp for the measurement, and allows
296 * sub-nanosecond accuracy.
297 * This is a mandatory value.
298 */
299 double timeOffsetNs;
300
301 /*
302 * Per satellite sync state. It represents the current sync state for the
303 * associated satellite.
304 * Based on the sync state, the 'received GNSS tow' field must be interpreted
305 * accordingly.
306 *
307 * This is a mandatory value.
308 */
Yifan Hong7037fdb2016-12-05 17:16:09 -0800309 bitfield<GnssMeasurementState> state;
Hridya Valsarajue596a712016-09-22 14:07:22 -0700310
311 /*
312 * The received GNSS Time-of-Week at the measurement time, in nanoseconds.
313 * For GNSS & QZSS, this is the received GNSS Time-of-Week at the
314 * measurement time, in nanoseconds. The value is relative to the
315 * beginning of the current GNSS week.
316 *
317 * Given the highest sync state that can be achieved, per each satellite,
318 * valid range for this field can be:
319 * Searching : [ 0 ] : STATE_UNKNOWN
320 * C/A code lock : [ 0 1ms ] : STATE_CODE_LOCK set
321 * Bit sync : [ 0 20ms ] : STATE_BIT_SYNC set
322 * Subframe sync : [ 0 6s ] : STATE_SUBFRAME_SYNC set
323 * TOW decoded : [ 0 1week ] : STATE_TOW_DECODED set
324 *
325 * Note: If there is any ambiguity in integer millisecond,
326 * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS must be set accordingly, in the
327 * 'state' field.
328 *
329 * This value must be populated if 'state' != STATE_UNKNOWN.
330 *
331 * For Glonass, this is the received Glonass time of day, at the
332 * measurement time in nanoseconds.
333 *
334 * Given the highest sync state that can be achieved, per each satellite,
335 * valid range for this field can be:
336 * Searching : [ 0 ] : STATE_UNKNOWN set
337 * C/A code lock : [ 0 1ms ] : STATE_CODE_LOCK set
338 * Symbol sync : [ 0 10ms ] : STATE_SYMBOL_SYNC set
339 * Bit sync : [ 0 20ms ] : STATE_BIT_SYNC set
340 * String sync : [ 0 2s ] : STATE_GLO_STRING_SYNC set
341 * Time of day : [ 0 1day ] : STATE_GLO_TOW_DECODED set
342 *
343 * For Beidou, this is the received Beidou time of week,
344 * at the measurement time in nanoseconds.
345 *
346 * Given the highest sync state that can be achieved, per each satellite,
347 * valid range for this field can be:
348 * Searching : [ 0 ] : STATE_UNKNOWN set.
349 * C/A code lock: [ 0 1ms ] : STATE_CODE_LOCK set.
350 * Bit sync (D2): [ 0 2ms ] : STATE_BDS_D2_BIT_SYNC set.
351 * Bit sync (D1): [ 0 20ms ] : STATE_BIT_SYNC set.
352 * Subframe (D2): [ 0 0.6s ] : STATE_BDS_D2_SUBFRAME_SYNC set.
353 * Subframe (D1): [ 0 6s ] : STATE_SUBFRAME_SYNC set.
354 * Time of week : [ 0 1week ] : STATE_TOW_DECODED set.
355 *
356 * For Galileo, this is the received Galileo time of week,
357 * at the measurement time in nanoseconds.
358 *
359 * E1BC code lock : [ 0 4ms ] : STATE_GAL_E1BC_CODE_LOCK set.
360 * E1C 2nd code lock: [ 0 100ms] : STATE_GAL_E1C_2ND_CODE_LOCK set.
361 * E1B page : [ 0 2s ] : STATE_GAL_E1B_PAGE_SYNC set.
362 * Time of week : [ 0 1week] : STATE_TOW_DECODED is set.
363 *
364 * For SBAS, this is received SBAS time, at the measurement time in
365 * nanoseconds.
366 *
367 * Given the highest sync state that can be achieved, per each satellite,
368 * valid range for this field can be:
369 * Searching : [ 0 ] : STATE_UNKNOWN
370 * C/A code lock: [ 0 1ms ] : STATE_CODE_LOCK is set
371 * Symbol sync : [ 0 2ms ] : STATE_SYMBOL_SYNC is set
372 * Message : [ 0 1s ] : STATE_SBAS_SYNC is set
373 */
374 int64_t receivedSvTimeInNs;
375
376 /*
377 * 1-Sigma uncertainty of the Received GNSS Time-of-Week in nanoseconds.
378 *
379 * This value must be populated if 'state' != STATE_UNKNOWN.
380 */
381 int64_t receivedSvTimeUncertaintyInNs;
382
383 /*
384 * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
385 * It contains the measured C/N0 value for the signal at the antenna port.
386 *
387 * This is a mandatory value.
388 */
389 double cN0DbHz;
390
391 /*
392 * Pseudorange rate at the timestamp in m/s. The correction of a given
393 * Pseudorange Rate value includes corrections for receiver and satellite
394 * clock frequency errors. Ensure that this field is independent (see
395 * comment at top of GnssMeasurement struct.)
396 *
397 * It is mandatory to provide the 'uncorrected' 'pseudorange rate', and
398 * provide GnssClock's 'drift' field as well. When providing the
399 * uncorrected pseudorange rate, do not apply the corrections described above.)
400 *
401 * The value includes the 'pseudorange rate uncertainty' in it.
402 * A positive 'uncorrected' value indicates that the SV is moving away from
403 * the receiver.
404 *
405 * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the
406 * sign of 'doppler shift' is given by the equation:
407 * pseudorange rate = -k * doppler shift (where k is a constant)
408 *
409 * This must be the most accurate pseudorange rate available, based on
410 * fresh signal measurements from this channel.
411 *
412 * It is mandatory that this value be provided at typical carrier phase PRR
413 * quality (few cm/sec per second of uncertainty, or better) - when signals
414 * are sufficiently strong & stable, e.g. signals from a GNSS simulator at >=
415 * 35 dB-Hz.
416 */
417 double pseudorangeRateMps;
418
419 /*
420 * 1-Sigma uncertainty of the pseudorangeRateMps.
421 * The uncertainty is represented as an absolute (single sided) value.
422 *
423 * This is a mandatory value.
424 */
425 double pseudorangeRateUncertaintyMps;
426
427 /*
428 * Accumulated delta range's state. It indicates whether ADR is reset or
429 * there is a cycle slip(indicating loss of lock).
430 *
431 * This is a mandatory value.
432 */
Yifan Hong7037fdb2016-12-05 17:16:09 -0800433 bitfield<GnssAccumulatedDeltaRangeState> accumulatedDeltaRangeState;
Hridya Valsarajue596a712016-09-22 14:07:22 -0700434
435 /*
436 * Accumulated delta range since the last channel reset in meters.
437 * A positive value indicates that the SV is moving away from the receiver.
438 *
439 * The sign of the 'accumulated delta range' and its relation to the sign of
440 * 'carrier phase' is given by the equation:
441 * accumulated delta range = -k * carrier phase (where k is a constant)
442 *
443 * This value must be populated if 'accumulated delta range state' !=
444 * ADR_STATE_UNKNOWN.
445 * However, it is expected that the data is only accurate when:
446 * 'accumulated delta range state' == ADR_STATE_VALID.
447 */
448 double accumulatedDeltaRangeM;
449
450 /*
451 * 1-Sigma uncertainty of the accumulated delta range in meters.
452 * This value must be populated if 'accumulated delta range state' !=
453 * ADR_STATE_UNKNOWN.
454 */
455 double accumulatedDeltaRangeUncertaintyM;
456
457 /*
458 * Carrier frequency at which codes and messages are modulated, it can
459 * be L1 or L2. If the field is not set, the carrier frequency is
460 * assumed to be L1.
461 *
462 * If the data is available, gnssClockFlags must contain
463 * HAS_CARRIER_FREQUENCY.
464 */
465 float carrierFrequencyHz;
466
467 /*
468 * The number of full carrier cycles between the satellite and the
469 * receiver. The reference frequency is given by the field
470 * 'carrierFrequencyHz'. Indications of possible cycle slips and
471 * resets in the accumulation of this value can be inferred from the
472 * accumulatedDeltaRangeState flags.
473 *
474 * If the data is available, gnssClockFlags must contain
475 * HAS_CARRIER_CYCLES.
476 */
477 int64_t carrierCycles;
478
479 /*
480 * The RF phase detected by the receiver, in the range [0.0, 1.0].
481 * This is usually the fractional part of the complete carrier phase
482 * measurement.
483 *
484 * The reference frequency is given by the field 'carrierFrequencyHz'.
485 * The value contains the 'carrier-phase uncertainty' in it.
486 *
487 * If the data is available, gnssClockFlags must contain
488 * HAS_CARRIER_PHASE.
489 */
490 double carrierPhase;
491
492 /*
493 * 1-Sigma uncertainty of the carrier-phase.
494 * If the data is available, gnssClockFlags must contain
495 * HAS_CARRIER_PHASE_UNCERTAINTY.
496 */
497 double carrierPhaseUncertainty;
498
499 /*
500 * An enumeration that indicates the 'multipath' state of the event.
501 *
502 * The multipath Indicator is intended to report the presence of overlapping
503 * signals that manifest as distorted correlation peaks.
504 *
505 * - if there is a distorted correlation peak shape, report that multipath
506 * is MULTIPATH_INDICATOR_PRESENT.
507 * - if there is no distorted correlation peak shape, report
508 * MULTIPATH_INDICATOR_NOT_PRESENT
509 * - if signals are too weak to discern this information, report
510 * MULTIPATH_INDICATOR_UNKNOWN
511 *
512 * Example: when doing the standardized overlapping Multipath Performance
513 * test (3GPP TS 34.171) the Multipath indicator must report
514 * MULTIPATH_INDICATOR_PRESENT for those signals that are tracked, and
515 * contain multipath, and MULTIPATH_INDICATOR_NOT_PRESENT for those
516 * signals that are tracked and do not contain multipath.
517 */
518 GnssMultipathIndicator multipathIndicator;
519
520 /*
521 * Signal-to-noise ratio at correlator output in dB.
522 * If the data is available, gnssClockFlags must contain MEASUREMENT_HAS_SNR.
523 * This is the power ratio of the "correlation peak height above the
524 * observed noise floor" to "the noise RMS".
525 */
526 double snrDb;
527 };
528
529 /*
530 * Represents a reading of GNSS measurements. For devices where GnssSystemInfo's
531 * yearOfHw is set to 2016+, it is mandatory that these be provided, on
532 * request, when the GNSS receiver is searching/tracking signals.
533 *
534 * - Reporting of GNSS constellation measurements is mandatory.
535 * - Reporting of all tracked constellations are encouraged.
536 */
537 struct GnssData {
538 /* Number of GnssMeasurement elements. */
539 uint32_t measurementCount;
540
541 /* The array of measurements. */
Hridya Valsaraju97ecaa02016-11-02 10:20:07 -0700542 GnssMeasurement[GnssMax:SVS_COUNT] measurements;
Hridya Valsarajue596a712016-09-22 14:07:22 -0700543
544 /** The GNSS clock time reading. */
545 GnssClock clock;
546 };
547
548 /*
549 * Callback for the hal to pass a GnssData structure back to the client.
550 *
551 * @param data Contains a reading of GNSS measurements.
552 */
553 GnssMeasurementCb(GnssData data);
554};