4 * Copyright (c) 2015 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_WORKER_H_
21 #define _EXTERNAL_SENSOR_WORKER_H_
23 #include <worker_thread.h>
25 #include <sensor_common.h>
28 class external_client_manager;
29 class external_sensor;
31 class external_sensor_worker {
33 typedef bool (external_sensor_worker::*cmd_handler_t)(void *payload);
37 worker_thread m_worker;
38 external_sensor *m_sensor;
39 sensor_id_t m_sensor_id;
40 static cmd_handler_t m_cmd_handlers[CMD_EXT_CNT];
42 static void init_cmd_handlers(void);
43 static bool working(void *ctx);
44 static bool stopped(void *ctx);
46 bool dispatch_command(int cmd, void *payload);
48 bool send_cmd_done(long value);
49 bool send_cmd_get_id_done(int client_id);
50 bool send_cmd_connect_done(sensor_id_t sensor_id);
52 bool cmd_get_id(void *payload);
53 bool cmd_connect(void *payload);
54 bool cmd_disconnect(void *payload);
55 bool cmd_post(void *payload);
57 static external_client_manager& get_client_manager(void);
59 void get_info(std::string &info);
61 external_sensor_worker(const csocket& socket);
62 ~external_sensor_worker();
67 #endif /* _EXTERNAL_SENSOR_WORKER_H_ */