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_ias_zone.h>
23 static void on_zclias_control_enroll_response_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_zclias_control_enroll_response(ZigbeeZcl_ias_zone *zclias_control_object,
37 GDBusMethodInvocation *invocation,
44 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
45 ZigbeeZclIasZoneEnrollResponse_t req;
46 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
50 memset(&req, 0x0, sizeof(ZigbeeZclIasZoneEnrollResponse_t));
52 /* Update request structure */
53 req.node_id = node_id;
54 req.dest_ep = dest_ep;
55 req.enroll_code = enroll_code;
56 req.zone_id = zone_id;
58 /* Allocate response callback data */
60 zigbee_service_dbus_interface_create_resp_cb_data(zclias_control_object,
62 if (NULL == resp_cb_data) {
63 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
65 /* Send failure response */
66 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
71 /* Dispatch request */
72 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
73 ZBLIB_DRIVER_TYPE_ZCL_IAS_ZONE,
74 ZBLIB_ZCL_IAS_ZONE_OPS_ENROLL_RESPONSE,
76 on_zclias_control_enroll_response_resp, resp_cb_data);
78 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
80 /* Free response callback data */
81 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
83 /* Send failure response */
84 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
92 void zigbee_service_dbus_interface_zcl_ias_zone_notification(ZigBeeServiceInterface *service_interface,
93 guint noti_id, gpointer noti_data, guint noti_data_len, gpointer noti_cb_data)
95 if (NULL == service_interface) {
96 Z_LOGE("service_interface is NULL");
102 NOT_USED(noti_data_len);
103 NOT_USED(noti_cb_data);
106 gboolean zigbee_service_dbus_interface_zcl_ias_zone_init(ZigBeeServiceInterface *service_interface,
107 ZigbeeObjectSkeleton *zigbee_object)
109 ZigbeeZcl_ias_zone *zclias_control_object;
111 if (NULL == service_interface) {
112 Z_LOGE("service_interface is NULL");
116 zclias_control_object = zigbee_zcl_ias_zone_skeleton_new();
117 zigbee_object_skeleton_set_zcl_ias_zone(zigbee_object, zclias_control_object);
118 g_object_unref(zclias_control_object);
120 Z_LOGI("zclias_control_object: [%p]", zclias_control_object);
123 * Register signal handlers for 'zclias_control' interface
125 g_signal_connect(zclias_control_object,
126 "handle-enroll-response",
127 G_CALLBACK(on_zclias_control_enroll_response), service_interface);