1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 // IWYU pragma: private, include "chre_api/chre.h"
18 // IWYU pragma: friend chre/.*\.h
19
20 #ifndef _CHRE_SENSOR_H_
21 #define _CHRE_SENSOR_H_
22
23 /**
24 * @file
25 * API dealing with sensor interaction in the Context Hub Runtime
26 * Environment.
27 *
28 * This includes the definition of our sensor types and the ability to
29 * configure them for receiving events.
30 */
31
32 #include <stdbool.h>
33 #include <stdint.h>
34
35 #include <chre/common.h>
36 #include <chre/event.h>
37 #include <chre/sensor_types.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43
44 /**
45 * Base value for all of the data events for sensors.
46 *
47 * The value for a data event FOO is
48 * CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_FOO
49 *
50 * This allows for easy mapping, and also explains why there are gaps
51 * in our values since we don't have all possible sensor types assigned.
52 */
53 #define CHRE_EVENT_SENSOR_DATA_EVENT_BASE CHRE_EVENT_SENSOR_FIRST_EVENT
54
55 /**
56 * nanoappHandleEvent argument: struct chreSensorThreeAxisData
57 *
58 * The data can be interpreted using the 'x', 'y', and 'z' fields within
59 * 'readings', or by the 3D array 'v' (v[0] == x; v[1] == y; v[2] == z).
60 *
61 * All values are in SI units (m/s^2) and measure the acceleration applied to
62 * the device.
63 */
64 #define CHRE_EVENT_SENSOR_ACCELEROMETER_DATA \
65 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_ACCELEROMETER)
66
67 /**
68 * nanoappHandleEvent argument: struct chreSensorOccurrenceData
69 *
70 * Since this is a one-shot sensor, after this event is delivered to the
71 * nanoapp, the sensor automatically goes into DONE mode. Sensors of this
72 * type must be configured with a ONE_SHOT mode.
73 */
74 #define CHRE_EVENT_SENSOR_INSTANT_MOTION_DETECT_DATA \
75 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_INSTANT_MOTION_DETECT)
76
77 /**
78 * nanoappHandleEvent argument: struct chreSensorOccurrenceData
79 *
80 * Since this is a one-shot sensor, after this event is delivered to the
81 * nanoapp, the sensor automatically goes into DONE mode. Sensors of this
82 * type must be configured with a ONE_SHOT mode.
83 */
84 #define CHRE_EVENT_SENSOR_STATIONARY_DETECT_DATA \
85 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_STATIONARY_DETECT)
86
87 /**
88 * nanoappHandleEvent argument: struct struct chreSensorOccurrenceData
89 *
90 * Since this is a one-shot sensor, after this event is delivered to the
91 * nanoapp, the sensor automatically goes into DONE mode. Sensors of this
92 * type must be configured with a ONE_SHOT mode.
93 */
94 #define CHRE_EVENT_SENSOR_SIGNIFICANT_MOTION_DATA \
95 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_SIGNIFICANT_MOTION)
96
97 /**
98 * nanoappHandleEvent argument: struct chreSensorThreeAxisData
99 *
100 * The data can be interpreted using the 'x', 'y', and 'z' fields within
101 * 'readings', or by the 3D array 'v' (v[0] == x; v[1] == y; v[2] == z).
102 *
103 * All values are in radians/second and measure the rate of rotation
104 * around the X, Y and Z axis.
105 */
106 #define CHRE_EVENT_SENSOR_GYROSCOPE_DATA \
107 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_GYROSCOPE)
108
109 /**
110 * nanoappHandleEvent argument: struct chreSensorThreeAxisData
111 *
112 * The data can be interpreted using the 'x', 'y', and 'z' fields within
113 * 'readings', or by the 3D array 'v' (v[0] == x; v[1] == y; v[2] == z).
114 *
115 * All values are in micro-Tesla (uT) and measure the geomagnetic
116 * field in the X, Y and Z axis.
117 */
118 #define CHRE_EVENT_SENSOR_GEOMAGNETIC_FIELD_DATA \
119 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_GEOMAGNETIC_FIELD)
120
121 /**
122 * nanoappHandleEvent argument: struct chreSensorFloatData
123 *
124 * The data can be interpreted using the 'pressure' field within 'readings'.
125 * This value is in hectopascals (hPa).
126 */
127 #define CHRE_EVENT_SENSOR_PRESSURE_DATA \
128 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_PRESSURE)
129
130 /**
131 * nanoappHandleEvent argument: struct chreSensorFloatData
132 *
133 * The data can be interpreted using the 'light' field within 'readings'.
134 * This value is in SI lux units.
135 */
136 #define CHRE_EVENT_SENSOR_LIGHT_DATA \
137 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_LIGHT)
138
139 /**
140 * nanoappHandleEvent argument: struct chreSensorByteData
141 *
142 * The data is interpreted from the following fields in 'readings':
143 * o 'isNear': If set to 1, we are nearby (on the order of centimeters);
144 * if set to 0, we are far. The meaning of near/far in this field must be
145 * consistent with the Android definition.
146 * o 'invalid': If set to 1, this is not a valid reading of this data.
147 * As of CHRE API v1.2, this field is deprecated and must always be set to
148 * 0. If an invalid reading is generated by the sensor hardware, it must
149 * be dropped and not delivered to any nanoapp.
150 *
151 * In prior versions of the CHRE API, there can be an invalid event generated
152 * upon configuring this sensor. Thus, the 'invalid' field must be checked on
153 * the first event before interpreting 'isNear'.
154 */
155 #define CHRE_EVENT_SENSOR_PROXIMITY_DATA \
156 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_PROXIMITY)
157
158 /**
159 * nanoappHandleEvent argument: struct chreSensorOccurrenceData
160 *
161 * This data is generated every time a step is taken by the user.
162 *
163 * This is backed by the same algorithm that feeds Android's
164 * SENSOR_TYPE_STEP_DETECTOR, and therefore sacrifices some accuracy to target
165 * an update latency of under 2 seconds.
166 *
167 * @since v1.3
168 */
169 #define CHRE_EVENT_SENSOR_STEP_DETECT_DATA \
170 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_STEP_DETECT)
171
172 /**
173 * nanoappHandleEvent argument: struct chreSensorUint64Data
174 *
175 * The value of the data is the cumulative number of steps taken by the user
176 * since the last reboot while the sensor is active. This data is generated
177 * every time a step is taken by the user.
178 *
179 * This is backed by the same algorithm that feeds Android's
180 * SENSOR_TYPE_STEP_COUNTER, and therefore targets high accuracy with under
181 * 10 seconds of update latency.
182 *
183 * @since v1.5
184 */
185 #define CHRE_EVENT_SENSOR_STEP_COUNTER_DATA \
186 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_STEP_COUNTER)
187
188 /**
189 * nanoappHandleEvent argument: struct chreSensorFloatData
190 *
191 * The value of the data is the measured hinge angle between 0 and 360 degrees
192 * inclusive.
193 *
194 * This is backed by the same algorithm that feeds Android's
195 * SENSOR_TYPE_HINGE_ANGLE.
196 *
197 * @since v1.5
198 */
199 #define CHRE_EVENT_SENSOR_HINGE_ANGLE_DATA \
200 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_HINGE_ANGLE)
201
202 /**
203 * nanoappHandleEvent argument: struct chreSensorThreeAxisData
204 *
205 * The data can be interpreted using the 'x', 'y', and 'z' fields within
206 * 'readings', or by the 3D array 'v' (v[0] == x; v[1] == y; v[2] == z).
207 *
208 * All values are in SI units (m/s^2) and measure the acceleration applied to
209 * the device.
210 */
211 #define CHRE_EVENT_SENSOR_UNCALIBRATED_ACCELEROMETER_DATA \
212 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_UNCALIBRATED_ACCELEROMETER)
213
214 /**
215 * nanoappHandleEvent argument: struct chreSensorThreeAxisData
216 *
217 * The data can be interpreted using the 'x', 'y', and 'z' fields within
218 * 'readings', or by the 3D array 'v' (v[0] == x; v[1] == y; v[2] == z).
219 *
220 * All values are in radians/second and measure the rate of rotation
221 * around the X, Y and Z axis.
222 */
223 #define CHRE_EVENT_SENSOR_UNCALIBRATED_GYROSCOPE_DATA \
224 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_UNCALIBRATED_GYROSCOPE)
225
226 /**
227 * nanoappHandleEvent argument: struct chreSensorThreeAxisData
228 *
229 * The data can be interpreted using the 'x', 'y', and 'z' fields within
230 * 'readings', or by the 3D array 'v' (v[0] == x; v[1] == y; v[2] == z).
231 *
232 * All values are in micro-Tesla (uT) and measure the geomagnetic
233 * field in the X, Y and Z axis.
234 */
235 #define CHRE_EVENT_SENSOR_UNCALIBRATED_GEOMAGNETIC_FIELD_DATA \
236 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_UNCALIBRATED_GEOMAGNETIC_FIELD)
237
238 /**
239 * nanoappHandleEvent argument: struct chreSensorFloatData
240 *
241 * The data can be interpreted using the 'temperature' field within 'readings'.
242 * This value is in degrees Celsius.
243 */
244 #define CHRE_EVENT_SENSOR_ACCELEROMETER_TEMPERATURE_DATA \
245 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_ACCELEROMETER_TEMPERATURE)
246
247 /**
248 * nanoappHandleEvent argument: struct chreSensorFloatData
249 *
250 * The data can be interpreted using the 'temperature' field within 'readings'.
251 * This value is in degrees Celsius.
252 */
253 #define CHRE_EVENT_SENSOR_GYROSCOPE_TEMPERATURE_DATA \
254 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_GYROSCOPE_TEMPERATURE)
255
256 /**
257 * nanoappHandleEvent argument: struct chreSensorFloatData
258 *
259 * The data can be interpreted using the 'temperature' field within 'readings'.
260 * This value is in degrees Celsius.
261 */
262 #define CHRE_EVENT_SENSOR_GEOMAGNETIC_FIELD_TEMPERATURE_DATA \
263 (CHRE_EVENT_SENSOR_DATA_EVENT_BASE + CHRE_SENSOR_TYPE_GEOMAGNETIC_FIELD_TEMPERATURE)
264
265 /**
266 * First value for sensor events which are not data from the sensor.
267 *
268 * Unlike the data event values, these other event values don't have any
269 * mapping to sensor types.
270 */
271 #define CHRE_EVENT_SENSOR_OTHER_EVENTS_BASE \
272 (CHRE_EVENT_SENSOR_FIRST_EVENT + 0x0100)
273
274 /**
275 * nanoappHandleEvent argument: struct chreSensorSamplingStatusEvent
276 *
277 * Indicates that the interval and/or the latency which this sensor is
278 * sampling at has changed.
279 */
280 #define CHRE_EVENT_SENSOR_SAMPLING_CHANGE \
281 (CHRE_EVENT_SENSOR_OTHER_EVENTS_BASE + 0)
282
283 /**
284 * nanoappHandleEvent argument: struct chreSensorThreeAxisData
285 *
286 * The data can be interpreted using the 'x_bias', 'y_bias', and 'z_bias'
287 * field within 'readings', or by the 3D array 'bias' (bias[0] == x_bias;
288 * bias[1] == y_bias; bias[2] == z_bias). Bias is subtracted from uncalibrated
289 * data to generate calibrated data.
290 *
291 * All values are in radians/second and measure the rate of rotation
292 * around the X, Y and Z axis.
293 *
294 * If bias delivery is supported, this event is generated by default when
295 * chreSensorConfigure is called to enable for the sensor of type
296 * CHRE_SENSOR_TYPE_GYROSCOPE, or if bias delivery is explicitly enabled
297 * through chreSensorConfigureBiasEvents() for the sensor.
298 */
299 #define CHRE_EVENT_SENSOR_GYROSCOPE_BIAS_INFO \
300 (CHRE_EVENT_SENSOR_OTHER_EVENTS_BASE + 1)
301
302 /**
303 * nanoappHandleEvent argument: struct chreSensorThreeAxisData
304 *
305 * The data can be interpreted using the 'x_bias', 'y_bias', and 'z_bias'
306 * field within 'readings', or by the 3D array 'bias' (bias[0] == x_bias;
307 * bias[1] == y_bias; bias[2] == z_bias). Bias is subtracted from uncalibrated
308 * data to generate calibrated data.
309 *
310 * All values are in micro-Tesla (uT) and measure the geomagnetic
311 * field in the X, Y and Z axis.
312 *
313 * If bias delivery is supported, this event is generated by default when
314 * chreSensorConfigure is called to enable for the sensor of type
315 * CHRE_SENSOR_TYPE_GEOMAGNETIC_FIELD, or if bias delivery is explicitly enabled
316 * through chreSensorConfigureBiasEvents() for the sensor.
317 */
318 #define CHRE_EVENT_SENSOR_GEOMAGNETIC_FIELD_BIAS_INFO \
319 (CHRE_EVENT_SENSOR_OTHER_EVENTS_BASE + 2)
320
321 /**
322 * nanoappHandleEvent argument: struct chreSensorThreeAxisData
323 *
324 * The data can be interpreted using the 'x_bias', 'y_bias', and 'z_bias'
325 * field within 'readings', or by the 3D array 'bias' (bias[0] == x_bias;
326 * bias[1] == y_bias; bias[2] == z_bias). Bias is subtracted from uncalibrated
327 * data to generate calibrated data.
328 *
329 * All values are in SI units (m/s^2) and measure the acceleration applied to
330 * the device.
331 *
332 * If bias delivery is supported, this event is generated by default when
333 * chreSensorConfigure is called to enable for the sensor of type
334 * CHRE_SENSOR_TYPE_ACCELEROMETER, or if bias delivery is explicitly enabled
335 * through chreSensorConfigureBiasEvents() for the sensor.
336 *
337 * @since v1.3
338 */
339 #define CHRE_EVENT_SENSOR_ACCELEROMETER_BIAS_INFO \
340 (CHRE_EVENT_SENSOR_OTHER_EVENTS_BASE + 3)
341
342 /**
343 * nanoappHandleEvent argument: struct chreSensorFlushCompleteEvent
344 *
345 * An event indicating that a flush request made by chreSensorFlushAsync has
346 * completed.
347 *
348 * @see chreSensorFlushAsync
349 *
350 * @since v1.3
351 */
352 #define CHRE_EVENT_SENSOR_FLUSH_COMPLETE \
353 (CHRE_EVENT_SENSOR_OTHER_EVENTS_BASE + 4)
354
355 /**
356 * nanoappHandleEvent argument: struct chreSensorThreeAxisData
357 *
358 * The data of this event is the same as that of
359 * CHRE_EVENT_SENSOR_GYROSCOPE_BIAS_INFO, except the sensorHandle field of
360 * chreSensorDataHeader contains the handle of the sensor of type
361 * CHRE_SENSOR_TYPE_UNCALIBRATED_GYROSCOPE.
362 *
363 * This event is only generated if the bias reporting is explicitly enabled
364 * for a nanoapp through chreSensorConfigureBiasEvents() for the sensor of type
365 * CHRE_SENSOR_TYPE_UNCALIBRATED_GYROSCOPE.
366 *
367 * @see CHRE_EVENT_SENSOR_GYROSCOPE_BIAS_INFO
368 *
369 * @since v1.3
370 */
371 #define CHRE_EVENT_SENSOR_UNCALIBRATED_GYROSCOPE_BIAS_INFO \
372 (CHRE_EVENT_SENSOR_OTHER_EVENTS_BASE + 5)
373
374 /**
375 * nanoappHandleEvent argument: struct chreSensorThreeAxisData
376 *
377 * The data of this event is the same as that of
378 * CHRE_EVENT_SENSOR_GEOMAGNETIC_FIELD_BIAS_INFO, except the sensorHandle field
379 * of chreSensorDataHeader contains the handle of the sensor of type
380 * CHRE_SENSOR_TYPE_UNCALIBRATED_GEOMAGNETIC_FIELD.
381 *
382 * This event is only generated if the bias reporting is explicitly enabled
383 * for a nanoapp through chreSensorConfigureBiasEvents() for the sensor of type
384 * CHRE_SENSOR_TYPE_UNCALIBRATED_GEOMAGNETIC_FIELD.
385 *
386 * @see CHRE_EVENT_SENSOR_GEOMAGNETIC_FIELD_BIAS_INFO
387 *
388 * @since v1.3
389 */
390 #define CHRE_EVENT_SENSOR_UNCALIBRATED_GEOMAGNETIC_FIELD_BIAS_INFO \
391 (CHRE_EVENT_SENSOR_OTHER_EVENTS_BASE + 6)
392
393 /**
394 * nanoappHandleEvent argument: struct chreSensorThreeAxisData
395 *
396 * The data of this event is the same as that of
397 * CHRE_EVENT_SENSOR_ACCELEROMETER_BIAS_INFO, except the sensorHandle field
398 * of chreSensorDataHeader contains the handle of the sensor of type
399 * CHRE_SENSOR_TYPE_UNCALIBRATED_ACCELEROMETER.
400 *
401 * This event is only generated if the bias reporting is explicitly enabled
402 * for a nanoapp through chreSensorConfigureBiasEvents for the sensor of type
403 * CHRE_SENSOR_TYPE_UNCALIBRATED_ACCELEROMETER.
404 *
405 * @see CHRE_EVENT_SENSOR_ACCELEROMETER_BIAS_INFO
406 *
407 * @since v1.3
408 */
409 #define CHRE_EVENT_SENSOR_UNCALIBRATED_ACCELEROMETER_BIAS_INFO \
410 (CHRE_EVENT_SENSOR_OTHER_EVENTS_BASE + 7)
411
412 #if CHRE_EVENT_SENSOR_UNCALIBRATED_ACCELEROMETER_BIAS_INFO > \
413 CHRE_EVENT_SENSOR_LAST_EVENT
414 #error Too many sensor events.
415 #endif
416
417 /**
418 * Value indicating we want the smallest possible latency for a sensor.
419 *
420 * This literally translates to 0 nanoseconds for the chreSensorConfigure()
421 * argument. While we won't get exactly 0 nanoseconds, the CHRE will
422 * queue up this event As Soon As Possible.
423 */
424 #define CHRE_SENSOR_LATENCY_ASAP UINT64_C(0)
425
426 /**
427 * Special value indicating non-importance, or non-applicability of the sampling
428 * interval.
429 *
430 * @see chreSensorConfigure
431 * @see chreSensorSamplingStatus
432 */
433 #define CHRE_SENSOR_INTERVAL_DEFAULT UINT64_C(-1)
434
435 /**
436 * Special value indicating non-importance of the latency.
437 *
438 * @see chreSensorConfigure
439 * @see chreSensorSamplingStatus
440 */
441 #define CHRE_SENSOR_LATENCY_DEFAULT UINT64_C(-1)
442
443 /**
444 * A sensor index value indicating that it is the default sensor.
445 *
446 * @see chreSensorFind
447 */
448 #define CHRE_SENSOR_INDEX_DEFAULT UINT8_C(0)
449
450 /**
451 * Special value indicating non-importance of the batch interval.
452 *
453 * @see chreSensorConfigureWithBatchInterval
454 */
455 #define CHRE_SENSOR_BATCH_INTERVAL_DEFAULT UINT64_C(-1)
456
457 // This is used to define elements of enum chreSensorConfigureMode.
458 #define CHRE_SENSOR_CONFIGURE_RAW_POWER_ON (1 << 0)
459
460 // This is used to define elements of enum chreSensorConfigureMode.
461 #define CHRE_SENSOR_CONFIGURE_RAW_REPORT_CONTINUOUS (1 << 1)
462
463 // This is used to define elements of enum chreSensorConfigureMode.
464 #define CHRE_SENSOR_CONFIGURE_RAW_REPORT_ONE_SHOT (2 << 1)
465
466 /**
467 * The maximum amount of time allowed to elapse between the call to
468 * chreSensorFlushAsync() and when CHRE_EVENT_SENSOR_FLUSH_COMPLETE is delivered
469 * to the nanoapp on a successful flush.
470 */
471 #define CHRE_SENSOR_FLUSH_COMPLETE_TIMEOUT_NS (5 * CHRE_NSEC_PER_SEC)
472
473 /**
474 * Modes we can configure a sensor to use.
475 *
476 * Our mode will affect not only how/if we receive events, but
477 * also whether or not the sensor will be powered on our behalf.
478 *
479 * @see chreSensorConfigure
480 */
481 enum chreSensorConfigureMode {
482 /**
483 * Get events from the sensor.
484 *
485 * Power: Turn on if not already on.
486 * Reporting: Continuous. Send each new event as it comes (subject to
487 * batching and latency).
488 */
489 CHRE_SENSOR_CONFIGURE_MODE_CONTINUOUS =
490 (CHRE_SENSOR_CONFIGURE_RAW_POWER_ON |
491 CHRE_SENSOR_CONFIGURE_RAW_REPORT_CONTINUOUS),
492
493 /**
494 * Get a single event from the sensor and then become DONE.
495 *
496 * Once the event is sent, the sensor automatically
497 * changes to CHRE_SENSOR_CONFIGURE_MODE_DONE mode.
498 *
499 * Power: Turn on if not already on.
500 * Reporting: One shot. Send the next event and then be DONE.
501 */
502 CHRE_SENSOR_CONFIGURE_MODE_ONE_SHOT =
503 (CHRE_SENSOR_CONFIGURE_RAW_POWER_ON |
504 CHRE_SENSOR_CONFIGURE_RAW_REPORT_ONE_SHOT),
505
506 /**
507 * Get events from a sensor that are generated for any client in the system.
508 *
509 * This is considered passive because the sensor will not be powered on for
510 * the sake of our nanoapp. If and only if another client in the system has
511 * requested this sensor power on will we get events.
512 *
513 * This can be useful for something which is interested in seeing data, but
514 * not interested enough to be responsible for powering on the sensor.
515 *
516 * Power: Do not power the sensor on our behalf.
517 * Reporting: Continuous. Send each event as it comes.
518 */
519 CHRE_SENSOR_CONFIGURE_MODE_PASSIVE_CONTINUOUS =
520 CHRE_SENSOR_CONFIGURE_RAW_REPORT_CONTINUOUS,
521
522 /**
523 * Get a single event from a sensor that is generated for any client in the
524 * system.
525 *
526 * See CHRE_SENSOR_CONFIGURE_MODE_PASSIVE_CONTINUOUS for more details on
527 * what the "passive" means.
528 *
529 * Power: Do not power the sensor on our behalf.
530 * Reporting: One shot. Send only the next event and then be DONE.
531 */
532 CHRE_SENSOR_CONFIGURE_MODE_PASSIVE_ONE_SHOT =
533 CHRE_SENSOR_CONFIGURE_RAW_REPORT_ONE_SHOT,
534
535 /**
536 * Indicate we are done using this sensor and no longer interested in it.
537 *
538 * See chreSensorConfigure for more details on expressing interest or
539 * lack of interest in a sensor.
540 *
541 * Power: Do not power the sensor on our behalf.
542 * Reporting: None.
543 */
544 CHRE_SENSOR_CONFIGURE_MODE_DONE = 0,
545 };
546
547 /**
548 * A structure containing information about a Sensor.
549 *
550 * See documentation of individual fields below.
551 */
552 struct chreSensorInfo {
553 /**
554 * The name of the sensor.
555 *
556 * A text name, useful for logging/debugging, describing the Sensor. This
557 * is not assured to be unique (i.e. there could be multiple sensors with
558 * the name "Temperature").
559 *
560 * CHRE implementations may not set this as NULL. An empty
561 * string, while discouraged, is legal.
562 */
563 const char *sensorName;
564
565 /**
566 * One of the CHRE_SENSOR_TYPE_* defines above.
567 */
568 uint8_t sensorType;
569
570 /**
571 * Flag indicating if this sensor is on-change.
572 *
573 * An on-change sensor only generates events when underlying state
574 * changes. This has the same meaning as on-change does in the Android
575 * Sensors HAL. See sensors.h for much more details.
576 *
577 * A value of 1 indicates this is on-change. 0 indicates this is not
578 * on-change.
579 */
580 uint8_t isOnChange : 1;
581
582 /**
583 * Flag indicating if this sensor is one-shot.
584 *
585 * A one-shot sensor only triggers a single event, and then automatically
586 * disables itself.
587 *
588 * A value of 1 indicates this is one-shot. 0 indicates this is not
589 * on-change.
590 */
591 uint8_t isOneShot : 1;
592
593 /**
594 * Flag indicating if this sensor supports reporting bias info events.
595 *
596 * This field will be set to 0 when running on CHRE API versions prior to
597 * v1.3, but must be ignored (i.e. does not mean bias info event is not
598 * supported).
599 *
600 * @see chreSensorConfigureBiasEvents
601 *
602 * @since v1.3
603 */
604 uint8_t reportsBiasEvents : 1;
605
606 /**
607 * Flag indicating if this sensor supports passive mode requests.
608 *
609 * This field will be set to 0 when running on CHRE API versions prior to
610 * v1.4, and must be ignored (i.e. does not mean passive mode requests are
611 * not supported).
612 *
613 * @see chreSensorConfigure
614 *
615 * @since v1.4
616 */
617 uint8_t supportsPassiveMode : 1;
618
619 uint8_t unusedFlags : 4;
620
621 /**
622 * The minimum sampling interval supported by this sensor, in nanoseconds.
623 *
624 * Requests to chreSensorConfigure with a lower interval than this will
625 * fail. If the sampling interval is not applicable to this sensor, this
626 * will be set to CHRE_SENSOR_INTERVAL_DEFAULT.
627 *
628 * This field will be set to 0 when running on CHRE API versions prior to
629 * v1.1, indicating that the minimum interval is not known.
630 *
631 * @since v1.1
632 */
633 uint64_t minInterval;
634
635 /**
636 * Uniquely identifies the sensor for a given type. A value of 0 indicates
637 * that this is the "default" sensor, which is returned by
638 * chreSensorFindDefault().
639 *
640 * The sensor index of a given type must be stable across boots (i.e. must
641 * not change), and a different sensor of the same type must have different
642 * sensor index values, and the set of sensorIndex values for a given sensor
643 * type must be continuguous.
644 *
645 * @since v1.5
646 */
647 uint8_t sensorIndex;
648 };
649
650 /**
651 * The status of a sensor's sampling configuration.
652 */
653 struct chreSensorSamplingStatus {
654 /**
655 * The interval, in nanoseconds, at which sensor data is being sampled at.
656 * This should be used by nanoapps to determine the rate at which samples
657 * will be generated and not to indicate what the sensor is truly sampling
658 * at since resampling may occur to limit incoming data.
659 *
660 * If this is CHRE_SENSOR_INTERVAL_DEFAULT, then a sampling interval
661 * isn't meaningful for this sensor.
662 *
663 * Note that if 'enabled' is false, this value is not meaningful.
664 */
665 uint64_t interval;
666
667 /**
668 * The latency, in nanoseconds, at which the sensor is now reporting.
669 *
670 * If this is CHRE_SENSOR_LATENCY_DEFAULT, then a latency
671 * isn't meaningful for this sensor.
672 *
673 * The effective batch interval can be derived from this value by
674 * adding the current sampling interval.
675 *
676 * Note that if 'enabled' is false, this value is not meaningful.
677 */
678 uint64_t latency;
679
680 /**
681 * True if the sensor is actively powered and sampling; false otherwise.
682 */
683 bool enabled;
684 };
685
686 /**
687 * The nanoappHandleEvent argument for CHRE_EVENT_SENSOR_SAMPLING_CHANGE.
688 *
689 * Note that only at least one of 'interval' or 'latency' must be
690 * different than it was prior to this event. Thus, one of these
691 * fields may be (but doesn't need to be) the same as before.
692 */
693 struct chreSensorSamplingStatusEvent {
694 /**
695 * The handle of the sensor which has experienced a change in sampling.
696 */
697 uint32_t sensorHandle;
698
699 /**
700 * The new sampling status.
701 *
702 * At least one of the field in this struct will be different from
703 * the previous sampling status event.
704 */
705 struct chreSensorSamplingStatus status;
706 };
707
708 /**
709 * The nanoappHandleEvent argument for CHRE_EVENT_SENSOR_FLUSH_COMPLETE.
710 *
711 * @see chreSensorFlushAsync
712 *
713 * @since v1.3
714 */
715 struct chreSensorFlushCompleteEvent {
716 /**
717 * The handle of the sensor which a flush was completed.
718 */
719 uint32_t sensorHandle;
720
721 /**
722 * Populated with a value from enum {@link #chreError}, indicating whether
723 * the flush failed, and if so, provides the cause of the failure.
724 */
725 uint8_t errorCode;
726
727 /**
728 * Reserved for future use. Set to 0.
729 */
730 uint8_t reserved[3];
731
732 /**
733 * Set to the cookie parameter given to chreSensorFlushAsync.
734 */
735 const void *cookie;
736 };
737
738 /**
739 * Find the default sensor for a given sensor type.
740 *
741 * @param sensorType One of the CHRE_SENSOR_TYPE_* constants.
742 * @param handle If a sensor is found, then the memory will be filled with
743 * the value for the sensor's handle. This argument must be non-NULL.
744 * @return true if a sensor was found, false otherwise.
745 */
746 bool chreSensorFindDefault(uint8_t sensorType, uint32_t *handle);
747
748 /**
749 * Finds a sensor of a given index and sensor type.
750 *
751 * For CHRE implementations that support multiple sensors of the same sensor
752 * type, this method can be used to get the non-default sensor(s). The default
753 * sensor, as defined in the chreSensorFindDefault(), will be returned if
754 * a sensor index of zero is specified.
755 *
756 * A simple example of iterating all available sensors of a given type is
757 * provided here:
758 *
759 * uint32_t handle;
760 * for (uint8_t i = 0; chreSensorFind(sensorType, i, &handle); i++) {
761 * chreLog(CHRE_LOG_INFO,
762 * "Found sensor index %" PRIu8 ", which has handle %" PRIu32,
763 * i, handle);
764 * }
765 *
766 * If this method is invoked for CHRE versions prior to v1.5, invocations with
767 * sensorIndex value of 0 will be equivalent to using chreSensorFindDefault, and
768 * if sensorIndex is non-zero will return false.
769 *
770 * In cases where multiple sensors are supported in both the Android sensors
771 * framework and CHRE, the sensorName of the chreSensorInfo struct for a given
772 * sensor instance must match exactly with that of the
773 * android.hardware.Sensor#getName() return value. This can be used to match a
774 * sensor instance between the Android and CHRE sensors APIs.
775 *
776 * @param sensorType One of the CHRE_SENSOR_TYPE_* constants.
777 * @param sensorIndex The index of the desired sensor.
778 * @param handle If a sensor is found, then the memory will be filled with
779 * the value for the sensor's handle. This argument must be non-NULL.
780 * @return true if a sensor was found, false otherwise.
781 *
782 * @since v1.5
783 */
784 bool chreSensorFind(uint8_t sensorType, uint8_t sensorIndex, uint32_t *handle);
785
786 /**
787 * Get the chreSensorInfo struct for a given sensor.
788 *
789 * @param sensorHandle The sensor handle, as obtained from
790 * chreSensorFindDefault() or passed to nanoappHandleEvent().
791 * @param info If the sensor is valid, then this memory will be filled with
792 * the SensorInfo contents for this sensor. This argument must be
793 * non-NULL.
794 * @return true if the senor handle is valid and 'info' was filled in;
795 * false otherwise.
796 */
797 bool chreGetSensorInfo(uint32_t sensorHandle, struct chreSensorInfo *info);
798
799 /**
800 * Get the chreSensorSamplingStatus struct for a given sensor.
801 *
802 * Note that this may be different from what was requested in
803 * chreSensorConfigure(), for multiple reasons. It's possible that the sensor
804 * does not exactly support the interval requested in chreSensorConfigure(), so
805 * a faster one was chosen.
806 *
807 * It's also possible that there is another user of this sensor who has
808 * requested a faster interval and/or lower latency. This latter scenario
809 * should be noted, because it means the sensor rate can change due to no
810 * interaction from this nanoapp. Note that the
811 * CHRE_EVENT_SENSOR_SAMPLING_CHANGE event will trigger in this case, so it's
812 * not necessary to poll for such a change.
813 *
814 * This function must return a valid status if the provided sensor is being
815 * actively sampled by a nanoapp and a CHRE_EVENT_SENSOR_SAMPLING_CHANGE has
816 * been delivered indicating their request has taken effect. It is not required
817 * to return a valid status if no nanoapp is actively sampling the sensor.
818 *
819 * @param sensorHandle The sensor handle, as obtained from
820 * chreSensorFindDefault() or passed to nanoappHandleEvent().
821 * @param status If the sensor is actively enabled by a nanoapp, then this
822 * memory must be filled with the sampling status contents for this sensor.
823 * This argument must be non-NULL.
824 * @return true if the sensor handle is valid and 'status' was filled in;
825 * false otherwise.
826 */
827 bool chreGetSensorSamplingStatus(uint32_t sensorHandle,
828 struct chreSensorSamplingStatus *status);
829
830 /**
831 * Configures a given sensor at a specific interval and latency and mode.
832 *
833 * If this sensor's chreSensorInfo has isOneShot set to 1,
834 * then the mode must be one of the ONE_SHOT modes, or this method will fail.
835 *
836 * The CHRE wants to power as few sensors as possible, in keeping with its
837 * low power design. As such, it only turns on sensors when there are clients
838 * actively interested in that sensor data, and turns off sensors as soon as
839 * there are no clients interested in them. Calling this method generally
840 * indicates an interest, and using CHRE_SENSOR_CONFIGURE_MODE_DONE shows
841 * when we are no longer interested.
842 *
843 * Thus, each initial Configure of a sensor (per nanoapp) needs to eventually
844 * have a DONE call made, either directly or on its behalf. Subsequent calls
845 * to a Configure method within the same nanoapp, when there has been no DONE
846 * in between, still only require a single DONE call.
847 *
848 * For example, the following is valid usage:
849 * <code>
850 * chreSensorConfigure(myHandle, mode, interval0, latency0);
851 * [...]
852 * chreSensorConfigure(myHandle, mode, interval1, latency0);
853 * [...]
854 * chreSensorConfigure(myHandle, mode, interval1, latency1);
855 * [...]
856 * chreSensorConfigureModeOnly(myHandle, CHRE_SENSOR_CONFIGURE_MODE_DONE);
857 * </code>
858 *
859 * The first call to Configure is the one which creates the requirement
860 * to eventually call with DONE. The subsequent calls are just changing the
861 * interval/latency. They have not changed the fact that this nanoapp is
862 * still interested in output from the sensor 'myHandle'. Thus, only one
863 * single call for DONE is needed.
864 *
865 * There is a special case. One-shot sensors, sensors which
866 * just trigger a single event and never trigger again, implicitly go into
867 * DONE mode after that single event triggers. Thus, the
868 * following are legitimate usages:
869 * <code>
870 * chreSensorConfigure(myHandle, MODE_ONE_SHOT, interval, latency);
871 * [...]
872 * [myHandle triggers an event]
873 * [no need to configure to DONE].
874 * </code>
875 *
876 * And:
877 * <code>
878 * chreSensorConfigure(myHandle, MODE_ONE_SHOT, interval, latency);
879 * [...]
880 * chreSensorConfigureModeOnly(myHandle, MODE_DONE);
881 * [we cancelled myHandle before it ever triggered an event]
882 * </code>
883 *
884 * Note that while PASSIVE modes, by definition, don't express an interest in
885 * powering the sensor, DONE is still necessary to silence the event reporting.
886 * Starting with CHRE API v1.4, for sensors that do not support passive mode, a
887 * request with mode set to CHRE_SENSOR_CONFIGURE_MODE_PASSIVE_CONTINUOUS or
888 * CHRE_SENSOR_CONFIGURE_MODE_PASSIVE_ONE_SHOT will be rejected. CHRE API
889 * versions 1.3 and older implicitly assume that passive mode is supported
890 * across all sensors, however this is not necessarily the case. Clients can
891 * call chreSensorInfo to identify whether a sensor supports passive mode.
892 *
893 * When a calibrated sensor (e.g. CHRE_SENSOR_TYPE_ACCELEROMETER) is
894 * successfully enabled through this method and if bias delivery is supported,
895 * by default CHRE will start delivering bias events for the sensor
896 * (e.g. CHRE_EVENT_SENSOR_ACCELEROMETER_BIAS_INFO) to the nanoapp. If the
897 * nanoapp does not wish to receive these events, they can be disabled through
898 * chreSensorConfigureBiasEvents after enabling the sensor.
899 *
900 * @param sensorHandle The handle to the sensor, as obtained from
901 * chreSensorFindDefault().
902 * @param mode The mode to use. See descriptions within the
903 * chreSensorConfigureMode enum.
904 * @param interval The interval, in nanoseconds, at which we want events from
905 * the sensor. On success, the sensor will be set to 'interval', or a value
906 * less than 'interval'. There is a special value
907 * CHRE_SENSOR_INTERVAL_DEFAULT, in which we don't express a preference for
908 * the interval, and allow the sensor to choose what it wants. Note that
909 * due to batching, we may receive events less frequently than
910 * 'interval'.
911 * @param latency The maximum latency, in nanoseconds, allowed before the
912 * CHRE begins delivery of an event. This will control how many events
913 * can be queued by the sensor before requiring a delivery event.
914 * Latency is defined as the "timestamp when event is queued by the CHRE"
915 * minus "timestamp of oldest unsent data reading".
916 * There is a special value CHRE_SENSOR_LATENCY_DEFAULT, in which we don't
917 * express a preference for the latency, and allow the sensor to choose what
918 * it wants.
919 * Note that there is no assurance of how long it will take an event to
920 * get through a CHRE's queueing system, and thus there is no ability to
921 * request a minimum time from the occurrence of a phenomenon to when the
922 * nanoapp receives the information. The current CHRE API has no
923 * real-time elements, although future versions may introduce some to
924 * help with this issue.
925 * @return true if the configuration succeeded, false otherwise.
926 *
927 * @see chreSensorConfigureMode
928 * @see chreSensorFindDefault
929 * @see chreSensorInfo
930 * @see chreSensorConfigureBiasEvents
931 */
932 bool chreSensorConfigure(uint32_t sensorHandle,
933 enum chreSensorConfigureMode mode,
934 uint64_t interval, uint64_t latency);
935
936 /**
937 * Short cut for chreSensorConfigure where we only want to configure the mode
938 * and do not care about interval/latency.
939 *
940 * @see chreSensorConfigure
941 */
chreSensorConfigureModeOnly(uint32_t sensorHandle,enum chreSensorConfigureMode mode)942 static inline bool chreSensorConfigureModeOnly(
943 uint32_t sensorHandle, enum chreSensorConfigureMode mode) {
944 return chreSensorConfigure(sensorHandle,
945 mode,
946 CHRE_SENSOR_INTERVAL_DEFAULT,
947 CHRE_SENSOR_LATENCY_DEFAULT);
948 }
949
950 /**
951 * Convenience function that wraps chreSensorConfigure but enables batching to
952 * be controlled by specifying the desired maximum batch interval rather
953 * than maximum sample latency. Users may find the batch interval to be a more
954 * intuitive method of expressing the desired batching behavior.
955 *
956 * Batch interval is different from latency as the batch interval time is
957 * counted starting when the prior event containing a batch of sensor samples is
958 * delivered, while latency starts counting when the first sample is deferred to
959 * start collecting a batch. In other words, latency ignores the time between
960 * the last sample in a batch to the first sample of the next batch, while it's
961 * included in the batch interval, as illustrated below.
962 *
963 * Time 0 1 2 3 4 5 6 7 8
964 * Batch A B C
965 * Sample a1 a2 a3 b1 b2 b3 c1 c2 c3
966 * Latency [ ] [ ] [ ]
967 * BatchInt | | |
968 *
969 * In the diagram, the effective sample interval is 1 time unit, latency is 2
970 * time units, and batch interval is 3 time units.
971 *
972 * @param sensorHandle See chreSensorConfigure#sensorHandle
973 * @param mode See chreSensorConfigure#mode
974 * @param sampleInterval See chreSensorConfigure#interval, but note that
975 * CHRE_SENSOR_INTERVAL_DEFAULT is not a supported input to this method.
976 * @param batchInterval The desired maximum interval, in nanoseconds, between
977 * CHRE enqueuing each batch of sensor samples.
978 * @return Same as chreSensorConfigure
979 *
980 * @see chreSensorConfigure
981 *
982 * @since v1.1
983 */
chreSensorConfigureWithBatchInterval(uint32_t sensorHandle,enum chreSensorConfigureMode mode,uint64_t sampleInterval,uint64_t batchInterval)984 static inline bool chreSensorConfigureWithBatchInterval(
985 uint32_t sensorHandle, enum chreSensorConfigureMode mode,
986 uint64_t sampleInterval, uint64_t batchInterval) {
987 bool result = false;
988
989 if (sampleInterval != CHRE_SENSOR_INTERVAL_DEFAULT) {
990 uint64_t latency;
991 if (batchInterval == CHRE_SENSOR_BATCH_INTERVAL_DEFAULT) {
992 latency = CHRE_SENSOR_LATENCY_DEFAULT;
993 } else if (batchInterval > sampleInterval) {
994 latency = batchInterval - sampleInterval;
995 } else {
996 latency = CHRE_SENSOR_LATENCY_ASAP;
997 }
998 result = chreSensorConfigure(sensorHandle, mode, sampleInterval,
999 latency);
1000 }
1001
1002 return result;
1003 }
1004
1005 /**
1006 * Configures the reception of bias events for a specific sensor.
1007 *
1008 * If bias event delivery is supported for a sensor, the sensor's chreSensorInfo
1009 * has reportsBiasEvents set to 1. If supported, it must be supported for both
1010 * calibrated and uncalibrated versions of the sensor. If supported, CHRE must
1011 * provide bias events to the nanoapp by default when chreSensorConfigure is
1012 * called to enable the calibrated version of the sensor (for backwards
1013 * compatibility reasons, as this is the defined behavior for CHRE API v1.0).
1014 * When configuring uncalibrated sensors, nanoapps must explicitly configure an
1015 * enable request through this method to receive bias events. If bias event
1016 * delivery is not supported for the sensor, this method will return false and
1017 * no bias events will be generated.
1018 *
1019 * To enable bias event delivery (enable=true), the nanoapp must be registered
1020 * to the sensor through chreSensorConfigure, and bias events will only be
1021 * generated when the sensor is powered on. To disable the bias event delivery,
1022 * this method can be invoked with enable=false.
1023 *
1024 * If an enable configuration is successful, the calling nanoapp will receive
1025 * bias info events, e.g. CHRE_EVENT_SENSOR_ACCELEROMETER_BIAS_INFO, when the
1026 * bias status changes (or first becomes available). Calibrated data
1027 * (e.g. CHRE_SENSOR_TYPE_ACCELEROMETER) is generated by subracting bias from
1028 * uncalibrated data (e.g. CHRE_SENSOR_TYPE_UNCALIBRATED_ACCELEROMETER).
1029 * Calibrated sensor events are generated by applying the most recent bias
1030 * available (i.e. timestamp of calibrated data are greater than or equal to the
1031 * timestamp of the bias data that has been applied to it). The configuration of
1032 * bias event delivery persists until the sensor is unregistered by the nanoapp
1033 * through chreSensorConfigure or modified through this method.
1034 *
1035 * To get an initial bias before new bias events, the nanoapp should get the
1036 * bias synchronously after this method is invoked, e.g.:
1037 *
1038 * if (chreSensorConfigure(handle, ...)) {
1039 * chreSensorConfigureBiasEvents(handle, true);
1040 * chreSensorGetThreeAxisBias(handle, &bias);
1041 * }
1042 *
1043 * Note that chreSensorGetThreeAxisBias() should be called after
1044 * chreSensorConfigureBiasEvents() to ensure that no bias events are lost.
1045 *
1046 * If called while running on a CHRE API version below v1.3, this function
1047 * returns false and has no effect. The default behavior regarding bias events
1048 * is unchanged, meaning that the implementation may still send bias events
1049 * when a calibrated sensor is registered (if supported), and will not send bias
1050 * events when an uncalibrated sensor is registered.
1051 *
1052 * @param sensorHandle The handle to the sensor, as obtained from
1053 * chreSensorFindDefault().
1054 * @param enable true to receive bias events, false otherwise
1055 *
1056 * @return true if the configuration succeeded, false otherwise
1057 *
1058 * @since v1.3
1059 */
1060 bool chreSensorConfigureBiasEvents(uint32_t sensorHandle, bool enable);
1061
1062 /**
1063 * Synchronously provides the most recent bias info available for a sensor. The
1064 * bias will only be provided for a sensor that supports bias event delivery
1065 * using the chreSensorThreeAxisData type. If the bias is not yet available
1066 * (but is supported), this method will store data with a bias of 0 and the
1067 * accuracy field in chreSensorDataHeader set to CHRE_SENSOR_ACCURACY_UNKNOWN.
1068 *
1069 * If called while running on a CHRE API version below v1.3, this function
1070 * returns false.
1071 *
1072 * @param sensorHandle The handle to the sensor, as obtained from
1073 * chreSensorFindDefault().
1074 * @param bias A pointer to where the bias will be stored.
1075 *
1076 * @return true if the bias was successfully stored, false if sensorHandle was
1077 * invalid or the sensor does not support three axis bias delivery
1078 *
1079 * @since v1.3
1080 *
1081 * @see chreSensorConfigureBiasEvents
1082 */
1083 bool chreSensorGetThreeAxisBias(uint32_t sensorHandle,
1084 struct chreSensorThreeAxisData *bias);
1085
1086 /**
1087 * Makes a request to flush all samples stored for batching. The nanoapp must be
1088 * registered to the sensor through chreSensorConfigure, and the sensor must be
1089 * powered on. If the request is accepted, all batched samples of the sensor
1090 * are sent to nanoapps registered to the sensor. During a flush, it is treated
1091 * as though the latency as given in chreSensorConfigure has expired. When all
1092 * batched samples have been flushed (or the flush fails), the nanoapp will
1093 * receive a unicast CHRE_EVENT_SENSOR_FLUSH_COMPLETE event. The time to deliver
1094 * this event must not exceed CHRE_SENSOR_FLUSH_COMPLETE_TIMEOUT_NS after this
1095 * method is invoked. If there are no samples in the batch buffer (either in
1096 * hardware FIFO or software), then this method will return true and a
1097 * CHRE_EVENT_SENSOR_FLUSH_COMPLETE event is delivered immediately.
1098 *
1099 * If a flush request is invalid (e.g. the sensor refers to a one-shot sensor,
1100 * or the sensor was not enabled), and this API will return false and no
1101 * CHRE_EVENT_SENSOR_FLUSH_COMPLETE event will be delivered.
1102 *
1103 * If multiple flush requests are made for a sensor prior to flush completion,
1104 * then the requesting nanoapp will receive all batched samples existing at the
1105 * time of the latest flush request. In this case, the number of
1106 * CHRE_EVENT_SENSOR_FLUSH_COMPLETE events received must equal the number of
1107 * flush requests made.
1108 *
1109 * If a sensor request is disabled after a flush request is made through this
1110 * method but before the flush operation is completed, the nanoapp will receive
1111 * a CHRE_EVENT_SENSOR_FLUSH_COMPLETE with the error code
1112 * CHRE_ERROR_FUNCTION_DISABLED for any pending flush requests.
1113 *
1114 * Starting with CHRE API v1.3, implementations must support this capability
1115 * across all exposed sensor types.
1116 *
1117 * @param sensorHandle The handle to the sensor, as obtained from
1118 * chreSensorFindDefault().
1119 * @param cookie An opaque value that will be included in the
1120 * chreSensorFlushCompleteEvent sent in relation to this request.
1121 *
1122 * @return true if the request was accepted for processing, false otherwise
1123 *
1124 * @since v1.3
1125 */
1126 bool chreSensorFlushAsync(uint32_t sensorHandle, const void *cookie);
1127
1128 #ifdef __cplusplus
1129 }
1130 #endif
1131
1132 #endif /* _CHRE_SENSOR_H_ */
1133