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 __SENSOR_LISTENER_H__
21 #define __SENSOR_LISTENER_H__
23 #include <ipc_client.h>
25 #include <channel_handler.h>
26 #include <event_loop.h>
27 #include <sensor_info.h>
28 #include <sensor_types.h>
34 class sensor_listener {
36 sensor_listener(sensor_t sensor);
37 virtual ~sensor_listener();
40 sensor_t get_sensor(void);
42 ipc::channel_handler *get_event_handler(void);
43 ipc::channel_handler *get_accuracy_handler(void);
45 /* TODO: modify the listener so that it can register multiple handlers(1:n) */
46 void set_event_handler(ipc::channel_handler *handler);
47 void set_accuracy_handler(ipc::channel_handler *handler);
49 void unset_event_handler(void);
50 void unset_accuracy_handler(void);
55 int get_interval(void);
56 int get_max_batch_latency(void);
57 int get_pause_policy(void);
58 int get_passive_mode(void);
60 int set_interval(unsigned int interval);
61 int set_max_batch_latency(unsigned int max_batch_latency);
62 int set_passive_mode(bool passive);
63 int set_attribute(int attribute, int value);
64 int set_attribute(int attribute, const char *value, int len);
66 int get_sensor_data(sensor_data_t *data);
76 void disconnect(void);
77 bool is_connected(void);
80 sensor_info *m_sensor;
82 ipc::ipc_client *m_client;
83 ipc::channel *m_cmd_channel;
84 ipc::channel *m_evt_channel;
85 ipc::channel_handler *m_handler;
86 ipc::channel_handler *m_evt_handler;
87 ipc::channel_handler *m_acc_handler;
88 ipc::event_loop m_loop;
89 std::atomic<bool> m_connected;
90 std::atomic<bool> m_started;
91 std::map<int, int> m_attributes;
96 #endif /* __SENSOR_LISTENER_H__ */