1ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
2ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *
3ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * Redistribution and use in source and binary forms, with or without
4ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * modification, are permitted provided that the following conditions are
5ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * met:
6ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *     * Redistributions of source code must retain the above copyright
7ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *       notice, this list of conditions and the following disclaimer.
8ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *     * Redistributions in binary form must reproduce the above
9ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *       copyright notice, this list of conditions and the following
10ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *       disclaimer in the documentation and/or other materials provided
11ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *       with the distribution.
12ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *     * Neither the name of The Linux Foundation nor the names of its
13ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *       contributors may be used to endorse or promote products derived
14ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *       from this software without specific prior written permission.
15ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *
16ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo */
28ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
29ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#ifndef GPS_EXTENDED_C_H
30ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_EXTENDED_C_H
31ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
32ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#ifdef __cplusplus
33ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russoextern "C" {
34ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#endif /* __cplusplus */
35ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
36ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#include <ctype.h>
37ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#include <stdbool.h>
38ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#include <hardware/gps.h>
39ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
40ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** Location has valid source information. */
41ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOCATION_HAS_SOURCE_INFO   0x0020
42ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** GpsLocation has valid "is indoor?" flag */
43ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_LOCATION_HAS_IS_INDOOR   0x0040
44ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** GpsLocation has valid floor number */
45ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_LOCATION_HAS_FLOOR_NUMBER   0x0080
46ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** GpsLocation has valid map URL*/
47ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_LOCATION_HAS_MAP_URL   0x0100
48ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** GpsLocation has valid map index */
49ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_LOCATION_HAS_MAP_INDEX   0x0200
50ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
51ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** Sizes for indoor fields */
52ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_LOCATION_MAP_URL_SIZE 400
53ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_LOCATION_MAP_INDEX_SIZE 16
54ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
55ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** Position source is ULP */
56ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define ULP_LOCATION_IS_FROM_HYBRID   0x0001
57ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** Position source is GNSS only */
58ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define ULP_LOCATION_IS_FROM_GNSS   0x0002
59ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
60ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define ULP_MIN_INTERVAL_INVALID 0xffffffff
61ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
62ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
63ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef struct {
64ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /** set to sizeof(UlpLocation) */
65ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    size_t          size;
66ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    GpsLocation     gpsLocation;
67ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /* Provider indicator for HYBRID or GPS */
68ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    uint16_t        position_source;
69ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /*allows HAL to pass additional information related to the location */
70ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    int             rawDataSize;         /* in # of bytes */
71ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    void            * rawData;
72ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    bool            is_indoor;
73ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    float           floor_number;
74ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    char            map_url[GPS_LOCATION_MAP_URL_SIZE];
75ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    unsigned char   map_index[GPS_LOCATION_MAP_INDEX_SIZE];
76ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} UlpLocation;
77ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
78ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** AGPS type */
79ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef int16_t AGpsExtType;
80ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define AGPS_TYPE_INVALID       -1
81ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define AGPS_TYPE_ANY           0
82ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define AGPS_TYPE_SUPL          1
83ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define AGPS_TYPE_C2K           2
84ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define AGPS_TYPE_WWAN_ANY      3
85ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define AGPS_TYPE_WIFI          4
86ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define AGPS_TYPE_SUPL_ES       5
87ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
88ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** SSID length */
89ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define SSID_BUF_SIZE (32+1)
90ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
91ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef int16_t AGpsBearerType;
92ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define AGPS_APN_BEARER_INVALID    -1
93ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define AGPS_APN_BEARER_IPV4        0
94ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define AGPS_APN_BEARER_IPV6        1
95ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define AGPS_APN_BEARER_IPV4V6      2
96ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
97ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_DELETE_ALMANAC_CORR     0x00001000
98ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_DELETE_FREQ_BIAS_EST    0x00002000
99ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_DELETE_EPHEMERIS_GLO    0x00004000
100ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_DELETE_ALMANAC_GLO      0x00008000
101ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_DELETE_SVDIR_GLO        0x00010000
102ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_DELETE_SVSTEER_GLO      0x00020000
103ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_DELETE_ALMANAC_CORR_GLO 0x00040000
104ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_DELETE_TIME_GPS         0x00080000
105ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_DELETE_TIME_GLO         0x00100000
106ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
107ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** GPS extended callback structure. */
108ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef struct {
109ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /** set to sizeof(GpsCallbacks) */
110ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    size_t      size;
111ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    gps_set_capabilities set_capabilities_cb;
112ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    gps_acquire_wakelock acquire_wakelock_cb;
113ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    gps_release_wakelock release_wakelock_cb;
114ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    gps_create_thread create_thread_cb;
115ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    gps_request_utc_time request_utc_time_cb;
116ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} GpsExtCallbacks;
117ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
118ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** Callback to report the xtra server url to the client.
119ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *  The client should use this url when downloading xtra unless overwritten
120ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *  in the gps.conf file
121ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo */
122ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef void (* report_xtra_server)(const char*, const char*, const char*);
123ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
124ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** Callback structure for the XTRA interface. */
125ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef struct {
126ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    gps_xtra_download_request download_request_cb;
127ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    gps_create_thread create_thread_cb;
128ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    report_xtra_server report_xtra_server_cb;
129ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} GpsXtraExtCallbacks;
130ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
131ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** Represents the status of AGPS. */
132ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef struct {
133ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /** set to sizeof(AGpsExtStatus) */
134ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    size_t          size;
135ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
136ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    AGpsExtType type;
137ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    AGpsStatusValue status;
138ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    uint32_t        ipv4_addr;
139ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    char            ipv6_addr[16];
140ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    char            ssid[SSID_BUF_SIZE];
141ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    char            password[SSID_BUF_SIZE];
142ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} AGpsExtStatus;
143ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
144ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** Callback with AGPS status information.
145ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *  Can only be called from a thread created by create_thread_cb.
146ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo */
147ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef void (* agps_status_extended)(AGpsExtStatus* status);
148ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
149ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** Callback structure for the AGPS interface. */
150ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef struct {
151ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    agps_status_extended status_cb;
152ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    gps_create_thread create_thread_cb;
153ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} AGpsExtCallbacks;
154ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
155ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
156ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** GPS NI callback structure. */
157ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef struct
158ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo{
159ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /**
160ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo     * Sends the notification request from HAL to GPSLocationProvider.
161ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo     */
162ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    gps_ni_notify_callback notify_cb;
163ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    gps_create_thread create_thread_cb;
164ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} GpsNiExtCallbacks;
165ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
166ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef enum loc_server_type {
167ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_AGPS_CDMA_PDE_SERVER,
168ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_AGPS_CUSTOM_PDE_SERVER,
169ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_AGPS_MPC_SERVER,
170ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_AGPS_SUPL_SERVER
171ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} LocServerType;
172ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
173ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef enum loc_position_mode_type {
174ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_POSITION_MODE_STANDALONE,
175ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_POSITION_MODE_MS_BASED,
176ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_POSITION_MODE_MS_ASSISTED,
177ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_POSITION_MODE_RESERVED_1,
178ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_POSITION_MODE_RESERVED_2,
179ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_POSITION_MODE_RESERVED_3,
180ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_POSITION_MODE_RESERVED_4,
181ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_POSITION_MODE_RESERVED_5
182ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} LocPositionMode;
183ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
184ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */
185ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
186ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** Flags to indicate which values are valid in a GpsLocationExtended. */
187ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef uint16_t GpsLocationExtendedFlags;
188ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** GpsLocationExtended has valid pdop, hdop, vdop. */
189ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_LOCATION_EXTENDED_HAS_DOP 0x0001
190ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** GpsLocationExtended has valid altitude mean sea level. */
191ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL 0x0002
192ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** UlpLocation has valid magnetic deviation. */
193ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_LOCATION_EXTENDED_HAS_MAG_DEV 0x0004
194ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** UlpLocation has valid mode indicator. */
195ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_LOCATION_EXTENDED_HAS_MODE_IND 0x0008
196ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** GpsLocationExtended has valid vertical uncertainty */
197ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_LOCATION_EXTENDED_HAS_VERT_UNC 0x0010
198ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** GpsLocationExtended has valid speed uncertainty */
199ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_LOCATION_EXTENDED_HAS_SPEED_UNC 0x0020
200ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
201ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/** Represents gps location extended. */
202ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef struct {
203ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /** set to sizeof(GpsLocationExtended) */
204ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    size_t          size;
205ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /** Contains GpsLocationExtendedFlags bits. */
206ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    uint16_t        flags;
207ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /** Contains the Altitude wrt mean sea level */
208ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    float           altitudeMeanSeaLevel;
209ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /** Contains Position Dilusion of Precision. */
210ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    float           pdop;
211ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /** Contains Horizontal Dilusion of Precision. */
212ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    float           hdop;
213ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /** Contains Vertical Dilusion of Precision. */
214ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    float           vdop;
215ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /** Contains Magnetic Deviation. */
216ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    float           magneticDeviation;
217ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /** vertical uncertainty in meters */
218ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    float           vert_unc;
219ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    /** speed uncertainty in m/s */
220ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    float           speed_unc;
221ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} GpsLocationExtended;
222ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
223ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russoenum loc_sess_status {
224ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_SESS_SUCCESS,
225ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_SESS_INTERMEDIATE,
226ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_SESS_FAILURE
227ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo};
228ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
229ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef uint32_t LocPosTechMask;
230ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_POS_TECH_MASK_DEFAULT ((LocPosTechMask)0x00000000)
231ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_POS_TECH_MASK_SATELLITE ((LocPosTechMask)0x00000001)
232ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_POS_TECH_MASK_CELLID ((LocPosTechMask)0x00000002)
233ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_POS_TECH_MASK_WIFI ((LocPosTechMask)0x00000004)
234ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_POS_TECH_MASK_SENSORS ((LocPosTechMask)0x00000008)
235ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_POS_TECH_MASK_REFERENCE_LOCATION ((LocPosTechMask)0x00000010)
236ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_POS_TECH_MASK_INJECTED_COARSE_POSITION ((LocPosTechMask)0x00000020)
237ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_POS_TECH_MASK_AFLT ((LocPosTechMask)0x00000040)
238ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_POS_TECH_MASK_HYBRID ((LocPosTechMask)0x00000080)
239ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
240ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef enum {
241ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo  LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0,
242ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo  LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,
243ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo  LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,
244ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo  LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
245ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo  LOC_ENG_IF_REQUEST_SENDER_ID_MODEM,
246ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo  LOC_ENG_IF_REQUEST_SENDER_ID_UNKNOWN
247ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} loc_if_req_sender_id_e_type;
248ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
249ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
250ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define smaller_of(a, b) (((a) > (b)) ? (b) : (a))
251ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define MAX_APN_LEN 100
252ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
253ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo// This will be overridden by the individual adapters
254ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo// if necessary.
255ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define DEFAULT_IMPL(rtv)                                     \
256ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo{                                                             \
257ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_LOGD("%s: default implementation invoked", __func__); \
258ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    return rtv;                                               \
259ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo}
260ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
261ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russoenum loc_api_adapter_err {
262ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_ERR_SUCCESS             = 0,
263ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_ERR_GENERAL_FAILURE     = 1,
264ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_ERR_UNSUPPORTED         = 2,
265ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_ERR_INVALID_HANDLE      = 4,
266ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_ERR_INVALID_PARAMETER   = 5,
267ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_ERR_ENGINE_BUSY         = 6,
268ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_ERR_PHONE_OFFLINE       = 7,
269ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_ERR_TIMEOUT             = 8,
270ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_ERR_SERVICE_NOT_PRESENT = 9,
271ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
272ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_ERR_ENGINE_DOWN         = 100,
273ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_ERR_FAILURE,
274ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_ERR_UNKNOWN
275ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo};
276ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
277ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russoenum loc_api_adapter_event_index {
278ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REPORT_POSITION = 0,       // Position report comes in loc_parsed_position_s_type
279ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REPORT_SATELLITE,          // Satellite in view report
280ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REPORT_NMEA_1HZ,           // NMEA report at 1HZ rate
281ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REPORT_NMEA_POSITION,      // NMEA report at position report rate
282ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY,  // NI notification/verification request
283ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA,   // Assistance data, eg: time, predicted orbits request
284ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REQUEST_LOCATION_SERVER,   // Request for location server
285ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REPORT_IOCTL,              // Callback report for loc_ioctl
286ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REPORT_STATUS,             // Misc status report: eg, engine state
287ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REQUEST_WIFI,              //
288ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_SENSOR_STATUS,             //
289ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REQUEST_TIME_SYNC,         //
290ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REPORT_SPI,                //
291ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REPORT_NI_GEOFENCE,        //
292ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_GEOFENCE_GEN_ALERT,        //
293ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_REPORT_GENFENCE_BREACH,    //
294ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_PEDOMETER_CTRL,            //
295ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_MOTION_CTRL,               //
296ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
297ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LOC_API_ADAPTER_EVENT_MAX
298ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo};
299ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
300ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT   (1<<LOC_API_ADAPTER_REPORT_POSITION)
301ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_SATELLITE_REPORT         (1<<LOC_API_ADAPTER_REPORT_SATELLITE)
302ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT          (1<<LOC_API_ADAPTER_REPORT_NMEA_1HZ)
303ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT     (1<<LOC_API_ADAPTER_REPORT_NMEA_POSITION)
304ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST (1<<LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY)
305ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST  (1<<LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA)
306ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST  (1<<LOC_API_ADAPTER_REQUEST_LOCATION_SERVER)
307ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_IOCTL_REPORT             (1<<LOC_API_ADAPTER_REPORT_IOCTL)
308ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_STATUS_REPORT            (1<<LOC_API_ADAPTER_REPORT_STATUS)
309ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_REQUEST_WIFI             (1<<LOC_API_ADAPTER_REQUEST_WIFI)
310ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_SENSOR_STATUS            (1<<LOC_API_ADAPTER_SENSOR_STATUS)
311ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_REQUEST_TIME_SYNC        (1<<LOC_API_ADAPTER_REQUEST_TIME_SYNC)
312ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_REPORT_SPI               (1<<LOC_API_ADAPTER_REPORT_SPI)
313ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_REPORT_NI_GEOFENCE       (1<<LOC_API_ADAPTER_REPORT_NI_GEOFENCE)
314ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT       (1<<LOC_API_ADAPTER_GEOFENCE_GEN_ALERT)
315ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_REPORT_GENFENCE_BREACH   (1<<LOC_API_ADAPTER_REPORT_GENFENCE_BREACH)
316ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_PEDOMETER_CTRL           (1<<LOC_API_ADAPTER_PEDOMETER_CTRL)
317ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOC_API_ADAPTER_BIT_MOTION_CTRL              (1<<LOC_API_ADAPTER_MOTION_CTRL)
318ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
319ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russotypedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T;
320ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
321ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
322ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#ifdef __cplusplus
323ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo}
324ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#endif /* __cplusplus */
325ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
326ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#endif /* GPS_EXTENDED_C_H */
327ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
328