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");
66 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
67 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
69 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
70 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
72 zigbee_service_complete_enable(service_object, invocation,
73 payload->result, payload->enabled);
78 static gboolean on_service_enable(ZigbeeService *service_object,
79 GDBusMethodInvocation *invocation,
82 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
83 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
87 /* Allocate response callback data */
89 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
91 if (NULL == resp_cb_data) {
92 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
94 /* Send failure response */
95 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
100 /* Dispatch request */
101 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
102 ZBLIB_DRIVER_TYPE_SERVICE,
103 ZBLIB_SERVICE_OPS_ENABLE,
105 on_service_enable_resp, resp_cb_data);
107 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
109 /* Free response callback data */
110 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
112 /* Send failure response */
113 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
121 static void on_service_disable_resp(ZigBeeServiceInterface *service_interface,
122 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
124 ZigbeeServiceInterfaceRespCbData_t *cb_data =
125 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
127 ZigbeeService *service_object;
128 GDBusMethodInvocation *invocation;
129 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
131 NOT_USED(service_interface);
132 NOT_USED(request_id);
134 if (NULL == resp_data || 0 == resp_data_len) {
135 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");
213 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
214 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
216 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
217 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
219 zigbee_service_complete_zb_hw_reset(service_object, invocation, payload->result);
224 static gboolean on_service_zb_hw_reset(ZigbeeService *service_object,
225 GDBusMethodInvocation *invocation,
228 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
229 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
233 /* Allocate response callback data */
235 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
236 invocation, NULL, 0);
237 if (NULL == resp_cb_data) {
238 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
240 /* Send failure response */
241 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
246 /* Dispatch request */
247 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
248 ZBLIB_DRIVER_TYPE_SERVICE,
249 ZBLIB_SERVICE_OPS_ZB_HW_RESET,
251 on_service_zb_hw_reset_resp, resp_cb_data);
253 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
255 /* Free response callback data */
256 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
258 /* Send failure response */
259 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
267 static void on_service_form_network_resp(ZigBeeServiceInterface *service_interface,
268 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
270 ZigbeeServiceInterfaceRespCbData_t *cb_data =
271 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
273 ZigbeeService *service_object;
274 GDBusMethodInvocation *invocation;
275 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
277 NOT_USED(service_interface);
278 NOT_USED(request_id);
280 if (NULL == resp_data || 0 == resp_data_len) {
281 Z_LOGE("resp_data is null");
286 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
287 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
289 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
290 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
292 zigbee_service_complete_form_network(service_object, invocation, payload->result);
297 static gboolean on_service_form_network(ZigbeeService *service_object,
298 GDBusMethodInvocation *invocation,
301 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
302 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
306 /* Allocate response callback data */
308 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
309 invocation, NULL, 0);
310 if (NULL == resp_cb_data) {
311 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
313 /* Send failure response */
314 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
319 /* Dispatch request */
320 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
321 ZBLIB_DRIVER_TYPE_SERVICE,
322 ZBLIB_SERVICE_OPS_FORM_NETWORK,
324 on_service_form_network_resp, resp_cb_data);
326 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
328 /* Free response callback data */
329 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
331 /* Send failure response */
332 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
340 static void on_service_coex_start_resp(ZigBeeServiceInterface *service_interface,
341 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
343 ZigbeeServiceInterfaceRespCbData_t *cb_data =
344 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
346 ZigbeeService *service_object;
347 GDBusMethodInvocation *invocation;
348 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
350 NOT_USED(service_interface);
351 NOT_USED(request_id);
353 if (NULL == resp_data || 0 == resp_data_len) {
354 Z_LOGE("resp_data is null");
359 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
360 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
362 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
363 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
365 zigbee_service_complete_coex_start(service_object, invocation, payload->result);
370 static gboolean on_service_coex_start(ZigbeeService *service_object,
371 GDBusMethodInvocation *invocation,
375 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
376 ZigbeeServiceCoexStart_t req;
377 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
381 memset(&req, 0x0, sizeof(ZigbeeServiceCoexStart_t));
383 /* Update request structure */
384 req.channel = channel;
386 /* Allocate response callback data */
388 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
389 invocation, NULL, 0);
390 if (NULL == resp_cb_data) {
391 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
393 /* Send failure response */
394 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
399 /* Dispatch request */
400 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
401 ZBLIB_DRIVER_TYPE_SERVICE,
402 ZBLIB_SERVICE_OPS_COEX_START,
404 on_service_coex_start_resp, resp_cb_data);
406 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
408 /* Free response callback data */
409 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
411 /* Send failure response */
412 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
420 static void on_service_coex_stop_resp(ZigBeeServiceInterface *service_interface,
421 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
423 ZigbeeServiceInterfaceRespCbData_t *cb_data =
424 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
426 ZigbeeService *service_object;
427 GDBusMethodInvocation *invocation;
428 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
430 NOT_USED(service_interface);
431 NOT_USED(request_id);
433 if (NULL == resp_data || 0 == resp_data_len) {
434 Z_LOGE("resp_data is null");
439 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
440 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
442 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
443 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
445 zigbee_service_complete_coex_stop(service_object, invocation, payload->result);
450 static gboolean on_service_coex_stop(ZigbeeService *service_object,
451 GDBusMethodInvocation *invocation,
454 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
455 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
459 /* Allocate response callback data */
461 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
462 invocation, NULL, 0);
463 if (NULL == resp_cb_data) {
464 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
466 /* Send failure response */
467 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
472 /* Dispatch request */
473 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
474 ZBLIB_DRIVER_TYPE_SERVICE,
475 ZBLIB_SERVICE_OPS_COEX_STOP,
477 on_service_coex_stop_resp, resp_cb_data);
479 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
481 /* Free response callback data */
482 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
484 /* Send failure response */
485 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
493 static void on_service_leave_network_resp(ZigBeeServiceInterface *service_interface,
494 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
496 ZigbeeServiceInterfaceRespCbData_t *cb_data =
497 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
499 ZigbeeService *service_object;
500 GDBusMethodInvocation *invocation;
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 is null");
512 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
513 zblib_check_null_free_and_ret("service_object", service_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_service_complete_leave_network(service_object, invocation, payload->result);
523 static gboolean on_service_leave_network(ZigbeeService *service_object,
524 GDBusMethodInvocation *invocation,
527 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
528 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
532 /* Allocate response callback data */
534 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
535 invocation, NULL, 0);
536 if (NULL == resp_cb_data) {
537 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
539 /* Send failure response */
540 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
545 /* Dispatch request */
546 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
547 ZBLIB_DRIVER_TYPE_SERVICE,
548 ZBLIB_SERVICE_OPS_LEAVE_NETWORK,
550 on_service_leave_network_resp, resp_cb_data);
552 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
554 /* Free response callback data */
555 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
557 /* Send failure response */
558 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
566 static void on_service_get_network_info_resp(ZigBeeServiceInterface *service_interface,
567 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
569 ZigbeeServiceInterfaceRespCbData_t *cb_data =
570 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
572 ZigbeeService *service_object;
573 GDBusMethodInvocation *invocation;
575 ZigbeeServiceGetNetworkInfoResp_t *payload =
576 (ZigbeeServiceGetNetworkInfoResp_t*)resp_data;
578 GVariant *v_eui64 = NULL;
580 NOT_USED(service_interface);
581 NOT_USED(request_id);
583 if (NULL == resp_data || 0 == resp_data_len) {
584 Z_LOGE("resp_data is null");
589 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
590 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
592 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
593 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
595 v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
596 payload->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
598 zigbee_service_complete_get_network_info(service_object, invocation,
599 payload->result, v_eui64, payload->node_id,
600 payload->pan_id, payload->channel, payload->radio_tx_power);
605 static gboolean on_service_get_network_info(ZigbeeService *service_object,
606 GDBusMethodInvocation *invocation,
609 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
610 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
614 /* Allocate response callback data */
616 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
617 invocation, NULL, 0);
618 if (NULL == resp_cb_data) {
619 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
621 /* Send failure response */
622 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
627 /* Dispatch request */
628 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
629 ZBLIB_DRIVER_TYPE_SERVICE,
630 ZBLIB_SERVICE_OPS_GET_NETWORK_INFO,
632 on_service_get_network_info_resp, resp_cb_data);
634 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
636 /* Free response callback data */
637 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
639 /* Send failure response */
640 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
648 static void on_service_permit_join_resp(ZigBeeServiceInterface *service_interface,
649 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
651 ZigbeeServiceInterfaceRespCbData_t *cb_data =
652 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
654 ZigbeeService *service_object;
655 GDBusMethodInvocation *invocation;
656 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
658 NOT_USED(service_interface);
659 NOT_USED(request_id);
661 if (NULL == resp_data || 0 == resp_data_len) {
662 Z_LOGE("resp_data is null");
667 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
668 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
670 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
671 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
673 zigbee_service_complete_permit_join(service_object, invocation, payload->result);
678 static gboolean on_service_permit_join(ZigbeeService *service_object,
679 GDBusMethodInvocation *invocation,
681 gboolean permit_join,
684 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
685 ZigbeeServicePermitJoin_t req;
686 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
690 memset(&req, 0x0, sizeof(ZigbeeServicePermitJoin_t));
692 /* Update request structure */
693 req.duration = duration;
694 req.permit_join = permit_join;
696 /* Allocate response callback data */
698 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
699 invocation, NULL, 0);
700 if (NULL == resp_cb_data) {
701 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
703 /* Send failure response */
704 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
709 /* Dispatch request */
710 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
711 ZBLIB_DRIVER_TYPE_SERVICE,
712 ZBLIB_SERVICE_OPS_PERMIT_JOIN,
714 on_service_permit_join_resp, resp_cb_data);
716 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
718 /* Free response callback data */
719 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
721 /* Send failure response */
722 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
730 static void on_service_leave_request_resp(ZigBeeServiceInterface *service_interface,
731 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
733 ZigbeeServiceInterfaceRespCbData_t *cb_data =
734 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
736 ZigbeeService *service_object;
737 GDBusMethodInvocation *invocation;
738 ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
740 NOT_USED(service_interface);
741 NOT_USED(request_id);
743 if (NULL == resp_data || 0 == resp_data_len) {
744 Z_LOGE("resp_data is null");
749 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
750 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
752 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
753 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
755 zigbee_service_complete_leave_request(service_object, invocation, payload->result);
760 static gboolean on_service_leave_request(ZigbeeService *service_object,
761 GDBusMethodInvocation *invocation,
767 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
768 ZigbeeServiceLeaveRequest_t req;
769 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
771 GVariantIter *iter = NULL;
776 memset(&req, 0x0, sizeof(ZigbeeServiceLeaveRequest_t));
778 /* Update request structure */
779 g_variant_get(eui64, "a(y)", &iter);
780 while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
782 if (i >= ZIGBEE_EUI64_SIZE)
785 req.remove_child = remove_child;
788 Z_LOGD("IEEE Address = %X:%X:%X:%X:%X:%X:%X:%X",
789 req.eui64[0], req.eui64[1], req.eui64[2], req.eui64[3],
790 req.eui64[4], req.eui64[5], req.eui64[6], req.eui64[7]);
791 Z_LOGD("remove_child [%d]", remove_child);
792 Z_LOGD("rejoin [%d]", rejoin);
794 /* Allocate response callback data */
796 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
797 invocation, NULL, 0);
798 if (NULL == resp_cb_data) {
799 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
801 /* Send failure response */
802 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
807 /* Dispatch request */
808 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
809 ZBLIB_DRIVER_TYPE_SERVICE,
810 ZBLIB_SERVICE_OPS_LEAVE_REQUEST,
812 on_service_leave_request_resp, resp_cb_data);
814 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
816 /* Free response callback data */
817 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
819 /* Send failure response */
820 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
828 static void on_service_get_device_list_resp(ZigBeeServiceInterface *service_interface,
829 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
831 ZigbeeServiceInterfaceRespCbData_t *cb_data =
832 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
834 ZigbeeService *service_object;
835 GDBusMethodInvocation *invocation;
837 NOT_USED(service_interface);
838 NOT_USED(request_id);
840 if (NULL == resp_data || 0 == resp_data_len) {
841 Z_LOGE("resp_data is null");
846 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
847 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
849 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
850 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
852 /* To-To : zigbee_service_complete_get_device_list */
853 //zigbee_service_complete_get_device_list(service_object, invocation, resp_data);
858 static gboolean on_service_get_device_list(ZigbeeService *service_object,
859 GDBusMethodInvocation *invocation,
862 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
863 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
867 /* Allocate response callback data */
869 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
870 invocation, NULL, 0);
871 if (NULL == resp_cb_data) {
872 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
874 /* Send failure response */
875 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
880 /* Dispatch request */
881 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
882 ZBLIB_DRIVER_TYPE_SERVICE,
883 ZBLIB_SERVICE_OPS_GET_DEVICE_LIST,
885 on_service_get_device_list_resp, resp_cb_data);
887 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
889 /* Free response callback data */
890 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
892 /* Send failure response */
893 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
901 static void on_service_get_mac_resp(ZigBeeServiceInterface *service_interface,
902 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
904 ZigbeeServiceInterfaceRespCbData_t *cb_data =
905 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
907 ZigbeeService *service_object;
908 GDBusMethodInvocation *invocation;
909 ZigbeeServiceGetMacResp_t *payload =
910 (ZigbeeServiceGetMacResp_t*)resp_data;
912 GVariant *v_eui64 = NULL;
914 NOT_USED(service_interface);
915 NOT_USED(request_id);
917 if (NULL == resp_data || 0 == resp_data_len) {
918 Z_LOGE("resp_data is null");
923 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
924 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
926 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
927 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
929 v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
930 payload->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
932 zigbee_service_complete_get_mac(service_object, invocation, payload->result,
938 static gboolean on_service_get_mac(ZigbeeService *service_object,
939 GDBusMethodInvocation *invocation,
942 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
943 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
947 /* Allocate response callback data */
949 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
950 invocation, NULL, 0);
951 if (NULL == resp_cb_data) {
952 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
954 /* Send failure response */
955 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
960 /* Dispatch request */
961 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
962 ZBLIB_DRIVER_TYPE_SERVICE,
963 ZBLIB_SERVICE_OPS_GET_MAC,
965 on_service_get_mac_resp, resp_cb_data);
967 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
969 /* Free response callback data */
970 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
972 /* Send failure response */
973 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
981 static void on_service_get_device_info_resp(ZigBeeServiceInterface *service_interface,
982 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
984 ZigbeeServiceInterfaceRespCbData_t *cb_data =
985 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
987 ZigbeeService *service_object;
988 GDBusMethodInvocation *invocation;
989 ZigbeeServiceGetDeviceInfoResp_t *payload =
990 (ZigbeeServiceGetDeviceInfoResp_t*)resp_data;
992 GVariant *variant = NULL;
993 GVariantBuilder* builder = NULL;
997 NOT_USED(service_interface);
998 NOT_USED(request_id);
1000 if (NULL == resp_data || 0 == resp_data_len) {
1001 Z_LOGE("resp_data is null");
1006 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
1007 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
1009 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
1010 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
1012 builder = g_variant_builder_new(G_VARIANT_TYPE ("a(qyayyay)"));
1013 for (index = 0; index < payload->count; index++) {
1014 ZigbeeServiceGetDeviceInfoDetailResp_t *device = &(payload->list[index]);
1015 GVariantBuilder* mac_builder = g_variant_builder_new(G_VARIANT_TYPE ("ay"));
1016 GVariantBuilder* endpoint_builder = g_variant_builder_new(G_VARIANT_TYPE ("ay"));
1018 for (i = 0; i < ZIGBEE_EUI64_SIZE; i++) {
1019 g_variant_builder_add (mac_builder, "y", device->eui64[i]);
1021 for (i = 0; i < device->endpoint_count; i++) {
1022 g_variant_builder_add (endpoint_builder, "y", device->endpoints[i]);
1025 g_variant_builder_add (builder, "(qyayyay)",
1026 device->node_id, device->node_type,
1027 mac_builder, device->endpoint_count, endpoint_builder);
1029 g_variant_builder_unref (mac_builder);
1030 g_variant_builder_unref (endpoint_builder);
1033 variant = g_variant_builder_end(builder);
1034 zigbee_service_complete_get_device_info(service_object, invocation,
1035 payload->result, variant);
1040 static gboolean on_service_get_device_info(ZigbeeService *service_object,
1041 GDBusMethodInvocation *invocation,
1044 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1045 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1049 /* Allocate response callback data */
1051 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
1052 invocation, NULL, 0);
1053 if (NULL == resp_cb_data) {
1054 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1056 /* Send failure response */
1057 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1062 /* Dispatch request */
1063 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1064 ZBLIB_DRIVER_TYPE_SERVICE,
1065 ZBLIB_SERVICE_OPS_GET_DEVICE_INFO,
1067 on_service_get_device_info_resp, resp_cb_data);
1069 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1071 /* Free response callback data */
1072 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1074 /* Send failure response */
1075 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1083 static void on_service_get_endpoint_list_resp(ZigBeeServiceInterface *service_interface,
1084 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
1086 ZigbeeServiceInterfaceRespCbData_t *cb_data =
1087 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
1089 ZigbeeService *service_object;
1090 GDBusMethodInvocation *invocation;
1091 ZigbeeServiceGetEndpointListResp_t *payload =
1092 (ZigbeeServiceGetEndpointListResp_t*)resp_data;
1093 GVariant *v_endpoints = NULL;
1095 NOT_USED(service_interface);
1096 NOT_USED(request_id);
1098 if (NULL == resp_data || 0 == resp_data_len) {
1099 Z_LOGE("resp_data is null");
1104 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
1105 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
1107 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
1108 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
1110 v_endpoints = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1111 payload->endpoints, payload->endpoint_count, TRUE, NULL, NULL);
1113 zigbee_service_complete_get_endpoint_list(service_object, invocation,
1114 payload->result, v_endpoints);
1119 static gboolean on_service_get_endpoint_list(ZigbeeService *service_object,
1120 GDBusMethodInvocation *invocation,
1124 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1125 ZigbeeServiceGetEndpointList_t req;
1126 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1128 GVariantIter *iter = NULL;
1133 memset(&req, 0x0, sizeof(ZigbeeServiceGetEndpointList_t));
1135 /* Update request structure */
1136 g_variant_get(eui64, "a(y)", &iter);
1137 while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
1139 if (i >= ZIGBEE_EUI64_SIZE)
1143 /* Allocate response callback data */
1145 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
1146 invocation, NULL, 0);
1147 if (NULL == resp_cb_data) {
1148 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1150 /* Send failure response */
1151 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1156 /* Dispatch request */
1157 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1158 ZBLIB_DRIVER_TYPE_SERVICE,
1159 ZBLIB_SERVICE_OPS_GET_ENDPOINT_LIST,
1161 on_service_get_endpoint_list_resp, resp_cb_data);
1163 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1165 /* Free response callback data */
1166 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1168 /* Send failure response */
1169 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1177 static void on_service_get_cluster_list_resp(ZigBeeServiceInterface *service_interface,
1178 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
1180 ZigbeeServiceInterfaceRespCbData_t *cb_data =
1181 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
1183 ZigbeeService *service_object;
1184 GDBusMethodInvocation *invocation;
1185 ZigbeeServiceGetClusterListResp_t *payload =
1186 (ZigbeeServiceGetClusterListResp_t*)resp_data;
1187 GVariant *v_clusters = NULL;
1189 NOT_USED(service_interface);
1190 NOT_USED(request_id);
1192 if (NULL == resp_data || 0 == resp_data_len) {
1193 Z_LOGE("resp_data is null");
1198 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
1199 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
1201 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
1202 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
1204 v_clusters = g_variant_new_from_data(G_VARIANT_TYPE("aq"),
1205 payload->clusters, payload->cluster_count, TRUE, NULL, NULL);
1207 zigbee_service_complete_get_cluster_list(service_object, invocation,
1208 payload->result, v_clusters);
1213 static gboolean on_service_get_cluster_list(ZigbeeService *service_object,
1214 GDBusMethodInvocation *invocation,
1219 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1220 ZigbeeServiceGetClusterList_t req;
1221 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1223 GVariantIter *iter = NULL;
1228 memset(&req, 0x0, sizeof(ZigbeeServiceGetClusterList_t));
1230 /* Update request structure */
1231 g_variant_get(eui64, "a(y)", &iter);
1232 while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
1234 if (i >= ZIGBEE_EUI64_SIZE)
1237 req.endpoint = endpoint;
1239 /* Allocate response callback data */
1241 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
1242 invocation, NULL, 0);
1243 if (NULL == resp_cb_data) {
1244 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1246 /* Send failure response */
1247 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1252 /* Dispatch request */
1253 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1254 ZBLIB_DRIVER_TYPE_SERVICE,
1255 ZBLIB_SERVICE_OPS_GET_CLUSTER_LIST,
1257 on_service_get_cluster_list_resp, resp_cb_data);
1259 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1261 /* Free response callback data */
1262 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1264 /* Send failure response */
1265 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1273 static void on_service_get_node_type_resp(ZigBeeServiceInterface *service_interface,
1274 guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
1276 ZigbeeServiceInterfaceRespCbData_t *cb_data =
1277 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
1279 ZigbeeService *service_object;
1280 GDBusMethodInvocation *invocation;
1281 ZigbeeServiceServiceNodeTypeResp_t *payload =
1282 (ZigbeeServiceServiceNodeTypeResp_t *)resp_data;
1284 NOT_USED(service_interface);
1285 NOT_USED(request_id);
1287 if (NULL == resp_data || 0 == resp_data_len) {
1288 Z_LOGE("resp_data is null");
1293 service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
1294 zblib_check_null_free_and_ret("service_object", service_object, cb_data);
1296 invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
1297 zblib_check_null_free_and_ret("invocation", invocation, cb_data);
1299 zigbee_service_complete_get_node_type(service_object, invocation,
1300 payload->result, payload->node_type);
1305 static gboolean on_service_get_node_type(ZigbeeService *service_object,
1306 GDBusMethodInvocation *invocation,
1310 ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1311 ZigbeeServiceGetNodeType_t req;
1312 ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1314 GVariantIter *iter = NULL;
1319 memset(&req, 0x0, sizeof(ZigbeeServiceGetNodeType_t));
1321 /* Update request structure */
1322 g_variant_get(eui64, "a(y)", &iter);
1323 while (g_variant_iter_loop(iter, "(y)", req.eui64[i])) {
1325 if (i >= ZIGBEE_EUI64_SIZE)
1329 /* Allocate response callback data */
1331 zigbee_service_dbus_interface_create_resp_cb_data(service_object,
1332 invocation, NULL, 0);
1333 if (NULL == resp_cb_data) {
1334 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1336 /* Send failure response */
1337 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1342 /* Dispatch request */
1343 ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1344 ZBLIB_DRIVER_TYPE_SERVICE,
1345 ZBLIB_SERVICE_OPS_GET_NODE_TYPE,
1347 on_service_get_node_type_resp, resp_cb_data);
1349 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1351 /* Free response callback data */
1352 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1354 /* Send failure response */
1355 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1363 void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface *service_interface,
1364 guint noti_id, gpointer noti_data, guint noti_data_len, gpointer noti_cb_data)
1366 ZigbeeService *service_object;
1368 zblib_check_null_ret("service_interface", service_interface);
1370 if (NULL == noti_data || 0 == noti_data_len) {
1371 Z_LOGE("noti_data is NULL");
1375 service_object = _service_interface_ref_zigbee_service(service_interface);
1376 zblib_check_null_ret("service_object", service_object);
1378 NOT_USED(noti_cb_data);
1381 case ZBLIB_SERVICE_NOTI_FORM_NETWORK_DONE: {
1382 ZigbeeServiceServiceFormNetworkDone_t *panid_t =
1383 (ZigbeeServiceServiceFormNetworkDone_t*)noti_data;
1385 Z_LOGD("form_network_done : [0x%X]", panid_t->pan_id);
1387 zigbee_service_emit_form_network_done(service_object, panid_t->pan_id);
1390 case ZBLIB_SERVICE_NOTI_CHILD_JOINED: {
1391 ZigbeeServiceServiceChildJoined_t *child_t =
1392 (ZigbeeServiceServiceChildJoined_t*)noti_data;
1394 GVariant *v_eui64 = NULL;
1395 GVariant *v_endpoints = NULL;
1397 v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1398 child_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
1399 v_endpoints = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1400 child_t->endpoints, child_t->endpoint_count, TRUE, NULL, NULL);
1401 if (NULL == v_eui64 || NULL == v_endpoints) {
1402 Z_LOGE("Failed to create variant!");
1404 g_object_unref(v_eui64);
1406 g_object_unref(v_endpoints);
1408 zigbee_service_emit_child_joined(service_object,
1409 v_eui64, child_t->endpoint_count, v_endpoints, child_t->node_id);
1413 case ZBLIB_SERVICE_NOTI_CHILD_REJOINED: {
1414 ZigbeeServiceServiceChildRejoined_t *child_t =
1415 (ZigbeeServiceServiceChildRejoined_t*)noti_data;
1417 GVariant *v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1418 child_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
1419 if (NULL == v_eui64) {
1420 Z_LOGE("Failed to create variant!");
1422 zigbee_service_emit_child_rejoined(service_object, v_eui64);
1426 case ZBLIB_SERVICE_NOTI_CHILD_LEFT: {
1427 ZigbeeServiceServiceChildLeft_t *child_left_t =
1428 (ZigbeeServiceServiceChildLeft_t*)noti_data;
1430 GVariant *v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
1431 child_left_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
1432 if (NULL == v_eui64) {
1433 Z_LOGE("Failed to create variant!");
1435 zigbee_service_emit_child_left(service_object,
1436 v_eui64, child_left_t->status);
1440 case ZBLIB_SERVICE_NOTI_LEAVE_NETWORK_DONE: {
1441 ZigbeeServiceServiceLeaveNetworkDone_t leave_net_t;
1442 memcpy(&leave_net_t, noti_data, noti_data_len);
1443 zigbee_service_emit_leave_network_done(service_object, leave_net_t.pan_id);
1447 Z_LOGE("Unexpected notification [%x]", noti_id);
1451 /* ZigbeeService should be dereferenced */
1452 g_object_unref(service_object);
1455 gboolean zigbee_service_dbus_interface_service_init(ZigBeeServiceInterface *service_interface,
1456 ZigbeeObjectSkeleton *zigbee_object)
1458 ZigbeeService *service_object;
1460 if (NULL == service_interface) {
1461 Z_LOGE("service_interface is NULL");
1465 service_object = zigbee_service_skeleton_new();
1466 zigbee_object_skeleton_set_service(zigbee_object, service_object);
1467 g_object_unref(service_object);
1469 Z_LOGI("service_object: [%p]", service_object);
1472 * Register signal handlers for 'service' interface
1474 g_signal_connect(service_object,
1476 G_CALLBACK(on_service_enable), service_interface);
1478 g_signal_connect(service_object,
1480 G_CALLBACK(on_service_disable), service_interface);
1482 g_signal_connect(service_object,
1483 "handle-zb-hw-reset",
1484 G_CALLBACK(on_service_zb_hw_reset), service_interface);
1486 g_signal_connect(service_object,
1487 "handle-form-network",
1488 G_CALLBACK(on_service_form_network), service_interface);
1490 g_signal_connect(service_object,
1491 "handle-coex-start",
1492 G_CALLBACK(on_service_coex_start), service_interface);
1494 g_signal_connect(service_object,
1496 G_CALLBACK(on_service_coex_stop), service_interface);
1498 g_signal_connect(service_object,
1499 "handle-leave-network",
1500 G_CALLBACK(on_service_leave_network), service_interface);
1502 g_signal_connect(service_object,
1503 "handle-get-network-info",
1504 G_CALLBACK(on_service_get_network_info), service_interface);
1506 g_signal_connect(service_object,
1507 "handle-permit-join",
1508 G_CALLBACK(on_service_permit_join), service_interface);
1510 g_signal_connect(service_object,
1511 "handle-leave-request",
1512 G_CALLBACK(on_service_leave_request), service_interface);
1514 g_signal_connect(service_object,
1515 "handle-get-device-list",
1516 G_CALLBACK(on_service_get_device_list), service_interface);
1518 g_signal_connect(service_object,
1520 G_CALLBACK(on_service_get_mac), service_interface);
1522 g_signal_connect(service_object,
1523 "handle-get-device-info",
1524 G_CALLBACK(on_service_get_device_info), service_interface);
1526 g_signal_connect(service_object,
1527 "handle-get-endpoint-list",
1528 G_CALLBACK(on_service_get_endpoint_list), service_interface);
1530 g_signal_connect(service_object,
1531 "handle-get-cluster-list",
1532 G_CALLBACK(on_service_get_cluster_list), service_interface);
1534 g_signal_connect(service_object,
1535 "handle-get-node-type",
1536 G_CALLBACK(on_service_get_node_type), service_interface);