Skip to content

Commit 2d4e05a

Browse files
MarkWangChinesekartben
authored andcommitted
bluetooth: improve the controller address resolution enablement
If the controller resolving list is cleared by HCI_LE_Clear_Resolving_List, don't need to enable the controller address resolution. Signed-off-by: Mark Wang <[email protected]>
1 parent c14ee16 commit 2d4e05a

File tree

1 file changed

+12
-1
lines changed
  • subsys/bluetooth/host

1 file changed

+12
-1
lines changed

subsys/bluetooth/host/id.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ void bt_id_add(struct bt_keys *keys)
10111011

10121012
struct bt_conn *conn;
10131013
int err;
1014+
bool enable_controller_res = true;
10141015

10151016
LOG_DBG("addr %s", bt_addr_le_str(&keys->addr));
10161017

@@ -1067,13 +1068,21 @@ void bt_id_add(struct bt_keys *keys)
10671068
err = addr_res_enable(BT_HCI_ADDR_RES_DISABLE);
10681069
if (err) {
10691070
LOG_WRN("Failed to disable address resolution");
1071+
/* If it fails to disable, it should already be enabled,
1072+
* don't need to enable again.
1073+
*/
1074+
enable_controller_res = false;
10701075
goto done;
10711076
}
10721077
}
10731078

10741079
if (bt_dev.le.rl_entries == bt_dev.le.rl_size) {
10751080
LOG_WRN("Resolving list size exceeded. Switching to host.");
10761081

1082+
/* Since the controller resolving list is cleared,
1083+
* don't need to enable the address resolution.
1084+
*/
1085+
enable_controller_res = false;
10771086
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_CLEAR_RL, NULL, NULL);
10781087
if (err) {
10791088
LOG_ERR("Failed to clear resolution list");
@@ -1114,7 +1123,9 @@ void bt_id_add(struct bt_keys *keys)
11141123
}
11151124

11161125
done:
1117-
addr_res_enable(BT_HCI_ADDR_RES_ENABLE);
1126+
if (enable_controller_res) {
1127+
addr_res_enable(BT_HCI_ADDR_RES_ENABLE);
1128+
}
11181129

11191130
#if defined(CONFIG_BT_OBSERVER)
11201131
if (scan_enabled) {

0 commit comments

Comments
 (0)