sensord: clean up command-related types and log-related files
[platform/core/system/sensord.git] / include / sensor_types.h
1 /*
2  * sensord
3  *
4  * Copyright (c) 2016 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_TYPES_H__
21 #define __SENSOR_TYPES_H__
22
23 /* TODO: It is for compatibility with capi-system-sensor */
24 #define __SENSOR_COMMON_H__
25
26 #include <stddef.h>
27 #include <stdint.h>
28 #include <sensor_hal_types.h>
29
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34
35 #ifndef OP_SUCCESS
36 #define OP_SUCCESS 0
37 #endif
38 #ifndef OP_ERROR
39 #define OP_ERROR   -1
40 #endif
41 #ifndef OP_DEFAULT
42 #define OP_DEFAULT 1
43 #endif
44 #ifndef OP_CONTINUE
45 #define OP_CONTINUE 2
46 #endif
47 #ifndef NAME_MAX
48 #define NAME_MAX 256
49 #endif
50
51 #define SENSOR_TYPE_SHIFT 32
52 #define SENSOR_EVENT_SHIFT 16
53 #define SENSOR_INDEX_MASK 0xFFFFFFFF
54
55 #define CONVERT_ID_TYPE(id) ((id) >> SENSOR_TYPE_SHIFT)
56 #define CONVERT_TYPE_EVENT(type) ((type) << SENSOR_EVENT_SHIFT | 0x1)
57
58 #define MICROSECONDS(tv)        ((tv.tv_sec * 1000000ll) + tv.tv_usec)
59
60 typedef int64_t sensor_id_t;
61 typedef void *sensor_t;
62
63 typedef enum sensor_type_t {
64         UNKNOWN_SENSOR = -2,
65         ALL_SENSOR = -1,
66         ACCELEROMETER_SENSOR = 0,
67         GRAVITY_SENSOR,
68         LINEAR_ACCEL_SENSOR,
69         GEOMAGNETIC_SENSOR,
70         ROTATION_VECTOR_SENSOR,
71         ORIENTATION_SENSOR,
72         GYROSCOPE_SENSOR,
73         LIGHT_SENSOR,
74         PROXIMITY_SENSOR,
75         PRESSURE_SENSOR,
76         ULTRAVIOLET_SENSOR,
77         TEMPERATURE_SENSOR,
78         HUMIDITY_SENSOR,
79         HRM_SENSOR,
80         BIO_HRM_SENSOR = HRM_SENSOR,
81         HRM_LED_GREEN_SENSOR,
82         BIO_LED_GREEN_SENSOR = HRM_LED_GREEN_SENSOR,
83         HRM_LED_IR_SENSOR,
84         BIO_LED_IR_SENSOR = HRM_LED_IR_SENSOR,
85         HRM_LED_RED_SENSOR,
86         BIO_LED_RED_SENSOR = HRM_LED_RED_SENSOR,
87         GYROSCOPE_UNCAL_SENSOR,
88         GEOMAGNETIC_UNCAL_SENSOR,
89         GYROSCOPE_RV_SENSOR,
90         GEOMAGNETIC_RV_SENSOR,
91
92         HUMAN_PEDOMETER_SENSOR = 0x300,
93         HUMAN_SLEEP_MONITOR_SENSOR,
94         HUMAN_SLEEP_DETECTOR_SENSOR,
95         SLEEP_DETECTOR_SENSOR = HUMAN_SLEEP_DETECTOR_SENSOR,
96         HUMAN_STRESS_MONITOR_SENSOR,
97         STRESS_MONITOR_SENSOR = HUMAN_STRESS_MONITOR_SENSOR,
98
99         EXERCISE_WALKING_SENSOR = 0x400,
100         EXERCISE_RUNNING_SENSOR,
101         EXERCISE_HIKING_SENSOR,
102         EXERCISE_CYCLING_SENSOR,
103         EXERCISE_ELLIPTICAL_SENSOR,
104         EXERCISE_INDOOR_CYCLING_SENSOR,
105         EXERCISE_ROWING_SENSOR,
106         EXERCISE_STEPPER_SENSOR,
107
108         EXTERNAL_EXERCISE_SENSOR = 0x800,
109         EXERCISE_SENSOR = EXTERNAL_EXERCISE_SENSOR,
110
111         FUSION_SENSOR = 0x900,
112         AUTO_ROTATION_SENSOR,
113         AUTO_BRIGHTNESS_SENSOR,
114
115         GESTURE_MOVEMENT_SENSOR = 0x1200,
116         GESTURE_WRIST_UP_SENSOR,
117         GESTURE_WRIST_DOWN_SENSOR,
118         GESTURE_MOVEMENT_STATE_SENSOR,
119         GESTURE_FACE_DOWN_SENSOR,
120
121         ACTIVITY_TRACKER_SENSOR = 0x1A00,
122         ACTIVITY_LEVEL_MONITOR_SENSOR,
123         GPS_BATCH_SENSOR,
124
125         HRM_CTRL_SENSOR = 0x1A80,
126
127         WEAR_STATUS_SENSOR = 0x2000,
128         WEAR_ON_MONITOR_SENSOR,
129         NO_MOVE_DETECTOR_SENSOR,
130         RESTING_HR_SENSOR,
131         STEP_LEVEL_MONITOR_SENSOR,
132         EXERCISE_STANDALONE_SENSOR,
133         EXERCISE_COACH_SENSOR = EXERCISE_STANDALONE_SENSOR,
134         EXERCISE_HR_SENSOR,
135         WORKOUT_SENSOR,
136         AUTOSESSION_EXERCISE_SENSOR = WORKOUT_SENSOR,
137         CYCLE_MONITOR_SENSOR,
138         STAIR_TRACKER_SENSOR,
139         PRESSURE_INDICATOR_SENSOR,
140         PRESSURE_ALERT_SENSOR,
141         HR_CALORIE_SENSOR,
142
143         CONTEXT_SENSOR = 0x7000,
144         MOTION_SENSOR,
145         PIR_SENSOR,
146         PIR_LONG_SENSOR,
147         DUST_SENSOR,
148         THERMOMETER_SENSOR,
149         PEDOMETER_SENSOR,
150         FLAT_SENSOR,
151         HRM_RAW_SENSOR,
152         BIO_SENSOR = HRM_RAW_SENSOR,
153         TILT_SENSOR,
154         RV_RAW_SENSOR,
155         GSR_SENSOR,
156         SIMSENSE_SENSOR,
157         PPG_SENSOR,
158
159         CUSTOM_SENSOR = 0X9000,
160 } sensor_type_t;
161
162
163 typedef enum sensor_permission_t {
164         SENSOR_PERMISSION_NONE = 0,
165         SENSOR_PERMISSION_STANDARD = 1,
166         SENSOR_PERMISSION_HEALTH_INFO = 2,
167 } sensor_permission_t;
168
169 typedef enum sensor_privilege_t {
170         SENSOR_PRIVILEGE_PUBLIC = 1,
171 } sensor_privilege_t;
172
173 typedef struct sensor_event_t {
174         unsigned int event_type;
175         sensor_id_t sensor_id;
176         unsigned int data_length;
177         sensor_data_t *data;
178 } sensor_event_t;
179
180 /*
181  *      To prevent naming confliction as using same enums as sensor CAPI use
182  */
183 #ifndef __SENSOR_H__
184 enum sensor_option_t {
185         SENSOR_OPTION_DEFAULT = 0,
186         SENSOR_OPTION_ON_IN_SCREEN_OFF = 1,
187         SENSOR_OPTION_ON_IN_POWERSAVE_MODE = 2,
188         SENSOR_OPTION_ALWAYS_ON = SENSOR_OPTION_ON_IN_SCREEN_OFF | SENSOR_OPTION_ON_IN_POWERSAVE_MODE,
189         SENSOR_OPTION_END
190 };
191
192 typedef enum sensor_option_t sensor_option_e;
193 #endif
194
195 enum sensord_attribute_e {
196         SENSORD_ATTRIBUTE_AXIS_ORIENTATION = 1,
197         SENSORD_ATTRIBUTE_PAUSE_POLICY,
198         SENSORD_ATTRIBUTE_INTERVAL = 0x10,
199         SENSORD_ATTRIBUTE_MAX_BATCH_LATENCY,
200         SENSORD_ATTRIBUTE_PASSIVE_MODE,
201         SENSORD_ATTRIBUTE_FLUSH,
202 };
203
204 enum sensord_axis_e {
205         SENSORD_AXIS_DEVICE_ORIENTED = 1,
206         SENSORD_AXIS_DISPLAY_ORIENTED,
207 };
208
209 enum sensord_pause_e {
210         SENSORD_PAUSE_NONE = 0,
211         SENSORD_PAUSE_ON_DISPLAY_OFF = 1,
212         SENSORD_PAUSE_ON_POWERSAVE_MODE = 2,
213         SENSORD_PAUSE_ALL = 3,
214         SENSORD_PAUSE_END,
215 };
216
217 enum poll_interval_t {
218         POLL_100HZ_MS   = 10,
219         POLL_50HZ_MS    = 20,
220         POLL_25HZ_MS    = 40,
221         POLL_20HZ_MS    = 50,
222         POLL_10HZ_MS    = 100,
223         POLL_5HZ_MS             = 200,
224         POLL_1HZ_MS             = 1000,
225         POLL_MAX_HZ_MS  = 255000,
226 };
227
228 #define DEFAULT_INTERVAL POLL_10HZ_MS
229
230 enum sensor_interval_t {
231         SENSOR_INTERVAL_FASTEST = POLL_100HZ_MS,
232         SENSOR_INTERVAL_NORMAL = POLL_5HZ_MS,
233 };
234
235 enum proxi_change_state {
236         PROXIMITY_STATE_NEAR = 0,
237         PROXIMITY_STATE_FAR = 1,
238 };
239
240 enum auto_rotation_state {
241         AUTO_ROTATION_DEGREE_UNKNOWN = 0,
242         AUTO_ROTATION_DEGREE_0,
243         AUTO_ROTATION_DEGREE_90,
244         AUTO_ROTATION_DEGREE_180,
245         AUTO_ROTATION_DEGREE_270,
246 };
247
248 #ifdef __cplusplus
249 }
250 #endif
251
252 #include <sensor_deprecated.h>
253
254 #endif /* __SENSOR_TYPES_H__ */