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;
88 /* Allocate response callback data */
90 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
92 if (NULL == resp_cb_data) {
93 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
95 /* Send failure response */
96 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
101 /* Dispatch request */
102 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
103 ZBLIB_DRIVER_TYPE_SERVICE,
104 ZBLIB_SERVICE_OPS_ENABLE,
106 on_service_enable_resp, resp_cb_data);
108 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
110 /* Free response callback data */
111 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
113 /* Send failure response */
114 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
122 static void on_service_disable_resp(ZigBeeServiceInterface *service_interface,
123 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
125 ZigbeeServiceInterfaceRespCbData_t *cb_data =
126 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
128 ZigbeeService *service_object;
129 GDBusMethodInvocation *invocation;
130 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
132 NOT_USED(service_interface);
133 NOT_USED(request_id);
135 if (NULL == resp_data || 0 == resp_data_len) {
136 Z_LOGE("resp_data is null");
140 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
141 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
143 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
144 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
146 zigbee_service_complete_disable(service_object, invocation, payload->result);
151 static gboolean on_service_disable(ZigbeeService *service_object,
152 GDBusMethodInvocation *invocation,
155 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
156 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
160 /* Allocate response callback data */
162 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
163 invocation, NULL, 0);
164 if (NULL == resp_cb_data) {
165 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
167 /* Send failure response */
168 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
173 /* Dispatch request */
174 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
175 ZBLIB_DRIVER_TYPE_SERVICE,
176 ZBLIB_SERVICE_OPS_DISABLE,
178 on_service_disable_resp, resp_cb_data);
180 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
182 /* Free response callback data */
183 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
185 /* Send failure response */
186 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
194 static void on_service_zb_hw_reset_resp(ZigBeeServiceInterface *service_interface,
195 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
197 ZigbeeServiceInterfaceRespCbData_t *cb_data =
198 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
200 ZigbeeService *service_object;
201 GDBusMethodInvocation *invocation;
202 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
204 NOT_USED(service_interface);
205 NOT_USED(request_id);
207 if (NULL == resp_data || 0 == resp_data_len) {
208 Z_LOGE("resp_data is null");
212 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
213 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
215 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
216 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
218 zigbee_service_complete_zb_hw_reset(service_object, invocation, payload->result);
223 static gboolean on_service_zb_hw_reset(ZigbeeService *service_object,
224 GDBusMethodInvocation *invocation,
227 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
228 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
232 /* Allocate response callback data */
234 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
235 invocation, NULL, 0);
236 if (NULL == resp_cb_data) {
237 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
239 /* Send failure response */
240 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
245 /* Dispatch request */
246 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
247 ZBLIB_DRIVER_TYPE_SERVICE,
248 ZBLIB_SERVICE_OPS_ZB_HW_RESET,
250 on_service_zb_hw_reset_resp, resp_cb_data);
252 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
254 /* Free response callback data */
255 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
257 /* Send failure response */
258 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
266 static void on_service_form_network_resp(ZigBeeServiceInterface *service_interface,
267 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
269 ZigbeeServiceInterfaceRespCbData_t *cb_data =
270 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
272 ZigbeeService *service_object;
273 GDBusMethodInvocation *invocation;
274 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
276 NOT_USED(service_interface);
277 NOT_USED(request_id);
279 if (NULL == resp_data || 0 == resp_data_len) {
280 Z_LOGE("resp_data is null");
284 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
285 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
287 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
288 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
290 zigbee_service_complete_form_network(service_object, invocation, payload->result);
295 static gboolean on_service_form_network(ZigbeeService *service_object,
296 GDBusMethodInvocation *invocation,
299 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
300 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
304 /* Allocate response callback data */
306 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
307 invocation, NULL, 0);
308 if (NULL == resp_cb_data) {
309 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
311 /* Send failure response */
312 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
317 /* Dispatch request */
318 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
319 ZBLIB_DRIVER_TYPE_SERVICE,
320 ZBLIB_SERVICE_OPS_FORM_NETWORK,
322 on_service_form_network_resp, resp_cb_data);
324 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
326 /* Free response callback data */
327 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
329 /* Send failure response */
330 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
338 static void on_service_coex_start_resp(ZigBeeServiceInterface *service_interface,
339 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
341 ZigbeeServiceInterfaceRespCbData_t *cb_data =
342 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
344 ZigbeeService *service_object;
345 GDBusMethodInvocation *invocation;
346 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
348 NOT_USED(service_interface);
349 NOT_USED(request_id);
351 if (NULL == resp_data || 0 == resp_data_len) {
352 Z_LOGE("resp_data is null");
356 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
357 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
359 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
360 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
362 zigbee_service_complete_coex_start(service_object, invocation, payload->result);
367 static gboolean on_service_coex_start(ZigbeeService *service_object,
368 GDBusMethodInvocation *invocation,
372 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
373 ZigbeeServiceCoexStart_t req;
374 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
378 memset(&req, 0x0, sizeof(ZigbeeServiceCoexStart_t));
380 /* Update request structure */
381 req.channel = channel;
383 /* Allocate response callback data */
385 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
386 invocation, NULL, 0);
387 if (NULL == resp_cb_data) {
388 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
390 /* Send failure response */
391 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
396 /* Dispatch request */
397 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
398 ZBLIB_DRIVER_TYPE_SERVICE,
399 ZBLIB_SERVICE_OPS_COEX_START,
401 on_service_coex_start_resp, resp_cb_data);
403 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
405 /* Free response callback data */
406 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
408 /* Send failure response */
409 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
417 static void on_service_coex_stop_resp(ZigBeeServiceInterface *service_interface,
418 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
420 ZigbeeServiceInterfaceRespCbData_t *cb_data =
421 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
423 ZigbeeService *service_object;
424 GDBusMethodInvocation *invocation;
425 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
427 NOT_USED(service_interface);
428 NOT_USED(request_id);
430 if (NULL == resp_data || 0 == resp_data_len) {
431 Z_LOGE("resp_data is null");
435 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
436 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
438 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
439 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
441 zigbee_service_complete_coex_stop(service_object, invocation, payload->result);
446 static gboolean on_service_coex_stop(ZigbeeService *service_object,
447 GDBusMethodInvocation *invocation,
450 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
451 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
455 /* Allocate response callback data */
457 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
458 invocation, NULL, 0);
459 if (NULL == resp_cb_data) {
460 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
462 /* Send failure response */
463 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
468 /* Dispatch request */
469 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
470 ZBLIB_DRIVER_TYPE_SERVICE,
471 ZBLIB_SERVICE_OPS_COEX_STOP,
473 on_service_coex_stop_resp, resp_cb_data);
475 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
477 /* Free response callback data */
478 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
480 /* Send failure response */
481 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
489 static void on_service_leave_network_resp(ZigBeeServiceInterface *service_interface,
490 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
492 ZigbeeServiceInterfaceRespCbData_t *cb_data =
493 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
495 ZigbeeService *service_object;
496 GDBusMethodInvocation *invocation;
497 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
499 NOT_USED(service_interface);
500 NOT_USED(request_id);
502 if (NULL == resp_data || 0 == resp_data_len) {
503 Z_LOGE("resp_data is null");
507 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
508 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
510 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
511 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
513 zigbee_service_complete_leave_network(service_object, invocation, payload->result);
518 static gboolean on_service_leave_network(ZigbeeService *service_object,
519 GDBusMethodInvocation *invocation,
522 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
523 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
527 /* Allocate response callback data */
529 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
530 invocation, NULL, 0);
531 if (NULL == resp_cb_data) {
532 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
534 /* Send failure response */
535 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
540 /* Dispatch request */
541 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
542 ZBLIB_DRIVER_TYPE_SERVICE,
543 ZBLIB_SERVICE_OPS_LEAVE_NETWORK,
545 on_service_leave_network_resp, resp_cb_data);
547 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
549 /* Free response callback data */
550 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
552 /* Send failure response */
553 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
561 static void on_service_get_network_info_resp(ZigBeeServiceInterface *service_interface,
562 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
564 ZigbeeServiceInterfaceRespCbData_t *cb_data =
565 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
567 ZigbeeService *service_object;
568 GDBusMethodInvocation *invocation;
570 ZigbeeServiceGetNetworkInfoResp_t *payload =
571 (ZigbeeServiceGetNetworkInfoResp_t*)resp_data;
573 GVariant *v_eui64 = NULL;
575 NOT_USED(service_interface);
576 NOT_USED(request_id);
578 if (NULL == resp_data || 0 == resp_data_len) {
579 Z_LOGE("resp_data is null");
583 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
584 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
586 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
587 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
589 v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
590 payload->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
592 zigbee_service_complete_get_network_info(service_object, invocation,
593 payload->result, v_eui64, payload->node_id,
594 payload->pan_id, payload->channel, payload->radio_tx_power);
599 static gboolean on_service_get_network_info(ZigbeeService *service_object,
600 GDBusMethodInvocation *invocation,
603 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
604 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
608 /* Allocate response callback data */
610 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
611 invocation, NULL, 0);
612 if (NULL == resp_cb_data) {
613 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
615 /* Send failure response */
616 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
621 /* Dispatch request */
622 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
623 ZBLIB_DRIVER_TYPE_SERVICE,
624 ZBLIB_SERVICE_OPS_GET_NETWORK_INFO,
626 on_service_get_network_info_resp, resp_cb_data);
628 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
630 /* Free response callback data */
631 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
633 /* Send failure response */
634 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
642 static void on_service_permit_join_resp(ZigBeeServiceInterface *service_interface,
643 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
645 ZigbeeServiceInterfaceRespCbData_t *cb_data =
646 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
648 ZigbeeService *service_object;
649 GDBusMethodInvocation *invocation;
650 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
652 NOT_USED(service_interface);
653 NOT_USED(request_id);
655 if (NULL == resp_data || 0 == resp_data_len) {
656 Z_LOGE("resp_data is null");
660 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
661 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
663 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
664 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
666 zigbee_service_complete_permit_join(service_object, invocation, payload->result);
671 static gboolean on_service_permit_join(ZigbeeService *service_object,
672 GDBusMethodInvocation *invocation,
674 gboolean permit_join,
677 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
678 ZigbeeServicePermitJoin_t req;
679 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
683 memset(&req, 0x0, sizeof(ZigbeeServicePermitJoin_t));
685 /* Update request structure */
686 req.duration = duration;
687 req.permit_join = permit_join;
689 /* Allocate response callback data */
691 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
692 invocation, NULL, 0);
693 if (NULL == resp_cb_data) {
694 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
696 /* Send failure response */
697 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
702 /* Dispatch request */
703 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
704 ZBLIB_DRIVER_TYPE_SERVICE,
705 ZBLIB_SERVICE_OPS_PERMIT_JOIN,
707 on_service_permit_join_resp, resp_cb_data);
709 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
711 /* Free response callback data */
712 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
714 /* Send failure response */
715 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
723 static void on_service_leave_request_resp(ZigBeeServiceInterface *service_interface,
724 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
726 ZigbeeServiceInterfaceRespCbData_t *cb_data =
727 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
729 ZigbeeService *service_object;
730 GDBusMethodInvocation *invocation;
731 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
733 NOT_USED(service_interface);
734 NOT_USED(request_id);
736 if (NULL == resp_data || 0 == resp_data_len) {
737 Z_LOGE("resp_data is null");
741 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
742 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
744 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
745 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
747 zigbee_service_complete_leave_request(service_object, invocation, payload->result);
752 static gboolean on_service_leave_request(ZigbeeService *service_object,
753 GDBusMethodInvocation *invocation,
759 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
760 ZigbeeServiceLeaveRequest_t req;
761 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
763 GVariantIter *iter = NULL;
768 memset(&req, 0x0, sizeof(ZigbeeServiceLeaveRequest_t));
770 /* Update request structure */
771 g_variant_get(eui64, "a(y)", &iter);
772 while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
774 if (i >= ZIGBEE_EUI64_SIZE)
777 req.remove_child = remove_child;
780 Z_LOGD("IEEE Address = %X:%X:%X:%X:%X:%X:%X:%X",
781 req.eui64[0], req.eui64[1], req.eui64[2], req.eui64[3],
782 req.eui64[4], req.eui64[5], req.eui64[6], req.eui64[7]);
783 Z_LOGD("remove_child [%d]", remove_child);
784 Z_LOGD("rejoin [%d]", rejoin);
786 /* Allocate response callback data */
788 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
789 invocation, NULL, 0);
790 if (NULL == resp_cb_data) {
791 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
793 /* Send failure response */
794 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
799 /* Dispatch request */
800 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
801 ZBLIB_DRIVER_TYPE_SERVICE,
802 ZBLIB_SERVICE_OPS_LEAVE_REQUEST,
804 on_service_leave_request_resp, resp_cb_data);
806 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
808 /* Free response callback data */
809 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
811 /* Send failure response */
812 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
820 static void on_service_get_device_list_resp(ZigBeeServiceInterface *service_interface,
821 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
823 ZigbeeServiceInterfaceRespCbData_t *cb_data =
824 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
826 ZigbeeService *service_object;
827 GDBusMethodInvocation *invocation;
829 NOT_USED(service_interface);
830 NOT_USED(request_id);
832 if (NULL == resp_data || 0 == resp_data_len) {
833 Z_LOGE("resp_data is null");
838 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
839 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
841 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
842 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
844 /* To-To : zigbee_service_complete_get_device_list */
845 //zigbee_service_complete_get_device_list(service_object, invocation, resp_data);
850 static gboolean on_service_get_device_list(ZigbeeService *service_object,
851 GDBusMethodInvocation *invocation,
854 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
855 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
859 /* Allocate response callback data */
861 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
862 invocation, NULL, 0);
863 if (NULL == resp_cb_data) {
864 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
866 /* Send failure response */
867 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
872 /* Dispatch request */
873 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
874 ZBLIB_DRIVER_TYPE_SERVICE,
875 ZBLIB_SERVICE_OPS_GET_DEVICE_LIST,
877 on_service_get_device_list_resp, resp_cb_data);
879 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
881 /* Free response callback data */
882 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
884 /* Send failure response */
885 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
893 static void on_service_get_mac_resp(ZigBeeServiceInterface *service_interface,
894 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
896 ZigbeeServiceInterfaceRespCbData_t *cb_data =
897 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
899 ZigbeeService *service_object;
900 GDBusMethodInvocation *invocation;
901 ZigbeeServiceGetMacResp_t *payload =
902 (ZigbeeServiceGetMacResp_t*)resp_data;
904 GVariant *v_eui64 = NULL;
906 NOT_USED(service_interface);
907 NOT_USED(request_id);
909 if (NULL == resp_data || 0 == resp_data_len) {
910 Z_LOGE("resp_data is null");
915 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
916 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
918 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
919 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
921 v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
922 payload->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
924 zigbee_service_complete_get_mac(service_object, invocation, payload->result,
930 static gboolean on_service_get_mac(ZigbeeService *service_object,
931 GDBusMethodInvocation *invocation,
934 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
935 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
939 /* Allocate response callback data */
941 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
942 invocation, NULL, 0);
943 if (NULL == resp_cb_data) {
944 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
946 /* Send failure response */
947 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
952 /* Dispatch request */
953 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
954 ZBLIB_DRIVER_TYPE_SERVICE,
955 ZBLIB_SERVICE_OPS_GET_MAC,
957 on_service_get_mac_resp, resp_cb_data);
959 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
961 /* Free response callback data */
962 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
964 /* Send failure response */
965 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
973 static void on_service_get_device_info_resp(ZigBeeServiceInterface *service_interface,
974 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
976 ZigbeeServiceInterfaceRespCbData_t *cb_data =
977 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
979 ZigbeeService *service_object;
980 GDBusMethodInvocation *invocation;
981 ZigbeeServiceGetDeviceInfoResp_t *payload =
982 (ZigbeeServiceGetDeviceInfoResp_t*)resp_data;
984 GVariant *variant = NULL;
985 GVariantBuilder* builder = NULL;
989 NOT_USED(service_interface);
990 NOT_USED(request_id);
992 if (NULL == resp_data || 0 == resp_data_len) {
993 Z_LOGE("resp_data is null");
998 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
999 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
1001 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
1002 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
1004 builder = g_variant_builder_new(G_VARIANT_TYPE ("a(qyayyay)"));
1005 for (index = 0; index < payload->count; index++) {
1006 ZigbeeServiceGetDeviceInfoDetailResp_t *device = &(payload->list[index]);
1007 GVariantBuilder* mac_builder = g_variant_builder_new(G_VARIANT_TYPE ("ay"));
1008 GVariantBuilder* endpoint_builder = g_variant_builder_new(G_VARIANT_TYPE ("ay"));
1010 for (i = 0; i < ZIGBEE_EUI64_SIZE; i++) {
1011 g_variant_builder_add (mac_builder, "y", device->eui64[i]);
1013 for (i = 0; i < device->endpoint_count; i++) {
1014 g_variant_builder_add (endpoint_builder, "y", device->endpoints[i]);
1017 g_variant_builder_add (builder, "(qyayyay)",
1018 device->node_id, device->node_type,
1019 mac_builder, device->endpoint_count, endpoint_builder);
1021 g_variant_builder_unref (mac_builder);
1022 g_variant_builder_unref (endpoint_builder);
1025 variant = g_variant_builder_end(builder);
1026 zigbee_service_complete_get_device_info(service_object, invocation,
1027 payload->result, variant);
1032 static gboolean on_service_get_device_info(ZigbeeService *service_object,
1033 GDBusMethodInvocation *invocation,
1036 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1037 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1041 /* Allocate response callback data */
1043 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
1044 invocation, NULL, 0);
1045 if (NULL == resp_cb_data) {
1046 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1048 /* Send failure response */
1049 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1054 /* Dispatch request */
1055 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1056 ZBLIB_DRIVER_TYPE_SERVICE,
1057 ZBLIB_SERVICE_OPS_GET_DEVICE_INFO,
1059 on_service_get_device_info_resp, resp_cb_data);
1061 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1063 /* Free response callback data */
1064 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1066 /* Send failure response */
1067 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1075 static void on_service_get_endpoint_list_resp(ZigBeeServiceInterface *service_interface,
1076 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
1078 ZigbeeServiceInterfaceRespCbData_t *cb_data =
1079 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
1081 ZigbeeService *service_object;
1082 GDBusMethodInvocation *invocation;
1083 ZigbeeServiceGetEndpointListResp_t *payload =
1084 (ZigbeeServiceGetEndpointListResp_t*)resp_data;
1085 GVariant *v_endpoints = NULL;
1087 NOT_USED(service_interface);
1088 NOT_USED(request_id);
1090 if (NULL == resp_data || 0 == resp_data_len) {
1091 Z_LOGE("resp_data is null");
1096 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
1097 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
1099 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
1100 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
1102 v_endpoints = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1103 payload->endpoints, payload->endpoint_count, TRUE, NULL, NULL);
1105 zigbee_service_complete_get_endpoint_list(service_object, invocation,
1106 payload->result, v_endpoints);
1111 static gboolean on_service_get_endpoint_list(ZigbeeService *service_object,
1112 GDBusMethodInvocation *invocation,
1116 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1117 ZigbeeServiceGetEndpointList_t req;
1118 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1120 GVariantIter *iter = NULL;
1125 memset(&req, 0x0, sizeof(ZigbeeServiceGetEndpointList_t));
1127 /* Update request structure */
1128 g_variant_get(eui64, "a(y)", &iter);
1129 while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
1131 if (i >= ZIGBEE_EUI64_SIZE)
1135 /* Allocate response callback data */
1137 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
1138 invocation, NULL, 0);
1139 if (NULL == resp_cb_data) {
1140 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1142 /* Send failure response */
1143 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1148 /* Dispatch request */
1149 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1150 ZBLIB_DRIVER_TYPE_SERVICE,
1151 ZBLIB_SERVICE_OPS_GET_ENDPOINT_LIST,
1153 on_service_get_endpoint_list_resp, resp_cb_data);
1155 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1157 /* Free response callback data */
1158 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1160 /* Send failure response */
1161 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1169 static void on_service_get_cluster_list_resp(ZigBeeServiceInterface *service_interface,
1170 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
1172 ZigbeeServiceInterfaceRespCbData_t *cb_data =
1173 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
1175 ZigbeeService *service_object;
1176 GDBusMethodInvocation *invocation;
1177 ZigbeeServiceGetClusterListResp_t *payload =
1178 (ZigbeeServiceGetClusterListResp_t*)resp_data;
1179 GVariant *v_clusters = NULL;
1181 NOT_USED(service_interface);
1182 NOT_USED(request_id);
1184 if (NULL == resp_data || 0 == resp_data_len) {
1185 Z_LOGE("resp_data is null");
1190 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
1191 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
1193 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
1194 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
1196 v_clusters = g_variant_new_from_data(G_VARIANT_TYPE("aq"),
1197 payload->clusters, payload->cluster_count, TRUE, NULL, NULL);
1199 zigbee_service_complete_get_cluster_list(service_object, invocation,
1200 payload->result, v_clusters);
1205 static gboolean on_service_get_cluster_list(ZigbeeService *service_object,
1206 GDBusMethodInvocation *invocation,
1211 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1212 ZigbeeServiceGetClusterList_t req;
1213 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1215 GVariantIter *iter = NULL;
1220 memset(&req, 0x0, sizeof(ZigbeeServiceGetClusterList_t));
1222 /* Update request structure */
1223 g_variant_get(eui64, "a(y)", &iter);
1224 while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
1226 if (i >= ZIGBEE_EUI64_SIZE)
1229 req.endpoint = endpoint;
1231 /* Allocate response callback data */
1233 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
1234 invocation, NULL, 0);
1235 if (NULL == resp_cb_data) {
1236 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1238 /* Send failure response */
1239 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1244 /* Dispatch request */
1245 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1246 ZBLIB_DRIVER_TYPE_SERVICE,
1247 ZBLIB_SERVICE_OPS_GET_CLUSTER_LIST,
1249 on_service_get_cluster_list_resp, resp_cb_data);
1251 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1253 /* Free response callback data */
1254 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1256 /* Send failure response */
1257 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1265 static void on_service_get_node_type_resp(ZigBeeServiceInterface *service_interface,
1266 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
1268 ZigbeeServiceInterfaceRespCbData_t *cb_data =
1269 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
1271 ZigbeeService *service_object;
1272 GDBusMethodInvocation *invocation;
1273 ZigbeeServiceServiceNodeTypeResp_t *payload =
1274 (ZigbeeServiceServiceNodeTypeResp_t *)resp_data;
1276 NOT_USED(service_interface);
1277 NOT_USED(request_id);
1279 if (NULL == resp_data || 0 == resp_data_len) {
1280 Z_LOGE("resp_data is null");
1285 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
1286 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
1288 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
1289 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
1291 zigbee_service_complete_get_node_type(service_object, invocation,
1292 payload->result, payload->node_type);
1297 static gboolean on_service_get_node_type(ZigbeeService *service_object,
1298 GDBusMethodInvocation *invocation,
1302 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1303 ZigbeeServiceGetNodeType_t req;
1304 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1306 GVariantIter *iter = NULL;
1311 memset(&req, 0x0, sizeof(ZigbeeServiceGetNodeType_t));
1313 /* Update request structure */
1314 g_variant_get(eui64, "a(y)", &iter);
1315 while (g_variant_iter_loop(iter, "(y)", req.eui64[i])) {
1317 if (i >= ZIGBEE_EUI64_SIZE)
1321 /* Allocate response callback data */
1323 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
1324 invocation, NULL, 0);
1325 if (NULL == resp_cb_data) {
1326 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1328 /* Send failure response */
1329 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1334 /* Dispatch request */
1335 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1336 ZBLIB_DRIVER_TYPE_SERVICE,
1337 ZBLIB_SERVICE_OPS_GET_NODE_TYPE,
1339 on_service_get_node_type_resp, resp_cb_data);
1341 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1343 /* Free response callback data */
1344 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1346 /* Send failure response */
1347 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1355 void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface *service_interface,
1356 guint noti_id, gpointer noti_data, guint noti_data_len, gpointer noti_cb_data)
1358 ZigbeeService *service_object;
1360 zblib_check_null_ret("service_interface", service_interface);
1362 if (NULL == noti_data || 0 == noti_data_len) {
1363 Z_LOGE("noti_data is NULL");
1367 service_object = _service_interface_ref_zigbee_service(service_interface);
1368 zblib_check_null_ret("service_object", service_object);
1370 NOT_USED(noti_cb_data);
1373 case ZBLIB_SERVICE_NOTI_FORM_NETWORK_DONE: {
1374 ZigbeeServiceServiceFormNetworkDone_t *panid_t =
1375 (ZigbeeServiceServiceFormNetworkDone_t*)noti_data;
1377 Z_LOGD("form_network_done : [0x%X]", panid_t->pan_id);
1379 zigbee_service_emit_form_network_done(service_object, panid_t->pan_id);
1382 case ZBLIB_SERVICE_NOTI_CHILD_JOINED: {
1383 ZigbeeServiceServiceChildJoined_t *child_t =
1384 (ZigbeeServiceServiceChildJoined_t*)noti_data;
1386 GVariant *v_eui64 = NULL;
1387 GVariant *v_endpoints = NULL;
1389 v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1390 child_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
1391 v_endpoints = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1392 child_t->endpoints, child_t->endpoint_count, TRUE, NULL, NULL);
1393 if (NULL == v_eui64 || NULL == v_endpoints) {
1394 Z_LOGE("Failed to create variant!");
1396 g_object_unref(v_eui64);
1398 g_object_unref(v_endpoints);
1400 zigbee_service_emit_child_joined(service_object,
1401 v_eui64, child_t->endpoint_count, v_endpoints, child_t->node_id);
1405 case ZBLIB_SERVICE_NOTI_CHILD_REJOINED: {
1406 ZigbeeServiceServiceChildRejoined_t *child_t =
1407 (ZigbeeServiceServiceChildRejoined_t*)noti_data;
1409 GVariant *v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1410 child_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
1411 if (NULL == v_eui64) {
1412 Z_LOGE("Failed to create variant!");
1414 zigbee_service_emit_child_rejoined(service_object, v_eui64);
1418 case ZBLIB_SERVICE_NOTI_CHILD_LEFT: {
1419 ZigbeeServiceServiceChildLeft_t *child_left_t =
1420 (ZigbeeServiceServiceChildLeft_t*)noti_data;
1422 GVariant *v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1423 child_left_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
1424 if (NULL == v_eui64) {
1425 Z_LOGE("Failed to create variant!");
1427 zigbee_service_emit_child_left(service_object,
1428 v_eui64, child_left_t->status);
1432 case ZBLIB_SERVICE_NOTI_LEAVE_NETWORK_DONE: {
1433 ZigbeeServiceServiceLeaveNetworkDone_t leave_net_t;
1434 memcpy(&leave_net_t, noti_data, noti_data_len);
1435 zigbee_service_emit_leave_network_done(service_object, leave_net_t.pan_id);
1439 Z_LOGE("Unexpected notification [%x]", noti_id);
1443 /* ZigbeeService should be dereferenced */
1444 g_object_unref(service_object);
1447 gboolean zigbee_service_dbus_interface_service_init(ZigBeeServiceInterface *service_interface,
1448 ZigbeeObjectSkeleton *zigbee_object)
1450 ZigbeeService *service_object;
1452 if (NULL == service_interface) {
1453 Z_LOGE("service_interface is NULL");
1457 service_object = zigbee_service_skeleton_new();
1458 zigbee_object_skeleton_set_service(zigbee_object, service_object);
1459 g_object_unref(service_object);
1461 Z_LOGI("service_object: [%p]", service_object);
1464 * Register signal handlers for 'service' interface
1466 g_signal_connect(service_object,
1468 G_CALLBACK(on_service_enable), service_interface);
1470 g_signal_connect(service_object,
1472 G_CALLBACK(on_service_disable), service_interface);
1474 g_signal_connect(service_object,
1475 "handle-zb-hw-reset",
1476 G_CALLBACK(on_service_zb_hw_reset), service_interface);
1478 g_signal_connect(service_object,
1479 "handle-form-network",
1480 G_CALLBACK(on_service_form_network), service_interface);
1482 g_signal_connect(service_object,
1483 "handle-coex-start",
1484 G_CALLBACK(on_service_coex_start), service_interface);
1486 g_signal_connect(service_object,
1488 G_CALLBACK(on_service_coex_stop), service_interface);
1490 g_signal_connect(service_object,
1491 "handle-leave-network",
1492 G_CALLBACK(on_service_leave_network), service_interface);
1494 g_signal_connect(service_object,
1495 "handle-get-network-info",
1496 G_CALLBACK(on_service_get_network_info), service_interface);
1498 g_signal_connect(service_object,
1499 "handle-permit-join",
1500 G_CALLBACK(on_service_permit_join), service_interface);
1502 g_signal_connect(service_object,
1503 "handle-leave-request",
1504 G_CALLBACK(on_service_leave_request), service_interface);
1506 g_signal_connect(service_object,
1507 "handle-get-device-list",
1508 G_CALLBACK(on_service_get_device_list), service_interface);
1510 g_signal_connect(service_object,
1512 G_CALLBACK(on_service_get_mac), service_interface);
1514 g_signal_connect(service_object,
1515 "handle-get-device-info",
1516 G_CALLBACK(on_service_get_device_info), service_interface);
1518 g_signal_connect(service_object,
1519 "handle-get-endpoint-list",
1520 G_CALLBACK(on_service_get_endpoint_list), service_interface);
1522 g_signal_connect(service_object,
1523 "handle-get-cluster-list",
1524 G_CALLBACK(on_service_get_cluster_list), service_interface);
1526 g_signal_connect(service_object,
1527 "handle-get-node-type",
1528 G_CALLBACK(on_service_get_node_type), service_interface);