4 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #pragma once /* __SENSOR_ADAPTER_H__ */
22 #include <sensor_internal.h>
29 sensor_info(sensor_type_t _type, int _index, int _interval, int _batch_latency, int _powersave, sensor_cb_t _cb, void *_user_data)
33 , batch_latency(_batch_latency)
34 , powersave(_powersave)
36 , user_data(_user_data)
39 sensor_info(sensor_type_t _type, int _index, int _interval, int _batch_latency, int _powersave, sensor_events_cb_t _events_cb, void *_user_data)
43 , batch_latency(_batch_latency)
44 , powersave(_powersave)
45 , events_cb(_events_cb)
46 , user_data(_user_data)
49 sensor_type_t type { UNKNOWN_SENSOR };
52 int batch_latency { 0 };
56 sensor_cb_t cb { NULL };
57 sensor_events_cb_t events_cb;
59 void *user_data { NULL };
62 class sensor_adapter {
64 static bool is_supported(sensor_type_t type);
65 static int get_count(sensor_type_t type);
66 static bool get_handle(sensor_info info, int &handle);
68 static bool start(sensor_info info, int &handle);
69 static bool stop(sensor_info info, int handle);
71 static bool change_interval(int handle, int interval);
72 static bool change_batch_latency(int handle, int batch_latency);
73 static bool change_powersave(int handle, int powersave);
74 static bool set_attribute(int handle, int attribute, int value);
75 static bool set_attribute(int handle, int attribute, char *value, int size);
77 static bool get_data(int handle, sensor_type_t type, sensor_data_t &data);
78 static bool flush(int handle);
79 static bool is_batch_mode;