Skip to content

Commit f390fcb

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'bugfix/fix_hid_reconnect_issue' into 'master'
feat(bt/bluedroid): Add Kconfig option to keep device bonding info when HID unplugging See merge request espressif/esp-idf!36975
2 parents 81e8b75 + 540b013 commit f390fcb

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

components/bt/host/bluedroid/Kconfig.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ config BT_HID_DEVICE_ENABLED
192192
help
193193
This enables the BT HID Device
194194

195+
config BT_HID_REMOVE_DEVICE_BONDING_ENABLED
196+
bool "Remove Device Bonding Information when HID Virtual Cable Unplugging"
197+
depends on BT_HID_ENABLED
198+
default y
199+
help
200+
This enables the BT HID to remove device bonding information when virtual cable unplugging,
201+
removing device bonding information is optional in HID 1.0 but mandatory in HID 1.1
202+
195203
menuconfig BT_PBAC_ENABLED
196204
bool "PBAP Client"
197205
depends on BT_CLASSIC_ENABLED

components/bt/host/bluedroid/btc/profile/std/hid/btc_hd.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -903,14 +903,10 @@ void btc_hd_cb_handler(btc_msg_t *msg)
903903
btc_hd_cb_to_app(ESP_HIDD_INTR_DATA_EVT, &param);
904904
break;
905905
case BTA_HD_VC_UNPLUG_EVT: {
906-
bt_bdaddr_t *bd_addr = (bt_bdaddr_t *)&p_data->conn.bda;
907-
if (bta_dm_check_if_only_hd_connected(p_data->conn.bda)) {
908-
BTC_TRACE_DEBUG("%s: Removing bonding as only HID profile connected", __func__);
909-
BTA_DmRemoveDevice((uint8_t *)&p_data->conn.bda, BT_TRANSPORT_BR_EDR);
910-
} else {
911-
BTC_TRACE_DEBUG("%s: Only removing HID data as some other profiles connected", __func__);
912-
btc_hd_remove_device(*bd_addr);
913-
}
906+
#if BTC_HID_REMOVE_DEVICE_BONDING
907+
BTC_TRACE_DEBUG("%s: Removing bonding information", __func__);
908+
BTA_DmRemoveDevice((uint8_t *)&p_data->conn.bda, BT_TRANSPORT_BR_EDR);
909+
#endif
914910

915911
if (btc_hd_cb.status == BTC_HD_DISCONNECTING || btc_hd_cb.status == BTC_HD_CONNECTING ||
916912
btc_hd_cb.status == BTC_HD_CONNECTED) {

components/bt/host/bluedroid/btc/profile/std/hid/btc_hh.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,10 @@ void btc_hh_cb_handler(btc_msg_t *msg)
13721372
*/
13731373
if (p_dev->local_vup) {
13741374
p_dev->local_vup = false;
1375+
#if BTC_HID_REMOVE_DEVICE_BONDING
13751376
BTA_DmRemoveDevice(p_dev->bd_addr, BT_TRANSPORT_BR_EDR);
1377+
#endif
1378+
btc_hh_remove_device(p_dev->bd_addr);
13761379
}
13771380

13781381
btc_hh_cb.status = (BTC_HH_STATUS)BTC_HH_DEV_DISCONNECTED;
@@ -1406,8 +1409,9 @@ void btc_hh_cb_handler(btc_msg_t *msg)
14061409
// [boblane]
14071410
if (p_dev->local_vup) {
14081411
p_dev->local_vup = false;
1412+
#if BTC_HID_REMOVE_DEVICE_BONDING
14091413
BTA_DmRemoveDevice(p_dev->bd_addr, BT_TRANSPORT_BR_EDR);
1410-
} else {
1414+
#endif
14111415
btc_hh_remove_device(p_dev->bd_addr);
14121416
}
14131417
param.unplug.status = p_data->dev_status.status;

components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@
108108
#define UC_BT_HID_DEVICE_ENABLED FALSE
109109
#endif
110110

111+
//HID remove device bonding option
112+
#ifdef CONFIG_BT_HID_REMOVE_DEVICE_BONDING_ENABLED
113+
#define UC_BT_HID_REMOVE_DEVICE_BONDING_ENABLED CONFIG_BT_HID_REMOVE_DEVICE_BONDING_ENABLED
114+
#else
115+
#define UC_BT_HID_REMOVE_DEVICE_BONDING_ENABLED FALSE
116+
#endif
117+
111118
//BQB(BT)
112119
#ifdef CONFIG_BT_CLASSIC_BQB_ENABLED
113120
#define UC_BT_CLASSIC_BQB_ENABLED CONFIG_BT_CLASSIC_BQB_ENABLED

components/bt/host/bluedroid/common/include/common/bt_target.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@
176176
#define BTC_HD_INCLUDED TRUE
177177
#endif /* UC_BT_HID_DEVICE_ENABLED */
178178

179+
#if UC_BT_HID_REMOVE_DEVICE_BONDING_ENABLED
180+
#define BTC_HID_REMOVE_DEVICE_BONDING TRUE
181+
#endif
182+
179183
#if UC_BT_GOEPC_ENABLED
180184
#ifndef RFCOMM_INCLUDED
181185
#define RFCOMM_INCLUDED TRUE
@@ -481,6 +485,10 @@
481485
#define BTC_HD_INCLUDED FALSE
482486
#endif
483487

488+
#ifndef BTC_HID_REMOVE_DEVICE_BONDING
489+
#define BTC_HID_REMOVE_DEVICE_BONDING FALSE
490+
#endif
491+
484492
#ifndef SBC_DEC_INCLUDED
485493
#define SBC_DEC_INCLUDED FALSE
486494
#endif

0 commit comments

Comments
 (0)