sensor-hal-tm1: sync with sensor-hal-tw1 HAL
[platform/adaptation/tm1/sensor-hal-tm1.git] / src / proxi / proxi_device.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #ifndef _PROXI_DEVICE_H_
19 #define _PROXI_DEVICE_H_
20
21 #include <sensor/sensor_hal.h>
22 #include <string>
23 #include <vector>
24 #include <functional>
25
26 class proxi_device : public sensor_device {
27 public:
28         enum proxi_node_state_event_t {
29                 PROXIMITY_NODE_STATE_NEAR = 0,
30                 PROXIMITY_NODE_STATE_FAR = 1,
31                 PROXIMITY_NODE_STATE_UNKNOWN = 2,
32         };
33
34         proxi_device();
35         virtual ~proxi_device();
36
37         int get_poll_fd(void);
38         int get_sensors(const sensor_info_t **sensors);
39
40         bool enable(uint32_t id);
41         bool disable(uint32_t id);
42
43         int read_fd(uint32_t **ids);
44         int get_data(uint32_t id, sensor_data_t **data, int *length);
45
46 private:
47         int m_node_handle;
48         unsigned int m_state;
49         unsigned long long m_fired_time;
50         bool m_sensorhub_controlled;
51
52         int m_method;
53         std::string m_data_node;
54         std::string m_enable_node;
55
56         std::function<bool (void)> update_value;
57
58         std::vector<uint32_t> event_ids;
59
60         bool update_value_input_event(void);
61 };
62
63 #endif /* _PROXI_DEVICE_H_ */