Modify API to get in/out cluster list
[platform/core/connectivity/zigbee-manager.git] / zigbee-daemon / zigbee-interface / src / zigbee_service_dbus_interface_service.c
index 879ba23..cf97c6e 100644 (file)
@@ -22,7 +22,7 @@
 
 static void *_service_interface_ref_zigbee_service(ZigBeeServiceInterface *service_interface)
 {
-       ZigbeeObjectSkeleton *zigbee_object;
+       ZigbeeObjectSkeleton *zigbee_object = NULL;
        ZigbeeCustomData_t *custom_data = NULL;
        ZigbeeService *service = NULL;
 
@@ -34,7 +34,7 @@ static void *_service_interface_ref_zigbee_service(ZigBeeServiceInterface *servi
 
        /* Get zigbee object */
        zigbee_object = g_hash_table_lookup(custom_data->objects, ZIGBEE_SERVICE_PATH);
-       if (zigbee_object) {
+       if (NULL == zigbee_object) {
                Z_LOGW("Cannot find ZigBee D-BUS interface object!", zigbee_object);
                return NULL;
        }
@@ -51,19 +51,26 @@ static void on_service_enable_resp(ZigBeeServiceInterface *service_interface,
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
+       ZigbeeServiceServiceStateResp_t *payload =
+               (ZigbeeServiceServiceStateResp_t*)resp_data;
 
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data is null");
+               g_free(cb_data);
+               return;
+       }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
 
-       zigbee_service_complete_enable(service_object, invocation, TRUE);
+       zigbee_service_complete_enable(service_object, invocation,
+               payload->result, payload->enabled);
 
        g_free(cb_data);
 }
@@ -77,8 +84,6 @@ static gboolean on_service_enable(ZigbeeService *service_object,
 
        gboolean ret;
 
-       Z_LOGE("KSR");
-
        /* Allocate response callback data */
        resp_cb_data =
                zigbee_service_dbus_interface_create_resp_cb_data(service_object,
@@ -121,19 +126,24 @@ static void on_service_disable_resp(ZigBeeServiceInterface *service_interface,
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
 
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data is null");
+               g_free(cb_data);
+               return;
+       }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
 
-       zigbee_service_complete_disable(service_object, invocation);
+       zigbee_service_complete_disable(service_object, invocation, payload->result);
 
        g_free(cb_data);
 }
@@ -189,19 +199,24 @@ static void on_service_zb_hw_reset_resp(ZigBeeServiceInterface *service_interfac
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
 
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data is null");
+               g_free(cb_data);
+               return;
+       }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
 
-       zigbee_service_complete_zb_hw_reset(service_object, invocation);
+       zigbee_service_complete_zb_hw_reset(service_object, invocation, payload->result);
 
        g_free(cb_data);
 }
@@ -257,19 +272,24 @@ static void on_service_form_network_resp(ZigBeeServiceInterface *service_interfa
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
 
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data is null");
+               g_free(cb_data);
+               return;
+       }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
 
-       zigbee_service_complete_form_network(service_object, invocation);
+       zigbee_service_complete_form_network(service_object, invocation, payload->result);
 
        g_free(cb_data);
 }
@@ -325,19 +345,24 @@ static void on_service_coex_start_resp(ZigBeeServiceInterface *service_interface
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
 
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data is null");
+               g_free(cb_data);
+               return;
+       }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
 
-       zigbee_service_complete_coex_start(service_object, invocation);
+       zigbee_service_complete_coex_start(service_object, invocation, payload->result);
 
        g_free(cb_data);
 }
@@ -400,19 +425,24 @@ static void on_service_coex_stop_resp(ZigBeeServiceInterface *service_interface,
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
 
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data is null");
+               g_free(cb_data);
+               return;
+       }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
 
-       zigbee_service_complete_coex_stop(service_object, invocation);
+       zigbee_service_complete_coex_stop(service_object, invocation, payload->result);
 
        g_free(cb_data);
 }
@@ -468,19 +498,24 @@ static void on_service_leave_network_resp(ZigBeeServiceInterface *service_interf
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
 
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data is null");
+               g_free(cb_data);
+               return;
+       }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
 
-       zigbee_service_complete_leave_network(service_object, invocation);
+       zigbee_service_complete_leave_network(service_object, invocation, payload->result);
 
        g_free(cb_data);
 }
@@ -537,23 +572,32 @@ static void on_service_get_network_info_resp(ZigBeeServiceInterface *service_int
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
 
-       ZigbeeServiceGetNetworkInfo_t payload;
+       ZigbeeServiceGetNetworkInfoResp_t *payload =
+               (ZigbeeServiceGetNetworkInfoResp_t*)resp_data;
+
+       GVariant *v_eui64 = NULL;
 
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data is null");
+               g_free(cb_data);
+               return;
+       }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+               payload->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
 
