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_color_control.h>
23 static void *_service_interface_ref_zigbee_zcl_color_control(
24 ZigBeeServiceInterface *service_interface)
26 ZigbeeObjectSkeleton *zigbee_object = NULL;
27 ZigbeeCustomData_t *custom_data = NULL;
28 ZigbeeZcl_color_control *color_object = NULL;
30 custom_data = (ZigbeeCustomData_t *)zblib_service_interface_ref_user_data(service_interface);
31 if (NULL == custom_data) {
32 Z_LOGE("D-BUS service interface custom_data is NULL!");
36 /* Get zigbee object */
37 zigbee_object = g_hash_table_lookup(custom_data->objects, ZIGBEE_SERVICE_PATH);
38 if (NULL == zigbee_object) {
39 Z_LOGW("Cannot find ZigBee D-BUS interface object!", zigbee_object);
43 color_object = zigbee_object_get_zcl_color_control(ZIGBEE_OBJECT(zigbee_object));
47 static void on_zcl_color_move_to_hue_resp(ZigBeeServiceInterface *service_interface,
48 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
50 ZigbeeServiceInterfaceRespCbData_t *cb_data =
51 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
53 ZigbeeZcl_color_control *zcl_color_object = NULL;
54 GDBusMethodInvocation *invocation = NULL;
56 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
58 NOT_USED(service_interface);
61 if (NULL == resp_data || 0 == resp_data_len) {
62 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
67 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
68 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
70 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
71 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
73 zigbee_zcl_color_control_complete_move_to_hue(zcl_color_object, invocation,
79 static gboolean on_zcl_color_move_to_hue(ZigbeeZcl_color_control *zcl_color_object,
80 GDBusMethodInvocation *invocation,
85 gshort transition_time,
88 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
89 ZigbeeZclColorControlMoveToHue_t req;
90 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
94 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveToHue_t));
96 /* Update request structure */
97 req.node_id = node_id;
98 req.dest_ep = endpoint;
100 req.direction = direction;
101 req.transition_time = transition_time;
103 /* Allocate response callback data */
105 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
106 invocation, NULL, 0);
107 if (NULL == resp_cb_data) {
108 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
110 /* Send failure response */
111 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
116 /* Dispatch request */
117 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
118 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
119 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_TO_HUE,
121 on_zcl_color_move_to_hue_resp, resp_cb_data);
123 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
125 /* Free response callback data */
126 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
128 /* Send failure response */
129 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
137 static void on_zcl_color_move_hue_resp(ZigBeeServiceInterface *service_interface,
138 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
140 ZigbeeServiceInterfaceRespCbData_t *cb_data =
141 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
143 ZigbeeZcl_color_control *zcl_color_object = NULL;
144 GDBusMethodInvocation *invocation = NULL;
146 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
148 NOT_USED(service_interface);
149 NOT_USED(request_id);
151 if (NULL == resp_data || 0 == resp_data_len) {
152 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
157 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
158 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
160 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
161 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
163 zigbee_zcl_color_control_complete_move_hue(zcl_color_object, invocation,
169 static gboolean on_zcl_color_move_hue(ZigbeeZcl_color_control *zcl_color_object,
170 GDBusMethodInvocation *invocation,
177 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
178 ZigbeeZclColorControlMoveHue_t req;
179 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
183 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveHue_t));
185 /* Update request structure */
186 req.node_id = node_id;
187 req.dest_ep = endpoint;
188 req.move_mode = move_mode;
191 /* Allocate response callback data */
193 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
194 invocation, NULL, 0);
195 if (NULL == resp_cb_data) {
196 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
198 /* Send failure response */
199 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
204 /* Dispatch request */
205 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
206 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
207 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_HUE,
209 on_zcl_color_move_hue_resp, resp_cb_data);
211 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
213 /* Free response callback data */
214 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
216 /* Send failure response */
217 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
225 static void on_zcl_color_step_hue_resp(ZigBeeServiceInterface *service_interface,
226 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
228 ZigbeeServiceInterfaceRespCbData_t *cb_data =
229 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
231 ZigbeeZcl_color_control *zcl_color_object = NULL;
232 GDBusMethodInvocation *invocation = NULL;
234 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
236 NOT_USED(service_interface);
237 NOT_USED(request_id);
239 if (NULL == resp_data || 0 == resp_data_len) {
240 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
245 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
246 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
248 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
249 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
251 zigbee_zcl_color_control_complete_step_hue(zcl_color_object, invocation,
257 static gboolean on_zcl_color_step_hue(ZigbeeZcl_color_control *zcl_color_object,
258 GDBusMethodInvocation *invocation,
263 gchar transition_time,
266 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
267 ZigbeeZclColorControlStepHue_t req;
268 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
272 memset(&req, 0x0, sizeof(ZigbeeZclColorControlStepHue_t));
274 /* Update request structure */
275 req.node_id = node_id;
276 req.dest_ep = endpoint;
277 req.step_mode = step_mode;
278 req.step_size = step_size;
279 req.transition_time = transition_time;
281 /* Allocate response callback data */
283 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
284 invocation, NULL, 0);
285 if (NULL == resp_cb_data) {
286 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
288 /* Send failure response */
289 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
294 /* Dispatch request */
295 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
296 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
297 ZBLIB_ZCL_COLOR_CONTROL_OPS_STEP_HUE,
299 on_zcl_color_step_hue_resp, resp_cb_data);
301 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
303 /* Free response callback data */
304 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
306 /* Send failure response */
307 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
315 static void on_zcl_color_move_to_saturation_resp(ZigBeeServiceInterface *service_interface,
316 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
318 ZigbeeServiceInterfaceRespCbData_t *cb_data =
319 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
321 ZigbeeZcl_color_control *zcl_color_object = NULL;
322 GDBusMethodInvocation *invocation = NULL;
324 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
326 NOT_USED(service_interface);
327 NOT_USED(request_id);
329 if (NULL == resp_data || 0 == resp_data_len) {
330 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
335 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
336 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
338 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
339 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
341 zigbee_zcl_color_control_complete_move_to_saturation(zcl_color_object, invocation,
347 static gboolean on_zcl_color_move_to_saturation(ZigbeeZcl_color_control *zcl_color_object,
348 GDBusMethodInvocation *invocation,
352 gshort transition_time,
355 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
356 ZigbeeZclColorControlMoveToSaturation_t req;
357 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
361 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveToSaturation_t));
363 /* Update request structure */
364 req.node_id = node_id;
365 req.dest_ep = endpoint;
366 req.saturation = saturation;
367 req.transition_time = transition_time;
369 /* Allocate response callback data */
371 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
372 invocation, NULL, 0);
373 if (NULL == resp_cb_data) {
374 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
376 /* Send failure response */
377 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
382 /* Dispatch request */
383 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
384 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
385 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_TO_STAURATION,
387 on_zcl_color_move_to_saturation_resp, resp_cb_data);
389 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
391 /* Free response callback data */
392 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
394 /* Send failure response */
395 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
403 static void on_zcl_color_move_saturation_resp(ZigBeeServiceInterface *service_interface,
404 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
406 ZigbeeServiceInterfaceRespCbData_t *cb_data =
407 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
409 ZigbeeZcl_color_control *zcl_color_object = NULL;
410 GDBusMethodInvocation *invocation = NULL;
412 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
414 NOT_USED(service_interface);
415 NOT_USED(request_id);
417 if (NULL == resp_data || 0 == resp_data_len) {
418 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
423 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
424 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
426 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
427 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
429 zigbee_zcl_color_control_complete_move_saturation(zcl_color_object, invocation,
435 static gboolean on_zcl_color_move_saturation(ZigbeeZcl_color_control *zcl_color_object,
436 GDBusMethodInvocation *invocation,
443 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
444 ZigbeeZclColorControlMoveSaturation_t req;
445 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
449 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveSaturation_t));
451 /* Update request structure */
452 req.node_id = node_id;
453 req.dest_ep = endpoint;
454 req.move_mode = move_mode;
457 /* Allocate response callback data */
459 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
460 invocation, NULL, 0);
461 if (NULL == resp_cb_data) {
462 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
464 /* Send failure response */
465 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
470 /* Dispatch request */
471 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
472 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
473 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_STAURATION,
475 on_zcl_color_move_saturation_resp, resp_cb_data);
477 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
479 /* Free response callback data */
480 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
482 /* Send failure response */
483 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
491 static void on_zcl_color_step_saturation_resp(ZigBeeServiceInterface *service_interface,
492 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
494 ZigbeeServiceInterfaceRespCbData_t *cb_data =
495 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
497 ZigbeeZcl_color_control *zcl_color_object = NULL;
498 GDBusMethodInvocation *invocation = NULL;
500 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
502 NOT_USED(service_interface);
503 NOT_USED(request_id);
505 if (NULL == resp_data || 0 == resp_data_len) {
506 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
511 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
512 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
514 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
515 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
517 zigbee_zcl_color_control_complete_step_saturation(zcl_color_object, invocation,
523 static gboolean on_zcl_color_step_saturation(ZigbeeZcl_color_control *zcl_color_object,
524 GDBusMethodInvocation *invocation,
529 gchar transition_time,
532 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
533 ZigbeeZclColorControlStepSaturation_t req;
534 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
538 memset(&req, 0x0, sizeof(ZigbeeZclColorControlStepSaturation_t));
540 /* Update request structure */
541 req.node_id = node_id;
542 req.dest_ep = endpoint;
543 req.step_mode = step_mode;
544 req.step_size = step_size;
545 req.transition_time = transition_time;
547 /* Allocate response callback data */
549 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
550 invocation, NULL, 0);
551 if (NULL == resp_cb_data) {
552 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
554 /* Send failure response */
555 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
560 /* Dispatch request */
561 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
562 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
563 ZBLIB_ZCL_COLOR_CONTROL_OPS_STEP_STAURATION,
565 on_zcl_color_step_saturation_resp, resp_cb_data);
567 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
569 /* Free response callback data */
570 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
572 /* Send failure response */
573 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
581 static void on_zcl_color_move_to_hue_and_saturation_resp(ZigBeeServiceInterface *service_interface,
582 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
584 ZigbeeServiceInterfaceRespCbData_t *cb_data =
585 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
587 ZigbeeZcl_color_control *zcl_color_object = NULL;
588 GDBusMethodInvocation *invocation = NULL;
590 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
592 NOT_USED(service_interface);
593 NOT_USED(request_id);
595 if (NULL == resp_data || 0 == resp_data_len) {
596 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
601 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
602 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
604 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
605 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
607 zigbee_zcl_color_control_complete_move_to_hue_and_saturation(zcl_color_object,
608 invocation, payload->result);
613 static gboolean on_zcl_color_move_to_hue_and_saturation(ZigbeeZcl_color_control *zcl_color_object,
614 GDBusMethodInvocation *invocation,
619 gshort transition_time,
622 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
623 ZigbeeZclColorControlMoveToHueAndSaturation_t req;
624 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
628 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveToHueAndSaturation_t));
630 /* Update request structure */
631 req.node_id = node_id;
632 req.dest_ep = endpoint;
634 req.saturation = saturation;
635 req.transition_time = transition_time;
637 /* Allocate response callback data */
639 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
640 invocation, NULL, 0);
641 if (NULL == resp_cb_data) {
642 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
644 /* Send failure response */
645 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
650 /* Dispatch request */
651 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
652 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
653 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_TO_HUE_AND_SATURATION,
655 on_zcl_color_move_to_hue_and_saturation_resp, resp_cb_data);
657 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
659 /* Free response callback data */
660 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
662 /* Send failure response */
663 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
671 static void on_zcl_color_move_to_color_resp(ZigBeeServiceInterface *service_interface,
672 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
674 ZigbeeServiceInterfaceRespCbData_t *cb_data =
675 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
677 ZigbeeZcl_color_control *zcl_color_object = NULL;
678 GDBusMethodInvocation *invocation = NULL;
680 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
682 NOT_USED(service_interface);
683 NOT_USED(request_id);
685 if (NULL == resp_data || 0 == resp_data_len) {
686 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
691 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
692 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
694 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
695 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
697 zigbee_zcl_color_control_complete_move_to_color(zcl_color_object, invocation,
703 static gboolean on_zcl_color_move_to_color(ZigbeeZcl_color_control *zcl_color_object,
704 GDBusMethodInvocation *invocation,
709 gshort transition_time,
712 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
713 ZigbeeZclColorControlMoveToColor_t req;
714 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
718 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveToColor_t));
720 /* Update request structure */
721 req.node_id = node_id;
722 req.dest_ep = endpoint;
723 req.color_x = start_x;
724 req.color_y = start_y;
725 req.transition_time = transition_time;
727 /* Allocate response callback data */
729 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
730 invocation, NULL, 0);
731 if (NULL == resp_cb_data) {
732 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
734 /* Send failure response */
735 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
740 /* Dispatch request */
741 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
742 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
743 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_TO_COLOR,
745 on_zcl_color_move_to_color_resp, resp_cb_data);
747 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
749 /* Free response callback data */
750 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
752 /* Send failure response */
753 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
761 static void on_zcl_color_move_color_resp(ZigBeeServiceInterface *service_interface,
762 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
764 ZigbeeServiceInterfaceRespCbData_t *cb_data =
765 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
767 ZigbeeZcl_color_control *zcl_color_object = NULL;
768 GDBusMethodInvocation *invocation = NULL;
770 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
772 NOT_USED(service_interface);
773 NOT_USED(request_id);
775 if (NULL == resp_data || 0 == resp_data_len) {
776 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
781 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
782 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
784 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
785 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
787 zigbee_zcl_color_control_complete_move_color(zcl_color_object, invocation,
793 static gboolean on_zcl_color_move_color(ZigbeeZcl_color_control *zcl_color_object,
794 GDBusMethodInvocation *invocation,
801 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
802 ZigbeeZclColorControlMoveColor_t req;
803 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
807 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveColor_t));
809 /* Update request structure */
810 req.node_id = node_id;
811 req.dest_ep = endpoint;
815 /* Allocate response callback data */
817 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
818 invocation, NULL, 0);
819 if (NULL == resp_cb_data) {
820 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
822 /* Send failure response */
823 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
828 /* Dispatch request */
829 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
830 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
831 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_COLOR,
833 on_zcl_color_move_color_resp, resp_cb_data);
835 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
837 /* Free response callback data */
838 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
840 /* Send failure response */
841 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
849 static void on_zcl_color_step_color_resp(ZigBeeServiceInterface *service_interface,
850 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
852 ZigbeeServiceInterfaceRespCbData_t *cb_data =
853 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
855 ZigbeeZcl_color_control *zcl_color_object = NULL;
856 GDBusMethodInvocation *invocation = NULL;
858 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
860 NOT_USED(service_interface);
861 NOT_USED(request_id);
863 if (NULL == resp_data || 0 == resp_data_len) {
864 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
869 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
870 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
872 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
873 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
875 zigbee_zcl_color_control_complete_step_color(zcl_color_object, invocation,
881 static gboolean on_zcl_color_step_color(ZigbeeZcl_color_control *zcl_color_object,
882 GDBusMethodInvocation *invocation,
887 gshort transition_time,
890 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
891 ZigbeeZclColorControlStepColor_t req;
892 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
896 memset(&req, 0x0, sizeof(ZigbeeZclColorControlStepColor_t));
898 /* Update request structure */
899 req.node_id = node_id;
900 req.dest_ep = endpoint;
903 req.transition_time = transition_time;
905 /* Allocate response callback data */
907 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
908 invocation, NULL, 0);
909 if (NULL == resp_cb_data) {
910 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
912 /* Send failure response */
913 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
918 /* Dispatch request */
919 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
920 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
921 ZBLIB_ZCL_COLOR_CONTROL_OPS_STEP_COLOR,
923 on_zcl_color_step_color_resp, resp_cb_data);
925 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
927 /* Free response callback data */
928 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
930 /* Send failure response */
931 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
939 static void on_zcl_color_move_color_temperature_resp(ZigBeeServiceInterface *service_interface,
940 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
942 ZigbeeServiceInterfaceRespCbData_t *cb_data =
943 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
945 ZigbeeZcl_color_control *zcl_color_object = NULL;
946 GDBusMethodInvocation *invocation = NULL;
948 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
950 NOT_USED(service_interface);
951 NOT_USED(request_id);
953 if (NULL == resp_data || 0 == resp_data_len) {
954 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
959 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
960 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
962 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
963 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
965 zigbee_zcl_color_control_complete_move_color_temperature(zcl_color_object, invocation,
971 static gboolean on_zcl_color_move_color_temperature(ZigbeeZcl_color_control *zcl_color_object,
972 GDBusMethodInvocation *invocation,
975 gshort color_temperature,
976 gshort transition_time,
979 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
980 ZigbeeZclColorControlMoveColorTemperature_t req;
981 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
985 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveColorTemperature_t));
987 /* Update request structure */
988 req.node_id = node_id;
989 req.dest_ep = endpoint;
990 req.color_temperature = color_temperature;
991 req.transition_time = transition_time;
993 /* Allocate response callback data */
995 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
996 invocation, NULL, 0);
997 if (NULL == resp_cb_data) {
998 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1000 /* Send failure response */
1001 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1006 /* Dispatch request */
1007 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1008 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
1009 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_COLOR_TEMPERATURE,
1011 on_zcl_color_move_color_temperature_resp, resp_cb_data);
1013 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1015 /* Free response callback data */
1016 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1018 /* Send failure response */
1019 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1027 void zigbee_service_dbus_interface_zcl_color_control_notification(ZigBeeServiceInterface *service_interface,
1028 guint noti_id, gpointer noti_data, guint noti_data_len, gpointer noti_cb_data)
1030 ZigbeeZcl_color_control *color_object;
1032 zblib_check_null_ret("service_interface", service_interface);
1034 if (NULL == noti_data || 0 == noti_data_len) {
1035 Z_LOGE("noti_data is NULL");
1039 color_object = _service_interface_ref_zigbee_zcl_color_control(service_interface);
1040 zblib_check_null_ret("color_object", color_object);
1042 NOT_USED(noti_cb_data);
1046 Z_LOGE("Unexpected notification [%x]", noti_id);
1050 /* ZigbeeZcl_color_control should be dereferenced */
1051 g_object_unref(color_object);
1054 gboolean zigbee_service_dbus_interface_zcl_color_control_init(ZigBeeServiceInterface *service_interface,
1055 ZigbeeObjectSkeleton *zigbee_object)
1057 ZigbeeZcl_color_control *zcl_color_object;
1059 if (NULL == service_interface) {
1060 Z_LOGE("service_interface is NULL");
1064 zcl_color_object = zigbee_zcl_color_control_skeleton_new();
1065 zigbee_object_skeleton_set_zcl_color_control(zigbee_object, zcl_color_object);
1066 g_object_unref(zcl_color_object);
1068 Z_LOGI("zcl_color_object: [%p]", zcl_color_object);
1071 * Register signal handlers for 'zcl_color' interface
1073 g_signal_connect(zcl_color_object,
1074 "handle-move-to-hue",
1075 G_CALLBACK(on_zcl_color_move_to_hue), service_interface);
1077 g_signal_connect(zcl_color_object,
1079 G_CALLBACK(on_zcl_color_move_hue), service_interface);
1081 g_signal_connect(zcl_color_object,
1083 G_CALLBACK(on_zcl_color_step_hue), service_interface);
1085 g_signal_connect(zcl_color_object,
1086 "handle-move-to-saturation",
1087 G_CALLBACK(on_zcl_color_move_to_saturation), service_interface);
1089 g_signal_connect(zcl_color_object,
1090 "handle-move-saturation",
1091 G_CALLBACK(on_zcl_color_move_saturation), service_interface);
1093 g_signal_connect(zcl_color_object,
1094 "handle-step-saturation",
1095 G_CALLBACK(on_zcl_color_step_saturation), service_interface);
1097 g_signal_connect(zcl_color_object,
1098 "handle-move-to-hue-and-saturation",
1099 G_CALLBACK(on_zcl_color_move_to_hue_and_saturation), service_interface);
1101 g_signal_connect(zcl_color_object,
1102 "handle-move-to-color",
1103 G_CALLBACK(on_zcl_color_move_to_color), service_interface);
1105 g_signal_connect(zcl_color_object,
1106 "handle-move-color",
1107 G_CALLBACK(on_zcl_color_move_color), service_interface);
1109 g_signal_connect(zcl_color_object,
1110 "handle-step-color",
1111 G_CALLBACK(on_zcl_color_step_color), service_interface);
1113 g_signal_connect(zcl_color_object,
1114 "handle-move-color-temperature",
1115 G_CALLBACK(on_zcl_color_move_color_temperature), service_interface);