196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/*
296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Copyright (C) 2010 The Android Open Source Project
396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Licensed under the Apache License, Version 2.0 (the "License");
596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * you may not use this file except in compliance with the License.
696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * You may obtain a copy of the License at
796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *      http://www.apache.org/licenses/LICENSE-2.0
996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
1096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Unless required by applicable law or agreed to in writing, software
1196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * distributed under the License is distributed on an "AS IS" BASIS,
1296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * See the License for the specific language governing permissions and
1496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * limitations under the License.
1596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
1696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
1796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#ifndef LOC_GPS_H
1896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_H
1996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
2096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#include <stdint.h>
2196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#include <sys/cdefs.h>
2296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#include <sys/types.h>
2396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#include <pthread.h>
2496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#include <sys/socket.h>
2596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#include <stdbool.h>
2696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
2796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel__BEGIN_DECLS
2896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
2996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_FLP_STATUS_LOCATION_AVAILABLE         0
3096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_FLP_STATUS_LOCATION_UNAVAILABLE       1
3196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_CAPABILITY_GNSS         (1U<<0)
3296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_CAPABILITY_WIFI         (1U<<1)
3396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_CAPABILITY_CELL         (1U<<3)
3496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
3596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Milliseconds since January 1, 1970 */
3696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef int64_t LocGpsUtcTime;
3796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
3896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Maximum number of SVs for loc_gps_sv_status_callback(). */
3996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MAX_SVS 32
4096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Maximum number of SVs for loc_gps_sv_status_callback(). */
4196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MAX_SVS 64
4296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
4396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Maximum number of Measurements in loc_gps_measurement_callback(). */
4496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MAX_MEASUREMENT   32
4596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
4696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Maximum number of Measurements in loc_gnss_measurement_callback(). */
4796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MAX_MEASUREMENT   64
4896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
4996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Requested operational mode for GPS operation. */
5096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint32_t LocGpsPositionMode;
5196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* IMPORTANT: Note that the following values must match
5296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * constants in GpsLocationProvider.java. */
5396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Mode for running GPS standalone (no assistance). */
5496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_POSITION_MODE_STANDALONE    0
5596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** AGPS MS-Based mode. */
5696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_POSITION_MODE_MS_BASED      1
5796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
5896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * AGPS MS-Assisted mode. This mode is not maintained by the platform anymore.
5996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * It is strongly recommended to use LOC_GPS_POSITION_MODE_MS_BASED instead.
6096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
6196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_POSITION_MODE_MS_ASSISTED   2
6296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
6396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Requested recurrence mode for GPS operation. */
6496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint32_t LocGpsPositionRecurrence;
6596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* IMPORTANT: Note that the following values must match
6696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * constants in GpsLocationProvider.java. */
6796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Receive GPS fixes on a recurring basis at a specified period. */
6896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_POSITION_RECURRENCE_PERIODIC    0
6996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Request a single shot GPS fix. */
7096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_POSITION_RECURRENCE_SINGLE      1
7196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
7296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS status event values. */
7396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t LocGpsStatusValue;
7496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* IMPORTANT: Note that the following values must match
7596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * constants in GpsLocationProvider.java. */
7696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS status unknown. */
7796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_STATUS_NONE             0
7896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS has begun navigating. */
7996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_STATUS_SESSION_BEGIN    1
8096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS has stopped navigating. */
8196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_STATUS_SESSION_END      2
8296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS has powered on but is not navigating. */
8396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_STATUS_ENGINE_ON        3
8496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS is powered off. */
8596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_STATUS_ENGINE_OFF       4
8696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
8796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Flags to indicate which values are valid in a LocGpsLocation. */
8896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t LocGpsLocationFlags;
8996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* IMPORTANT: Note that the following values must match
9096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * constants in GpsLocationProvider.java. */
9196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** LocGpsLocation has valid latitude and longitude. */
9296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_LOCATION_HAS_LAT_LONG   0x0001
9396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** LocGpsLocation has valid altitude. */
9496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_LOCATION_HAS_ALTITUDE   0x0002
9596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** LocGpsLocation has valid speed. */
9696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_LOCATION_HAS_SPEED      0x0004
9796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** LocGpsLocation has valid bearing. */
9896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_LOCATION_HAS_BEARING    0x0008
9996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** LocGpsLocation has valid accuracy. */
10096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_LOCATION_HAS_ACCURACY   0x0010
10196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
10296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Flags for the loc_gps_set_capabilities callback. */
10396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
10496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
10596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * GPS HAL schedules fixes for LOC_GPS_POSITION_RECURRENCE_PERIODIC mode. If this is
10696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * not set, then the framework will use 1000ms for min_interval and will start
10796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * and call start() and stop() to schedule the GPS.
10896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
10996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CAPABILITY_SCHEDULING       (1 << 0)
11096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS supports MS-Based AGPS mode */
11196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CAPABILITY_MSB              (1 << 1)
11296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS supports MS-Assisted AGPS mode */
11396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CAPABILITY_MSA              (1 << 2)
11496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS supports single-shot fixes */
11596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CAPABILITY_SINGLE_SHOT      (1 << 3)
11696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS supports on demand time injection */
11796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CAPABILITY_ON_DEMAND_TIME   (1 << 4)
11896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS supports Geofencing  */
11996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CAPABILITY_GEOFENCING       (1 << 5)
12096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS supports Measurements. */
12196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CAPABILITY_MEASUREMENTS     (1 << 6)
12296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS supports Navigation Messages */
12396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CAPABILITY_NAV_MESSAGES     (1 << 7)
12496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
12596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
12696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Flags used to specify which aiding data to delete when calling
12796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * delete_aiding_data().
12896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
12996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t LocGpsAidingData;
13096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* IMPORTANT: Note that the following values must match
13196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * constants in GpsLocationProvider.java. */
13296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DELETE_EPHEMERIS        0x0001
13396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DELETE_ALMANAC          0x0002
13496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DELETE_POSITION         0x0004
13596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DELETE_TIME             0x0008
13696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DELETE_IONO             0x0010
13796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DELETE_UTC              0x0020
13896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DELETE_HEALTH           0x0040
13996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DELETE_SVDIR            0x0080
14096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DELETE_SVSTEER          0x0100
14196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DELETE_SADATA           0x0200
14296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DELETE_RTI              0x0400
14396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DELETE_CELLDB_INFO      0x8000
14496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DELETE_ALL              0xFFFF
14596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
14696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** AGPS type */
14796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t LocAGpsType;
14896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_TYPE_SUPL          1
14996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_TYPE_C2K           2
15096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
15196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t LocAGpsSetIDType;
15296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_SETID_TYPE_NONE    0
15396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_SETID_TYPE_IMSI    1
15496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_SETID_TYPE_MSISDN  2
15596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
15696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t LocApnIpType;
15796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_APN_IP_INVALID          0
15896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_APN_IP_IPV4             1
15996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_APN_IP_IPV6             2
16096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_APN_IP_IPV4V6           3
16196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
16296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
16396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * String length constants
16496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
16596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NI_SHORT_STRING_MAXLEN      256
16696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NI_LONG_STRING_MAXLEN       2048
16796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
16896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
16996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * LocGpsNiType constants
17096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
17196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint32_t LocGpsNiType;
17296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NI_TYPE_VOICE              1
17396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NI_TYPE_UMTS_SUPL          2
17496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NI_TYPE_UMTS_CTRL_PLANE    3
17596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/*Emergency SUPL*/
17696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NI_TYPE_EMERGENCY_SUPL     4
17796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
17896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
17996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * LocGpsNiNotifyFlags constants
18096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
18196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint32_t LocGpsNiNotifyFlags;
18296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** NI requires notification */
18396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NI_NEED_NOTIFY          0x0001
18496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** NI requires verification */
18596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NI_NEED_VERIFY          0x0002
18696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** NI requires privacy override, no notification/minimal trace */
18796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NI_PRIVACY_OVERRIDE     0x0004
18896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
18996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
19096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * GPS NI responses, used to define the response in
19196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * NI structures
19296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
19396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef int LocGpsUserResponseType;
19496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NI_RESPONSE_ACCEPT         1
19596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NI_RESPONSE_DENY           2
19696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NI_RESPONSE_NORESP         3
19796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
19896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
19996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * NI data encoding scheme
20096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
20196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef int LocGpsNiEncodingType;
20296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_ENC_NONE                   0
20396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_ENC_SUPL_GSM_DEFAULT       1
20496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_ENC_SUPL_UTF8              2
20596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_ENC_SUPL_UCS2              3
20696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_ENC_UNKNOWN                -1
20796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
20896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** AGPS status event values. */
20996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t LocAGpsStatusValue;
21096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS requests data connection for AGPS. */
21196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_REQUEST_AGPS_DATA_CONN  1
21296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS releases the AGPS data connection. */
21396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_RELEASE_AGPS_DATA_CONN  2
21496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** AGPS data connection initiated */
21596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_AGPS_DATA_CONNECTED     3
21696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** AGPS data connection completed */
21796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_AGPS_DATA_CONN_DONE     4
21896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** AGPS data connection failed */
21996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_AGPS_DATA_CONN_FAILED   5
22096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
22196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t LocAGpsRefLocationType;
22296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_REF_LOCATION_TYPE_GSM_CELLID   1
22396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_REF_LOCATION_TYPE_UMTS_CELLID  2
22496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_REF_LOCATION_TYPE_MAC          3
22596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_REF_LOCATION_TYPE_LTE_CELLID   4
22696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
22796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* Deprecated, to be removed in the next Android release. */
22896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_REG_LOCATION_TYPE_MAC          3
22996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
23096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Network types for update_network_state "type" parameter */
23196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_RIL_NETWORK_TYPE_MOBILE        0
23296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_RIL_NETWORK_TYPE_WIFI          1
23396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_RIL_NETWORK_TYPE_MOBILE_MMS    2
23496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL   3
23596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN   4
23696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI 5
23796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_RIL_NETWORK_TTYPE_WIMAX        6
23896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
23996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* The following typedef together with its constants below are deprecated, and
24096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * will be removed in the next release. */
24196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t LocGpsClockFlags;
24296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CLOCK_HAS_LEAP_SECOND               (1<<0)
24396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CLOCK_HAS_TIME_UNCERTAINTY          (1<<1)
24496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CLOCK_HAS_FULL_BIAS                 (1<<2)
24596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CLOCK_HAS_BIAS                      (1<<3)
24696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CLOCK_HAS_BIAS_UNCERTAINTY          (1<<4)
24796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CLOCK_HAS_DRIFT                     (1<<5)
24896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CLOCK_HAS_DRIFT_UNCERTAINTY         (1<<6)
24996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
25096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
25196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Flags to indicate what fields in LocGnssClock are valid.
25296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
25396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t LocGnssClockFlags;
25496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** A valid 'leap second' is stored in the data structure. */
25596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CLOCK_HAS_LEAP_SECOND               (1<<0)
25696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** A valid 'time uncertainty' is stored in the data structure. */
25796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CLOCK_HAS_TIME_UNCERTAINTY          (1<<1)
25896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** A valid 'full bias' is stored in the data structure. */
25996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CLOCK_HAS_FULL_BIAS                 (1<<2)
26096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** A valid 'bias' is stored in the data structure. */
26196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CLOCK_HAS_BIAS                      (1<<3)
26296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** A valid 'bias uncertainty' is stored in the data structure. */
26396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CLOCK_HAS_BIAS_UNCERTAINTY          (1<<4)
26496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** A valid 'drift' is stored in the data structure. */
26596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CLOCK_HAS_DRIFT                     (1<<5)
26696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** A valid 'drift uncertainty' is stored in the data structure. */
26796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY         (1<<6)
26896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
26996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* The following typedef together with its constants below are deprecated, and
27096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * will be removed in the next release. */
27196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint8_t LocGpsClockType;
27296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CLOCK_TYPE_UNKNOWN                  0
27396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CLOCK_TYPE_LOCAL_HW_TIME            1
27496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_CLOCK_TYPE_GPS_TIME                 2
27596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
27696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* The following typedef together with its constants below are deprecated, and
27796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * will be removed in the next release. */
27896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint32_t LocGpsMeasurementFlags;
27996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_SNR                               (1<<0)
28096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_ELEVATION                         (1<<1)
28196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY             (1<<2)
28296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_AZIMUTH                           (1<<3)
28396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY               (1<<4)
28496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_PSEUDORANGE                       (1<<5)
28596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY           (1<<6)
28696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_CODE_PHASE                        (1<<7)
28796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY            (1<<8)
28896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY                 (1<<9)
28996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_CARRIER_CYCLES                    (1<<10)
29096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_CARRIER_PHASE                     (1<<11)
29196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY         (1<<12)
29296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_BIT_NUMBER                        (1<<13)
29396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT                (1<<14)
29496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_DOPPLER_SHIFT                     (1<<15)
29596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY         (1<<16)
29696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_USED_IN_FIX                       (1<<17)
29796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE      (1<<18)
29896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
29996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
30096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Flags to indicate what fields in LocGnssMeasurement are valid.
30196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
30296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint32_t LocGnssMeasurementFlags;
30396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** A valid 'snr' is stored in the data structure. */
30496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_HAS_SNR                               (1<<0)
30596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** A valid 'carrier frequency' is stored in the data structure. */
30696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY                 (1<<9)
30796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** A valid 'carrier cycles' is stored in the data structure. */
30896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_HAS_CARRIER_CYCLES                    (1<<10)
30996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** A valid 'carrier phase' is stored in the data structure. */
31096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_HAS_CARRIER_PHASE                     (1<<11)
31196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** A valid 'carrier phase uncertainty' is stored in the data structure. */
31296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY         (1<<12)
31396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
31496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* The following typedef together with its constants below are deprecated, and
31596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * will be removed in the next release. */
31696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint8_t LocGpsLossOfLock;
31796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_LOSS_OF_LOCK_UNKNOWN                            0
31896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_LOSS_OF_LOCK_OK                                 1
31996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_LOSS_OF_LOCK_CYCLE_SLIP                         2
32096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
32196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* The following typedef together with its constants below are deprecated, and
32296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * will be removed in the next release. Use LocGnssMultipathIndicator instead.
32396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
32496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint8_t LocGpsMultipathIndicator;
32596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MULTIPATH_INDICATOR_UNKNOWN                 0
32696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MULTIPATH_INDICATOR_DETECTED                1
32796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MULTIPATH_INDICATOR_NOT_USED                2
32896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
32996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
33096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Enumeration of available values for the GNSS Measurement's multipath
33196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * indicator.
33296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
33396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint8_t LocGnssMultipathIndicator;
33496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** The indicator is not available or unknown. */
33596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MULTIPATH_INDICATOR_UNKNOWN                 0
33696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** The measurement is indicated to be affected by multipath. */
33796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MULTIPATH_INDICATOR_PRESENT                 1
33896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** The measurement is indicated to be not affected by multipath. */
33996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MULTIPATH_INDICATOR_NOT_PRESENT             2
34096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
34196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* The following typedef together with its constants below are deprecated, and
34296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * will be removed in the next release. */
34396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t LocGpsMeasurementState;
34496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_STATE_UNKNOWN                   0
34596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_STATE_CODE_LOCK             (1<<0)
34696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_STATE_BIT_SYNC              (1<<1)
34796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_STATE_SUBFRAME_SYNC         (1<<2)
34896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_STATE_TOW_DECODED           (1<<3)
34996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS        (1<<4)
35096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
35196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
35296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Flags indicating the GNSS measurement state.
35396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
35496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The expected behavior here is for GPS HAL to set all the flags that applies.
35596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * For example, if the state for a satellite is only C/A code locked and bit
35696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * synchronized, and there is still millisecond ambiguity, the state should be
35796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * set as:
35896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
35996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK | LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC |
36096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *         LOC_GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS
36196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
36296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * If GNSS is still searching for a satellite, the corresponding state should be
36396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * set to LOC_GNSS_MEASUREMENT_STATE_UNKNOWN(0).
36496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
36596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint32_t LocGnssMeasurementState;
36696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_UNKNOWN                   0
36796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK             (1<<0)
36896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC              (1<<1)
36996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC         (1<<2)
37096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_TOW_DECODED           (1<<3)
37196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS        (1<<4)
37296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_SYMBOL_SYNC           (1<<5)
37396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC       (1<<6)
37496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED       (1<<7)
37596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC       (1<<8)
37696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC  (1<<9)
37796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK    (1<<10)
37896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK (1<<11)
37996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC     (1<<12)
38096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_MEASUREMENT_STATE_SBAS_SYNC             (1<<13)
38196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
38296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* The following typedef together with its constants below are deprecated, and
38396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * will be removed in the next release. */
38496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t LocGpsAccumulatedDeltaRangeState;
38596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_ADR_STATE_UNKNOWN                       0
38696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_ADR_STATE_VALID                     (1<<0)
38796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_ADR_STATE_RESET                     (1<<1)
38896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_ADR_STATE_CYCLE_SLIP                (1<<2)
38996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
39096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
39196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Flags indicating the Accumulated Delta Range's states.
39296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
39396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t LocGnssAccumulatedDeltaRangeState;
39496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_ADR_STATE_UNKNOWN                       0
39596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_ADR_STATE_VALID                     (1<<0)
39696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_ADR_STATE_RESET                     (1<<1)
39796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_ADR_STATE_CYCLE_SLIP                (1<<2)
39896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
39996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#if 0
40096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* The following typedef together with its constants below are deprecated, and
40196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * will be removed in the next release. */
40296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint8_t GpsNavigationMessageType;
40396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN         0
40496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GPS_NAVIGATION_MESSAGE_TYPE_L1CA            1
40596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV          2
40696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV          3
40796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2           4
40896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
40996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
41096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Enumeration of available values to indicate the GNSS Navigation message
41196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * types.
41296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
41396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * For convenience, first byte is the LocGnssConstellationType on which that signal
41496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * is typically transmitted
41596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
41696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef int16_t GnssNavigationMessageType;
41796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
41896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GNSS_NAVIGATION_MESSAGE_TYPE_UNKNOWN       0
41996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS L1 C/A message contained in the structure.  */
42096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L1CA      0x0101
42196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS L2-CNAV message contained in the structure. */
42296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L2CNAV    0x0102
42396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS L5-CNAV message contained in the structure. */
42496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L5CNAV    0x0103
42596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS CNAV-2 message contained in the structure. */
42696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_CNAV2     0x0104
42796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Glonass L1 CA message contained in the structure. */
42896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GNSS_NAVIGATION_MESSAGE_TYPE_GLO_L1CA      0x0301
42996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Beidou D1 message contained in the structure. */
43096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D1        0x0501
43196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Beidou D2 message contained in the structure. */
43296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D2        0x0502
43396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Galileo I/NAV message contained in the structure. */
43496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_I         0x0601
43596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Galileo F/NAV message contained in the structure. */
43696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_F         0x0602
43796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
43896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
43996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Status of Navigation Message
44096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * When a message is received properly without any parity error in its navigation words, the
44196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received
44296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * with words that failed parity check, but GPS is able to correct those words, the status
44396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT.
44496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * No need to send any navigation message that contains words with parity error and cannot be
44596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * corrected.
44696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
44796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint16_t NavigationMessageStatus;
44896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define NAV_MESSAGE_STATUS_UNKNOWN              0
44996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define NAV_MESSAGE_STATUS_PARITY_PASSED   (1<<0)
45096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define NAV_MESSAGE_STATUS_PARITY_REBUILT  (1<<1)
45196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
45296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* This constant is deprecated, and will be removed in the next release. */
45396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define NAV_MESSAGE_STATUS_UNKONW              0
45496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#endif
45596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
45696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
45796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Flags that indicate information about the satellite
45896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
45996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint8_t                                 LocGnssSvFlags;
46096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_SV_FLAGS_NONE                      0
46196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA        (1 << 0)
46296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_SV_FLAGS_HAS_ALMANAC_DATA          (1 << 1)
46396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_SV_FLAGS_USED_IN_FIX               (1 << 2)
46496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
46596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
46696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Constellation type of LocGnssSvInfo
46796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
46896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef uint8_t                         LocGnssConstellationType;
46996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CONSTELLATION_UNKNOWN      0
47096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CONSTELLATION_GPS          1
47196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CONSTELLATION_SBAS         2
47296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CONSTELLATION_GLONASS      3
47396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CONSTELLATION_QZSS         4
47496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CONSTELLATION_BEIDOU       5
47596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CONSTELLATION_GALILEO      6
47696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
47796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
47896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Name for the GPS XTRA interface.
47996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
48096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_XTRA_INTERFACE      "gps-xtra"
48196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
48296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
48396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Name for the GPS DEBUG interface.
48496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
48596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_DEBUG_INTERFACE      "gps-debug"
48696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
48796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
48896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Name for the AGPS interface.
48996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
49096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
49196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_INTERFACE      "agps"
49296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
49396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
49496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Name of the Supl Certificate interface.
49596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
49696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_SUPL_CERTIFICATE_INTERFACE  "supl-certificate"
49796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
49896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
49996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Name for NI interface
50096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
50196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NI_INTERFACE "gps-ni"
50296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
50396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
50496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Name for the AGPS-RIL interface.
50596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
50696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_RIL_INTERFACE      "agps_ril"
50796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
50896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
50996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Name for the GPS_Geofencing interface.
51096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
51196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_GEOFENCING_INTERFACE   "gps_geofencing"
51296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
51396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
51496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Name of the GPS Measurements interface.
51596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
51696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_INTERFACE   "gps_measurement"
51796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
51896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
51996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Name of the GPS navigation message interface.
52096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
52196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_NAVIGATION_MESSAGE_INTERFACE     "gps_navigation_message"
52296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
52396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
52496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Name of the GNSS/GPS configuration interface.
52596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
52696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GNSS_CONFIGURATION_INTERFACE     "gnss_configuration"
52796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
52896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Represents a location. */
52996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
53096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsLocation) */
53196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t          size;
53296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Contains LocGpsLocationFlags bits. */
53396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint16_t        flags;
53496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Represents latitude in degrees. */
53596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double          latitude;
53696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Represents longitude in degrees. */
53796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double          longitude;
53896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
53996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Represents altitude in meters above the WGS 84 reference ellipsoid.
54096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
54196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double          altitude;
54296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Represents speed in meters per second. */
54396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    float           speed;
54496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Represents heading in degrees. */
54596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    float           bearing;
54696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Represents expected accuracy in meters. */
54796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    float           accuracy;
54896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Timestamp for the location fix. */
54996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsUtcTime      timestamp;
55096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsLocation;
55196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
55296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Represents the status. */
55396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
55496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsStatus) */
55596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t          size;
55696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsStatusValue status;
55796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsStatus;
55896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
55996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
56096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Legacy struct to represents SV information.
56196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Deprecated, to be removed in the next Android release.
56296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Use LocGnssSvInfo instead.
56396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
56496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
56596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsSvInfo) */
56696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t          size;
56796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Pseudo-random number for the SV. */
56896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int     prn;
56996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Signal to noise ratio. */
57096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    float   snr;
57196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Elevation of SV in degrees. */
57296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    float   elevation;
57396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Azimuth of SV in degrees. */
57496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    float   azimuth;
57596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsSvInfo;
57696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
57796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
57896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGnssSvInfo) */
57996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
58096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
58196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
58296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Pseudo-random number for the SV, or FCN/OSN number for Glonass. The
58396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * distinction is made by looking at constellation field. Values should be
58496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * in the range of:
58596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
58696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - GPS:     1-32
58796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - SBAS:    120-151, 183-192
58896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - GLONASS: 1-24, the orbital slot number (OSN), if known.  Or, if not:
58996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *            93-106, the frequency channel number (FCN) (-7 to +6) offset by + 100
59096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *            i.e. report an FCN of -7 as 93, FCN of 0 as 100, and FCN of +6 as 106.
59196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - QZSS:    193-200
59296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - Galileo: 1-36
59396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - Beidou:  1-37
59496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
59596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int16_t svid;
59696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
59796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
59896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Defines the constellation of the given SV. Value should be one of those
59996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LOC_GNSS_CONSTELLATION_* constants
60096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
60196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGnssConstellationType constellation;
60296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
60396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
60496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
60596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * It contains the measured C/N0 value for the signal at the antenna port.
60696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
60796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This is a mandatory value.
60896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
60996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    float c_n0_dbhz;
61096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
61196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Elevation of SV in degrees. */
61296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    float elevation;
61396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
61496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Azimuth of SV in degrees. */
61596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    float azimuth;
61696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
61796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
61896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Contains additional data about the given SV. Value should be one of those
61996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LOC_GNSS_SV_FLAGS_* constants
62096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
62196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGnssSvFlags flags;
62296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
62396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGnssSvInfo;
62496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
62596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
62696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Legacy struct to represents SV status.
62796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Deprecated, to be removed in the next Android release.
62896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Use LocGnssSvStatus instead.
62996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
63096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
63196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsSvStatus) */
63296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
63396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int num_svs;
63496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsSvInfo sv_list[LOC_GPS_MAX_SVS];
63596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint32_t ephemeris_mask;
63696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint32_t almanac_mask;
63796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint32_t used_in_fix_mask;
63896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsSvStatus;
63996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
64096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
64196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Represents SV status.
64296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
64396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
64496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGnssSvStatus) */
64596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
64696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
64796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Number of GPS SVs currently visible, refers to the SVs stored in sv_list */
64896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int num_svs;
64996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
65096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Pointer to an array of SVs information for all GNSS constellations,
65196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * except GPS, which is reported using sv_list
65296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
65396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGnssSvInfo gnss_sv_list[LOC_GNSS_MAX_SVS];
65496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
65596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGnssSvStatus;
65696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
65796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/* CellID for 2G, 3G and LTE, used in AGPS. */
65896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
65996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocAGpsRefLocationType type;
66096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Mobile Country Code. */
66196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint16_t mcc;
66296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Mobile Network Code .*/
66396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint16_t mnc;
66496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Location Area Code in 2G, 3G and LTE. In 3G lac is discarded. In LTE,
66596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * lac is populated with tac, to ensure that we don't break old clients that
66696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * might rely in the old (wrong) behavior.
66796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
66896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint16_t lac;
66996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */
67096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint32_t cid;
67196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Tracking Area Code in LTE. */
67296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint16_t tac;
67396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Physical Cell id in LTE (not used in 2G and 3G) */
67496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint16_t pcid;
67596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocAGpsRefLocationCellID;
67696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
67796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
67896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint8_t mac[6];
67996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocAGpsRefLocationMac;
68096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
68196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Represents ref locations */
68296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
68396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocAGpsRefLocationType type;
68496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    union {
68596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel        LocAGpsRefLocationCellID   cellID;
68696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel        LocAGpsRefLocationMac      mac;
68796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    } u;
68896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocAGpsRefLocation;
68996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
69096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
69196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Callback with location information. Can only be called from a thread created
69296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * by create_thread_cb.
69396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
69496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (* loc_gps_location_callback)(LocGpsLocation* location);
69596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
69696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
69796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Callback with status information. Can only be called from a thread created by
69896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * create_thread_cb.
69996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
70096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (* loc_gps_status_callback)(LocGpsStatus* status);
70196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
70296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Legacy callback with SV status information.
70396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Can only be called from a thread created by create_thread_cb.
70496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
70596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * This callback is deprecated, and will be removed in the next release. Use
70696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * loc_gnss_sv_status_callback() instead.
70796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
70896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (* loc_gps_sv_status_callback)(LocGpsSvStatus* sv_info);
70996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
71096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
71196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Callback with SV status information.
71296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Can only be called from a thread created by create_thread_cb.
71396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
71496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (* loc_gnss_sv_status_callback)(LocGnssSvStatus* sv_info);
71596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
71696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
71796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Callback for reporting NMEA sentences. Can only be called from a thread
71896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * created by create_thread_cb.
71996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
72096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (* loc_gps_nmea_callback)(LocGpsUtcTime timestamp, const char* nmea, int length);
72196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
72296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
72396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Callback to inform framework of the GPS engine's capabilities. Capability
72496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * parameter is a bit field of LOC_GPS_CAPABILITY_* flags.
72596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
72696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (* loc_gps_set_capabilities)(uint32_t capabilities);
72796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
72896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
72996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Callback utility for acquiring the GPS wakelock. This can be used to prevent
73096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * the CPU from suspending while handling GPS events.
73196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
73296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (* loc_gps_acquire_wakelock)();
73396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
73496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Callback utility for releasing the GPS wakelock. */
73596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (* loc_gps_release_wakelock)();
73696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
73796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Callback for requesting NTP time */
73896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (* loc_gps_request_utc_time)();
73996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
74096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
74196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Callback for creating a thread that can call into the Java framework code.
74296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * This must be used to create any threads that report events up to the
74396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * framework.
74496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
74596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef pthread_t (* loc_gps_create_thread)(const char* name, void (*start)(void *), void* arg);
74696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
74796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
74896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Provides information about how new the underlying GPS/GNSS hardware and
74996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * software is.
75096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
75196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * This information will be available for Android Test Applications. If a GPS
75296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * HAL does not provide this information, it will be considered "2015 or
75396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * earlier".
75496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
75596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * If a GPS HAL does provide this information, then newer years will need to
75696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * meet newer CTS standards. E.g. if the date are 2016 or above, then N+ level
75796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * LocGpsMeasurement support will be verified.
75896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
75996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
76096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Set to sizeof(LocGnssSystemInfo) */
76196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t   size;
76296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /* year in which the last update was made to the underlying hardware/firmware
76396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * used to capture GNSS signals, e.g. 2016 */
76496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint16_t year_of_hw;
76596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGnssSystemInfo;
76696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
76796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
76896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Callback to inform framework of the engine's hardware version information.
76996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
77096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*loc_gnss_set_system_info)(const LocGnssSystemInfo* info);
77196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
77296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** New GPS callback structure. */
77396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
77496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsCallbacks) */
77596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t      size;
77696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_location_callback location_cb;
77796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_status_callback status_cb;
77896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_sv_status_callback sv_status_cb;
77996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_nmea_callback nmea_cb;
78096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_set_capabilities set_capabilities_cb;
78196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_acquire_wakelock acquire_wakelock_cb;
78296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_release_wakelock release_wakelock_cb;
78396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_create_thread create_thread_cb;
78496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_request_utc_time request_utc_time_cb;
78596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
78696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gnss_set_system_info set_system_info_cb;
78796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gnss_sv_status_callback gnss_sv_status_cb;
78896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsCallbacks;
78996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
79096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Represents the standard GPS interface. */
79196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
79296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsInterface) */
79396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t          size;
79496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
79596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Opens the interface and provides the callback routines
79696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * to the implementation of this interface.
79796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
79896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int   (*init)( LocGpsCallbacks* callbacks );
79996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
80096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Starts navigating. */
80196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int   (*start)( void );
80296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
80396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Stops navigating. */
80496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int   (*stop)( void );
80596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
80696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Closes the interface. */
80796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    void  (*cleanup)( void );
80896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
80996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Injects the current time. */
81096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int   (*inject_time)(LocGpsUtcTime time, int64_t timeReference,
81196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel                         int uncertainty);
81296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
81396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
81496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Injects current location from another location provider (typically cell
81596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * ID). Latitude and longitude are measured in degrees expected accuracy is
81696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * measured in meters
81796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
81896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int  (*inject_location)(double latitude, double longitude, float accuracy);
81996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
82096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
82196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Specifies that the next call to start will not use the
82296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * information defined in the flags. LOC_GPS_DELETE_ALL is passed for
82396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * a cold start.
82496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
82596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    void  (*delete_aiding_data)(LocGpsAidingData flags);
82696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
82796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
82896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * min_interval represents the time between fixes in milliseconds.
82996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * preferred_accuracy represents the requested fix accuracy in meters.
83096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * preferred_time represents the requested time to first fix in milliseconds.
83196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
83296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * 'mode' parameter should be one of LOC_GPS_POSITION_MODE_MS_BASED
83396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * or LOC_GPS_POSITION_MODE_STANDALONE.
83496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * It is allowed by the platform (and it is recommended) to fallback to
83596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LOC_GPS_POSITION_MODE_MS_BASED if LOC_GPS_POSITION_MODE_MS_ASSISTED is passed in, and
83696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LOC_GPS_POSITION_MODE_MS_BASED is supported.
83796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
83896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int   (*set_position_mode)(LocGpsPositionMode mode, LocGpsPositionRecurrence recurrence,
83996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel            uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time);
84096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
84196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Get a pointer to extension information. */
84296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    const void* (*get_extension)(const char* name);
84396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsInterface;
84496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
84596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
84696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Callback to request the client to download XTRA data. The client should
84796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * download XTRA data and inject it by calling inject_xtra_data(). Can only be
84896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * called from a thread created by create_thread_cb.
84996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
85096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (* loc_gps_xtra_download_request)();
85196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
85296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Callback structure for the XTRA interface. */
85396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
85496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_xtra_download_request download_request_cb;
85596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_create_thread create_thread_cb;
85696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsXtraCallbacks;
85796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
85896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Extended interface for XTRA support. */
85996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
86096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsXtraInterface) */
86196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t          size;
86296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
86396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Opens the XTRA interface and provides the callback routines
86496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * to the implementation of this interface.
86596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
86696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int  (*init)( LocGpsXtraCallbacks* callbacks );
86796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Injects XTRA data into the GPS. */
86896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int  (*inject_xtra_data)( char* data, int length );
86996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsXtraInterface;
87096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
87196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#if 0
87296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Extended interface for DEBUG support. */
87396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
87496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsDebugInterface) */
87596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t          size;
87696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
87796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
87896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This function should return any information that the native
87996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * implementation wishes to include in a bugreport.
88096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
88196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t (*get_internal_state)(char* buffer, size_t bufferSize);
88296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsDebugInterface;
88396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#endif
88496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
88596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/*
88696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Represents the status of AGPS augmented to support IPv4 and IPv6.
88796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
88896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
88996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocAGpsStatus) */
89096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t                  size;
89196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
89296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocAGpsType                type;
89396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocAGpsStatusValue         status;
89496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
89596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
89696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4
89796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * address, or set to INADDR_NONE otherwise.
89896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
89996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint32_t                ipaddr;
90096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
90196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
90296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report.
90396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Any other value of addr.ss_family will be rejected.
90496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
90596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    struct sockaddr_storage addr;
90696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocAGpsStatus;
90796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
90896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
90996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Callback with AGPS status information. Can only be called from a thread
91096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * created by create_thread_cb.
91196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
91296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (* loc_agps_status_callback)(LocAGpsStatus* status);
91396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
91496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Callback structure for the AGPS interface. */
91596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
91696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_agps_status_callback status_cb;
91796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_create_thread create_thread_cb;
91896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocAGpsCallbacks;
91996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
92096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
92196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Extended interface for AGPS support, it is augmented to enable to pass
92296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * extra APN data.
92396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
92496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
92596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocAGpsInterface) */
92696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
92796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
92896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
92996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Opens the AGPS interface and provides the callback routines to the
93096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * implementation of this interface.
93196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
93296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    void (*init)(LocAGpsCallbacks* callbacks);
93396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
93496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Deprecated.
93596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If the HAL supports LocAGpsInterface_v2 this API will not be used, see
93696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * data_conn_open_with_apn_ip_type for more information.
93796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
93896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int (*data_conn_open)(const char* apn);
93996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
94096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Notifies that the AGPS data connection has been closed.
94196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
94296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int (*data_conn_closed)();
94396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
94496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Notifies that a data connection is not available for AGPS.
94596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
94696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int (*data_conn_failed)();
94796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
94896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Sets the hostname and port for the AGPS server.
94996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
95096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int (*set_server)(LocAGpsType type, const char* hostname, int port);
95196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
95296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
95396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Notifies that a data connection is available and sets the name of the
95496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * APN, and its IP type, to be used for SUPL connections.
95596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
95696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int (*data_conn_open_with_apn_ip_type)(
95796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel            const char* apn,
95896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel            LocApnIpType apnIpType);
95996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocAGpsInterface;
96096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
96196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Error codes associated with certificate operations */
96296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_CERTIFICATE_OPERATION_SUCCESS               0
96396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_CERTIFICATE_ERROR_GENERIC                -100
96496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES  -101
96596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
96696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** A data structure that represents an X.509 certificate using DER encoding */
96796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
96896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t  length;
96996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    u_char* data;
97096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocDerEncodedCertificate;
97196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
97296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
97396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * A type definition for SHA1 Fingerprints used to identify X.509 Certificates
97496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The Fingerprint is a digest of the DER Certificate that uniquely identifies it.
97596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
97696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
97796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    u_char data[20];
97896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocSha1CertificateFingerprint;
97996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
98096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** AGPS Interface to handle SUPL certificate operations */
98196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
98296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocSuplCertificateInterface) */
98396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
98496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
98596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
98696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Installs a set of Certificates used for SUPL connections to the AGPS server.
98796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If needed the HAL should find out internally any certificates that need to be removed to
98896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * accommodate the certificates to install.
98996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The certificates installed represent a full set of valid certificates needed to connect to
99096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * AGPS SUPL servers.
99196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The list of certificates is required, and all must be available at the same time, when trying
99296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * to establish a connection with the AGPS Server.
99396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
99496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Parameters:
99596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      certificates - A pointer to an array of DER encoded certificates that are need to be
99696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *                     installed in the HAL.
99796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      length - The number of certificates to install.
99896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Returns:
99996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      LOC_AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully
100096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      LOC_AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of
100196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *          certificates attempted to be installed, the state of the certificates stored should
100296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *          remain the same as before on this error case.
100396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
100496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * IMPORTANT:
100596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      If needed the HAL should find out internally the set of certificates that need to be
100696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      removed to accommodate the certificates to install.
100796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
100896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int  (*install_certificates) ( const LocDerEncodedCertificate* certificates, size_t length );
100996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
101096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
101196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is
101296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * expected that the given set of certificates is removed from the internal store of the HAL.
101396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
101496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Parameters:
101596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of
101696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *                     certificates to revoke.
101796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      length - The number of fingerprints provided.
101896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Returns:
101996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      LOC_AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully.
102096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
102196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * IMPORTANT:
102296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      If any of the certificates provided (through its fingerprint) is not known by the HAL,
102396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      it should be ignored and continue revoking/deleting the rest of them.
102496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
102596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int  (*revoke_certificates) ( const LocSha1CertificateFingerprint* fingerprints, size_t length );
102696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocSuplCertificateInterface;
102796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
102896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Represents an NI request */
102996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
103096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsNiNotification) */
103196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t          size;
103296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
103396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
103496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * An ID generated by HAL to associate NI notifications and UI
103596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * responses
103696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
103796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int             notification_id;
103896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
103996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
104096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * An NI type used to distinguish different categories of NI
104196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * events, such as LOC_GPS_NI_TYPE_VOICE, LOC_GPS_NI_TYPE_UMTS_SUPL, ...
104296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
104396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsNiType       ni_type;
104496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
104596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
104696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Notification/verification options, combinations of LocGpsNiNotifyFlags constants
104796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
104896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsNiNotifyFlags notify_flags;
104996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
105096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
105196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Timeout period to wait for user response.
105296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Set to 0 for no time out limit.
105396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
105496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int             timeout;
105596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
105696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
105796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Default response when time out.
105896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
105996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsUserResponseType default_response;
106096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
106196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
106296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Requestor ID
106396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
106496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    char            requestor_id[LOC_GPS_NI_SHORT_STRING_MAXLEN];
106596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
106696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
106796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Notification message. It can also be used to store client_id in some cases
106896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
106996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    char            text[LOC_GPS_NI_LONG_STRING_MAXLEN];
107096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
107196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
107296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Client name decoding scheme
107396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
107496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsNiEncodingType requestor_id_encoding;
107596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
107696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
107796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Client name decoding scheme
107896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
107996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsNiEncodingType text_encoding;
108096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
108196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
108296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * A pointer to extra data. Format:
108396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * key_1 = value_1
108496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * key_2 = value_2
108596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
108696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    char           extras[LOC_GPS_NI_LONG_STRING_MAXLEN];
108796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
108896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsNiNotification;
108996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
109096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
109196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Callback with NI notification. Can only be called from a thread created by
109296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * create_thread_cb.
109396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
109496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*loc_gps_ni_notify_callback)(LocGpsNiNotification *notification);
109596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
109696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** GPS NI callback structure. */
109796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct
109896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel{
109996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
110096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Sends the notification request from HAL to GPSLocationProvider.
110196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
110296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_ni_notify_callback notify_cb;
110396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_create_thread create_thread_cb;
110496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsNiCallbacks;
110596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
110696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
110796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Extended interface for Network-initiated (NI) support.
110896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
110996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct
111096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel{
111196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsNiInterface) */
111296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t          size;
111396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
111496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   /** Registers the callbacks for HAL to use. */
111596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   void (*init) (LocGpsNiCallbacks *callbacks);
111696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
111796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   /** Sends a response to HAL. */
111896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   void (*respond) (int notif_id, LocGpsUserResponseType user_response);
111996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsNiInterface;
112096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
112196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_RIL_REQUEST_SETID_IMSI     (1<<0L)
112296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_RIL_REQUEST_SETID_MSISDN   (1<<1L)
112396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
112496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_RIL_REQUEST_REFLOC_CELLID  (1<<0L)
112596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_AGPS_RIL_REQUEST_REFLOC_MAC     (1<<1L)
112696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
112796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*loc_agps_ril_request_set_id)(uint32_t flags);
112896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*loc_agps_ril_request_ref_loc)(uint32_t flags);
112996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
113096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
113196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_agps_ril_request_set_id request_setid;
113296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_agps_ril_request_ref_loc request_refloc;
113396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_create_thread create_thread_cb;
113496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocAGpsRilCallbacks;
113596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
113696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Extended interface for AGPS_RIL support. */
113796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
113896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocAGpsRilInterface) */
113996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t          size;
114096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
114196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Opens the AGPS interface and provides the callback routines
114296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * to the implementation of this interface.
114396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
114496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    void  (*init)( LocAGpsRilCallbacks* callbacks );
114596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
114696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
114796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Sets the reference location.
114896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
114996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    void (*set_ref_location) (const LocAGpsRefLocation *agps_reflocation, size_t sz_struct);
115096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
115196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Sets the set ID.
115296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
115396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    void (*set_set_id) (LocAGpsSetIDType type, const char* setid);
115496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
115596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
115696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Send network initiated message.
115796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
115896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    void (*ni_message) (uint8_t *msg, size_t len);
115996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
116096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
116196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Notify GPS of network status changes.
116296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * These parameters match values in the android.net.NetworkInfo class.
116396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
116496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    void (*update_network_state) (int connected, int type, int roaming, const char* extra_info);
116596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
116696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
116796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Notify GPS of network status changes.
116896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * These parameters match values in the android.net.NetworkInfo class.
116996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
117096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    void (*update_network_availability) (int avaiable, const char* apn);
117196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocAGpsRilInterface;
117296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
117396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
117496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * GPS Geofence.
117596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *      There are 3 states associated with a Geofence: Inside, Outside, Unknown.
117696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * There are 3 transitions: ENTERED, EXITED, UNCERTAIN.
117796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
117896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * An example state diagram with confidence level: 95% and Unknown time limit
117996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * set as 30 secs is shown below. (confidence level and Unknown time limit are
118096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * explained latter)
118196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                         ____________________________
118296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                        |       Unknown (30 secs)   |
118396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                         """"""""""""""""""""""""""""
118496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                            ^ |                  |  ^
118596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                   UNCERTAIN| |ENTERED     EXITED|  |UNCERTAIN
118696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                            | v                  v  |
118796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                        ________    EXITED     _________
118896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                       | Inside | -----------> | Outside |
118996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                       |        | <----------- |         |
119096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                        """"""""    ENTERED    """""""""
119196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
119296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Inside state: We are 95% confident that the user is inside the geofence.
119396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Outside state: We are 95% confident that the user is outside the geofence
119496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Unknown state: Rest of the time.
119596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
119696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The Unknown state is better explained with an example:
119796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
119896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                            __________
119996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                           |         c|
120096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                           |  ___     |    _______
120196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                           |  |a|     |   |   b   |
120296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                           |  """     |    """""""
120396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                           |          |
120496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                            """"""""""
120596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy
120696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * circle reported by the GPS subsystem. Now with regard to "b", the system is
120796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * confident that the user is outside. But with regard to "a" is not confident
120896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * whether it is inside or outside the geofence. If the accuracy remains the
120996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * same for a sufficient period of time, the UNCERTAIN transition would be
121096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * triggered with the state set to Unknown. If the accuracy improves later, an
121196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * appropriate transition should be triggered.  This "sufficient period of time"
121296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * is defined by the parameter in the add_geofence_area API.
121396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *     In other words, Unknown state can be interpreted as a state in which the
121496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * GPS subsystem isn't confident enough that the user is either inside or
121596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * outside the Geofence. It moves to Unknown state only after the expiry of the
121696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * timeout.
121796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
121896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The geofence callback needs to be triggered for the ENTERED and EXITED
121996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * transitions, when the GPS system is confident that the user has entered
122096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * (Inside state) or exited (Outside state) the Geofence. An implementation
122196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * which uses a value of 95% as the confidence is recommended. The callback
122296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * should be triggered only for the transitions requested by the
122396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * add_geofence_area call.
122496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
122596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Even though the diagram and explanation talks about states and transitions,
122696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * the callee is only interested in the transistions. The states are mentioned
122796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * here for illustrative purposes.
122896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
122996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Startup Scenario: When the device boots up, if an application adds geofences,
123096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * and then we get an accurate GPS location fix, it needs to trigger the
123196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * appropriate (ENTERED or EXITED) transition for every Geofence it knows about.
123296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * By default, all the Geofences will be in the Unknown state.
123396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
123496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * When the GPS system is unavailable, loc_gps_geofence_status_callback should be
123596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * called to inform the upper layers of the same. Similarly, when it becomes
123696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * available the callback should be called. This is a global state while the
123796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * UNKNOWN transition described above is per geofence.
123896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
123996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * An important aspect to note is that users of this API (framework), will use
124096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * other subsystems like wifi, sensors, cell to handle Unknown case and
124196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * hopefully provide a definitive state transition to the third party
124296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * application. GPS Geofence will just be a signal indicating what the GPS
124396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * subsystem knows about the Geofence.
124496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
124596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
124696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_GEOFENCE_ENTERED     (1<<0L)
124796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_GEOFENCE_EXITED      (1<<1L)
124896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_GEOFENCE_UNCERTAIN   (1<<2L)
124996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
125096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_GEOFENCE_UNAVAILABLE (1<<0L)
125196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_GEOFENCE_AVAILABLE   (1<<1L)
125296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
125396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_GEOFENCE_OPERATION_SUCCESS           0
125496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES -100
125596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_GEOFENCE_ERROR_ID_EXISTS          -101
125696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_GEOFENCE_ERROR_ID_UNKNOWN         -102
125796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_GEOFENCE_ERROR_INVALID_TRANSITION -103
125896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_GEOFENCE_ERROR_GENERIC            -149
125996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
126096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
126196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The callback associated with the geofence.
126296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Parameters:
126396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *      geofence_id - The id associated with the add_geofence_area.
126496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *      location    - The current GPS location.
126596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *      transition  - Can be one of LOC_GPS_GEOFENCE_ENTERED, LOC_GPS_GEOFENCE_EXITED,
126696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                    LOC_GPS_GEOFENCE_UNCERTAIN.
126796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *      timestamp   - Timestamp when the transition was detected.
126896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
126996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The callback should only be called when the caller is interested in that
127096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * particular transition. For instance, if the caller is interested only in
127196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * ENTERED transition, then the callback should NOT be called with the EXITED
127296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * transition.
127396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
127496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * IMPORTANT: If a transition is triggered resulting in this callback, the GPS
127596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * subsystem will wake up the application processor, if its in suspend state.
127696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
127796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*loc_gps_geofence_transition_callback) (int32_t geofence_id,  LocGpsLocation* location,
127896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel        int32_t transition, LocGpsUtcTime timestamp);
127996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
128096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
128196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The callback associated with the availability of the GPS system for geofencing
128296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * monitoring. If the GPS system determines that it cannot monitor geofences
128396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * because of lack of reliability or unavailability of the GPS signals, it will
128496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * call this callback with LOC_GPS_GEOFENCE_UNAVAILABLE parameter.
128596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
128696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Parameters:
128796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *  status - LOC_GPS_GEOFENCE_UNAVAILABLE or LOC_GPS_GEOFENCE_AVAILABLE.
128896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *  last_location - Last known location.
128996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
129096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*loc_gps_geofence_status_callback) (int32_t status, LocGpsLocation* last_location);
129196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
129296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
129396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The callback associated with the add_geofence call.
129496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
129596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Parameter:
129696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * geofence_id - Id of the geofence.
129796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * status - LOC_GPS_GEOFENCE_OPERATION_SUCCESS
129896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *          LOC_GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES  - geofence limit has been reached.
129996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *          LOC_GPS_GEOFENCE_ERROR_ID_EXISTS  - geofence with id already exists
130096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *          LOC_GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an
130196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *              invalid transition
130296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *          LOC_GPS_GEOFENCE_ERROR_GENERIC - for other errors.
130396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
130496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*loc_gps_geofence_add_callback) (int32_t geofence_id, int32_t status);
130596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
130696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
130796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The callback associated with the remove_geofence call.
130896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
130996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Parameter:
131096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * geofence_id - Id of the geofence.
131196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * status - LOC_GPS_GEOFENCE_OPERATION_SUCCESS
131296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *          LOC_GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
131396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *          LOC_GPS_GEOFENCE_ERROR_GENERIC for others.
131496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
131596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*loc_gps_geofence_remove_callback) (int32_t geofence_id, int32_t status);
131696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
131796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
131896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
131996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The callback associated with the pause_geofence call.
132096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
132196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Parameter:
132296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * geofence_id - Id of the geofence.
132396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * status - LOC_GPS_GEOFENCE_OPERATION_SUCCESS
132496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *          LOC_GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
132596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *          LOC_GPS_GEOFENCE_ERROR_INVALID_TRANSITION -
132696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *                    when monitor_transitions is invalid
132796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *          LOC_GPS_GEOFENCE_ERROR_GENERIC for others.
132896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
132996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*loc_gps_geofence_pause_callback) (int32_t geofence_id, int32_t status);
133096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
133196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
133296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The callback associated with the resume_geofence call.
133396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
133496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Parameter:
133596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * geofence_id - Id of the geofence.
133696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * status - LOC_GPS_GEOFENCE_OPERATION_SUCCESS
133796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *          LOC_GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
133896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *          LOC_GPS_GEOFENCE_ERROR_GENERIC for others.
133996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
134096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*loc_gps_geofence_resume_callback) (int32_t geofence_id, int32_t status);
134196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
134296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
134396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_geofence_transition_callback geofence_transition_callback;
134496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_geofence_status_callback geofence_status_callback;
134596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_geofence_add_callback geofence_add_callback;
134696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_geofence_remove_callback geofence_remove_callback;
134796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_geofence_pause_callback geofence_pause_callback;
134896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_geofence_resume_callback geofence_resume_callback;
134996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_create_thread create_thread_cb;
135096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsGeofenceCallbacks;
135196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
135296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Extended interface for GPS_Geofencing support */
135396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
135496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   /** set to sizeof(LocGpsGeofencingInterface) */
135596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   size_t          size;
135696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
135796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   /**
135896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    * Opens the geofence interface and provides the callback routines
135996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    * to the implementation of this interface.
136096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    */
136196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   void  (*init)( LocGpsGeofenceCallbacks* callbacks );
136296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
136396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   /**
136496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    * Add a geofence area. This api currently supports circular geofences.
136596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    * Parameters:
136696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *    geofence_id - The id for the geofence. If a geofence with this id
136796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       already exists, an error value (LOC_GPS_GEOFENCE_ERROR_ID_EXISTS)
136896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       should be returned.
136996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *    latitude, longtitude, radius_meters - The lat, long and radius
137096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       (in meters) for the geofence
137196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *    last_transition - The current state of the geofence. For example, if
137296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       the system already knows that the user is inside the geofence,
137396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       this will be set to LOC_GPS_GEOFENCE_ENTERED. In most cases, it
137496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       will be LOC_GPS_GEOFENCE_UNCERTAIN.
137596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *    monitor_transition - Which transitions to monitor. Bitwise OR of
137696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       LOC_GPS_GEOFENCE_ENTERED, LOC_GPS_GEOFENCE_EXITED and
137796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       LOC_GPS_GEOFENCE_UNCERTAIN.
137896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *    notification_responsiveness_ms - Defines the best-effort description
137996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       of how soon should the callback be called when the transition
138096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       associated with the Geofence is triggered. For instance, if set
138196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       to 1000 millseconds with LOC_GPS_GEOFENCE_ENTERED, the callback
138296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       should be called 1000 milliseconds within entering the geofence.
138396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       This parameter is defined in milliseconds.
138496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       NOTE: This is not to be confused with the rate that the GPS is
138596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       polled at. It is acceptable to dynamically vary the rate of
138696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       sampling the GPS for power-saving reasons; thus the rate of
138796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       sampling may be faster or slower than this.
138896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *    unknown_timer_ms - The time limit after which the UNCERTAIN transition
138996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       should be triggered. This parameter is defined in milliseconds.
139096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       See above for a detailed explanation.
139196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    */
139296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude,
139396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel       double radius_meters, int last_transition, int monitor_transitions,
139496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel       int notification_responsiveness_ms, int unknown_timer_ms);
139596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
139696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   /**
139796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    * Pause monitoring a particular geofence.
139896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    * Parameters:
139996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *   geofence_id - The id for the geofence.
140096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    */
140196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   void (*pause_geofence) (int32_t geofence_id);
140296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
140396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   /**
140496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    * Resume monitoring a particular geofence.
140596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    * Parameters:
140696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *   geofence_id - The id for the geofence.
140796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *   monitor_transitions - Which transitions to monitor. Bitwise OR of
140896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       LOC_GPS_GEOFENCE_ENTERED, LOC_GPS_GEOFENCE_EXITED and
140996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       LOC_GPS_GEOFENCE_UNCERTAIN.
141096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       This supersedes the value associated provided in the
141196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *       add_geofence_area call.
141296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    */
141396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   void (*resume_geofence) (int32_t geofence_id, int monitor_transitions);
141496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
141596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   /**
141696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    * Remove a geofence area. After the function returns, no notifications
141796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    * should be sent.
141896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    * Parameter:
141996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    *   geofence_id - The id for the geofence.
142096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    */
142196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel   void (*remove_geofence_area) (int32_t geofence_id);
142296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsGeofencingInterface;
142396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
142496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
142596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Legacy struct to represent an estimate of the GPS clock time.
142696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Deprecated, to be removed in the next Android release.
142796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Use LocGnssClock instead.
142896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
142996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
143096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsClock) */
143196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
143296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsClockFlags flags;
143396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int16_t leap_second;
143496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsClockType type;
143596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int64_t time_ns;
143696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double time_uncertainty_ns;
143796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int64_t full_bias_ns;
143896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double bias_ns;
143996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double bias_uncertainty_ns;
144096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double drift_nsps;
144196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double drift_uncertainty_nsps;
144296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsClock;
144396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
144496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
144596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Represents an estimate of the GPS clock time.
144696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
144796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
144896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGnssClock) */
144996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
145096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
145196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
145296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * A set of flags indicating the validity of the fields in this data
145396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * structure.
145496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
145596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGnssClockFlags flags;
145696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
145796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
145896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Leap second data.
145996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The sign of the value is defined by the following equation:
146096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      utc_time_ns = time_ns - (full_bias_ns + bias_ns) - leap_second *
146196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      1,000,000,000
146296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
146396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If the data is available 'flags' must contain LOC_GNSS_CLOCK_HAS_LEAP_SECOND.
146496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
146596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int16_t leap_second;
146696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
146796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
146896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The GNSS receiver internal clock value. This is the local hardware clock
146996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * value.
147096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
147196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * For local hardware clock, this value is expected to be monotonically
147296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * increasing while the hardware clock remains power on. (For the case of a
147396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * HW clock that is not continuously on, see the
147496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * hw_clock_discontinuity_count field). The receiver's estimate of GPS time
147596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * can be derived by substracting the sum of full_bias_ns and bias_ns (when
147696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * available) from this value.
147796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
147896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This GPS time is expected to be the best estimate of current GPS time
147996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * that GNSS receiver can achieve.
148096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
148196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Sub-nanosecond accuracy can be provided by means of the 'bias_ns' field.
148296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The value contains the 'time uncertainty' in it.
148396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
148496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This field is mandatory.
148596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
148696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int64_t time_ns;
148796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
148896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
148996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * 1-Sigma uncertainty associated with the clock's time in nanoseconds.
149096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The uncertainty is represented as an absolute (single sided) value.
149196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
149296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If the data is available, 'flags' must contain
149396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LOC_GNSS_CLOCK_HAS_TIME_UNCERTAINTY. This value is effectively zero (it is
149496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * the reference local clock, by which all other times and time
149596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * uncertainties are measured.)  (And thus this field can be not provided,
149696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * per LOC_GNSS_CLOCK_HAS_TIME_UNCERTAINTY flag, or provided & set to 0.)
149796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
149896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double time_uncertainty_ns;
149996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
150096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
150196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The difference between hardware clock ('time' field) inside GPS receiver
150296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * and the true GPS time since 0000Z, January 6, 1980, in nanoseconds.
150396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
150496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The sign of the value is defined by the following equation:
150596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      local estimate of GPS time = time_ns - (full_bias_ns + bias_ns)
150696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
150796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This value is mandatory if the receiver has estimated GPS time. If the
150896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * computed time is for a non-GPS constellation, the time offset of that
150996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * constellation to GPS has to be applied to fill this value. The error
151096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * estimate for the sum of this and the bias_ns is the bias_uncertainty_ns,
151196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * and the caller is responsible for using this uncertainty (it can be very
151296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * large before the GPS time has been solved for.) If the data is available
151396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * 'flags' must contain LOC_GNSS_CLOCK_HAS_FULL_BIAS.
151496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
151596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int64_t full_bias_ns;
151696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
151796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
151896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Sub-nanosecond bias.
151996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The error estimate for the sum of this and the full_bias_ns is the
152096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * bias_uncertainty_ns
152196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
152296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If the data is available 'flags' must contain LOC_GNSS_CLOCK_HAS_BIAS. If GPS
152396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * has computed a position fix. This value is mandatory if the receiver has
152496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * estimated GPS time.
152596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
152696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double bias_ns;
152796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
152896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
152996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * 1-Sigma uncertainty associated with the local estimate of GPS time (clock
153096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * bias) in nanoseconds. The uncertainty is represented as an absolute
153196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * (single sided) value.
153296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
153396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If the data is available 'flags' must contain
153496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LOC_GNSS_CLOCK_HAS_BIAS_UNCERTAINTY. This value is mandatory if the receiver
153596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * has estimated GPS time.
153696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
153796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double bias_uncertainty_ns;
153896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
153996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
154096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The clock's drift in nanoseconds (per second).
154196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
154296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * A positive value means that the frequency is higher than the nominal
154396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * frequency, and that the (full_bias_ns + bias_ns) is growing more positive
154496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * over time.
154596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
154696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The value contains the 'drift uncertainty' in it.
154796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If the data is available 'flags' must contain LOC_GNSS_CLOCK_HAS_DRIFT.
154896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
154996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This value is mandatory if the receiver has estimated GNSS time
155096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
155196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double drift_nsps;
155296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
155396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
155496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second).
155596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The uncertainty is represented as an absolute (single sided) value.
155696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
155796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If the data is available 'flags' must contain
155896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LOC_GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY. If GPS has computed a position fix this
155996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * field is mandatory and must be populated.
156096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
156196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double drift_uncertainty_nsps;
156296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
156396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
156496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * When there are any discontinuities in the HW clock, this field is
156596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * mandatory.
156696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
156796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * A "discontinuity" is meant to cover the case of a switch from one source
156896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * of clock to another.  A single free-running crystal oscillator (XO)
156996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * should generally not have any discontinuities, and this can be set and
157096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * left at 0.
157196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
157296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If, however, the time_ns value (HW clock) is derived from a composite of
157396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * sources, that is not as smooth as a typical XO, or is otherwise stopped &
157496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * restarted, then this value shall be incremented each time a discontinuity
157596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * occurs.  (E.g. this value may start at zero at device boot-up and
157696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * increment each time there is a change in clock continuity. In the
157796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * unlikely event that this value reaches full scale, rollover (not
157896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * clamping) is required, such that this value continues to change, during
157996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * subsequent discontinuity events.)
158096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
158196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * While this number stays the same, between LocGnssClock reports, it can be
158296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * safely assumed that the time_ns value has been running continuously, e.g.
158396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * derived from a single, high quality clock (XO like, or better, that's
158496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * typically used during continuous GNSS signal sampling.)
158596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
158696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * It is expected, esp. during periods where there are few GNSS signals
158796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * available, that the HW clock be discontinuity-free as long as possible,
158896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * as this avoids the need to use (waste) a GNSS measurement to fully
158996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * re-solve for the GPS clock bias and drift, when using the accompanying
159096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * measurements, from consecutive LocGnssData reports.
159196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
159296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint32_t hw_clock_discontinuity_count;
159396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
159496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGnssClock;
159596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
159696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
159796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Legacy struct to represent a GPS Measurement, it contains raw and computed
159896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * information.
159996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Deprecated, to be removed in the next Android release.
160096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Use LocGnssMeasurement instead.
160196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
160296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
160396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsMeasurement) */
160496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
160596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsMeasurementFlags flags;
160696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int8_t prn;
160796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double time_offset_ns;
160896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsMeasurementState state;
160996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int64_t received_gps_tow_ns;
161096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int64_t received_gps_tow_uncertainty_ns;
161196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double c_n0_dbhz;
161296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double pseudorange_rate_mps;
161396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double pseudorange_rate_uncertainty_mps;
161496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsAccumulatedDeltaRangeState accumulated_delta_range_state;
161596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double accumulated_delta_range_m;
161696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double accumulated_delta_range_uncertainty_m;
161796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double pseudorange_m;
161896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double pseudorange_uncertainty_m;
161996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double code_phase_chips;
162096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double code_phase_uncertainty_chips;
162196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    float carrier_frequency_hz;
162296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int64_t carrier_cycles;
162396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double carrier_phase;
162496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double carrier_phase_uncertainty;
162596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsLossOfLock loss_of_lock;
162696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int32_t bit_number;
162796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int16_t time_from_last_bit_ms;
162896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double doppler_shift_hz;
162996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double doppler_shift_uncertainty_hz;
163096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsMultipathIndicator multipath_indicator;
163196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double snr_db;
163296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double elevation_deg;
163396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double elevation_uncertainty_deg;
163496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double azimuth_deg;
163596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double azimuth_uncertainty_deg;
163696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    bool used_in_fix;
163796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsMeasurement;
163896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
163996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
164096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Represents a GNSS Measurement, it contains raw and computed information.
164196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
164296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Independence - All signal measurement information (e.g. sv_time,
164396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * pseudorange_rate, multipath_indicator) reported in this struct should be
164496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * based on GNSS signal measurements only. You may not synthesize measurements
164596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * by calculating or reporting expected measurements based on known or estimated
164696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * position, velocity, or time.
164796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
164896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
164996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGnssMeasurement) */
165096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
165196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
165296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** A set of flags indicating the validity of the fields in this data structure. */
165396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGnssMeasurementFlags flags;
165496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
165596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
165696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Satellite vehicle ID number, as defined in LocGnssSvInfo::svid
165796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This is a mandatory value.
165896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
165996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int16_t svid;
166096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
166196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
166296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Defines the constellation of the given SV. Value should be one of those
166396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LOC_GNSS_CONSTELLATION_* constants
166496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
166596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGnssConstellationType constellation;
166696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
166796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
166896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Time offset at which the measurement was taken in nanoseconds.
166996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The reference receiver's time is specified by LocGpsData::clock::time_ns and should be
167096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * interpreted in the same way as indicated by LocGpsClock::type.
167196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
167296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The sign of time_offset_ns is given by the following equation:
167396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      measurement time = LocGpsClock::time_ns + time_offset_ns
167496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
167596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy.
167696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This is a mandatory value.
167796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
167896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double time_offset_ns;
167996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
168096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
168196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Per satellite sync state. It represents the current sync state for the associated satellite.
168296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly.
168396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
168496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This is a mandatory value.
168596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
168696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGnssMeasurementState state;
168796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
168896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
168996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The received GNSS Time-of-Week at the measurement time, in nanoseconds.
169096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Ensure that this field is independent (see comment at top of
169196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LocGnssMeasurement struct.)
169296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
169396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * For GPS & QZSS, this is:
169496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   Received GPS Time-of-Week at the measurement time, in nanoseconds.
169596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   The value is relative to the beginning of the current GPS week.
169696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
169796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   Given the highest sync state that can be achieved, per each satellite, valid range
169896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   for this field can be:
169996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Searching       : [ 0       ]   : LOC_GNSS_MEASUREMENT_STATE_UNKNOWN
170096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     C/A code lock   : [ 0   1ms ]   : LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK is set
170196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Bit sync        : [ 0  20ms ]   : LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC is set
170296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Subframe sync   : [ 0    6s ]   : LOC_GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
170396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     TOW decoded     : [ 0 1week ]   : LOC_GNSS_MEASUREMENT_STATE_TOW_DECODED is set
170496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
170596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   Note well: if there is any ambiguity in integer millisecond,
170696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   LOC_GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field.
170796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
170896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   This value must be populated if 'state' != LOC_GNSS_MEASUREMENT_STATE_UNKNOWN.
170996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
171096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * For Glonass, this is:
171196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   Received Glonass time of day, at the measurement time in nanoseconds.
171296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
171396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   Given the highest sync state that can be achieved, per each satellite, valid range for
171496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   this field can be:
171596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Searching       : [ 0       ]   : LOC_GNSS_MEASUREMENT_STATE_UNKNOWN
171696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     C/A code lock   : [ 0   1ms ]   : LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK is set
171796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Symbol sync     : [ 0  10ms ]   : LOC_GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set
171896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Bit sync        : [ 0  20ms ]   : LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC is set
171996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     String sync     : [ 0    2s ]   : LOC_GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC is set
172096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Time of day     : [ 0  1day ]   : LOC_GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED is set
172196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
172296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * For Beidou, this is:
172396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   Received Beidou time of week, at the measurement time in nanoseconds.
172496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
172596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   Given the highest sync state that can be achieved, per each satellite, valid range for
172696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   this field can be:
172796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Searching    : [ 0       ] : LOC_GNSS_MEASUREMENT_STATE_UNKNOWN
172896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     C/A code lock: [ 0   1ms ] : LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK is set
172996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Bit sync (D2): [ 0   2ms ] : LOC_GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC is set
173096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Bit sync (D1): [ 0  20ms ] : LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC is set
173196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Subframe (D2): [ 0  0.6s ] : LOC_GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC is set
173296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Subframe (D1): [ 0    6s ] : LOC_GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
173396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Time of week : [ 0 1week ] : LOC_GNSS_MEASUREMENT_STATE_TOW_DECODED is set
173496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
173596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * For Galileo, this is:
173696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   Received Galileo time of week, at the measurement time in nanoseconds.
173796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
173896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     E1BC code lock   : [ 0   4ms ]   : LOC_GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK is set
173996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     E1C 2nd code lock: [ 0 100ms ]   :
174096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     LOC_GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK is set
174196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
174296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     E1B page    : [ 0    2s ] : LOC_GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC is set
174396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Time of week: [ 0 1week ] : LOC_GNSS_MEASUREMENT_STATE_TOW_DECODED is set
174496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
174596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * For SBAS, this is:
174696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   Received SBAS time, at the measurement time in nanoseconds.
174796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
174896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   Given the highest sync state that can be achieved, per each satellite,
174996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   valid range for this field can be:
175096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Searching    : [ 0     ] : LOC_GNSS_MEASUREMENT_STATE_UNKNOWN
175196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     C/A code lock: [ 0 1ms ] : LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK is set
175296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Symbol sync  : [ 0 2ms ] : LOC_GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set
175396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     Message      : [ 0  1s ] : LOC_GNSS_MEASUREMENT_STATE_SBAS_SYNC is set
175496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    */
175596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int64_t received_sv_time_in_ns;
175696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
175796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
175896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds.
175996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
176096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This value must be populated if 'state' != LOC_GPS_MEASUREMENT_STATE_UNKNOWN.
176196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
176296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int64_t received_sv_time_uncertainty_in_ns;
176396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
176496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
176596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
176696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * It contains the measured C/N0 value for the signal at the antenna port.
176796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
176896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This is a mandatory value.
176996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
177096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double c_n0_dbhz;
177196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
177296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
177396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Pseudorange rate at the timestamp in m/s. The correction of a given
177496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Pseudorange Rate value includes corrections for receiver and satellite
177596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * clock frequency errors. Ensure that this field is independent (see
177696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * comment at top of LocGnssMeasurement struct.)
177796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
177896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * It is mandatory to provide the 'uncorrected' 'pseudorange rate', and provide LocGpsClock's
177996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * 'drift' field as well (When providing the uncorrected pseudorange rate, do not apply the
178096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * corrections described above.)
178196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
178296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The value includes the 'pseudorange rate uncertainty' in it.
178396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * A positive 'uncorrected' value indicates that the SV is moving away from the receiver.
178496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
178596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler
178696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * shift' is given by the equation:
178796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      pseudorange rate = -k * doppler shift   (where k is a constant)
178896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
178996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This should be the most accurate pseudorange rate available, based on
179096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * fresh signal measurements from this channel.
179196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
179296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * It is mandatory that this value be provided at typical carrier phase PRR
179396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * quality (few cm/sec per second of uncertainty, or better) - when signals
179496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * are sufficiently strong & stable, e.g. signals from a GPS simulator at >=
179596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * 35 dB-Hz.
179696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
179796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double pseudorange_rate_mps;
179896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
179996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
180096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * 1-Sigma uncertainty of the pseudorange_rate_mps.
180196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The uncertainty is represented as an absolute (single sided) value.
180296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
180396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This is a mandatory value.
180496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
180596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double pseudorange_rate_uncertainty_mps;
180696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
180796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
180896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip
180996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * (indicating loss of lock).
181096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
181196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This is a mandatory value.
181296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
181396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGnssAccumulatedDeltaRangeState accumulated_delta_range_state;
181496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
181596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
181696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Accumulated delta range since the last channel reset in meters.
181796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * A positive value indicates that the SV is moving away from the receiver.
181896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
181996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase'
182096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * is given by the equation:
182196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *          accumulated delta range = -k * carrier phase    (where k is a constant)
182296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
182396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This value must be populated if 'accumulated delta range state' != LOC_GPS_ADR_STATE_UNKNOWN.
182496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * However, it is expected that the data is only accurate when:
182596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      'accumulated delta range state' == LOC_GPS_ADR_STATE_VALID.
182696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
182796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double accumulated_delta_range_m;
182896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
182996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
183096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * 1-Sigma uncertainty of the accumulated delta range in meters.
183196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This value must be populated if 'accumulated delta range state' != LOC_GPS_ADR_STATE_UNKNOWN.
183296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
183396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double accumulated_delta_range_uncertainty_m;
183496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
183596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
183696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Carrier frequency at which codes and messages are modulated, it can be L1 or L2.
183796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If the field is not set, the carrier frequency is assumed to be L1.
183896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
183996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If the data is available, 'flags' must contain
184096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LOC_GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY.
184196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
184296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    float carrier_frequency_hz;
184396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
184496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
184596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The number of full carrier cycles between the satellite and the receiver.
184696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The reference frequency is given by the field 'carrier_frequency_hz'.
184796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Indications of possible cycle slips and resets in the accumulation of
184896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * this value can be inferred from the accumulated_delta_range_state flags.
184996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
185096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If the data is available, 'flags' must contain
185196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LOC_GNSS_MEASUREMENT_HAS_CARRIER_CYCLES.
185296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
185396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int64_t carrier_cycles;
185496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
185596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
185696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The RF phase detected by the receiver, in the range [0.0, 1.0].
185796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This is usually the fractional part of the complete carrier phase measurement.
185896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
185996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The reference frequency is given by the field 'carrier_frequency_hz'.
186096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The value contains the 'carrier-phase uncertainty' in it.
186196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
186296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If the data is available, 'flags' must contain
186396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LOC_GNSS_MEASUREMENT_HAS_CARRIER_PHASE.
186496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
186596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double carrier_phase;
186696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
186796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
186896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * 1-Sigma uncertainty of the carrier-phase.
186996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If the data is available, 'flags' must contain
187096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LOC_GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY.
187196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
187296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double carrier_phase_uncertainty;
187396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
187496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
187596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * An enumeration that indicates the 'multipath' state of the event.
187696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
187796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The multipath Indicator is intended to report the presence of overlapping
187896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * signals that manifest as distorted correlation peaks.
187996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
188096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - if there is a distorted correlation peak shape, report that multipath
188196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   is LOC_GNSS_MULTIPATH_INDICATOR_PRESENT.
188296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - if there is not a distorted correlation peak shape, report
188396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   LOC_GNSS_MULTIPATH_INDICATOR_NOT_PRESENT
188496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - if signals are too weak to discern this information, report
188596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   LOC_GNSS_MULTIPATH_INDICATOR_UNKNOWN
188696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
188796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Example: when doing the standardized overlapping Multipath Performance
188896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * test (3GPP TS 34.171) the Multipath indicator should report
188996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * LOC_GNSS_MULTIPATH_INDICATOR_PRESENT for those signals that are tracked, and
189096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * contain multipath, and LOC_GNSS_MULTIPATH_INDICATOR_NOT_PRESENT for those
189196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * signals that are tracked and do not contain multipath.
189296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
189396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGnssMultipathIndicator multipath_indicator;
189496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
189596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
189696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Signal-to-noise ratio at correlator output in dB.
189796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If the data is available, 'flags' must contain LOC_GNSS_MEASUREMENT_HAS_SNR.
189896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This is the power ratio of the "correlation peak height above the
189996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * observed noise floor" to "the noise RMS".
190096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
190196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    double snr_db;
190296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGnssMeasurement;
190396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
190496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
190596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Legacy struct to represents a reading of GPS measurements.
190696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Deprecated, to be removed in the next Android release.
190796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Use LocGnssData instead.
190896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
190996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
191096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsData) */
191196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
191296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t measurement_count;
191396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsMeasurement measurements[LOC_GPS_MAX_MEASUREMENT];
191496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
191596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** The GPS clock time reading. */
191696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGpsClock clock;
191796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsData;
191896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
191996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
192096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Represents a reading of GNSS measurements. For devices where LocGnssSystemInfo's
192196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * year_of_hw is set to 2016+, it is mandatory that these be provided, on
192296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * request, when the GNSS receiver is searching/tracking signals.
192396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
192496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * - Reporting of GPS constellation measurements is mandatory.
192596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * - Reporting of all tracked constellations are encouraged.
192696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
192796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
192896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGnssData) */
192996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
193096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
193196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Number of measurements. */
193296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t measurement_count;
193396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
193496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** The array of measurements. */
193596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGnssMeasurement measurements[LOC_GNSS_MAX_MEASUREMENT];
193696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
193796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** The GPS clock time reading. */
193896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    LocGnssClock clock;
193996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGnssData;
194096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
194196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
194296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The legacy callback for to report measurements from the HAL.
194396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
194496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * This callback is deprecated, and will be removed in the next release. Use
194596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * loc_gnss_measurement_callback() instead.
194696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
194796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Parameters:
194896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *    data - A data structure containing the measurements.
194996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
195096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*loc_gps_measurement_callback) (LocGpsData* data);
195196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
195296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
195396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The callback for to report measurements from the HAL.
195496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
195596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Parameters:
195696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *    data - A data structure containing the measurements.
195796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
195896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*loc_gnss_measurement_callback) (LocGnssData* data);
195996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
196096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
196196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(LocGpsMeasurementCallbacks) */
196296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
196396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gps_measurement_callback measurement_callback;
196496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    loc_gnss_measurement_callback loc_gnss_measurement_callback;
196596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsMeasurementCallbacks;
196696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
196796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_OPERATION_SUCCESS          0
196896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_ERROR_ALREADY_INIT      -100
196996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define LOC_GPS_MEASUREMENT_ERROR_GENERIC           -101
197096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
197196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
197296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Extended interface for GPS Measurements support.
197396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
197496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
197596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Set to sizeof(LocGpsMeasurementInterface) */
197696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
197796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
197896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
197996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Initializes the interface and registers the callback routines with the HAL.
198096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * After a successful call to 'init' the HAL must begin to provide updates at its own phase.
198196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
198296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Status:
198396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *    LOC_GPS_MEASUREMENT_OPERATION_SUCCESS
198496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *    LOC_GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a
198596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *              corresponding call to 'close'
198696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *    LOC_GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL
198796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *              will not generate any updates upon returning this error code.
198896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
198996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int (*init) (LocGpsMeasurementCallbacks* callbacks);
199096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
199196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
199296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Stops updates from the HAL, and unregisters the callback routines.
199396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * After a call to stop, the previously registered callbacks must be considered invalid by the
199496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * HAL.
199596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If stop is invoked without a previous 'init', this function should perform no work.
199696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
199796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    void (*close) ();
199896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
199996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGpsMeasurementInterface;
200096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
200196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#if 0
200296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
200396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Legacy struct to represents a GPS navigation message (or a fragment of it).
200496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Deprecated, to be removed in the next Android release.
200596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Use GnssNavigationMessage instead.
200696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
200796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
200896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(GpsNavigationMessage) */
200996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
201096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int8_t prn;
201196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    GpsNavigationMessageType type;
201296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    NavigationMessageStatus status;
201396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int16_t message_id;
201496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int16_t submessage_id;
201596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t data_length;
201696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint8_t* data;
201796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} GpsNavigationMessage;
201896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
201996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/** Represents a GPS navigation message (or a fragment of it). */
202096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
202196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(GnssNavigationMessage) */
202296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
202396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
202496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
202596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Satellite vehicle ID number, as defined in LocGnssSvInfo::svid
202696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This is a mandatory value.
202796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
202896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int16_t svid;
202996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
203096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
203196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The type of message contained in the structure.
203296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This is a mandatory value.
203396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
203496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    GnssNavigationMessageType type;
203596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
203696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
203796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The status of the received navigation message.
203896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * No need to send any navigation message that contains words with parity error and cannot be
203996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * corrected.
204096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
204196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    NavigationMessageStatus status;
204296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
204396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
204496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Message identifier. It provides an index so the complete Navigation
204596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Message can be assembled.
204696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
204796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For GPS L1 C/A subframe 4 and 5, this value corresponds to the 'frame
204896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   id' of the navigation message, in the range of 1-25 (Subframe 1, 2, 3
204996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   does not contain a 'frame id' and this value can be set to -1.)
205096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
205196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For Glonass L1 C/A, this refers to the frame ID, in the range of 1-5.
205296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
205396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For BeiDou D1, this refers to the frame number in the range of 1-24
205496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
205596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For Beidou D2, this refers to the frame number, in the range of 1-120
205696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
205796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For Galileo F/NAV nominal frame structure, this refers to the subframe
205896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   number, in the range of 1-12
205996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
206096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For Galileo I/NAV nominal frame structure, this refers to the subframe
206196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   number in the range of 1-24
206296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
206396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int16_t message_id;
206496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
206596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
206696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Sub-message identifier. If required by the message 'type', this value
206796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * contains a sub-index within the current message (or frame) that is being
206896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * transmitted.
206996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
207096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For GPS L1 C/A, BeiDou D1 & BeiDou D2, the submessage id corresponds to
207196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   the subframe number of the navigation message, in the range of 1-5.
207296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
207396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For Glonass L1 C/A, this refers to the String number, in the range from
207496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   1-15
207596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
207696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For Galileo F/NAV, this refers to the page type in the range 1-6
207796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
207896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For Galileo I/NAV, this refers to the word type in the range 1-10+
207996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
208096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int16_t submessage_id;
208196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
208296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
208396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The length of the data (in bytes) contained in the current message.
208496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If this value is different from zero, 'data' must point to an array of the same size.
208596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word).
208696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
208796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * This is a mandatory value.
208896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
208996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t data_length;
209096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
209196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
209296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * The data of the reported GPS message. The bytes (or words) specified
209396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * using big endian format (MSB first).
209496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
209596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For GPS L1 C/A, Beidou D1 & Beidou D2, each subframe contains 10 30-bit
209696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   words. Each word (30 bits) should be fit into the last 30 bits in a
209796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   4-byte word (skip B31 and B32), with MSB first, for a total of 40
209896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   bytes, covering a time period of 6, 6, and 0.6 seconds, respectively.
209996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
210096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For Glonass L1 C/A, each string contains 85 data bits, including the
210196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   checksum.  These bits should be fit into 11 bytes, with MSB first (skip
210296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   B86-B88), covering a time period of 2 seconds.
210396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
210496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For Galileo F/NAV, each word consists of 238-bit (sync & tail symbols
210596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   excluded). Each word should be fit into 30-bytes, with MSB first (skip
210696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   B239, B240), covering a time period of 10 seconds.
210796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
210896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * - For Galileo I/NAV, each page contains 2 page parts, even and odd, with
210996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   a total of 2x114 = 228 bits, (sync & tail excluded) that should be fit
211096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *   into 29 bytes, with MSB first (skip B229-B232).
211196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
211296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    uint8_t* data;
211396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
211496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} GnssNavigationMessage;
211596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
211696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
211796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The legacy callback to report an available fragment of a GPS navigation
211896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * messages from the HAL.
211996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
212096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * This callback is deprecated, and will be removed in the next release. Use
212196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * gnss_navigation_message_callback() instead.
212296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
212396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Parameters:
212496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *      message - The GPS navigation submessage/subframe representation.
212596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
212696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message);
212796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
212896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
212996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * The callback to report an available fragment of a GPS navigation messages from the HAL.
213096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *
213196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Parameters:
213296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel *      message - The GPS navigation submessage/subframe representation.
213396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
213496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef void (*gnss_navigation_message_callback) (GnssNavigationMessage* message);
213596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
213696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
213796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** set to sizeof(GpsNavigationMessageCallbacks) */
213896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
213996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    gps_navigation_message_callback navigation_message_callback;
214096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    gnss_navigation_message_callback gnss_navigation_message_callback;
214196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} GpsNavigationMessageCallbacks;
214296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
214396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS             0
214496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT         -100
214596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#define GPS_NAVIGATION_MESSAGE_ERROR_GENERIC              -101
214696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
214796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
214896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Extended interface for GPS navigation message reporting support.
214996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
215096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
215196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Set to sizeof(GpsNavigationMessageInterface) */
215296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
215396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
215496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
215596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Initializes the interface and registers the callback routines with the HAL.
215696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * After a successful call to 'init' the HAL must begin to provide updates as they become
215796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * available.
215896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
215996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Status:
216096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS
216196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered
216296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *              without a corresponding call to 'close'.
216396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that
216496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *              the HAL will not generate any updates upon returning this error code.
216596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
216696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    int (*init) (GpsNavigationMessageCallbacks* callbacks);
216796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
216896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
216996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Stops updates from the HAL, and unregisters the callback routines.
217096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * After a call to stop, the previously registered callbacks must be considered invalid by the
217196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * HAL.
217296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * If stop is invoked without a previous 'init', this function should perform no work.
217396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
217496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    void (*close) ();
217596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
217696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} GpsNavigationMessageInterface;
217796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#endif
217896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
217996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel/**
218096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel * Interface for passing GNSS configuration contents from platform to HAL.
218196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel */
218296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudeltypedef struct {
218396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /** Set to sizeof(LocGnssConfigurationInterface) */
218496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    size_t size;
218596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
218696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    /**
218796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Deliver GNSS configuration contents to HAL.
218896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * Parameters:
218996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     config_data - a pointer to a char array which holds what usually is expected from
2190f61e72231a566483d798c8bf446a00c7d736d1a5Thierry Strudel                         file(/vendor/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'.
219196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *     length - total number of UTF8 characters in configuraiton data.
219296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *
219396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     * IMPORTANT:
219496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      GPS HAL should expect this function can be called multiple times. And it may be
219596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      called even when GpsLocationProvider is already constructed and enabled. GPS HAL
219696349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      should maintain the existing requests for various callback regardless the change
219796349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     *      in configuration data.
219896349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel     */
219996349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel    void (*configuration_update) (const char* config_data, int32_t length);
220096349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel} LocGnssConfigurationInterface;
220196349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
220296349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel__END_DECLS
220396349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
220496349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel#endif /* LOC_GPS_H */
220596349ca119abc52af4d13198e70d20a7ff848a58Thierry Strudel
2206