1/*
2 * Copyright (C) 2011 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 ANDROID_SENSORS_PORT_H_
18#define ANDROID_SENSORS_PORT_H_
19
20/*
21 * Encapsulates exchange protocol between the sensor emulator, and an application
22 * running on an Android device that provides sensor values, and is connected to
23 * the host via USB.
24 */
25
26/* Declares sensors port descriptor. */
27typedef struct AndroidSensorsPort AndroidSensorsPort;
28
29/* Creates sensors port, and connects it to the device.
30 * Param:
31 *  opaque - An opaque pointer that is passed back to the callback routines.
32 * Return:
33 *  Initialized device descriptor on success, or NULL on failure. If failure is
34 *  returned from this routine, 'errno' indicates the reason for failure. If this
35 *  routine successeds, a connection is established with the sensor reading
36 *  application on the device.
37 */
38extern AndroidSensorsPort* sensors_port_create(void* opaque);
39
40/* Disconnects from the sensors port, and destroys the descriptor. */
41extern void sensors_port_destroy(AndroidSensorsPort* asp);
42
43/* Enables events from a particular sensor.
44 * Param:
45 *  asp - Android sensors port instance returned from sensors_port_create.
46 *  name - Name of the sensor to enable events on. If this parameter is "all",
47 *      then events on all sensors will be enabled.
48 * Return:
49 *  Zero on success, failure otherwise.
50 */
51extern int sensors_port_enable_sensor(AndroidSensorsPort* asp, const char* name);
52
53
54/* Disables events from a particular sensor.
55 * Param:
56 *  asp - Android sensors port instance returned from sensors_port_create.
57 *  name - Name of the sensor to disable events on. If this parameter is "all",
58 *      then events on all sensors will be disable.
59 * Return:
60 *  Zero on success, failure otherwise.
61 */
62extern int sensors_port_disable_sensor(AndroidSensorsPort* asp, const char* name);
63
64#endif  /* ANDROID_SENSORS_PORT_H_ */
65