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 #ifndef __EXTERNAL_SENSOR_H__
21 #define __EXTERNAL_SENSOR_H__
25 #include <sensor_types.h>
28 #ifndef EXTERNAL_SENSOR_VERSION
29 #define EXTERNAL_SENSOR_VERSION(maj, min) \
30 ((((maj) & 0xFFFF) << 24) | ((min) & 0xFFFF))
46 typedef void *external_sensor_t;
47 typedef int (*create_external_t)(external_sensor_t **sensors);
49 typedef void *observer_h;
52 * Sensor event notifier
53 * External Sensor has to call notify() function if data is ready.
55 class sensor_notifier {
57 virtual ~sensor_notifier() {}
59 virtual int notify(void) = 0;
65 class external_sensor {
67 virtual ~external_sensor() {}
69 inline uint32_t get_version(void) { return EXTERNAL_SENSOR_VERSION(1, 0); }
71 virtual int get_sensor_info(const sensor_info2_t **info) = 0;
72 virtual int set_notifier(sensor_notifier *notifier) = 0;
73 virtual int get_data(sensor_data_t **data, int *len) = 0;
75 virtual int start(observer_h ob)
80 virtual int stop(observer_h ob)
85 virtual int set_interval(observer_h ob, int32_t &interval)
90 virtual int set_batch_latency(observer_h ob, int32_t &latency)
95 virtual int set_attribute(observer_h ob, int32_t attr, int32_t value)
100 virtual int set_attribute(observer_h ob, int32_t attr, const char *value, int len)
105 virtual int flush(observer_h ob)
111 #endif /* __EXTERNAL_SENSOR_H__ */