Merge branch 'devel/tizen_3.0' into tizen
[platform/core/system/sensord.git] / src / shared / 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_types.h>
41
42 #define MAX_KEY_LEN 30
43
44 typedef struct {
45         condition_op_t cond_op;
46         float cond_value1;
47 } event_condition_t;
48
49 typedef struct {
50         size_t event_data_size;
51         void *event_data;
52 } sensor_event_data_t;
53
54 typedef void (*sensor_callback_func_t)(unsigned int, sensor_event_data_t *, void *);
55 typedef sensor_callback_func_t sensor_legacy_cb_t;
56
57 typedef struct {
58         int x;
59         int y;
60         int z;
61 } sensor_panning_data_t;
62
63 typedef struct {
64         int sensor_unit_idx;
65         float sensor_min_range;
66         float sensor_max_range;
67         float sensor_resolution;
68         char sensor_name[MAX_KEY_LEN];
69         char sensor_vendor[MAX_KEY_LEN];
70 } sensor_properties_t;
71
72 typedef struct {
73         int sensor_unit_idx;
74         float sensor_min_range;
75         float sensor_max_range;
76         float sensor_resolution;
77 } sensor_data_properties_t;
78
79 int sf_is_sensor_event_available(sensor_type_t sensor_type , unsigned int event_type);
80
81 int sf_get_data_properties(unsigned int data_id, sensor_data_properties_t *return_data_properties);
82
83 int sf_get_properties(sensor_type_t sensor_type, sensor_properties_t *return_properties);
84
85 int sf_check_rotation(unsigned long *rotation);
86
87 /**
88  * @fn int sf_connect(sensor_type_t sensor)
89  * @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.
90  * @param[in] sensor_type your desired sensor type
91  * @return if it succeed, it return handle value( >=0 ) , otherwise negative value return
92  */
93 int sf_connect(sensor_type_t sensor_type);
94
95 /**
96  * @fn int sf_disconnect(int handle)
97  * @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.
98  * @param[in] handle received handle value by sf_connect()
99  * @return if it succeed, it return zero value , otherwise negative value return
100  */
101 int sf_disconnect(int handle);
102
103 /**
104  * @fn int sf_start(int handle , int option)
105  * @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.
106  * @param[in] handle received handle value by sf_connect()
107  * @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
108  * @return if it succeed, it return zero value , otherwise negative value return
109  */
110 int sf_start(int handle , int option);
111
112 /**
113  * @fn int sf_stop(int handle)
114  * @brief This API sends a stop command to the Sensor server indicating that the data processing is stopped from application side for this time.
115  * @param[in] handle received handle value by sf_connect()
116  * @return if it succeed, it return zero value , otherwise negative value return
117  */
118 int sf_stop(int handle);
119
120 /**
121  * @fn int sf_register_event(int handle , unsigned int event_type , event_conditon_t *event_condition , sensor_callback_func_t cb , void *user_data )
122  * @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.
123  * @param[in] handle received handle value by sf_connect()
124  * @param[in] event_type your desired event_type to register it
125  * @param[in] event_condition input event_condition for special event. if you want to register without event_condition, just use a NULL value
126  * @param[in] cb your define callback function
127  * @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
128  * @return if it succeed, it return zero value , otherwise negative value return
129  */
130 int sf_register_event(int handle , unsigned int event_type , event_condition_t *event_condition , sensor_callback_func_t cb , void *user_data );
131
132 /**
133  * @fn int sf_unregister_event(int handle, unsigned int event_type)
134  * @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.
135  * @param[in] handle received handle value by sf_connect()
136  * @param[in] event_type your desired event_type that you want to unregister event
137  * @return if it succeed, it return zero value , otherwise negative value return
138  */
139 int sf_unregister_event(int handle, unsigned int event_type);
140
141 /**
142  * @fn int sf_get_data(int handle , unsigned int data_id , sensor_data_t* values)
143  * @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 [].
144  * @param[in] handle received handle value by sf_connect()
145  * @param[in] data_id predefined data_ID as every sensor in own header - sensor_xxx.h , enum xxx_data_id {}
146  * @param[out] values return values
147  * @return if it succeed, it return zero value , otherwise negative value return
148  */
149 int sf_get_data(int handle , unsigned int data_id , sensor_data_t* values);
150
151 /**
152  * @fn int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition)
153  * @brief This API change a user defined callback function condition with a sensor registered with the specified handle.
154  * @param[in] handle received handle value by sf_connect()
155  * @param[in] event_type your desired event_type that you want to unregister event
156  * @param[in] event_condition your desired event condition that you want to change event
157  * @return if it succeed, it return zero value , otherwise negative value return
158  */
159 int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition);
160
161 /**
162  * @fn int sf_change_sensor_option(int handle, int option)
163  * @brief This API change sensor option .
164  * @param[in] handle received handle value by sf_connect()
165  * @param[in] option your desired option that you want to turn on sensor during LCD OFF
166  * @return if it succeed, it return zero value , otherwise negative value return
167  */
168
169 int sf_change_sensor_option(int handle, int option);
170
171 /**
172  * @fn int sf_send_sensorhub_data(int handle, const char* buffer, int data_len)
173  * @brief This API sends data to sensorhub.
174  * @param[in] handle received handle by sf_connect()
175  * @param[in] data it holds data to send to sensorhub
176  * @param[in] data_len the length of data
177  * @return if it succeed, it returns zero, otherwise negative value
178  */
179 int sf_send_sensorhub_data(int handle, const char* data, int data_len);
180
181
182 #ifdef __cplusplus
183 }
184 #endif
185
186
187 #endif