1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CHPP_GNSS_COMMON_H_
18 #define CHPP_GNSS_COMMON_H_
19 
20 #include <stdbool.h>
21 #include <stdint.h>
22 
23 #include "chpp/app.h"
24 #include "chpp/macros.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /************************************************
31  *  Public Definitions
32  ***********************************************/
33 
34 #define CHPP_PAL_GNSS_API_VERSION CHRE_PAL_GNSS_API_V1_4
35 
36 /**
37  * Data structures for Control Location Session request.
38  */
39 CHPP_PACKED_START
40 struct ChppGnssControlLocationSessionParameters {
41   bool enable;
42   uint32_t minIntervalMs;
43   uint32_t minTimeToNextFixMs;
44 } CHPP_PACKED_ATTR;
45 CHPP_PACKED_END
46 
47 CHPP_PACKED_START
48 struct ChppGnssControlLocationSessionRequest {
49   struct ChppAppHeader header;
50   struct ChppGnssControlLocationSessionParameters params;
51 } CHPP_PACKED_ATTR;
52 CHPP_PACKED_END
53 
54 /**
55  * Data structures for Control Measurement Session request.
56  */
57 CHPP_PACKED_START
58 struct ChppGnssControlMeasurementSessionParameters {
59   bool enable;
60   uint32_t minIntervalMs;
61 } CHPP_PACKED_ATTR;
62 CHPP_PACKED_END
63 
64 CHPP_PACKED_START
65 struct ChppGnssControlMeasurementSessionRequest {
66   struct ChppAppHeader header;
67   struct ChppGnssControlMeasurementSessionParameters params;
68 } CHPP_PACKED_ATTR;
69 CHPP_PACKED_END
70 
71 /**
72  * Data structures for Configure Passive Listener request.
73  */
74 CHPP_PACKED_START
75 struct ChppGnssConfigurePassiveLocationListenerParameters {
76   bool enable;
77 } CHPP_PACKED_ATTR;
78 CHPP_PACKED_END
79 
80 CHPP_PACKED_START
81 struct ChppGnssConfigurePassiveLocationListenerRequest {
82   struct ChppAppHeader header;
83   struct ChppGnssConfigurePassiveLocationListenerParameters params;
84 } CHPP_PACKED_ATTR;
85 CHPP_PACKED_END
86 
87 /**
88  * Data structures used by the Get Capabilities response.
89  */
90 CHPP_PACKED_START
91 struct ChppGnssGetCapabilitiesParameters {
92   uint32_t capabilities;
93 } CHPP_PACKED_ATTR;
94 CHPP_PACKED_END
95 
96 CHPP_PACKED_START
97 struct ChppGnssGetCapabilitiesResponse {
98   struct ChppAppHeader header;
99   struct ChppGnssGetCapabilitiesParameters params;
100 } CHPP_PACKED_ATTR;
101 CHPP_PACKED_END
102 
103 /**
104  * Data structure used by the Control Location Session response.
105  */
106 CHPP_PACKED_START struct ChppGnssControlLocationSessionResponse {
107   struct ChppAppHeader header;
108   bool enabled;
109   uint8_t errorCode;
110 } CHPP_PACKED_ATTR;
111 CHPP_PACKED_END
112 
113 /**
114  * Data structure used by the Control Measurement Session response.
115  */
116 CHPP_PACKED_START struct ChppGnssControlMeasurementSessionResponse {
117   struct ChppAppHeader header;
118   bool enabled;
119   uint8_t errorCode;
120 } CHPP_PACKED_ATTR;
121 CHPP_PACKED_END
122 
123 /**
124  * Commands used by the GNSS (GPS) Service.
125  */
126 enum ChppGnssCommands {
127   //! Initializes the service.
128   CHPP_GNSS_OPEN = 0x0000,
129 
130   //! Deinitializes the service.
131   CHPP_GNSS_CLOSE = 0x0001,
132 
133   //! Retrieves a set of flags indicating supported features.
134   CHPP_GNSS_GET_CAPABILITIES = 0x0002,
135 
136   //! Start/stop/modify the GNSS location session.
137   CHPP_GNSS_CONTROL_LOCATION_SESSION = 0x0003,
138 
139   //!  Start/stop/modify the raw GNSS measurement session.
140   CHPP_GNSS_CONTROL_MEASUREMENT_SESSION = 0x0004,
141 
142   //! Configures opportunistic reporting of location fixes produced for other
143   //! GNSS clients.
144   CHPP_GNSS_CONFIGURE_PASSIVE_LOCATION_LISTENER = 0x0005,
145 
146   //! Notification to request that the core CHRE system re-send requests for any
147   //! active sessions and its current passive location listener setting.
148   CHPP_GNSS_REQUEST_STATE_RESYNC_NOTIFICATION = 0x0006,
149 
150   //! Notification with GNSS location results.
151   CHPP_GNSS_LOCATION_RESULT_NOTIFICATION = 0x0007,
152 
153   //!  Notification with raw GNSS measurement results.
154   CHPP_GNSS_MEASUREMENT_RESULT_NOTIFICATION = 0x0008,
155 };
156 #define CHPP_GNSS_CLIENT_REQUEST_MAX \
157   CHPP_GNSS_CONFIGURE_PASSIVE_LOCATION_LISTENER
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif  // CHPP_GNSS_COMMON_H_
164