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 __PHYSICAL_SENSOR_H__
21 #define __PHYSICAL_SENSOR_H__
26 #include <sensor_types.h>
28 #ifndef SENSOR_VERSION
29 #define PHYSICAL_SENSOR_VERSION(maj, min) \
30 ((((maj) & 0xFFFF) << 24) | ((min) & 0xFFFF))
46 typedef void *physical_sensor_t;
47 typedef int (*create_physical_t)(physical_sensor_t **sensors);
49 typedef void *observer_h;
54 class physical_sensor {
56 virtual ~physical_sensor() {}
58 inline uint32_t get_version(void) { return PHYSICAL_SENSOR_VERSION(1, 0); }
61 virtual std::string get_privilege(void) { return ""; }
63 virtual int start(observer_h ob) = 0;
64 virtual int stop(observer_h ob) = 0;
65 virtual int set_interval(observer_h ob, uint32_t interval)
70 virtual int set_batch_latency(observer_h ob, uint32_t latency)
75 virtual int set_attribute(observer_h ob, int32_t attr, int32_t value)
80 virtual int set_attribute(observer_h ob, int32_t attr, const char *value, int len)
85 virtual int flush(observer_h ob)
90 virtual int on_event(sensor_data_t *data, int32_t len, int32_t remains)
96 #endif /* __PHYSICAL_SENSOR_H__ */