From 6ff94ec5596118113532636b27ca3b014718f255 Mon Sep 17 00:00:00 2001 From: "injun.yang" Date: Mon, 1 Apr 2019 09:27:05 +0900 Subject: [PATCH] Fix the malfunction of bonding [Model] All [BinType] AP [Customer] OPEN [Issue#] N/A [Request] Internal [Occurrence Version] N/A [Problem] When app request bt_device_create_bond(), host initiate BT pairing instead of BLE pairing [Cause & Measure] Till now, bluez didn't check the link status. Even though BLE connected, bluez initiate BT pairing. To prevent the malfunction, bluez will check the link type also. [Checking Method] Initiate pairing [Team] IoT Hub [Developer] Injun Yang [Solution company] Samsung [Change Type] Specification change Change-Id: I5dbcc0a827ccc566b15490d3f1edc31acbac949c Signed-off-by: injun.yang Signed-off-by: DoHyun Pyun --- src/device.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/device.c b/src/device.c index 41a6dae..7bca3e6 100644 --- a/src/device.c +++ b/src/device.c @@ -3222,6 +3222,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg, #ifdef TIZEN_FEATURE_BLUEZ_MODIFY uint8_t conn_type; bool connect_le = FALSE; + uint8_t link_type = DEV_CONNECTED_NONE; #endif int err; @@ -3240,17 +3241,29 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg, #ifdef TIZEN_FEATURE_BLUEZ_MODIFY if (conn_type == DEV_CONN_DEFAULT) { - if (device_is_bonded(device, DEV_CONN_BREDR)) - return btd_error_already_exists(msg); - else if (device_is_bonded(device, DEV_CONN_LE)) - return btd_error_already_exists(msg); + link_type = device_get_connected_state(device); - if (device->bredr) - conn_type = DEV_CONN_BREDR; - else if (device->le) - conn_type = DEV_CONN_LE; - else + if (link_type == DEV_CONNECTED_BREDR) { + if (device_is_bonded(device, DEV_CONN_BREDR)) + return btd_error_already_exists(msg); conn_type = DEV_CONN_BREDR; + } else if (link_type == DEV_CONNECTED_LE) { + if (device_is_bonded(device, DEV_CONN_LE)) + return btd_error_already_exists(msg); + conn_type = DEV_CONN_LE; + } else { + if (device_is_bonded(device, DEV_CONN_BREDR)) + return btd_error_already_exists(msg); + else if (device_is_bonded(device, DEV_CONN_LE)) + return btd_error_already_exists(msg); + + if (device->bredr) + conn_type = DEV_CONN_BREDR; + else if (device->le) + conn_type = DEV_CONN_LE; + else + conn_type = DEV_CONN_BREDR; + } } else { if (device_is_bonded(device, conn_type)) return btd_error_already_exists(msg); @@ -3271,6 +3284,8 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg, #endif #ifdef TIZEN_FEATURE_BLUEZ_MODIFY + DBG("conn_type %d, link_type %d, bdaddr_type %d, device->bredr %d", + conn_type, link_type, bdaddr_type, device->bredr); if (conn_type == DEV_CONN_LE && (device_is_bredrle(device) || bdaddr_type != BDADDR_BREDR)) { DBG("LE Connect request"); -- 2.7.4