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 #include "sensor_provider_channel_handler.h"
22 #include <command_types.h>
23 #include <sensor_log.h>
24 #include "sensor_provider.h"
26 using namespace sensor;
28 sensor_provider::channel_handler::channel_handler(sensor_provider *provider)
29 : m_provider(provider)
32 , m_set_interval_cb(NULL)
33 , m_start_user_data(NULL)
34 , m_stop_user_data(NULL)
35 , m_set_interval_user_data(NULL)
39 void sensor_provider::channel_handler::connected(ipc::channel *ch)
44 void sensor_provider::channel_handler::disconnected(ipc::channel *ch)
47 /* m_provider->restore(); */
50 void sensor_provider::channel_handler::read(ipc::channel *ch, ipc::message &msg)
53 case CMD_PROVIDER_START:
54 m_start_cb(m_provider, m_start_user_data);
56 case CMD_PROVIDER_STOP:
57 m_stop_cb(m_provider, m_stop_user_data);
59 case CMD_PROVIDER_ATTR_INT:
60 cmd_provider_attr_int_t buf;
61 msg.disclose((char *)&buf);
63 if (buf.attribute == SENSORD_ATTRIBUTE_INTERVAL)
64 m_set_interval_cb(m_provider, buf.value, m_set_interval_user_data);
69 void sensor_provider::channel_handler::read_complete(ipc::channel *ch)
73 void sensor_provider::channel_handler::error_caught(ipc::channel *ch, int error)
77 void sensor_provider::channel_handler::set_start_cb(sensord_provider_start_cb cb, void *user_data)
80 m_start_user_data = user_data;
83 void sensor_provider::channel_handler::set_stop_cb(sensord_provider_stop_cb cb, void *user_data)
86 m_stop_user_data = user_data;
89 void sensor_provider::channel_handler::set_interval_cb(sensord_provider_set_interval_cb cb, void *user_data)
91 m_set_interval_cb = cb;
92 m_set_interval_user_data = user_data;