sensord: add/change enums and types for avoiding build-break
[platform/core/system/sensord.git] / src / libsensord / sensor_internal_deprecated.h
1 /*
2  * libsensord
3  *
4  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef __SENSOR_INTERNAL_DEPRECATED__
21 #define __SENSOR_INTERNAL_DEPRECATED__
22
23 #ifndef DEPRECATED
24 #define DEPRECATED __attribute__((deprecated))
25 #endif
26
27 #include "stdbool.h"
28
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33
34 #include <sys/types.h>
35
36 /*header for common sensor type*/
37 #include <sensor_common.h>
38
39 /*header for each sensor type*/
40 #include <sensor_accel.h>
41 #include <sensor_geomag.h>
42 #include <sensor_light.h>
43 #include <sensor_proxi.h>
44 #include <sensor_gyro.h>
45 #include <sensor_pressure.h>
46 #include <sensor_context.h>
47 #include <sensor_gravity.h>
48 #include <sensor_linear_accel.h>
49 #include <sensor_orientation.h>
50 #include <sensor_temperature.h>
51 #include <sensor_rv.h>
52 #include <sensor_motion.h>
53 #include <sensor_deprecated.h>
54
55 #define MAX_KEY_LEN 30
56
57 typedef struct {
58         condition_op_t cond_op;
59         float cond_value1;
60 } event_condition_t;
61
62 typedef struct {
63         size_t event_data_size;
64         void *event_data;
65 } sensor_event_data_t;
66
67 typedef void (*sensor_callback_func_t)(unsigned int, sensor_event_data_t *, void *);
68 typedef sensor_callback_func_t sensor_legacy_cb_t;
69
70 typedef struct {
71         int x;
72         int y;
73         int z;
74 } sensor_panning_data_t;
75
76 typedef struct {
77         int sensor_unit_idx;
78         float sensor_min_range;
79         float sensor_max_range;
80         float sensor_resolution;
81         char sensor_name[MAX_KEY_LEN];
82         char sensor_vendor[MAX_KEY_LEN];
83 } sensor_properties_t;
84
85 typedef struct {
86         int sensor_unit_idx;
87         float sensor_min_range;
88         float sensor_max_range;
89         float sensor_resolution;
90 } sensor_data_properties_t;
91
92 int sf_is_sensor_event_available(sensor_type_t sensor_type , unsigned int event_type);
93
94 int sf_get_data_properties(unsigned int data_id, sensor_data_properties_t *return_data_properties);
95
96 int sf_get_properties(sensor_type_t sensor_type, sensor_properties_t *return_properties);
97
98 int sf_check_rotation(unsigned long *rotation);
99
100 /**
101  * @fn int sf_connect(sensor_type_t sensor)
102  * @brief  This API connects a sensor type to respective sensor. The application calls with the type of the sensor (ex. ACCELEROMETER_SENSOR) and on basis of that server takes decision of which plug-in to be connected. Once sensor connected application can proceed for data processing. This API returns a positive handle which should be used by application to communicate on sensor type.
103  * @param[in] sensor_type your desired sensor type
104  * @return if it succeed, it return handle value( >=0 ) , otherwise negative value return
105  */
106 int sf_connect(sensor_type_t sensor_type);
107
108 /**
109  * @fn int sf_disconnect(int handle)
110  * @brief This API disconnects an attached sensor from an application. Application must use the handle retuned after attaching the sensor. After detaching, the corresponding handle will be released.
111  * @param[in] handle received handle value by sf_connect()
112  * @return if it succeed, it return zero value , otherwise negative value return
113  */
114 int sf_disconnect(int handle);
115
116 /**
117  * @fn int sf_start(int handle , int option)
118  * @brief This API sends a start command to sensor server. This intimates server that the client side is ready to handle data and start processing. The parameter option should be '0' for current usages.
119  * @param[in] handle received handle value by sf_connect()
120  * @param[in] option With SENSOR_OPTION_DEFAULT, it stops to sense when LCD is off, and with SENSOR_OPTION_ALWAYS_ON, it continues to sense even when LCD is off
121  * @return if it succeed, it return zero value , otherwise negative value return
122  */
123 int sf_start(int handle , int option);
124
125 /**
126  * @fn int sf_stop(int handle)
127  * @brief This API sends a stop command to the Sensor server indicating that the data processing is stopped from application side for this time.
128  * @param[in] handle received handle value by sf_connect()
129  * @return if it succeed, it return zero value , otherwise negative value return
130  */
131 int sf_stop(int handle);
132
133 /**
134  * @fn int sf_register_event(int handle , unsigned int event_type , event_conditon_t *event_condition , sensor_callback_func_t cb , void *user_data )
135  * @brief This API registers a user defined callback function with a connected sensor for a particular event. This callback function will be called when there is a change in the state of respective sensor. user_data will be the parameter used during the callback call. Callback interval can be adjusted using even_contion_t argument.
136  * @param[in] handle received handle value by sf_connect()
137  * @param[in] event_type your desired event_type to register it
138  * @param[in] event_condition input event_condition for special event. if you want to register without event_condition, just use a NULL value
139  * @param[in] cb your define callback function
140  * @param[in] user_data your option data that will be send when your define callback function called. if you don't have any option data, just use a NULL value
141  * @return if it succeed, it return zero value , otherwise negative value return
142  */
143 int sf_register_event(int handle , unsigned int event_type , event_condition_t *event_condition , sensor_callback_func_t cb , void *user_data );
144
145 /**
146  * @fn int sf_unregister_event(int handle, unsigned int event_type)
147  * @brief This API de-registers a user defined callback function with a sensor registered with the specified handle. After unsubscribe, no event will be sent to the application.
148  * @param[in] handle received handle value by sf_connect()
149  * @param[in] event_type your desired event_type that you want to unregister event
150  * @return if it succeed, it return zero value , otherwise negative value return
151  */
152 int sf_unregister_event(int handle, unsigned int event_type);
153
154 /**
155  * @fn int sf_get_data(int handle , unsigned int data_id , sensor_data_t* values)
156  * @brief This API gets raw data from a sensor with connecting the sensor-server. The type of sensor is supplied and return data is stored in the output parameter values [].
157  * @param[in] handle received handle value by sf_connect()
158  * @param[in] data_id predefined data_ID as every sensor in own header - sensor_xxx.h , enum xxx_data_id {}
159  * @param[out] values return values
160  * @return if it succeed, it return zero value , otherwise negative value return
161  */
162 int sf_get_data(int handle , unsigned int data_id , sensor_data_t* values);
163
164 /**
165  * @fn int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition)
166  * @brief This API change a user defined callback function condition with a sensor registered with the specified handle.
167  * @param[in] handle received handle value by sf_connect()
168  * @param[in] event_type your desired event_type that you want to unregister event
169  * @param[in] event_condition your desired event condition that you want to change event
170  * @return if it succeed, it return zero value , otherwise negative value return
171  */
172 int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition);
173
174 /**
175  * @fn int sf_change_sensor_option(int handle, int option)
176  * @brief This API change sensor option .
177  * @param[in] handle received handle value by sf_connect()
178  * @param[in] option your desired option that you want to turn on sensor during LCD OFF
179  * @return if it succeed, it return zero value , otherwise negative value return
180  */
181
182 int sf_change_sensor_option(int handle, int option);
183
184 /**
185  * @fn int sf_send_sensorhub_data(int handle, const char* buffer, int data_len)
186  * @brief This API sends data to sensorhub.
187  * @param[in] handle received handle by sf_connect()
188  * @param[in] data it holds data to send to sensorhub
189  * @param[in] data_len the length of data
190  * @return if it succeed, it returns zero, otherwise negative value
191  */
192 int sf_send_sensorhub_data(int handle, const char* data, int data_len);
193
194
195 #ifdef __cplusplus
196 }
197 #endif
198
199
200 #endif