2 * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
4 * Contact: Suresh Kumar N (suresh.n@samsung.com)
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.
19 #include "zigbee_service_interface_common.h"
21 #include <zblib_driver_zcl_identify.h>
23 static void on_zclidentify_control_identify_resp(ZigBeeServiceInterface *service_interface,
24 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
26 ZigbeeServiceInterfaceRespCbData_t *cb_data =
27 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
30 NOT_USED(service_interface);
33 NOT_USED(resp_data_len);
36 static gboolean on_zclidentify_control_identify(ZigbeeZcl_identify *zclidentify_control_object,
37 GDBusMethodInvocation *invocation,
43 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
44 ZigbeeZclidentifyControlIdentify_t req;
45 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
49 memset(&req, 0x0, sizeof(ZigbeeZclidentifyControlIdentify_t));
51 /* Update request structure */
52 req.node_id = node_id;
53 req.dest_ep = dest_ep;
54 req.identify_time = identifytime;
56 /* Allocate response callback data */
58 zigbee_service_dbus_interface_create_resp_cb_data(zclidentify_control_object,
60 if (NULL == resp_cb_data) {
61 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
63 /* Send failure response */
64 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
69 /* Dispatch request */
70 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
71 ZBLIB_DRIVER_TYPE_ZCLIDENTIFY_CONTROL,
72 ZBLIB_ZCLIDENTIFY_CONTROL_OPS_IDENTIFY,
74 on_zclidentify_control_identify_resp, resp_cb_data);
76 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
78 /* Free response callback data */
79 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
81 /* Send failure response */
82 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
90 static void on_zclidentify_control_query_resp(ZigBeeServiceInterface *service_interface,
91 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
93 ZigbeeServiceInterfaceRespCbData_t *cb_data =
94 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
97 NOT_USED(service_interface);
100 NOT_USED(resp_data_len);
103 static gboolean on_zclidentify_control_query(ZigbeeZcl_identify *zclidentify_control_object,
104 GDBusMethodInvocation *invocation,
109 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
110 ZigbeeZclidentifyControlQuery_t req;
111 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
115 memset(&req, 0x0, sizeof(ZigbeeZclidentifyControlQuery_t));
117 /* Update request structure */
118 req.node_id = node_id;
119 req.dest_ep = dest_ep;
121 /* Allocate response callback data */
123 zigbee_service_dbus_interface_create_resp_cb_data(zclidentify_control_object,
124 invocation, NULL, 0);
125 if (NULL == resp_cb_data) {
126 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
128 /* Send failure response */
129 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
134 /* Dispatch request */
135 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
136 ZBLIB_DRIVER_TYPE_ZCLIDENTIFY_CONTROL,
137 ZBLIB_ZCLIDENTIFY_CONTROL_OPS_QUERY,
139 on_zclidentify_control_query_resp, resp_cb_data);
141 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
143 /* Free response callback data */
144 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
146 /* Send failure response */
147 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
155 gboolean zigbee_service_dbus_interface_zcl_identify_init(ZigBeeServiceInterface *service_interface,
156 ZigbeeObjectSkeleton *zigbee_object)
158 ZigbeeZcl_identify *zclidentify_control_object;
160 if (NULL == service_interface) {
161 Z_LOGE("service_interface is NULL");
165 zclidentify_control_object = zigbee_zcl_identify_skeleton_new();
166 zigbee_object_skeleton_set_zcl_identify(zigbee_object, zclidentify_control_object);
167 g_object_unref(zclidentify_control_object);
169 Z_LOGI("zclidentify_control_object: [%p]", zclidentify_control_object);
172 * Register signal handlers for 'zclidentify_control' interface
174 g_signal_connect(zclidentify_control_object,
176 G_CALLBACK(on_zclidentify_control_identify), service_interface);
178 g_signal_connect(zclidentify_control_object,
180 G_CALLBACK(on_zclidentify_control_query), service_interface);