Fix BT enable issue on XU3 TV profile
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-gatt-client.c
index a3258ee..749088e 100755 (executable)
@@ -223,11 +223,11 @@ BT_EXPORT_API int bluetooth_gatt_get_service_property(const char *service_handle
        BT_CHECK_PARAMETER(service, return);
        BT_CHECK_ENABLED(return);
 
-       g_conn = _bt_gdbus_get_system_gconn();
+       g_conn = _bt_get_system_private_conn();
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        properties_proxy = g_dbus_proxy_new_sync(g_conn,
-                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
                        BT_BLUEZ_NAME,
                        service_handle,
                        BT_PROPERTIES_INTERFACE,
@@ -530,11 +530,11 @@ BT_EXPORT_API int bluetooth_gatt_discover_service_characteristics(
        BT_CHECK_PARAMETER(service_handle, return);
        BT_CHECK_ENABLED(return);
 
-       g_conn = _bt_gdbus_get_system_gconn();
+       g_conn = _bt_get_system_private_conn();
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        properties_proxy = g_dbus_proxy_new_sync(g_conn,
-                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
                        BT_BLUEZ_NAME,
                        service_handle,
                        BT_PROPERTIES_INTERFACE,
@@ -654,11 +654,11 @@ BT_EXPORT_API int bluetooth_gatt_get_characteristics_property(
 
        BT_CHECK_ENABLED(return);
 
-       g_conn = _bt_gdbus_get_system_gconn();
+       g_conn = _bt_get_system_private_conn();
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        properties_proxy = g_dbus_proxy_new_sync(g_conn,
-                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
                        BT_BLUEZ_NAME,
                        char_handle,
                        BT_PROPERTIES_INTERFACE,
@@ -819,11 +819,11 @@ BT_EXPORT_API int bluetooth_gatt_get_char_from_uuid(const char *service_handle,
        BT_CHECK_PARAMETER(char_uuid, return);
        BT_CHECK_ENABLED(return);
 
-       g_conn = _bt_gdbus_get_system_gconn();
+       g_conn = _bt_get_system_private_conn();
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        properties_proxy = g_dbus_proxy_new_sync(g_conn,
-                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
                        BT_BLUEZ_NAME,
                        service_handle,
                        BT_PROPERTIES_INTERFACE,
@@ -865,11 +865,11 @@ BT_EXPORT_API int bluetooth_gatt_get_char_descriptor_property(
 
        BT_CHECK_ENABLED(return);
 
-       g_conn = _bt_gdbus_get_system_gconn();
+       g_conn = _bt_get_system_private_conn();
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        properties_proxy = g_dbus_proxy_new_sync(g_conn,
-                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
                        BT_BLUEZ_NAME,
                        descriptor_handle,
                        BT_PROPERTIES_INTERFACE,
@@ -995,7 +995,7 @@ static void __bluetooth_internal_read_cb(GObject *source_object,
 
        BT_DBG("+");
 
-       system_gconn = _bt_gdbus_get_system_gconn();
+       system_gconn = _bt_get_system_private_conn();
        value = g_dbus_connection_call_finish(system_gconn, res, &error);
 
        user_info = _bt_get_user_data(BT_COMMON);
@@ -1056,7 +1056,7 @@ BT_EXPORT_API int bluetooth_gatt_read_characteristic_value(const char *chr,
        BT_CHECK_PARAMETER(chr, return);
        BT_CHECK_ENABLED(return);
 
-       conn = _bt_gdbus_get_system_gconn();
+       conn = _bt_get_system_private_conn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        resp_data = g_malloc0(sizeof(bt_gatt_resp_data_t));
@@ -1093,7 +1093,7 @@ static void __bluetooth_internal_write_cb(GObject *source_object,
        int att_ecode = 0;
        bt_gatt_resp_data_t *resp_data = user_data;
 
-       system_gconn = _bt_gdbus_get_system_gconn();
+       system_gconn = _bt_get_system_private_conn();
        value = g_dbus_connection_call_finish(system_gconn, res, &error);
 
        user_info = _bt_get_user_data(BT_COMMON);
@@ -1146,7 +1146,7 @@ BT_EXPORT_API int bluetooth_gatt_set_characteristics_value(
        retv_if(length == 0, BLUETOOTH_ERROR_INVALID_PARAM);
        BT_CHECK_ENABLED(return);
 
-       conn = _bt_gdbus_get_system_gconn();
+       conn = _bt_get_system_private_conn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
@@ -1211,7 +1211,7 @@ BT_EXPORT_API int bluetooth_gatt_set_characteristics_value_by_type(
        retv_if(length == 0, BLUETOOTH_ERROR_INVALID_PARAM);
        BT_CHECK_ENABLED_INTERNAL(return);
 
-       conn = _bt_gdbus_get_system_gconn();
+       conn = _bt_get_system_private_conn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
@@ -1266,7 +1266,7 @@ BT_EXPORT_API int bluetooth_gatt_set_characteristics_value_request(
        retv_if(length == 0, BLUETOOTH_ERROR_INVALID_PARAM);
        BT_CHECK_ENABLED(return);
 
-       conn = _bt_gdbus_get_system_gconn();
+       conn = _bt_get_system_private_conn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
@@ -1325,11 +1325,11 @@ static int __bluetooth_gatt_descriptor_iter(const char *char_handle,
        const gchar *key;
        char_descriptor_type_t desc_type = TYPE_NONE;
 
-       g_conn = _bt_gdbus_get_system_gconn();
+       g_conn = _bt_get_system_private_conn();
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        properties_proxy = g_dbus_proxy_new_sync(g_conn,
-                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
                        BT_BLUEZ_NAME,
                        char_handle,
                        BT_PROPERTIES_INTERFACE,
@@ -1490,11 +1490,11 @@ BT_EXPORT_API int bluetooth_gatt_discover_characteristic_descriptor(
        BT_CHECK_PARAMETER(characteristic_handle, return);
        BT_CHECK_ENABLED(return);
 
-       g_conn = _bt_gdbus_get_system_gconn();
+       g_conn = _bt_get_system_private_conn();
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        properties_proxy = g_dbus_proxy_new_sync(g_conn,
-                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
                        BT_BLUEZ_NAME,
                        characteristic_handle,
                        BT_PROPERTIES_INTERFACE,
@@ -1531,7 +1531,7 @@ static void __bluetooth_internal_read_desc_cb(GObject *source_object,
 
        BT_DBG("+");
 
-       system_gconn = _bt_gdbus_get_system_gconn();
+       system_gconn = _bt_get_system_private_conn();
        value = g_dbus_connection_call_finish(system_gconn, res, &error);
 
        user_info = _bt_get_user_data(BT_COMMON);
@@ -1595,7 +1595,7 @@ BT_EXPORT_API int bluetooth_gatt_read_descriptor_value(const char *desc,
        BT_CHECK_PARAMETER(desc, return);
        BT_CHECK_ENABLED(return);
 
-       conn = _bt_gdbus_get_system_gconn();
+       conn = _bt_get_system_private_conn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        resp_data = g_malloc0(sizeof(bt_gatt_resp_data_t));
@@ -1635,7 +1635,7 @@ static void __bluetooth_internal_write_desc_cb(GObject *source_object,
 
        BT_DBG("+");
 
-       system_gconn = _bt_gdbus_get_system_gconn();
+       system_gconn = _bt_get_system_private_conn();
        value = g_dbus_connection_call_finish(system_gconn, res, &error);
 
        user_info = _bt_get_user_data(BT_COMMON);
@@ -1689,7 +1689,7 @@ BT_EXPORT_API int bluetooth_gatt_write_descriptor_value(const char *desc,
        retv_if(length == 0, BLUETOOTH_ERROR_INVALID_PARAM);
        BT_CHECK_ENABLED(return);
 
-       conn = _bt_gdbus_get_system_gconn();
+       conn = _bt_get_system_private_conn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
@@ -1739,7 +1739,7 @@ BT_EXPORT_API int bluetooth_gatt_watch_characteristics(const char *char_handle,
 
        BT_INFO_C("### Enable CCCD : %s [%s]", char_handle + 15, svc_name);
 
-       conn = _bt_gdbus_get_system_gconn();
+       conn = _bt_get_system_private_conn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        g_dbus_connection_call_sync(conn,
@@ -1789,7 +1789,7 @@ BT_EXPORT_API int bluetooth_gatt_unwatch_characteristics(const char *char_handle
 
        BT_INFO("Disable CCCD : %s", char_handle);
 
-       conn = _bt_gdbus_get_system_gconn();
+       conn = _bt_get_system_private_conn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        g_dbus_connection_call_sync(conn,
@@ -2155,10 +2155,8 @@ static gboolean  bluetooth_gatt_client_notify_channel_watch_cb(GIOChannel *gio,
 {
        bt_gatt_characteristic_notify_info_t *chr_info = (bt_gatt_characteristic_notify_info_t *)data;
 
-       BT_INFO(" FD io NOTIFICATION recived\n");
-
        if (!chr_info) {
-               BT_ERR("char INFO nort recieved");
+               BT_ERR("chr_info is invalid");
                return FALSE;
        }
        if (cond & G_IO_IN) {
@@ -2194,33 +2192,31 @@ static gboolean  bluetooth_gatt_client_notify_channel_watch_cb(GIOChannel *gio,
                }
 
                if (len > 0 && len < chr_info->mtu) {
-
                        bt_gatt_char_property_t char_val;
-                       BT_INFO("FD io sending  value changed  %x %x %x %x %x %x %x %d \n", buffer[0], buffer[1], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], len);
-
+//                      BT_DBG("FD io sending  value changed  %x %x %x %x %x %x %x %zd \n", buffer[0], buffer[1], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], len);
 
                        memcpy(char_val.prop.uuid, chr_info->UUID, 16);
                        memcpy(char_val.value, buffer, len);
                        char_val.val_len = len;
-                       memcpy(char_val.address, chr_info->adress, 18);
+                       memcpy(char_val.address, chr_info->address, 18);
 
                        event_info = _bt_event_get_cb_data(BT_GATT_CLIENT_EVENT);
-
                        if (event_info) {
-
                                _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED,
                                                        BLUETOOTH_ERROR_NONE, &char_val,
-                                               event_info->cb, event_info->user_data);
+                                                       event_info->cb, event_info->user_data);
                        } else {
-                               BT_ERR("eventinfo failed");
+                               BT_ERR("event_info failed");
                        }
 
                } else
                        BT_ERR("Packet corrupted");
+
                g_free(buffer);
 
                return TRUE;
        }
+
        if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
                BT_ERR("Error : GIOCondition %d, [%s]", cond, chr_info->UUID);
                g_io_channel_shutdown(gio, TRUE, NULL);
@@ -2235,6 +2231,7 @@ static gboolean  bluetooth_gatt_client_notify_channel_watch_cb(GIOChannel *gio,
        return TRUE;
 }
 
+#ifndef TIZEN_FEATURE_BT_GATT_CLIENT_FD_DISABLE
 static bt_gatt_characteristic_notify_info_t * bluetooth_gatt_client_get_characteristic_notify_info(unsigned  char *handle , int id)
 {
        GSList *l;
@@ -2246,6 +2243,7 @@ static bt_gatt_characteristic_notify_info_t * bluetooth_gatt_client_get_characte
        }
        return NULL;
 }
+#endif
 
 static bt_gatt_characteristic_notify_info_t *  bluetooth_gatt_client_create_watch_io(int fd, int id, int mtu, char * address, unsigned char *uuid)
 {
@@ -2256,15 +2254,19 @@ static bt_gatt_characteristic_notify_info_t *  bluetooth_gatt_client_create_watc
        chr_info->notify_fd = fd;
        chr_info->id = id;
        chr_info->mtu = mtu;
-       g_strlcpy(chr_info->adress, address, 18);
+       g_strlcpy(chr_info->address, address, 18);
        memcpy(chr_info->UUID, uuid, 16);
 
        channel = g_io_channel_unix_new(fd);
+
+       chr_info->io_channel = channel;
+
        g_io_channel_set_encoding(channel, NULL, NULL);
        g_io_channel_set_buffered(channel, FALSE);
-       g_io_channel_set_close_on_unref(channel, FALSE);
+       g_io_channel_set_close_on_unref(channel, TRUE);
        g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL);
-       g_io_add_watch(channel, (G_IO_IN | G_IO_ERR | G_IO_HUP),
+
+       chr_info->watch_id = g_io_add_watch(channel, (G_IO_IN | G_IO_ERR | G_IO_HUP),
                         bluetooth_gatt_client_notify_channel_watch_cb, chr_info);
 
        return chr_info;
@@ -2283,19 +2285,30 @@ BT_EXPORT_API int bluetooth_gatt_client_watch_characteristics(
        bluetooth_gatt_client_char_prop_info_t param;
        bt_gatt_characteristic_notify_info_t *chr_info;
 
-       BT_DBG("+");
-
        BT_CHECK_PARAMETER(address, return);
        BT_CHECK_PARAMETER(service_handle, return);
        BT_CHECK_PARAMETER(char_handle, return);
 
+#ifndef TIZEN_FEATURE_BT_GATT_CLIENT_FD_DISABLE
        chr_info = bluetooth_gatt_client_get_characteristic_notify_info(char_handle->uuid , char_handle->instance_id);
        if (chr_info && !is_notify) {
                BT_INFO("Already CCCD enabled. fd %d", chr_info->notify_fd);
 
-               close(chr_info->notify_fd);
+               if (chr_info->watch_id > 0)
+                       g_source_remove(chr_info->watch_id);
+
+               if (chr_info->io_channel) {
+                       g_io_channel_shutdown(chr_info->io_channel, TRUE, NULL);
+                       g_io_channel_unref(chr_info->io_channel);
+               }
+
+               gatt_characteristic_notify_list = g_slist_remove(gatt_characteristic_notify_list, chr_info);
+
+               g_free(chr_info);
+
                return result;
        }
+#endif
 
        /* ASync Function, result expected in callback from bt-service */
 
@@ -2318,41 +2331,60 @@ BT_EXPORT_API int bluetooth_gatt_client_watch_characteristics(
        g_array_append_vals(in_param3, &is_notify, sizeof(gboolean));
        g_array_append_vals(in_param4, &is_indicate, sizeof(gboolean));
 
+#ifdef TIZEN_FEATURE_BT_GATT_CLIENT_FD_DISABLE
+       result = _bt_send_request(BT_BLUEZ_SERVICE,
+                       BT_GATT_WATCH_CHARACTERISTIC,
+                       in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       GUnixFDList *out_fd_list = NULL;
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       result  = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_GATT_WATCH_CHARACTERISTIC,
-                                                       in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list);
-       BT_DBG("result: %x", result);
+       BT_INFO("Result [%d]", result);
+       return result;
+#endif
 
-       if (result != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Fail to send request");
-               return result;
-       } else if (NULL == out_fd_list) {
-               BT_ERR("out_fd_list is NULL");
+       GUnixFDList *out_fd_list = NULL;
+       char *svc_name = NULL;
+       char  str_uuid[37];
 
-       } else {
+       _bt_convert_uuid_type_to_string(str_uuid, param.svc.uuid);
+       bluetooth_get_uuid_name(str_uuid, &svc_name);
 
-               int *fd_list_array;
-               int len = 0;
-               int mtu;
-               int fd = -1;;
+       _bt_convert_uuid_type_to_string(str_uuid, param.characteristic.uuid);
 
-               if (!out_fd_list)
-                       return BLUETOOTH_ERROR_INTERNAL;
+       BT_INFO_C("### Request subscription Notify : %s [%s]", str_uuid, svc_name);
+       g_free(svc_name);
 
-               fd_list_array = g_unix_fd_list_steal_fds(out_fd_list, &len);
-               BT_INFO("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
-               fd = fd_list_array[0];
-               mtu =  g_array_index(out_param, int, 0);
+       result  = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_GATT_WATCH_CHARACTERISTIC,
+                                                       in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list);
+       if (result != BLUETOOTH_ERROR_NONE) {
+               BT_ERR("Fail to get Nofify FD. result %d", result);
+               BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+               return result;
+       }
 
-               chr_info = bluetooth_gatt_client_create_watch_io(fd, char_handle->instance_id, mtu, (char *)address, char_handle->uuid);
+       if (is_indicate == false) {
+               if (NULL == out_fd_list) {
+                       BT_ERR("out_fd_list is NULL");
+                       result = BLUETOOTH_ERROR_INTERNAL;
+               } else {
+                       int *fd_list_array;
+                       int len = 0;
+                       int mtu;
+                       int fd = -1;
+
+                       fd_list_array = g_unix_fd_list_steal_fds(out_fd_list, &len);
+                       BT_INFO("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
+                       fd = fd_list_array[0];
+                       mtu =  g_array_index(out_param, int, 0);
 
-               gatt_characteristic_notify_list = g_slist_append(gatt_characteristic_notify_list, chr_info);
+                       BT_INFO("Acquired characteristic Notify FD %d, mtu %d", fd, mtu);
+                       chr_info = bluetooth_gatt_client_create_watch_io(fd, char_handle->instance_id, mtu, (char *)address, char_handle->uuid);
 
-               g_free(fd_list_array);
-               g_object_unref(out_fd_list);
+                       gatt_characteristic_notify_list = g_slist_append(gatt_characteristic_notify_list, chr_info);
 
+                       g_free(fd_list_array);
+                       g_object_unref(out_fd_list);
+               }
        }
 
        /*result = _bt_send_request(BT_BLUEZ_SERVICE,
@@ -2361,7 +2393,6 @@ BT_EXPORT_API int bluetooth_gatt_client_watch_characteristics(
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       BT_INFO("Result [%d]", result);
        return result;
 }
 
@@ -2373,7 +2404,6 @@ BT_EXPORT_API int bluetooth_gatt_client_read_characteristic_value(
        int result = BLUETOOTH_ERROR_NONE;
        bt_user_info_t *user_info;
        bluetooth_gatt_client_char_prop_info_t param;
-       BT_DBG("+");
 
        BT_CHECK_PARAMETER(address, return);
        BT_CHECK_PARAMETER(service_handle, return);
@@ -2400,13 +2430,10 @@ BT_EXPORT_API int bluetooth_gatt_client_read_characteristic_value(
        g_array_append_vals(in_param1, &param,
                        sizeof(bluetooth_gatt_client_char_prop_info_t));
 
-
        result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_GATT_READ_CHARACTERISTIC,
                        in_param1, in_param2, in_param3, in_param4,
                        user_info->cb, user_info->user_data);
 
-
-       BT_INFO("result = [%d]", result);
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
        return result;
 }
@@ -2420,7 +2447,6 @@ BT_EXPORT_API int bluetooth_gatt_client_read_descriptor_value(
        int result = BLUETOOTH_ERROR_NONE;
        bt_user_info_t *user_info;
        bluetooth_gatt_client_desc_prop_info_t param;
-       BT_DBG("+");
 
        BT_CHECK_PARAMETER(address, return);
        BT_CHECK_PARAMETER(service_handle, return);
@@ -2450,12 +2476,10 @@ BT_EXPORT_API int bluetooth_gatt_client_read_descriptor_value(
        g_array_append_vals(in_param1, &param,
                        sizeof(bluetooth_gatt_client_desc_prop_info_t));
 
-
        result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_GATT_READ_DESCRIPTOR_VALUE,
                        in_param1, in_param2, in_param3, in_param4,
                        user_info->cb, user_info->user_data);
 
-       BT_INFO("result = [%d]", result);
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
        return result;
 }
@@ -2465,15 +2489,16 @@ static bt_gatt_characteristic_write_info_t *  bluetooth_gatt_client_get_characte
 {
        GSList *l;
        char  str[37];
-       _bt_convert_uuid_type_to_string(str, handle);
-       BT_INFO("request found UUID [%s], sid [ %d]", str, id);
+
        for (l = gatt_characteristic_write_list; l != NULL; l = l->next) {
                bt_gatt_characteristic_write_info_t *info = l->data;
-               _bt_convert_uuid_type_to_string(str, info->UUID);
-               BT_INFO("UUID [%s], sid [ %d]" , str, info->id);
+
                if (memcmp(info->UUID, handle, 16) ==  0 &&  info->id == id)
                        return info;
        }
+
+       _bt_convert_uuid_type_to_string(str, handle);
+       BT_ERR("Unable to get characteristic fd. [%s] id [ %d]", str, id);
        return NULL;
 }
 
@@ -2503,17 +2528,16 @@ static int  bluetooth_gatt_client_write_characteristics_value_to_fd(
                         int fd, const guint8 *value, int length, int mtu,
                        gpointer user_data)
 {
-               int written;
-               int att_result = BLUETOOTH_ERROR_NONE;
-               BT_CHECK_PARAMETER(value, return);
-               written = write(fd, value, length);
-               if (written != length) {
-                       att_result = BLUETOOTH_ERROR_INTERNAL;
-                       BT_INFO("write data failed  %d is ", written);
-               } else
-                       BT_INFO("write data %s is sucess ", value);
+       int written;
+       int att_result = BLUETOOTH_ERROR_NONE;
+       BT_CHECK_PARAMETER(value, return);
+       written = write(fd, value, length);
+       if (written != length) {
+               att_result = BLUETOOTH_ERROR_INTERNAL;
+               BT_ERR("write data failed.  ret : %d ", written);
+       }
 
-               return att_result;
+       return att_result;
 }
 
 static void  bluetooth_gatt_client_create_write_io_channel(int fd, unsigned char * uuid, int id, int mtu)
@@ -2549,7 +2573,6 @@ BT_EXPORT_API int bluetooth_gatt_client_write_characteristic_value_by_type(
        int result = BLUETOOTH_ERROR_NONE;
        bt_user_info_t *user_info;
        bluetooth_gatt_client_char_prop_info_t param;
-       BT_DBG("+");
 
        BT_CHECK_PARAMETER(address, return);
        BT_CHECK_PARAMETER(service_handle, return);
@@ -2577,6 +2600,10 @@ BT_EXPORT_API int bluetooth_gatt_client_write_characteristic_value_by_type(
        g_array_append_vals(in_param2, data, sizeof(bluetooth_gatt_att_data_t));
        g_array_append_vals(in_param3, &write_type, sizeof(bluetooth_gatt_write_type_e));
 
+#ifdef TIZEN_FEATURE_BT_GATT_CLIENT_FD_DISABLE
+       goto done;
+#endif
+
        if (write_type == BLUETOOTH_GATT_TYPE_WRITE_NO_RESPONSE) {
                int fd = -1;
                int mtu = 0;
@@ -2594,12 +2621,11 @@ BT_EXPORT_API int bluetooth_gatt_client_write_characteristic_value_by_type(
 
                        result  = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_GATT_ACQUIRE_WRITE,
                                        in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list);
-                       BT_DBG("result: %x", result);
 
                        mtu =  g_array_index(out_param, int, 0);
 
                        if (result != BLUETOOTH_ERROR_NONE) {
-                                       BT_ERR("Fail to send request");
+                                       BT_ERR("Fail to get Write FD. result %d", result);
                                        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
                                        return result;
                        } else if (NULL == out_fd_list) {
@@ -2621,7 +2647,7 @@ BT_EXPORT_API int bluetooth_gatt_client_write_characteristic_value_by_type(
                                g_free(fd_list_array);
                                g_object_unref(out_fd_list);
                        }
-                       BT_INFO("Acquired characteristic fd %d --------------- mtu %d,    ", fd, mtu);
+                       BT_INFO("Acquired characteristic Write FD %d, mtu %d", fd, mtu);
 
                        if (fd > -1) {
 
@@ -2630,12 +2656,11 @@ BT_EXPORT_API int bluetooth_gatt_client_write_characteristic_value_by_type(
                                result =  bluetooth_gatt_client_write_characteristics_value_to_fd(fd, data->data, data->length, mtu, NULL);
 
                        } else {
-                               BT_INFO(" characteristic info  FD is invalid\n");
+                               BT_ERR("characteristic info  FD is invalid");
                                goto done;
                        }
 
                } else {
-                       BT_INFO("Acquired characteristic fd %d --------------- mtu %d,    ", fd, mtu);
                        result =  bluetooth_gatt_client_write_characteristics_value_to_fd(fd, data->data, data->length, mtu, NULL);
                }
 
@@ -2663,7 +2688,6 @@ BT_EXPORT_API int bluetooth_gatt_client_write_descriptor_value(
        int result = BLUETOOTH_ERROR_NONE;
        bt_user_info_t *user_info;
        bluetooth_gatt_client_desc_prop_info_t param;
-       BT_DBG("+");
 
        BT_CHECK_PARAMETER(address, return);
        BT_CHECK_PARAMETER(service_handle, return);
@@ -2795,7 +2819,7 @@ BT_EXPORT_API int bluetooth_gatt_client_deinit(
                        in_param1, in_param2, in_param3, in_param4, &out_param);
 
        if (result != BLUETOOTH_ERROR_NONE)
-               BT_INFO("GATT Client Unregistration failed result [%d]", result);
+               BT_ERR("GATT Client Unregistration failed result [%d]", result);
        else
                BT_INFO("GATT Client Unregistration successful");