xref: /aosp_15_r20/system/chre/apps/test/common/chre_api_test/rpc/chre_api_test.proto (revision 84e339476a462649f82315436d70fd732297a399)
1syntax = "proto3";
2
3package chre.rpc;
4
5import "google/protobuf/empty.proto";
6
7option java_package = "dev.chre.rpc.proto";
8
9// RPC functions to call CHRE APIs
10service ChreApiTestService {
11  // Returns the BLE capabilities.
12  rpc ChreBleGetCapabilities(google.protobuf.Empty) returns (Capabilities) {}
13
14  // Returns the BLE filter capabilities.
15  rpc ChreBleGetFilterCapabilities(google.protobuf.Empty)
16      returns (Capabilities) {}
17
18  // Finds the default sensor for the given sensor type.
19  rpc ChreSensorFindDefault(ChreSensorFindDefaultInput)
20      returns (ChreSensorFindDefaultOutput) {}
21
22  // Gets the information about a sensor.
23  rpc ChreGetSensorInfo(ChreHandleInput) returns (ChreGetSensorInfoOutput) {}
24
25  // Gets the sampling status for the sensor.
26  rpc ChreGetSensorSamplingStatus(ChreHandleInput)
27      returns (ChreGetSensorSamplingStatusOutput) {}
28
29  // Configures a sensor.
30  rpc ChreSensorConfigure(ChreSensorConfigureInput) returns (Status) {}
31
32  // Configures a sensor's mode.
33  rpc ChreSensorConfigureModeOnly(ChreSensorConfigureModeOnlyInput)
34      returns (Status) {}
35
36  // Gets the audio source's information.
37  rpc ChreAudioGetSource(ChreHandleInput) returns (ChreAudioGetSourceOutput) {}
38
39  // Configures delivery of audio data to the current nanoapp.
40  rpc ChreAudioConfigureSource(ChreAudioConfigureSourceInput) returns (Status) {
41  }
42
43  // Gets the current chreAudioGetSourceStatus for a given handle.
44  rpc ChreAudioGetStatus(ChreHandleInput) returns (ChreAudioGetStatusOutput) {}
45
46  // Configures the nanoapp to receive host endpoint information for a host
47  // endpoint id.
48  rpc ChreConfigureHostEndpointNotifications(
49      ChreConfigureHostEndpointNotificationsInput) returns (Status) {}
50
51  // Gets the host endpoint info for a given host endpoint id.
52  rpc ChreGetHostEndpointInfo(ChreGetHostEndpointInfoInput)
53      returns (ChreGetHostEndpointInfoOutput) {}
54
55  // Start synchronous functions
56
57  /* Starts a BLE scan synchronously. This will wait for the
58   * event and will return success if the chreBleStartScanAsync
59   * function returns success and the event is seen. This will
60   * return the event's success field.
61   */
62  rpc ChreBleStartScanSync(ChreBleStartScanAsyncInput)
63      returns (stream GeneralSyncMessage) {}
64
65  /* Stops a BLE scan synchronously. This will wait for the
66   * event and will return success if the chreBleStopScanAsync
67   * function returns success and the event is seen. This will
68   * return the event's success field.
69   */
70  rpc ChreBleStopScanSync(google.protobuf.Empty)
71      returns (stream GeneralSyncMessage) {}
72
73  // Returns events that match the eventType filter
74  rpc GatherEvents(GatherEventsInput) returns (stream GeneralEventsMessage) {}
75}
76
77// General messages
78
79// Contains a capabilities uint32
80message Capabilities {
81  uint32 capabilities = 1;
82}
83
84// Status message
85message Status {
86  bool status = 1;
87}
88
89// Input with a handle
90message ChreHandleInput {
91  uint32 handle = 1;
92}
93
94// Message for sync function output
95message GeneralSyncMessage {
96  bool status = 1;
97}
98
99// Event capturing messages
100
101// Contains event filters for gathering events
102message GatherEventsInput {
103  repeated uint32 eventTypes = 1;
104
105  // Deprecated: We use the built-in count variable now
106  uint32 eventTypeCount = 2 [deprecated = true];
107  uint32 eventCount = 3;
108  uint64 timeoutInNs = 4;
109}
110
111// Contains events that were gathered
112// To gather a new type of event, add its message to the oneof data, then define
113// the message below
114message GeneralEventsMessage {
115  bool status = 1;
116  oneof data {
117    ChreSensorThreeAxisData chreSensorThreeAxisData = 2;
118    ChreSensorSamplingStatusEvent chreSensorSamplingStatusEvent = 3;
119    ChreHostEndpointNotification chreHostEndpointNotification = 4;
120    ChreBleAdvertisementEvent chreBleAdvertisementEvent = 5;
121    ChreAudioSourceStatusEvent chreAudioSourceStatusEvent = 6;
122    ChreAudioDataMetadata chreAudioDataMetadata = 7;
123    ChreAudioDataSamples chreAudioDataSamples = 8;
124  }
125}
126
127// Captured events' arguments (arguments to nanoappHandleEvent)
128
129// A sensor sampling status update event
130message ChreSensorSamplingStatusEvent {
131  uint32 sensorHandle = 1;
132  ChreSensorSamplingStatus status = 2;
133}
134
135// The sampling status of a sensor
136message ChreSensorSamplingStatus {
137  uint64 interval = 1;
138  uint64 latency = 2;
139  bool enabled = 3;
140}
141
142// Contains three axis data for use with the accelerometer and other sensors
143message ChreSensorThreeAxisData {
144  ChreSensorDataHeader header = 1;
145  repeated ChreSensorThreeAxisSampleData readings = 2;
146}
147
148// Header for sensor data
149message ChreSensorDataHeader {
150  uint64 baseTimestamp = 1;
151  uint32 sensorHandle = 2;
152  uint32 readingCount = 3;
153  uint32 accuracy = 4;
154  uint32 reserved = 5;
155}
156
157// Individual sample data for a three-axis sensor
158message ChreSensorThreeAxisSampleData {
159  uint32 timestampDelta = 1;
160  float x = 2;
161  float y = 3;
162  float z = 4;
163}
164
165// Data provided in host endpoint notification
166message ChreHostEndpointNotification {
167  uint32 hostEndpointId = 1;
168  uint32 notificationType = 2;
169}
170
171// A BLE advertising event
172message ChreBleAdvertisementEvent {
173  uint32 reserved = 1;
174  repeated ChreBleAdvertisingReport reports = 2;
175}
176
177// A BLE advertising report
178message ChreBleAdvertisingReport {
179  uint64 timestamp = 1;
180  uint32 eventTypeAndDataStatus = 2;
181  uint32 addressType = 3;
182  bytes address = 4;
183  uint32 primaryPhy = 5;
184  uint32 secondaryPhy = 6;
185  uint32 advertisingSid = 7;
186  int32 txPower = 8;
187  uint32 periodicAdvertisingInterval = 9;
188  int32 rssi = 10;
189  uint32 directAddressType = 11;
190  bytes directAddress = 12;
191  bytes data = 13;
192  uint32 reserved = 14;
193}
194
195// Enabled/suspended status for an audio source
196message ChreAudioSourceStatusEvent {
197  uint32 handle = 1;
198  ChreAudioSourceStatus status = 2;
199}
200
201// Status for an audio source
202message ChreAudioSourceStatus {
203  bool enabled = 1;
204  bool suspended = 2;
205}
206
207// Data provided from audio data event - only used as a framework to reconstruct
208// the message on host
209message ChreAudioDataEvent {
210  bool status = 1;
211  uint32 version = 2;
212  uint32 reserved = 3;
213  uint32 handle = 4;
214  uint64 timestamp = 5;
215  uint32 sampleRate = 6;
216  uint32 sampleCount = 7;
217  uint32 format = 8;
218  bytes samples = 9;
219}
220
221// Chre audio data metadata and samples events to send in the general event
222message ChreAudioDataMetadata {
223  uint32 version = 1;
224  uint32 reserved = 2;
225  uint32 handle = 3;
226  uint64 timestamp = 4;
227  uint32 sampleRate = 5;
228  uint32 sampleCount = 6;
229  uint32 format = 7;
230}
231
232message ChreAudioDataSamples {
233  uint32 id = 1;
234  bytes samples = 2;
235}
236
237// Function specific input/output messages
238
239// Input value for ChreSensorFindDefault
240message ChreSensorFindDefaultInput {
241  uint32 sensorType = 1;
242}
243
244// Input value for ChreConfigureHostEndpointNotifications
245message ChreConfigureHostEndpointNotificationsInput {
246  uint32 hostEndpointId = 1;
247  bool enable = 2;
248}
249
250// Retrieving subscribed disconnected host endpoint notification
251message RetrieveLatestDisconnectedHostEndpointEventOutput {
252  // Records how many disconnected event received by this nanoapp.
253  uint32 disconnectedCount = 1;
254  uint32 hostEndpointId = 2;
255}
256
257// Input value for ChreGetHostEndpointInfo
258message ChreGetHostEndpointInfoInput {
259  uint32 hostEndpointId = 1;
260}
261
262// Return value for ChreGetHostEndpointInfo.
263// Bool + chreHostEndpointInfo
264// @see chreHostEndpointInfo for description of each field.
265message ChreGetHostEndpointInfoOutput {
266  bool status = 1;
267  uint32 hostEndpointId = 2;
268  uint32 hostEndpointType = 3;
269  bool isNameValid = 4;
270  bool isTagValid = 5;
271  string endpointName = 6;
272  string endpointTag = 7;
273}
274
275// Return value for ChreSensorFindDefault. sensorHandle is only valid if
276// foundSensor is true.
277message ChreSensorFindDefaultOutput {
278  bool foundSensor = 1;
279  uint32 sensorHandle = 2;
280}
281
282// Return value for ChreGetSensorInfo
283message ChreGetSensorInfoOutput {
284  bool status = 1;
285  string sensorName = 2;
286  uint32 sensorType = 3;
287  uint32 isOnChange = 4;
288  uint32 isOneShot = 5;
289  uint32 reportsBiasEvents = 6;
290  uint32 supportsPassiveMode = 7;
291  uint32 unusedFlags = 8;
292  uint64 minInterval = 9;
293  uint32 sensorIndex = 10;
294}
295
296// Return value for ChreGetSensorSamplingStatus
297message ChreGetSensorSamplingStatusOutput {
298  bool status = 1;
299  uint64 interval = 2;
300  uint64 latency = 3;
301  bool enabled = 4;
302}
303
304// Input value for ChreSensorConfigureModeOnly
305message ChreSensorConfigureInput {
306  uint32 sensorHandle = 1;
307  uint32 mode = 2;
308  uint64 interval = 3;
309  uint64 latency = 4;
310}
311
312// Input value for ChreSensorConfigureModeOnly
313message ChreSensorConfigureModeOnlyInput {
314  uint32 sensorHandle = 1;
315  uint32 mode = 2;
316}
317
318// Enumeration for Audio Data Format
319// Must match the chreAudioDataFormat enum in audio.h
320enum ChreAudioDataFormat {
321  CHRE_AUDIO_DATA_FORMAT_8_BIT_U_LAW = 0;
322  CHRE_AUDIO_DATA_FORMAT_16_BIT_SIGNED_PCM = 1;
323}
324
325// Return value for ChreAudioGetStatus
326message ChreAudioGetStatusOutput {
327  bool status = 1;
328  ChreAudioSourceStatus audioSourceStatus = 2;
329}
330
331// Return value for ChreAudioGetSource
332message ChreAudioGetSourceOutput {
333  bool status = 1;
334  string name = 2;
335  uint32 sampleRate = 3;
336  uint64 minBufferDuration = 4;
337  uint64 maxBufferDuration = 5;
338  uint32 format = 6;
339}
340
341// Input value for ChreAudioConfigureSource
342message ChreAudioConfigureSourceInput {
343  uint32 handle = 1;
344  bool enable = 2;
345  uint64 bufferDuration = 3;
346  uint64 deliveryInterval = 4;
347}
348
349// Enumeration for BLE scan mode
350enum ChreBleScanMode {
351  INVALID = 0;
352  CHRE_BLE_SCAN_MODE_BACKGROUND = 1;
353  CHRE_BLE_SCAN_MODE_FOREGROUND = 2;
354  CHRE_BLE_SCAN_MODE_AGGRESSIVE = 3;
355}
356
357// BLE scan filters
358message ChreBleGenericFilter {
359  uint32 type = 1;
360  uint32 length = 2;
361  bytes data = 3;
362  bytes mask = 4;
363}
364
365// Scan filter for BLE scanning
366message ChreBleScanFilter {
367  int32 rssiThreshold = 1;
368
369  // Deprecated: We use the built-in count variable now
370  uint32 scanFilterCount = 2 [deprecated = true];
371  repeated ChreBleGenericFilter scanFilters = 3;
372}
373
374// Input value for ChreBleStartScanAsync
375message ChreBleStartScanAsyncInput {
376  ChreBleScanMode mode = 1;
377  uint32 reportDelayMs = 2;
378  bool hasFilter = 3;
379  ChreBleScanFilter filter = 4;
380}
381