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>
24 static void *_service_interface_ref_zigbee_zcl_color_control(
25 ZigBeeServiceInterface *service_interface)
27 ZigbeeObjectSkeleton *zigbee_object = NULL;
28 ZigbeeCustomData_t *custom_data = NULL;
29 ZigbeeZcl_color_control *color_object = NULL;
31 custom_data = (ZigbeeCustomData_t *)zblib_service_interface_ref_user_data(service_interface);
32 if (NULL == custom_data) {
33 Z_LOGE("D-BUS service interface custom_data is NULL!");
37 /* Get zigbee object */
38 zigbee_object = g_hash_table_lookup(custom_data->objects, ZIGBEE_SERVICE_PATH);
39 if (NULL == zigbee_object) {
40 Z_LOGW("Cannot find ZigBee D-BUS interface object!");
44 color_object = zigbee_object_get_zcl_color_control(ZIGBEE_OBJECT(zigbee_object));
48 static void on_zcl_color_move_to_hue_resp(ZigBeeServiceInterface *service_interface,
49 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
51 ZigbeeServiceInterfaceRespCbData_t *cb_data =
52 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
54 ZigbeeZcl_color_control *zcl_color_object = NULL;
55 GDBusMethodInvocation *invocation = NULL;
57 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
59 NOT_USED(service_interface);
62 if (NULL == resp_data || 0 == resp_data_len) {
63 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
68 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
69 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
71 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
72 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
74 zigbee_zcl_color_control_complete_move_to_hue(zcl_color_object, invocation,
80 static gboolean on_zcl_color_move_to_hue(ZigbeeZcl_color_control *zcl_color_object,
81 GDBusMethodInvocation *invocation,
86 gshort transition_time,
89 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
90 ZigbeeZclColorControlMoveToHue_t req;
91 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
95 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveToHue_t));
97 /* Update request structure */
98 req.node_id = node_id;
99 req.dest_ep = endpoint;
101 req.direction = direction;
102 req.transition_time = transition_time;
104 /* Allocate response callback data */
106 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
107 invocation, NULL, 0);
108 if (NULL == resp_cb_data) {
109 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
111 /* Send failure response */
112 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
117 /* Dispatch request */
118 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
119 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
120 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_TO_HUE,
122 on_zcl_color_move_to_hue_resp, resp_cb_data);
124 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
126 /* Free response callback data */
127 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
129 /* Send failure response */
130 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
138 static void on_zcl_color_move_hue_resp(ZigBeeServiceInterface *service_interface,
139 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
141 ZigbeeServiceInterfaceRespCbData_t *cb_data =
142 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
144 ZigbeeZcl_color_control *zcl_color_object = NULL;
145 GDBusMethodInvocation *invocation = NULL;
147 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
149 NOT_USED(service_interface);
150 NOT_USED(request_id);
152 if (NULL == resp_data || 0 == resp_data_len) {
153 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
158 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
159 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
161 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
162 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
164 zigbee_zcl_color_control_complete_move_hue(zcl_color_object, invocation,
170 static gboolean on_zcl_color_move_hue(ZigbeeZcl_color_control *zcl_color_object,
171 GDBusMethodInvocation *invocation,
178 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
179 ZigbeeZclColorControlMoveHue_t req;
180 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
184 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveHue_t));
186 /* Update request structure */
187 req.node_id = node_id;
188 req.dest_ep = endpoint;
189 req.move_mode = move_mode;
192 /* Allocate response callback data */
194 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
195 invocation, NULL, 0);
196 if (NULL == resp_cb_data) {
197 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
199 /* Send failure response */
200 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
205 /* Dispatch request */
206 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
207 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
208 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_HUE,
210 on_zcl_color_move_hue_resp, resp_cb_data);
212 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
214 /* Free response callback data */
215 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
217 /* Send failure response */
218 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
226 static void on_zcl_color_step_hue_resp(ZigBeeServiceInterface *service_interface,
227 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
229 ZigbeeServiceInterfaceRespCbData_t *cb_data =
230 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
232 ZigbeeZcl_color_control *zcl_color_object = NULL;
233 GDBusMethodInvocation *invocation = NULL;
235 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
237 NOT_USED(service_interface);
238 NOT_USED(request_id);
240 if (NULL == resp_data || 0 == resp_data_len) {
241 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
246 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
247 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
249 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
250 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
252 zigbee_zcl_color_control_complete_step_hue(zcl_color_object, invocation,
258 static gboolean on_zcl_color_step_hue(ZigbeeZcl_color_control *zcl_color_object,
259 GDBusMethodInvocation *invocation,
264 gchar transition_time,
267 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
268 ZigbeeZclColorControlStepHue_t req;
269 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
273 memset(&req, 0x0, sizeof(ZigbeeZclColorControlStepHue_t));
275 /* Update request structure */
276 req.node_id = node_id;
277 req.dest_ep = endpoint;
278 req.step_mode = step_mode;
279 req.step_size = step_size;
280 req.transition_time = transition_time;
282 /* Allocate response callback data */
284 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
285 invocation, NULL, 0);
286 if (NULL == resp_cb_data) {
287 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
289 /* Send failure response */
290 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
295 /* Dispatch request */
296 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
297 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
298 ZBLIB_ZCL_COLOR_CONTROL_OPS_STEP_HUE,
300 on_zcl_color_step_hue_resp, resp_cb_data);
302 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
304 /* Free response callback data */
305 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
307 /* Send failure response */
308 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
316 static void on_zcl_color_move_to_saturation_resp(ZigBeeServiceInterface *service_interface,
317 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
319 ZigbeeServiceInterfaceRespCbData_t *cb_data =
320 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
322 ZigbeeZcl_color_control *zcl_color_object = NULL;
323 GDBusMethodInvocation *invocation = NULL;
325 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
327 NOT_USED(service_interface);
328 NOT_USED(request_id);
330 if (NULL == resp_data || 0 == resp_data_len) {
331 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
336 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
337 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
339 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
340 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
342 zigbee_zcl_color_control_complete_move_to_saturation(zcl_color_object, invocation,
348 static gboolean on_zcl_color_move_to_saturation(ZigbeeZcl_color_control *zcl_color_object,
349 GDBusMethodInvocation *invocation,
353 gshort transition_time,
356 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
357 ZigbeeZclColorControlMoveToSaturation_t req;
358 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
362 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveToSaturation_t));
364 /* Update request structure */
365 req.node_id = node_id;
366 req.dest_ep = endpoint;
367 req.saturation = saturation;
368 req.transition_time = transition_time;
370 /* Allocate response callback data */
372 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
373 invocation, NULL, 0);
374 if (NULL == resp_cb_data) {
375 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
377 /* Send failure response */
378 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
383 /* Dispatch request */
384 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
385 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
386 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_TO_STAURATION,
388 on_zcl_color_move_to_saturation_resp, resp_cb_data);
390 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
392 /* Free response callback data */
393 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
395 /* Send failure response */
396 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
404 static void on_zcl_color_move_saturation_resp(ZigBeeServiceInterface *service_interface,
405 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
407 ZigbeeServiceInterfaceRespCbData_t *cb_data =
408 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
410 ZigbeeZcl_color_control *zcl_color_object = NULL;
411 GDBusMethodInvocation *invocation = NULL;
413 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
415 NOT_USED(service_interface);
416 NOT_USED(request_id);
418 if (NULL == resp_data || 0 == resp_data_len) {
419 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
424 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
425 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
427 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
428 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
430 zigbee_zcl_color_control_complete_move_saturation(zcl_color_object, invocation,
436 static gboolean on_zcl_color_move_saturation(ZigbeeZcl_color_control *zcl_color_object,
437 GDBusMethodInvocation *invocation,
444 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
445 ZigbeeZclColorControlMoveSaturation_t req;
446 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
450 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveSaturation_t));
452 /* Update request structure */
453 req.node_id = node_id;
454 req.dest_ep = endpoint;
455 req.move_mode = move_mode;
458 /* Allocate response callback data */
460 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
461 invocation, NULL, 0);
462 if (NULL == resp_cb_data) {
463 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
465 /* Send failure response */
466 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
471 /* Dispatch request */
472 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
473 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
474 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_STAURATION,
476 on_zcl_color_move_saturation_resp, resp_cb_data);
478 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
480 /* Free response callback data */
481 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
483 /* Send failure response */
484 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
492 static void on_zcl_color_step_saturation_resp(ZigBeeServiceInterface *service_interface,
493 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
495 ZigbeeServiceInterfaceRespCbData_t *cb_data =
496 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
498 ZigbeeZcl_color_control *zcl_color_object = NULL;
499 GDBusMethodInvocation *invocation = NULL;
501 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
503 NOT_USED(service_interface);
504 NOT_USED(request_id);
506 if (NULL == resp_data || 0 == resp_data_len) {
507 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
512 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
513 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
515 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
516 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
518 zigbee_zcl_color_control_complete_step_saturation(zcl_color_object, invocation,
524 static gboolean on_zcl_color_step_saturation(ZigbeeZcl_color_control *zcl_color_object,
525 GDBusMethodInvocation *invocation,
530 gchar transition_time,
533 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
534 ZigbeeZclColorControlStepSaturation_t req;
535 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
539 memset(&req, 0x0, sizeof(ZigbeeZclColorControlStepSaturation_t));
541 /* Update request structure */
542 req.node_id = node_id;
543 req.dest_ep = endpoint;
544 req.step_mode = step_mode;
545 req.step_size = step_size;
546 req.transition_time = transition_time;
548 /* Allocate response callback data */
550 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
551 invocation, NULL, 0);
552 if (NULL == resp_cb_data) {
553 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
555 /* Send failure response */
556 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
561 /* Dispatch request */
562 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
563 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
564 ZBLIB_ZCL_COLOR_CONTROL_OPS_STEP_STAURATION,
566 on_zcl_color_step_saturation_resp, resp_cb_data);
568 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
570 /* Free response callback data */
571 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
573 /* Send failure response */
574 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
582 static void on_zcl_color_move_to_hue_and_saturation_resp(ZigBeeServiceInterface *service_interface,
583 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
585 ZigbeeServiceInterfaceRespCbData_t *cb_data =
586 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
588 ZigbeeZcl_color_control *zcl_color_object = NULL;
589 GDBusMethodInvocation *invocation = NULL;
591 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
593 NOT_USED(service_interface);
594 NOT_USED(request_id);
596 if (NULL == resp_data || 0 == resp_data_len) {
597 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
602 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
603 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
605 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
606 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
608 zigbee_zcl_color_control_complete_move_to_hue_and_saturation(zcl_color_object,
609 invocation, payload->result);
614 static gboolean on_zcl_color_move_to_hue_and_saturation(ZigbeeZcl_color_control *zcl_color_object,
615 GDBusMethodInvocation *invocation,
620 gshort transition_time,
623 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
624 ZigbeeZclColorControlMoveToHueAndSaturation_t req;
625 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
629 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveToHueAndSaturation_t));
631 /* Update request structure */
632 req.node_id = node_id;
633 req.dest_ep = endpoint;
635 req.saturation = saturation;
636 req.transition_time = transition_time;
638 /* Allocate response callback data */
640 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
641 invocation, NULL, 0);
642 if (NULL == resp_cb_data) {
643 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
645 /* Send failure response */
646 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
651 /* Dispatch request */
652 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
653 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
654 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_TO_HUE_AND_SATURATION,
656 on_zcl_color_move_to_hue_and_saturation_resp, resp_cb_data);
658 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
660 /* Free response callback data */
661 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
663 /* Send failure response */
664 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
672 static void on_zcl_color_move_to_color_resp(ZigBeeServiceInterface *service_interface,
673 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
675 ZigbeeServiceInterfaceRespCbData_t *cb_data =
676 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
678 ZigbeeZcl_color_control *zcl_color_object = NULL;
679 GDBusMethodInvocation *invocation = NULL;
681 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
683 NOT_USED(service_interface);
684 NOT_USED(request_id);
686 if (NULL == resp_data || 0 == resp_data_len) {
687 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
692 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
693 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
695 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
696 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
698 zigbee_zcl_color_control_complete_move_to_color(zcl_color_object, invocation,
704 static gboolean on_zcl_color_move_to_color(ZigbeeZcl_color_control *zcl_color_object,
705 GDBusMethodInvocation *invocation,
710 gshort transition_time,
713 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
714 ZigbeeZclColorControlMoveToColor_t req;
715 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
719 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveToColor_t));
721 /* Update request structure */
722 req.node_id = node_id;
723 req.dest_ep = endpoint;
724 req.color_x = start_x;
725 req.color_y = start_y;
726 req.transition_time = transition_time;
728 /* Allocate response callback data */
730 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
731 invocation, NULL, 0);
732 if (NULL == resp_cb_data) {
733 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
735 /* Send failure response */
736 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
741 /* Dispatch request */
742 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
743 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
744 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_TO_COLOR,
746 on_zcl_color_move_to_color_resp, resp_cb_data);
748 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
750 /* Free response callback data */
751 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
753 /* Send failure response */
754 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
762 static void on_zcl_color_move_color_resp(ZigBeeServiceInterface *service_interface,
763 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
765 ZigbeeServiceInterfaceRespCbData_t *cb_data =
766 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
768 ZigbeeZcl_color_control *zcl_color_object = NULL;
769 GDBusMethodInvocation *invocation = NULL;
771 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
773 NOT_USED(service_interface);
774 NOT_USED(request_id);
776 if (NULL == resp_data || 0 == resp_data_len) {
777 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
782 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
783 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
785 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
786 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
788 zigbee_zcl_color_control_complete_move_color(zcl_color_object, invocation,
794 static gboolean on_zcl_color_move_color(ZigbeeZcl_color_control *zcl_color_object,
795 GDBusMethodInvocation *invocation,
802 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
803 ZigbeeZclColorControlMoveColor_t req;
804 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
808 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveColor_t));
810 /* Update request structure */
811 req.node_id = node_id;
812 req.dest_ep = endpoint;
816 /* Allocate response callback data */
818 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
819 invocation, NULL, 0);
820 if (NULL == resp_cb_data) {
821 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
823 /* Send failure response */
824 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
829 /* Dispatch request */
830 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
831 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
832 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_COLOR,
834 on_zcl_color_move_color_resp, resp_cb_data);
836 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
838 /* Free response callback data */
839 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
841 /* Send failure response */
842 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
850 static void on_zcl_color_step_color_resp(ZigBeeServiceInterface *service_interface,
851 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
853 ZigbeeServiceInterfaceRespCbData_t *cb_data =
854 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
856 ZigbeeZcl_color_control *zcl_color_object = NULL;
857 GDBusMethodInvocation *invocation = NULL;
859 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
861 NOT_USED(service_interface);
862 NOT_USED(request_id);
864 if (NULL == resp_data || 0 == resp_data_len) {
865 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
870 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
871 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
873 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
874 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
876 zigbee_zcl_color_control_complete_step_color(zcl_color_object, invocation,
882 static gboolean on_zcl_color_step_color(ZigbeeZcl_color_control *zcl_color_object,
883 GDBusMethodInvocation *invocation,
888 gshort transition_time,
891 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
892 ZigbeeZclColorControlStepColor_t req;
893 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
897 memset(&req, 0x0, sizeof(ZigbeeZclColorControlStepColor_t));
899 /* Update request structure */
900 req.node_id = node_id;
901 req.dest_ep = endpoint;
904 req.transition_time = transition_time;
906 /* Allocate response callback data */
908 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
909 invocation, NULL, 0);
910 if (NULL == resp_cb_data) {
911 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
913 /* Send failure response */
914 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
919 /* Dispatch request */
920 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
921 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
922 ZBLIB_ZCL_COLOR_CONTROL_OPS_STEP_COLOR,
924 on_zcl_color_step_color_resp, resp_cb_data);
926 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
928 /* Free response callback data */
929 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
931 /* Send failure response */
932 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
940 static void on_zcl_color_move_color_temperature_resp(ZigBeeServiceInterface *service_interface,
941 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
943 ZigbeeServiceInterfaceRespCbData_t *cb_data =
944 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
946 ZigbeeZcl_color_control *zcl_color_object = NULL;
947 GDBusMethodInvocation *invocation = NULL;
949 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t *)resp_data;
951 NOT_USED(service_interface);
952 NOT_USED(request_id);
954 if (NULL == resp_data || 0 == resp_data_len) {
955 Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
960 zcl_color_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
961 zblib_check_null_free_and_ret("zcl_color_object", zcl_color_object, cb_data);
963 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
964 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
966 zigbee_zcl_color_control_complete_move_color_temperature(zcl_color_object, invocation,
972 static gboolean on_zcl_color_move_color_temperature(ZigbeeZcl_color_control *zcl_color_object,
973 GDBusMethodInvocation *invocation,
976 gshort color_temperature,
977 gshort transition_time,
980 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
981 ZigbeeZclColorControlMoveColorTemperature_t req;
982 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
986 memset(&req, 0x0, sizeof(ZigbeeZclColorControlMoveColorTemperature_t));
988 /* Update request structure */
989 req.node_id = node_id;
990 req.dest_ep = endpoint;
991 req.color_temperature = color_temperature;
992 req.transition_time = transition_time;
994 /* Allocate response callback data */
996 zigbee_service_dbus_interface_create_resp_cb_data(zcl_color_object,
997 invocation, NULL, 0);
998 if (NULL == resp_cb_data) {
999 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1001 /* Send failure response */
1002 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1007 /* Dispatch request */
1008 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1009 ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL,
1010 ZBLIB_ZCL_COLOR_CONTROL_OPS_MOVE_COLOR_TEMPERATURE,
1012 on_zcl_color_move_color_temperature_resp, resp_cb_data);
1014 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1016 /* Free response callback data */
1017 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1019 /* Send failure response */
1020 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1028 void zigbee_service_dbus_interface_zcl_color_control_notification(ZigBeeServiceInterface *service_interface,
1029 guint noti_id, gpointer noti_data, guint noti_data_len, gpointer noti_cb_data)
1031 ZigbeeZcl_color_control *color_object;
1033 zblib_check_null_ret("service_interface", service_interface);
1035 if (NULL == noti_data || 0 == noti_data_len) {
1036 Z_LOGE("noti_data is NULL");
1040 color_object = _service_interface_ref_zigbee_zcl_color_control(service_interface);
1041 zblib_check_null_ret("color_object", color_object);
1043 NOT_USED(noti_cb_data);
1047 Z_LOGE("Unexpected notification [%x]", noti_id);
1051 /* ZigbeeZcl_color_control should be dereferenced */
1052 g_object_unref(color_object);
1054 /* LCOV_EXCL_STOP */
1056 gboolean zigbee_service_dbus_interface_zcl_color_control_init(ZigBeeServiceInterface *service_interface,
1057 ZigbeeObjectSkeleton *zigbee_object)
1059 ZigbeeZcl_color_control *zcl_color_object;
1061 if (NULL == service_interface) {
1062 /* LCOV_EXCL_START */
1063 Z_LOGE("service_interface is NULL");
1065 /* LCOV_EXCL_STOP */
1068 zcl_color_object = zigbee_zcl_color_control_skeleton_new();
1069 zigbee_object_skeleton_set_zcl_color_control(zigbee_object, zcl_color_object);
1070 g_object_unref(zcl_color_object);
1072 Z_LOGI("zcl_color_object: [%p]", zcl_color_object);
1075 * Register signal handlers for 'zcl_color' interface
1077 g_signal_connect(zcl_color_object,
1078 "handle-move-to-hue",
1079 G_CALLBACK(on_zcl_color_move_to_hue), service_interface);
1081 g_signal_connect(zcl_color_object,
1083 G_CALLBACK(on_zcl_color_move_hue), service_interface);
1085 g_signal_connect(zcl_color_object,
1087 G_CALLBACK(on_zcl_color_step_hue), service_interface);
1089 g_signal_connect(zcl_color_object,
1090 "handle-move-to-saturation",
1091 G_CALLBACK(on_zcl_color_move_to_saturation), service_interface);
1093 g_signal_connect(zcl_color_object,
1094 "handle-move-saturation",
1095 G_CALLBACK(on_zcl_color_move_saturation), service_interface);
1097 g_signal_connect(zcl_color_object,
1098 "handle-step-saturation",
1099 G_CALLBACK(on_zcl_color_step_saturation), service_interface);
1101 g_signal_connect(zcl_color_object,
1102 "handle-move-to-hue-and-saturation",
1103 G_CALLBACK(on_zcl_color_move_to_hue_and_saturation), service_interface);
1105 g_signal_connect(zcl_color_object,
1106 "handle-move-to-color",
1107 G_CALLBACK(on_zcl_color_move_to_color), service_interface);
1109 g_signal_connect(zcl_color_object,
1110 "handle-move-color",
1111 G_CALLBACK(on_zcl_color_move_color), service_interface);
1113 g_signal_connect(zcl_color_object,
1114 "handle-step-color",
1115 G_CALLBACK(on_zcl_color_step_color), service_interface);
1117 g_signal_connect(zcl_color_object,
1118 "handle-move-color-temperature",
1119 G_CALLBACK(on_zcl_color_move_color_temperature), service_interface);