1db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine/*
2db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * Copyright (C) 2011 The Android Open Source Project
3db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *
4db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * Licensed under the Apache License, Version 2.0 (the "License");
5db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * you may not use this file except in compliance with the License.
6db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * You may obtain a copy of the License at
7db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *
8db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *      http://www.apache.org/licenses/LICENSE-2.0
9db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *
10db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * Unless required by applicable law or agreed to in writing, software
11db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * distributed under the License is distributed on an "AS IS" BASIS,
12db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * See the License for the specific language governing permissions and
14db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * limitations under the License.
15db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine */
16db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine
17db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine#ifndef ANDROID_SENSORS_PORT_H_
18db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine#define ANDROID_SENSORS_PORT_H_
19db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine
20db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine/*
21db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * Encapsulates exchange protocol between the sensor emulator, and an application
22db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * running on an Android device that provides sensor values, and is connected to
23db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * the host via USB.
24db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine */
25db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine
26db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine/* Declares sensors port descriptor. */
27db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkinetypedef struct AndroidSensorsPort AndroidSensorsPort;
28db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine
29db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine/* Creates sensors port, and connects it to the device.
30db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * Param:
31db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *  opaque - An opaque pointer that is passed back to the callback routines.
32db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * Return:
33db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *  Initialized device descriptor on success, or NULL on failure. If failure is
34db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *  returned from this routine, 'errno' indicates the reason for failure. If this
35db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *  routine successeds, a connection is established with the sensor reading
36db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *  application on the device.
37db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine */
38db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkineextern AndroidSensorsPort* sensors_port_create(void* opaque);
39db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine
40db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine/* Disconnects from the sensors port, and destroys the descriptor. */
41db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkineextern void sensors_port_destroy(AndroidSensorsPort* asp);
42db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine
43db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine/* Enables events from a particular sensor.
44db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * Param:
45db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *  asp - Android sensors port instance returned from sensors_port_create.
46db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *  name - Name of the sensor to enable events on. If this parameter is "all",
47db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *      then events on all sensors will be enabled.
48db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * Return:
49db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *  Zero on success, failure otherwise.
50db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine */
51db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkineextern int sensors_port_enable_sensor(AndroidSensorsPort* asp, const char* name);
52db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine
53db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine
54db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine/* Disables events from a particular sensor.
55db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * Param:
56db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *  asp - Android sensors port instance returned from sensors_port_create.
57db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *  name - Name of the sensor to disable events on. If this parameter is "all",
58db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *      then events on all sensors will be disable.
59db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine * Return:
60db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine *  Zero on success, failure otherwise.
61db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine */
62db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkineextern int sensors_port_disable_sensor(AndroidSensorsPort* asp, const char* name);
63db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine
64db611d57e0da9acd7ecf2a4a9b2a63e7620fe54dVladimir Chtchetkine#endif  /* ANDROID_SENSORS_PORT_H_ */
65