From 2aae2615f455d17847a608d181d3d06f45af25f9 Mon Sep 17 00:00:00 2001 From: Deokhyun Kim Date: Tue, 7 Nov 2017 18:49:21 +0900 Subject: [PATCH] Proceed HID connection procedure when it's already connected. - Application can use fd of HID channel even though it's already connected. Change-Id: Ic44f9730df35984b1c07eff244510fe9749782b0 Signed-off-by: Deokhyun Kim --- bt-api/bt-hid-device.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/bt-api/bt-hid-device.c b/bt-api/bt-hid-device.c index 21a7da0..93cd4fd 100644 --- a/bt-api/bt-hid-device.c +++ b/bt-api/bt-hid-device.c @@ -164,11 +164,6 @@ static void __hid_connect_response_cb(GDBusProxy *proxy, GAsyncResult *res, g_dbus_error_strip_remote_error(error); BT_ERR("Error : %s \n", error->message); - if (g_strcmp0(error->message, "In Progress") == 0) - result = BLUETOOTH_ERROR_DEVICE_BUSY; - else - result = BLUETOOTH_ERROR_INTERNAL; - info.ctrl_fd = -1; info.intr_fd = -1; @@ -177,10 +172,27 @@ static void __hid_connect_response_cb(GDBusProxy *proxy, GAsyncResult *res, path = g_dbus_proxy_get_object_path(proxy); _bt_convert_device_path_to_address(path, info.address); - __hid_connected_cb(&info, result); + if (g_strcmp0(error->message, "Already Connected") == 0) { + bluetooth_device_address_t dev_address = { {0} }; + int ctrl = -1, intr = -1; - g_free(info.address); + _bt_convert_addr_string_to_type(dev_address.addr, + info.address); + _bt_hid_device_get_fd(info.address, &ctrl, &intr); + if (ctrl != -1 && intr != -1) + _bt_hid_new_connection(&dev_address, ctrl, intr); + else + BT_ERR("fd is invalid.(ctrl=%d, intr=%d)", ctrl, intr); + } else { + if (g_strcmp0(error->message, "In Progress") == 0) + result = BLUETOOTH_ERROR_IN_PROGRESS; + else + result = BLUETOOTH_ERROR_INTERNAL; + + __hid_connected_cb(&info, result); + } + g_free(info.address); g_error_free(error); } else { g_variant_unref(ret); -- 2.7.4