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_service.h>
23 static void *_service_interface_ref_zigbee_service(ZigBeeServiceInterface *service_interface)
25 ZigbeeObjectSkeleton *zigbee_object = NULL;
26 ZigbeeCustomData_t *custom_data = NULL;
27 ZigbeeService *service = NULL;
29 custom_data = (ZigbeeCustomData_t *)zblib_service_interface_ref_user_data(service_interface);
30 if (NULL == custom_data) {
31 Z_LOGE("D-BUS service interface custom_data is NULL!");
35 /* Get zigbee object */
36 zigbee_object = g_hash_table_lookup(custom_data->objects, ZIGBEE_SERVICE_PATH);
37 if (NULL == zigbee_object) {
38 Z_LOGW("Cannot find ZigBee D-BUS interface object!", zigbee_object);
42 service = zigbee_object_get_service(ZIGBEE_OBJECT(zigbee_object));
46 static void on_service_enable_resp(ZigBeeServiceInterface *service_interface,
47 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
49 ZigbeeServiceInterfaceRespCbData_t *cb_data =
50 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
52 ZigbeeService *service_object;
53 GDBusMethodInvocation *invocation;
54 ZigbeeServiceServiceStateResp_t *payload =
55 (ZigbeeServiceServiceStateResp_t*)resp_data;
57 NOT_USED(service_interface);
60 if (NULL == resp_data || 0 == resp_data_len) {
61 Z_LOGE("resp_data is null");
65 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
66 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
68 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
69 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
71 zigbee_service_complete_enable(service_object, invocation,
72 payload->result, payload->enabled);
77 static gboolean on_service_enable(ZigbeeService *service_object,
78 GDBusMethodInvocation *invocation,
81 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
82 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
86 /* Allocate response callback data */
88 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
90 if (NULL == resp_cb_data) {
91 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
93 /* Send failure response */
94 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
99 /* Dispatch request */
100 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
101 ZBLIB_DRIVER_TYPE_SERVICE,
102 ZBLIB_SERVICE_OPS_ENABLE,
104 on_service_enable_resp, resp_cb_data);
106 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
108 /* Free response callback data */
109 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
111 /* Send failure response */
112 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
120 static void on_service_disable_resp(ZigBeeServiceInterface *service_interface,
121 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
123 ZigbeeServiceInterfaceRespCbData_t *cb_data =
124 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
126 ZigbeeService *service_object;
127 GDBusMethodInvocation *invocation;
128 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
130 NOT_USED(service_interface);
131 NOT_USED(request_id);
133 if (NULL == resp_data || 0 == resp_data_len) {
134 Z_LOGE("resp_data is null");
138 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
139 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
141 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
142 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
144 zigbee_service_complete_disable(service_object, invocation, payload->result);
149 static gboolean on_service_disable(ZigbeeService *service_object,
150 GDBusMethodInvocation *invocation,
153 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
154 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
158 /* Allocate response callback data */
160 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
161 invocation, NULL, 0);
162 if (NULL == resp_cb_data) {
163 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
165 /* Send failure response */
166 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
171 /* Dispatch request */
172 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
173 ZBLIB_DRIVER_TYPE_SERVICE,
174 ZBLIB_SERVICE_OPS_DISABLE,
176 on_service_disable_resp, resp_cb_data);
178 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
180 /* Free response callback data */
181 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
183 /* Send failure response */
184 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
192 static void on_service_zb_hw_reset_resp(ZigBeeServiceInterface *service_interface,
193 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
195 ZigbeeServiceInterfaceRespCbData_t *cb_data =
196 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
198 ZigbeeService *service_object;
199 GDBusMethodInvocation *invocation;
200 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
202 NOT_USED(service_interface);
203 NOT_USED(request_id);
205 if (NULL == resp_data || 0 == resp_data_len) {
206 Z_LOGE("resp_data is null");
210 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
211 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
213 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
214 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
216 zigbee_service_complete_zb_hw_reset(service_object, invocation, payload->result);
221 static gboolean on_service_zb_hw_reset(ZigbeeService *service_object,
222 GDBusMethodInvocation *invocation,
225 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
226 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
230 /* Allocate response callback data */
232 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
233 invocation, NULL, 0);
234 if (NULL == resp_cb_data) {
235 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
237 /* Send failure response */
238 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
243 /* Dispatch request */
244 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
245 ZBLIB_DRIVER_TYPE_SERVICE,
246 ZBLIB_SERVICE_OPS_ZB_HW_RESET,
248 on_service_zb_hw_reset_resp, resp_cb_data);
250 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
252 /* Free response callback data */
253 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
255 /* Send failure response */
256 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
264 static void on_service_form_network_resp(ZigBeeServiceInterface *service_interface,
265 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
267 ZigbeeServiceInterfaceRespCbData_t *cb_data =
268 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
270 ZigbeeService *service_object;
271 GDBusMethodInvocation *invocation;
272 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
274 NOT_USED(service_interface);
275 NOT_USED(request_id);
277 if (NULL == resp_data || 0 == resp_data_len) {
278 Z_LOGE("resp_data is null");
282 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
283 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
285 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
286 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
288 zigbee_service_complete_form_network(service_object, invocation, payload->result);
293 static gboolean on_service_form_network(ZigbeeService *service_object,
294 GDBusMethodInvocation *invocation,
297 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
298 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
302 /* Allocate response callback data */
304 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
305 invocation, NULL, 0);
306 if (NULL == resp_cb_data) {
307 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
309 /* Send failure response */
310 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
315 /* Dispatch request */
316 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
317 ZBLIB_DRIVER_TYPE_SERVICE,
318 ZBLIB_SERVICE_OPS_FORM_NETWORK,
320 on_service_form_network_resp, resp_cb_data);
322 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
324 /* Free response callback data */
325 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
327 /* Send failure response */
328 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
336 static void on_service_coex_start_resp(ZigBeeServiceInterface *service_interface,
337 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
339 ZigbeeServiceInterfaceRespCbData_t *cb_data =
340 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
342 ZigbeeService *service_object;
343 GDBusMethodInvocation *invocation;
344 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
346 NOT_USED(service_interface);
347 NOT_USED(request_id);
349 if (NULL == resp_data || 0 == resp_data_len) {
350 Z_LOGE("resp_data is null");
354 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
355 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
357 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
358 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
360 zigbee_service_complete_coex_start(service_object, invocation, payload->result);
365 static gboolean on_service_coex_start(ZigbeeService *service_object,
366 GDBusMethodInvocation *invocation,
370 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
371 ZigbeeServiceCoexStart_t req;
372 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
376 memset(&req, 0x0, sizeof(ZigbeeServiceCoexStart_t));
378 /* Update request structure */
379 req.channel = channel;
381 /* Allocate response callback data */
383 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
384 invocation, NULL, 0);
385 if (NULL == resp_cb_data) {
386 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
388 /* Send failure response */
389 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
394 /* Dispatch request */
395 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
396 ZBLIB_DRIVER_TYPE_SERVICE,
397 ZBLIB_SERVICE_OPS_COEX_START,
399 on_service_coex_start_resp, resp_cb_data);
401 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
403 /* Free response callback data */
404 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
406 /* Send failure response */
407 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
415 static void on_service_coex_stop_resp(ZigBeeServiceInterface *service_interface,
416 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
418 ZigbeeServiceInterfaceRespCbData_t *cb_data =
419 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
421 ZigbeeService *service_object;
422 GDBusMethodInvocation *invocation;
423 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
425 NOT_USED(service_interface);
426 NOT_USED(request_id);
428 if (NULL == resp_data || 0 == resp_data_len) {
429 Z_LOGE("resp_data is null");
433 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
434 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
436 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
437 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
439 zigbee_service_complete_coex_stop(service_object, invocation, payload->result);
444 static gboolean on_service_coex_stop(ZigbeeService *service_object,
445 GDBusMethodInvocation *invocation,
448 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
449 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
453 /* Allocate response callback data */
455 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
456 invocation, NULL, 0);
457 if (NULL == resp_cb_data) {
458 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
460 /* Send failure response */
461 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
466 /* Dispatch request */
467 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
468 ZBLIB_DRIVER_TYPE_SERVICE,
469 ZBLIB_SERVICE_OPS_COEX_STOP,
471 on_service_coex_stop_resp, resp_cb_data);
473 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
475 /* Free response callback data */
476 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
478 /* Send failure response */
479 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
487 static void on_service_leave_network_resp(ZigBeeServiceInterface *service_interface,
488 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
490 ZigbeeServiceInterfaceRespCbData_t *cb_data =
491 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
493 ZigbeeService *service_object;
494 GDBusMethodInvocation *invocation;
495 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
497 NOT_USED(service_interface);
498 NOT_USED(request_id);
500 if (NULL == resp_data || 0 == resp_data_len) {
501 Z_LOGE("resp_data is null");
505 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
506 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
508 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
509 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
511 zigbee_service_complete_leave_network(service_object, invocation, payload->result);
516 static gboolean on_service_leave_network(ZigbeeService *service_object,
517 GDBusMethodInvocation *invocation,
520 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
521 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
525 /* Allocate response callback data */
527 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
528 invocation, NULL, 0);
529 if (NULL == resp_cb_data) {
530 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
532 /* Send failure response */
533 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
538 /* Dispatch request */
539 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
540 ZBLIB_DRIVER_TYPE_SERVICE,
541 ZBLIB_SERVICE_OPS_LEAVE_NETWORK,
543 on_service_leave_network_resp, resp_cb_data);
545 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
547 /* Free response callback data */
548 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
550 /* Send failure response */
551 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
559 static void on_service_get_network_info_resp(ZigBeeServiceInterface *service_interface,
560 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
562 ZigbeeServiceInterfaceRespCbData_t *cb_data =
563 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
565 ZigbeeService *service_object;
566 GDBusMethodInvocation *invocation;
568 ZigbeeServiceGetNetworkInfoResp_t *payload =
569 (ZigbeeServiceGetNetworkInfoResp_t*)resp_data;
571 GVariant *v_eui64 = NULL;
573 NOT_USED(service_interface);
574 NOT_USED(request_id);
576 if (NULL == resp_data || 0 == resp_data_len) {
577 Z_LOGE("resp_data is null");
581 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
582 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
584 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
585 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
587 v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
588 payload->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
590 zigbee_service_complete_get_network_info(service_object, invocation,
591 payload->result, v_eui64, payload->node_id,
592 payload->pan_id, payload->channel, payload->radio_tx_power);
597 static gboolean on_service_get_network_info(ZigbeeService *service_object,
598 GDBusMethodInvocation *invocation,
601 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
602 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
606 /* Allocate response callback data */
608 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
609 invocation, NULL, 0);
610 if (NULL == resp_cb_data) {
611 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
613 /* Send failure response */
614 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
619 /* Dispatch request */
620 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
621 ZBLIB_DRIVER_TYPE_SERVICE,
622 ZBLIB_SERVICE_OPS_GET_NETWORK_INFO,
624 on_service_get_network_info_resp, resp_cb_data);
626 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
628 /* Free response callback data */
629 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
631 /* Send failure response */
632 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
640 static void on_service_permit_join_resp(ZigBeeServiceInterface *service_interface,
641 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
643 ZigbeeServiceInterfaceRespCbData_t *cb_data =
644 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
646 ZigbeeService *service_object;
647 GDBusMethodInvocation *invocation;
648 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
650 NOT_USED(service_interface);
651 NOT_USED(request_id);
653 if (NULL == resp_data || 0 == resp_data_len) {
654 Z_LOGE("resp_data is null");
658 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
659 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
661 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
662 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
664 zigbee_service_complete_permit_join(service_object, invocation, payload->result);
669 static gboolean on_service_permit_join(ZigbeeService *service_object,
670 GDBusMethodInvocation *invocation,
672 gboolean permit_join,
675 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
676 ZigbeeServicePermitJoin_t req;
677 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
681 memset(&req, 0x0, sizeof(ZigbeeServicePermitJoin_t));
683 /* Update request structure */
684 req.duration = duration;
685 req.permit_join = permit_join;
687 /* Allocate response callback data */
689 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
690 invocation, NULL, 0);
691 if (NULL == resp_cb_data) {
692 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
694 /* Send failure response */
695 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
700 /* Dispatch request */
701 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
702 ZBLIB_DRIVER_TYPE_SERVICE,
703 ZBLIB_SERVICE_OPS_PERMIT_JOIN,
705 on_service_permit_join_resp, resp_cb_data);
707 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
709 /* Free response callback data */
710 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
712 /* Send failure response */
713 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
721 static void on_service_leave_request_resp(ZigBeeServiceInterface *service_interface,
722 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
724 ZigbeeServiceInterfaceRespCbData_t *cb_data =
725 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
727 ZigbeeService *service_object;
728 GDBusMethodInvocation *invocation;
729 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
731 NOT_USED(service_interface);
732 NOT_USED(request_id);
734 if (NULL == resp_data || 0 == resp_data_len) {
735 Z_LOGE("resp_data is null");
739 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
740 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
742 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
743 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
745 zigbee_service_complete_leave_request(service_object, invocation, payload->result);
750 static gboolean on_service_leave_request(ZigbeeService *service_object,
751 GDBusMethodInvocation *invocation,
757 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
758 ZigbeeServiceLeaveRequest_t req;
759 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
761 GVariantIter *iter = NULL;
766 memset(&req, 0x0, sizeof(ZigbeeServiceLeaveRequest_t));
768 /* Update request structure */
769 g_variant_get(eui64, "a(y)", &iter);
770 while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
772 if (i >= ZIGBEE_EUI64_SIZE)
775 req.remove_child = remove_child;
778 Z_LOGD("IEEE Address = %X:%X:%X:%X:%X:%X:%X:%X",
779 req.eui64[0], req.eui64[1], req.eui64[2], req.eui64[3],
780 req.eui64[4], req.eui64[5], req.eui64[6], req.eui64[7]);
781 Z_LOGD("remove_child [%d]", remove_child);
782 Z_LOGD("rejoin [%d]", rejoin);
784 /* Allocate response callback data */
786 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
787 invocation, NULL, 0);
788 if (NULL == resp_cb_data) {
789 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
791 /* Send failure response */
792 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
797 /* Dispatch request */
798 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
799 ZBLIB_DRIVER_TYPE_SERVICE,
800 ZBLIB_SERVICE_OPS_LEAVE_REQUEST,
802 on_service_leave_request_resp, resp_cb_data);
804 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
806 /* Free response callback data */
807 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
809 /* Send failure response */
810 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
818 static void on_service_get_device_list_resp(ZigBeeServiceInterface *service_interface,
819 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
821 ZigbeeServiceInterfaceRespCbData_t *cb_data =
822 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
824 ZigbeeService *service_object;
825 GDBusMethodInvocation *invocation;
827 NOT_USED(service_interface);
828 NOT_USED(request_id);
830 if (NULL == resp_data || 0 == resp_data_len) {
831 Z_LOGE("resp_data is null");
836 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
837 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
839 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
840 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
842 /* To-To : zigbee_service_complete_get_device_list */
843 //zigbee_service_complete_get_device_list(service_object, invocation, resp_data);
848 static gboolean on_service_get_device_list(ZigbeeService *service_object,
849 GDBusMethodInvocation *invocation,
852 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
853 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
857 /* Allocate response callback data */
859 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
860 invocation, NULL, 0);
861 if (NULL == resp_cb_data) {
862 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
864 /* Send failure response */
865 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
870 /* Dispatch request */
871 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
872 ZBLIB_DRIVER_TYPE_SERVICE,
873 ZBLIB_SERVICE_OPS_GET_DEVICE_LIST,
875 on_service_get_device_list_resp, resp_cb_data);
877 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
879 /* Free response callback data */
880 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
882 /* Send failure response */
883 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
891 static void on_service_get_mac_resp(ZigBeeServiceInterface *service_interface,
892 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
894 ZigbeeServiceInterfaceRespCbData_t *cb_data =
895 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
897 ZigbeeService *service_object;
898 GDBusMethodInvocation *invocation;
899 ZigbeeServiceGetMacResp_t *payload =
900 (ZigbeeServiceGetMacResp_t*)resp_data;
902 GVariant *v_eui64 = NULL;
904 NOT_USED(service_interface);
905 NOT_USED(request_id);
907 if (NULL == resp_data || 0 == resp_data_len) {
908 Z_LOGE("resp_data is null");
913 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
914 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
916 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
917 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
919 v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
920 payload->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
922 zigbee_service_complete_get_mac(service_object, invocation, payload->result,
928 static gboolean on_service_get_mac(ZigbeeService *service_object,
929 GDBusMethodInvocation *invocation,
932 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
933 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
937 /* Allocate response callback data */
939 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
940 invocation, NULL, 0);
941 if (NULL == resp_cb_data) {
942 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
944 /* Send failure response */
945 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
950 /* Dispatch request */
951 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
952 ZBLIB_DRIVER_TYPE_SERVICE,
953 ZBLIB_SERVICE_OPS_GET_MAC,
955 on_service_get_mac_resp, resp_cb_data);
957 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
959 /* Free response callback data */
960 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
962 /* Send failure response */
963 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
971 static void on_service_get_device_info_resp(ZigBeeServiceInterface *service_interface,
972 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
974 ZigbeeServiceInterfaceRespCbData_t *cb_data =
975 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
977 ZigbeeService *service_object;
978 GDBusMethodInvocation *invocation;
979 ZigbeeServiceGetDeviceInfoResp_t *payload =
980 (ZigbeeServiceGetDeviceInfoResp_t*)resp_data;
982 GVariant *variant = NULL;
983 GVariantBuilder* builder = NULL;
987 NOT_USED(service_interface);
988 NOT_USED(request_id);
990 if (NULL == resp_data || 0 == resp_data_len) {
991 Z_LOGE("resp_data is null");
996 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
997 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
999 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
1000 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
1002 builder = g_variant_builder_new(G_VARIANT_TYPE ("a(qyayyay)"));
1003 for (index = 0; index < payload->count; index++) {
1004 ZigbeeServiceGetDeviceInfoDetailResp_t *device = &(payload->list[index]);
1005 GVariantBuilder* mac_builder = g_variant_builder_new(G_VARIANT_TYPE ("ay"));
1006 GVariantBuilder* endpoint_builder = g_variant_builder_new(G_VARIANT_TYPE ("ay"));
1008 for (i = 0; i < ZIGBEE_EUI64_SIZE; i++) {
1009 g_variant_builder_add (mac_builder, "y", device->eui64[i]);
1011 for (i = 0; i < device->endpoint_count; i++) {
1012 g_variant_builder_add (endpoint_builder, "y", device->endpoints[i]);
1015 g_variant_builder_add (builder, "(qyayyay)",
1016 device->node_id, device->node_type,
1017 mac_builder, device->endpoint_count, endpoint_builder);
1019 g_variant_builder_unref (mac_builder);
1020 g_variant_builder_unref (endpoint_builder);
1023 variant = g_variant_builder_end(builder);
1024 zigbee_service_complete_get_device_info(service_object, invocation,
1025 payload->result, variant);
1030 static gboolean on_service_get_device_info(ZigbeeService *service_object,
1031 GDBusMethodInvocation *invocation,
1034 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1035 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1039 /* Allocate response callback data */
1041 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
1042 invocation, NULL, 0);
1043 if (NULL == resp_cb_data) {
1044 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1046 /* Send failure response */
1047 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1052 /* Dispatch request */
1053 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1054 ZBLIB_DRIVER_TYPE_SERVICE,
1055 ZBLIB_SERVICE_OPS_GET_DEVICE_INFO,
1057 on_service_get_device_info_resp, resp_cb_data);
1059 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1061 /* Free response callback data */
1062 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1064 /* Send failure response */
1065 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1073 static void on_service_get_endpoint_list_resp(ZigBeeServiceInterface *service_interface,
1074 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
1076 ZigbeeServiceInterfaceRespCbData_t *cb_data =
1077 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
1079 ZigbeeService *service_object;
1080 GDBusMethodInvocation *invocation;
1081 ZigbeeServiceGetEndpointListResp_t *payload =
1082 (ZigbeeServiceGetEndpointListResp_t*)resp_data;
1083 GVariant *v_endpoints = NULL;
1085 NOT_USED(service_interface);
1086 NOT_USED(request_id);
1088 if (NULL == resp_data || 0 == resp_data_len) {
1089 Z_LOGE("resp_data is null");
1094 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
1095 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
1097 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
1098 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
1100 v_endpoints = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1101 payload->endpoints, payload->endpoint_count, TRUE, NULL, NULL);
1103 zigbee_service_complete_get_endpoint_list(service_object, invocation,
1104 payload->result, v_endpoints);
1109 static gboolean on_service_get_endpoint_list(ZigbeeService *service_object,
1110 GDBusMethodInvocation *invocation,
1114 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1115 ZigbeeServiceGetEndpointList_t req;
1116 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1118 GVariantIter *iter = NULL;
1123 memset(&req, 0x0, sizeof(ZigbeeServiceGetEndpointList_t));
1125 /* Update request structure */
1126 g_variant_get(eui64, "a(y)", &iter);
1127 while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
1129 if (i >= ZIGBEE_EUI64_SIZE)
1133 /* Allocate response callback data */
1135 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
1136 invocation, NULL, 0);
1137 if (NULL == resp_cb_data) {
1138 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1140 /* Send failure response */
1141 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1146 /* Dispatch request */
1147 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1148 ZBLIB_DRIVER_TYPE_SERVICE,
1149 ZBLIB_SERVICE_OPS_GET_ENDPOINT_LIST,
1151 on_service_get_endpoint_list_resp, resp_cb_data);
1153 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1155 /* Free response callback data */
1156 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1158 /* Send failure response */
1159 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1167 static void on_service_get_cluster_list_resp(ZigBeeServiceInterface *service_interface,
1168 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
1170 ZigbeeServiceInterfaceRespCbData_t *cb_data =
1171 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
1173 ZigbeeService *service_object;
1174 GDBusMethodInvocation *invocation;
1175 ZigbeeServiceGetClusterListResp_t *payload =
1176 (ZigbeeServiceGetClusterListResp_t*)resp_data;
1177 GVariant *v_clusters = NULL;
1179 NOT_USED(service_interface);
1180 NOT_USED(request_id);
1182 if (NULL == resp_data || 0 == resp_data_len) {
1183 Z_LOGE("resp_data is null");
1188 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
1189 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
1191 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
1192 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
1194 v_clusters = g_variant_new_from_data(G_VARIANT_TYPE("aq"),
1195 payload->clusters, payload->cluster_count, TRUE, NULL, NULL);
1197 zigbee_service_complete_get_cluster_list(service_object, invocation,
1198 payload->result, v_clusters);
1203 static gboolean on_service_get_cluster_list(ZigbeeService *service_object,
1204 GDBusMethodInvocation *invocation,
1209 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1210 ZigbeeServiceGetClusterList_t req;
1211 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1213 GVariantIter *iter = NULL;
1218 memset(&req, 0x0, sizeof(ZigbeeServiceGetClusterList_t));
1220 /* Update request structure */
1221 g_variant_get(eui64, "a(y)", &iter);
1222 while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
1224 if (i >= ZIGBEE_EUI64_SIZE)
1227 req.endpoint = endpoint;
1229 /* Allocate response callback data */
1231 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
1232 invocation, NULL, 0);
1233 if (NULL == resp_cb_data) {
1234 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1236 /* Send failure response */
1237 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1242 /* Dispatch request */
1243 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1244 ZBLIB_DRIVER_TYPE_SERVICE,
1245 ZBLIB_SERVICE_OPS_GET_CLUSTER_LIST,
1247 on_service_get_cluster_list_resp, resp_cb_data);
1249 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1251 /* Free response callback data */
1252 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1254 /* Send failure response */
1255 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1263 static void on_service_get_node_type_resp(ZigBeeServiceInterface *service_interface,
1264 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
1266 ZigbeeServiceInterfaceRespCbData_t *cb_data =
1267 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
1269 ZigbeeService *service_object;
1270 GDBusMethodInvocation *invocation;
1271 ZigbeeServiceServiceNodeTypeResp_t *payload =
1272 (ZigbeeServiceServiceNodeTypeResp_t *)resp_data;
1274 NOT_USED(service_interface);
1275 NOT_USED(request_id);
1277 if (NULL == resp_data || 0 == resp_data_len) {
1278 Z_LOGE("resp_data is null");
1283 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
1284 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
1286 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
1287 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
1289 zigbee_service_complete_get_node_type(service_object, invocation,
1290 payload->result, payload->node_type);
1295 static gboolean on_service_get_node_type(ZigbeeService *service_object,
1296 GDBusMethodInvocation *invocation,
1300 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1301 ZigbeeServiceGetNodeType_t req;
1302 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1304 GVariantIter *iter = NULL;
1309 memset(&req, 0x0, sizeof(ZigbeeServiceGetNodeType_t));
1311 /* Update request structure */
1312 g_variant_get(eui64, "a(y)", &iter);
1313 while (g_variant_iter_loop(iter, "(y)", req.eui64[i])) {
1315 if (i >= ZIGBEE_EUI64_SIZE)
1319 /* Allocate response callback data */
1321 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
1322 invocation, NULL, 0);
1323 if (NULL == resp_cb_data) {
1324 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1326 /* Send failure response */
1327 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1332 /* Dispatch request */
1333 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1334 ZBLIB_DRIVER_TYPE_SERVICE,
1335 ZBLIB_SERVICE_OPS_GET_NODE_TYPE,
1337 on_service_get_node_type_resp, resp_cb_data);
1339 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1341 /* Free response callback data */
1342 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1344 /* Send failure response */
1345 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1353 void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface *service_interface,
1354 guint noti_id, gpointer noti_data, guint noti_data_len, gpointer noti_cb_data)
1356 ZigbeeService *service_object;
1358 zblib_check_null_ret("service_interface", service_interface);
1360 if (NULL == noti_data || 0 == noti_data_len) {
1361 Z_LOGE("noti_data is NULL");
1365 service_object = _service_interface_ref_zigbee_service(service_interface);
1366 zblib_check_null_ret("service_object", service_object);
1368 NOT_USED(noti_cb_data);
1371 case ZBLIB_SERVICE_NOTI_FORM_NETWORK_DONE: {
1372 ZigbeeServiceServiceFormNetworkDone_t *panid_t =
1373 (ZigbeeServiceServiceFormNetworkDone_t*)noti_data;
1375 Z_LOGD("form_network_done : [0x%X]", panid_t->pan_id);
1377 zigbee_service_emit_form_network_done(service_object, panid_t->pan_id);
1380 case ZBLIB_SERVICE_NOTI_CHILD_JOINED: {
1381 ZigbeeServiceServiceChildJoined_t *child_t =
1382 (ZigbeeServiceServiceChildJoined_t*)noti_data;
1384 GVariant *v_eui64 = NULL;
1385 GVariant *v_endpoints = NULL;
1387 v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1388 child_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
1389 v_endpoints = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1390 child_t->endpoints, child_t->endpoint_count, TRUE, NULL, NULL);
1391 if (NULL == v_eui64 || NULL == v_endpoints) {
1392 Z_LOGE("Failed to create variant!");
1394 g_object_unref(v_eui64);
1396 g_object_unref(v_endpoints);
1398 zigbee_service_emit_child_joined(service_object,
1399 v_eui64, child_t->endpoint_count, v_endpoints, child_t->node_id);
1403 case ZBLIB_SERVICE_NOTI_CHILD_REJOINED: {
1404 ZigbeeServiceServiceChildRejoined_t *child_t =
1405 (ZigbeeServiceServiceChildRejoined_t*)noti_data;
1407 GVariant *v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1408 child_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
1409 if (NULL == v_eui64) {
1410 Z_LOGE("Failed to create variant!");
1412 zigbee_service_emit_child_rejoined(service_object, v_eui64);
1416 case ZBLIB_SERVICE_NOTI_CHILD_LEFT: {
1417 ZigbeeServiceServiceChildLeft_t *child_left_t =
1418 (ZigbeeServiceServiceChildLeft_t*)noti_data;
1420 GVariant *v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1421 child_left_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
1422 if (NULL == v_eui64) {
1423 Z_LOGE("Failed to create variant!");
1425 zigbee_service_emit_child_left(service_object,
1426 v_eui64, child_left_t->status);
1430 case ZBLIB_SERVICE_NOTI_LEAVE_NETWORK_DONE: {
1431 ZigbeeServiceServiceLeaveNetworkDone_t leave_net_t;
1432 memcpy(&leave_net_t, noti_data, noti_data_len);
1433 zigbee_service_emit_leave_network_done(service_object, leave_net_t.pan_id);
1437 Z_LOGE("Unexpected notification [%x]", noti_id);
1441 /* ZigbeeService should be dereferenced */
1442 g_object_unref(service_object);
1445 gboolean zigbee_service_dbus_interface_service_init(ZigBeeServiceInterface *service_interface,
1446 ZigbeeObjectSkeleton *zigbee_object)
1448 ZigbeeService *service_object;
1450 if (NULL == service_interface) {
1451 Z_LOGE("service_interface is NULL");
1455 service_object = zigbee_service_skeleton_new();
1456 zigbee_object_skeleton_set_service(zigbee_object, service_object);
1457 g_object_unref(service_object);
1459 Z_LOGI("service_object: [%p]", service_object);
1462 * Register signal handlers for 'service' interface
1464 g_signal_connect(service_object,
1466 G_CALLBACK(on_service_enable), service_interface);
1468 g_signal_connect(service_object,
1470 G_CALLBACK(on_service_disable), service_interface);
1472 g_signal_connect(service_object,
1473 "handle-zb-hw-reset",
1474 G_CALLBACK(on_service_zb_hw_reset), service_interface);
1476 g_signal_connect(service_object,
1477 "handle-form-network",
1478 G_CALLBACK(on_service_form_network), service_interface);
1480 g_signal_connect(service_object,
1481 "handle-coex-start",
1482 G_CALLBACK(on_service_coex_start), service_interface);
1484 g_signal_connect(service_object,
1486 G_CALLBACK(on_service_coex_stop), service_interface);
1488 g_signal_connect(service_object,
1489 "handle-leave-network",
1490 G_CALLBACK(on_service_leave_network), service_interface);
1492 g_signal_connect(service_object,
1493 "handle-get-network-info",
1494 G_CALLBACK(on_service_get_network_info), service_interface);
1496 g_signal_connect(service_object,
1497 "handle-permit-join",
1498 G_CALLBACK(on_service_permit_join), service_interface);
1500 g_signal_connect(service_object,
1501 "handle-leave-request",
1502 G_CALLBACK(on_service_leave_request), service_interface);
1504 g_signal_connect(service_object,
1505 "handle-get-device-list",
1506 G_CALLBACK(on_service_get_device_list), service_interface);
1508 g_signal_connect(service_object,
1510 G_CALLBACK(on_service_get_mac), service_interface);
1512 g_signal_connect(service_object,
1513 "handle-get-device-info",
1514 G_CALLBACK(on_service_get_device_info), service_interface);
1516 g_signal_connect(service_object,
1517 "handle-get-endpoint-list",
1518 G_CALLBACK(on_service_get_endpoint_list), service_interface);
1520 g_signal_connect(service_object,
1521 "handle-get-cluster-list",
1522 G_CALLBACK(on_service_get_cluster_list), service_interface);
1524 g_signal_connect(service_object,
1525 "handle-get-node-type",
1526 G_CALLBACK(on_service_get_node_type), service_interface);