Skip to content

bluetooth: improve the controller address resolution enablement #90705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion subsys/bluetooth/host/id.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ void bt_id_add(struct bt_keys *keys)

struct bt_conn *conn;
int err;
bool enable_controller_res = true;

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

Expand Down Expand Up @@ -1067,13 +1068,21 @@ void bt_id_add(struct bt_keys *keys)
err = addr_res_enable(BT_HCI_ADDR_RES_DISABLE);
if (err) {
LOG_WRN("Failed to disable address resolution");
/* If it fails to disable, it should already be enabled,
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment could be clearer and more concise. For example: /* On disable failure, resolution remains enabled—no need to re-enable. */

Copilot uses AI. Check for mistakes.

* don't need to enable again.
*/
enable_controller_res = false;
goto done;
}
}

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

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

done:
addr_res_enable(BT_HCI_ADDR_RES_ENABLE);
if (enable_controller_res) {
addr_res_enable(BT_HCI_ADDR_RES_ENABLE);
}

#if defined(CONFIG_BT_OBSERVER)
if (scan_enabled) {
Expand Down