-       memcpy(&payload, resp_data, resp_data_len);
        zigbee_service_complete_get_network_info(service_object, invocation,
-               payload.eui64, payload.node_id, payload.pan_id, payload.channel,
-               payload.radio_tx_power);
+               payload->result, v_eui64, payload->node_id,
+               payload->pan_id, payload->channel, payload->radio_tx_power);
 
        g_free(cb_data);
 }
@@ -609,19 +653,24 @@ static void on_service_permit_join_resp(ZigBeeServiceInterface *service_interfac
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
 
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data is null");
+               g_free(cb_data);
+               return;
+       }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
 
-       zigbee_service_complete_permit_join(service_object, invocation);
+       zigbee_service_complete_permit_join(service_object, invocation, payload->result);
 
        g_free(cb_data);
 }
@@ -686,19 +735,24 @@ static void on_service_leave_request_resp(ZigBeeServiceInterface *service_interf
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
 
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data is null");
+               g_free(cb_data);
+               return;
+       }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
 
-       zigbee_service_complete_leave_request(service_object, invocation);
+       zigbee_service_complete_leave_request(service_object, invocation, payload->result);
 
        g_free(cb_data);
 }
@@ -722,8 +776,8 @@ static gboolean on_service_leave_request(ZigbeeService *service_object,
        memset(&req, 0x0, sizeof(ZigbeeServiceLeaveRequest_t));
 
        /* Update request structure */
-       g_variant_get(eui64, "ay", &iter);
-       while (g_variant_iter_loop(iter, "y", req.eui64[i])) {
+       g_variant_get(eui64, "a(y)", &iter);
+       while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
                i++;
                if (i >= ZIGBEE_EUI64_SIZE)
                        break;
@@ -731,6 +785,12 @@ static gboolean on_service_leave_request(ZigbeeService *service_object,
        req.remove_child = remove_child;
        req.rejoin = rejoin;
 
+       Z_LOGD("IEEE Address = %X:%X:%X:%X:%X:%X:%X:%X",
+               req.eui64[0], req.eui64[1], req.eui64[2], req.eui64[3],
+               req.eui64[4], req.eui64[5], req.eui64[6], req.eui64[7]);
+       Z_LOGD("remove_child [%d]", remove_child);
+       Z_LOGD("rejoin [%d]", rejoin);
+
        /* Allocate response callback data */
        resp_cb_data =
                zigbee_service_dbus_interface_create_resp_cb_data(service_object,
@@ -784,12 +844,13 @@ static void on_service_get_device_list_resp(ZigBeeServiceInterface *service_inte
        }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
 
-       zigbee_service_complete_get_device_list(service_object, invocation,     resp_data);
+       /* To-To : zigbee_service_complete_get_device_list */
+       //zigbee_service_complete_get_device_list(service_object, invocation,   resp_data);
 
        g_free(cb_data);
 }
@@ -845,8 +906,11 @@ static void on_service_get_mac_resp(ZigBeeServiceInterface *service_interface,
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
+       ZigbeeServiceGetMacResp_t *payload =
+               (ZigbeeServiceGetMacResp_t*)resp_data;
+
+       GVariant *v_eui64 = NULL;
 
-       NOT_USED(cb_data);
        NOT_USED(service_interface);
        NOT_USED(request_id);
 
@@ -857,16 +921,18 @@ static void on_service_get_mac_resp(ZigBeeServiceInterface *service_interface,
        }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
 
-       /* Todo : plugin must load resp_data as char pointer */
-       zigbee_service_complete_get_mac(service_object, invocation, resp_data);
+       v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+               payload->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
 
-       g_free(cb_data);
+       zigbee_service_complete_get_mac(service_object, invocation, payload->result,
+               v_eui64);
 
+       g_free(cb_data);
 }
 
 static gboolean on_service_get_mac(ZigbeeService *service_object,
@@ -920,8 +986,14 @@ static void on_service_get_device_info_resp(ZigBeeServiceInterface *service_inte
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
+       ZigbeeServiceGetDeviceInfoResp_t *payload =
+               (ZigbeeServiceGetDeviceInfoResp_t*)resp_data;
+
+       GVariant *variant = NULL;
+       GVariantBuilder* builder = NULL;
+       int i = 0;
+       int index = 0;
 
-       NOT_USED(cb_data);
        NOT_USED(service_interface);
        NOT_USED(request_id);
 
@@ -932,12 +1004,35 @@ static void on_service_get_device_info_resp(ZigBeeServiceInterface *service_inte
        }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE ("a(qyayyay)"));
+       for (index = 0; index < payload->count; index++) {
+               ZigbeeServiceGetDeviceInfoDetailResp_t *device = &(payload->list[index]);
+               GVariantBuilder* mac_builder = g_variant_builder_new(G_VARIANT_TYPE ("ay"));
+               GVariantBuilder* endpoint_builder = g_variant_builder_new(G_VARIANT_TYPE ("ay"));
+
+               for (i = 0; i < ZIGBEE_EUI64_SIZE; i++) {
+                       g_variant_builder_add (mac_builder, "y", device->eui64[i]);
+               }
+               for (i = 0; i < device->endpoint_count; i++) {
+                       g_variant_builder_add (endpoint_builder, "y", device->endpoints[i]);
+               }
+
+               g_variant_builder_add (builder, "(qyayyay)",
+                       device->node_id, device->node_type,
+                       mac_builder, device->endpoint_count, endpoint_builder);
+
+               g_variant_builder_unref (mac_builder);
+               g_variant_builder_unref (endpoint_builder);
+       }
 
-       zigbee_service_complete_get_device_info(service_object, invocation, resp_data);
+       variant = g_variant_builder_end(builder);
+       zigbee_service_complete_get_device_info(service_object, invocation,
+               payload->result, variant);
 
        g_free(cb_data);
 }
@@ -993,8 +1088,10 @@ static void on_service_get_endpoint_list_resp(ZigBeeServiceInterface *service_in
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
+       ZigbeeServiceGetEndpointListResp_t *payload =
+               (ZigbeeServiceGetEndpointListResp_t*)resp_data;
+       GVariant *v_endpoints = NULL;
 
-       NOT_USED(cb_data);
        NOT_USED(service_interface);
        NOT_USED(request_id);
 
@@ -1005,13 +1102,16 @@ static void on_service_get_endpoint_list_resp(ZigBeeServiceInterface *service_in
        }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       v_endpoints = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+               payload->endpoints, payload->endpoint_count, TRUE, NULL, NULL);
 
-       /* To fix : end-points must be changed gchar* -> GVariant ay */
-       zigbee_service_complete_get_endpoint_list(service_object, invocation, resp_data);
+       zigbee_service_complete_get_endpoint_list(service_object, invocation,
+               payload->result, v_endpoints);
 
        g_free(cb_data);
 }
@@ -1033,8 +1133,8 @@ static gboolean on_service_get_endpoint_list(ZigbeeService *service_object,
        memset(&req, 0x0, sizeof(ZigbeeServiceGetEndpointList_t));
 
        /* Update request structure */
-       g_variant_get(eui64, "ay", &iter);
-       while (g_variant_iter_loop(iter, "y", req.eui64[i])) {
+       g_variant_get(eui64, "a(y)", &iter);
+       while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
                i++;
                if (i >= ZIGBEE_EUI64_SIZE)
                        break;
@@ -1082,8 +1182,11 @@ static void on_service_get_cluster_list_resp(ZigBeeServiceInterface *service_int
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
+       ZigbeeServiceGetClusterListResp_t *payload =
+               (ZigbeeServiceGetClusterListResp_t*)resp_data;
+       GVariant *v_in_clusters = NULL;
+       GVariant *v_out_clusters = NULL;
 
-       NOT_USED(cb_data);
        NOT_USED(service_interface);
        NOT_USED(request_id);
 
@@ -1094,12 +1197,18 @@ static void on_service_get_cluster_list_resp(ZigBeeServiceInterface *service_int
        }
 
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
 
-       zigbee_service_complete_get_cluster_list(service_object, invocation, resp_data);
+       v_in_clusters = g_variant_new_from_data(G_VARIANT_TYPE("aq"),
+               payload->in_clusters, payload->in_cluster_count, TRUE, NULL, NULL);
+       v_out_clusters = g_variant_new_from_data(G_VARIANT_TYPE("aq"),
+               payload->out_clusters, payload->out_cluster_count, TRUE, NULL, NULL);
+
+       zigbee_service_complete_get_cluster_list(service_object, invocation,
+               payload->result, v_in_clusters, v_out_clusters);
 
        g_free(cb_data);
 }
@@ -1122,8 +1231,8 @@ static gboolean on_service_get_cluster_list(ZigbeeService *service_object,
        memset(&req, 0x0, sizeof(ZigbeeServiceGetClusterList_t));
 
        /* Update request structure */
-       g_variant_get(eui64, "ay", &iter);
-       while (g_variant_iter_loop(iter, "y", req.eui64[i])) {
+       g_variant_get(eui64, "a(y)", &iter);
+       while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
                i++;
                if (i >= ZIGBEE_EUI64_SIZE)
                        break;
@@ -1172,9 +1281,9 @@ static void on_service_get_node_type_resp(ZigBeeServiceInterface *service_interf
 
        ZigbeeService *service_object;
        GDBusMethodInvocation *invocation;
-       ZigbeeServiceServiceNodeType_t payload;
+       ZigbeeServiceServiceNodeTypeResp_t *payload =
+               (ZigbeeServiceServiceNodeTypeResp_t *)resp_data;
 
-       NOT_USED(cb_data);
        NOT_USED(service_interface);
        NOT_USED(request_id);
 
@@ -1184,15 +1293,14 @@ static void on_service_get_node_type_resp(ZigBeeServiceInterface *service_interf
                return;
        }
 
-       memcpy(&payload, resp_data, resp_data_len);
-
        service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
-       zblib_check_null_ret("service_object", service_object);
+       zblib_check_null_free_and_ret("service_object", service_object, cb_data);
 
        invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
-       zblib_check_null_ret("invocation", invocation);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
 
-       zigbee_service_complete_get_node_type(service_object, invocation, payload.node_type);
+       zigbee_service_complete_get_node_type(service_object, invocation,
+               payload->result, payload->node_type);
 
        g_free(cb_data);
 }
@@ -1214,8 +1322,8 @@ static gboolean on_service_get_node_type(ZigbeeService *service_object,
        memset(&req, 0x0, sizeof(ZigbeeServiceGetNodeType_t));
 
        /* Update request structure */
-       g_variant_get(eui64, "ay", &iter);
-       while (g_variant_iter_loop(iter, "y", req.eui64[i])) {
+       g_variant_get(eui64, "a(y)", &iter);
+       while (g_variant_iter_loop(iter, "(y)", req.eui64[i])) {
                i++;
                if (i >= ZIGBEE_EUI64_SIZE)
                        break;
@@ -1274,25 +1382,62 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface *
 
        switch(noti_id) {
        case ZBLIB_SERVICE_NOTI_FORM_NETWORK_DONE: {
-               ZigbeeServiceServiceFormNetworkDone_t panid_t;
-               memcpy(&panid_t, noti_data, noti_data_len);
-               zigbee_service_emit_form_network_done(service_object, panid_t.pan_id);
+               ZigbeeServiceServiceFormNetworkDone_t *panid_t =
+                       (ZigbeeServiceServiceFormNetworkDone_t*)noti_data;
+
+               Z_LOGD("form_network_done : [0x%X]", panid_t->pan_id);
+
+               zigbee_service_emit_form_network_done(service_object, panid_t->pan_id);
        }
        break;
        case ZBLIB_SERVICE_NOTI_CHILD_JOINED: {
-               zigbee_service_emit_child_joined(service_object, (GVariant *)noti_data);
+               ZigbeeServiceServiceChildJoined_t *child_t =
+                       (ZigbeeServiceServiceChildJoined_t*)noti_data;
+
+               GVariant *v_eui64 = NULL;
+               GVariant *v_endpoints = NULL;
+
+               v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       child_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
+               v_endpoints = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       child_t->endpoints, child_t->endpoint_count, TRUE, NULL, NULL);
+               if (NULL == v_eui64 || NULL == v_endpoints) {
+                       Z_LOGE("Failed to create variant!");
+                       if (v_eui64)
+                               g_object_unref(v_eui64);
+                       if (v_endpoints)
+                               g_object_unref(v_endpoints);
+               } else {
+                       zigbee_service_emit_child_joined(service_object,
+                               v_eui64, child_t->endpoint_count, v_endpoints, child_t->node_id);
+               }
        }
        break;
        case ZBLIB_SERVICE_NOTI_CHILD_REJOINED: {
-               ZigbeeServiceServiceChildRejoined_t ieee_addr_t;
-               memcpy(&ieee_addr_t, noti_data, noti_data_len);
-               zigbee_service_emit_child_rejoined(service_object, ieee_addr_t.eui64);
+               ZigbeeServiceServiceChildRejoined_t *child_t =
+                       (ZigbeeServiceServiceChildRejoined_t*)noti_data;
+
+               GVariant *v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       child_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
+               if (NULL == v_eui64) {
+                       Z_LOGE("Failed to create variant!");
+               } else {
+                       zigbee_service_emit_child_rejoined(service_object, v_eui64);
+               }
        }
        break;
        case ZBLIB_SERVICE_NOTI_CHILD_LEFT: {
-               ZigbeeServiceServiceChildLeft_t child_left_t;
-               memcpy(&child_left_t, noti_data, noti_data_len);
-               zigbee_service_emit_child_left(service_object, child_left_t.eui64, child_left_t.status);
+               ZigbeeServiceServiceChildLeft_t *child_left_t =
+                       (ZigbeeServiceServiceChildLeft_t*)noti_data;
+
+               GVariant *v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       child_left_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
+               if (NULL == v_eui64) {
+                       Z_LOGE("Failed to create variant!");
+               } else {
+                       zigbee_service_emit_child_left(service_object,
+                               v_eui64, child_left_t->status);
+               }
        }
        break;
        case ZBLIB_SERVICE_NOTI_LEAVE_NETWORK_DONE: {