Skip to content
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

Optimize Set name and EIR #11

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
10 changes: 4 additions & 6 deletions subsys/bluetooth/host/classic/br.c
Original file line number Diff line number Diff line change
Expand Up @@ -1254,18 +1254,14 @@ int bt_br_write_local_name(const char *name)
struct net_buf *buf;
struct bt_hci_write_local_name *name_cp;

if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
return -EAGAIN;
}

buf = bt_hci_cmd_create(BT_HCI_OP_WRITE_LOCAL_NAME, sizeof(*name_cp));
if (!buf) {
return -ENOBUFS;
}

name_cp = net_buf_add(buf, sizeof(*name_cp));
memset(name_cp, 0, sizeof(*name_cp));
memcpy((char *)name_cp->local_name, name, sizeof(name_cp->local_name));
memcpy((char *)name_cp->local_name, name, strlen(name));

return bt_hci_cmd_send_sync(BT_HCI_OP_WRITE_LOCAL_NAME, buf, NULL);
}
Expand Down Expand Up @@ -1304,6 +1300,7 @@ int bt_br_write_ext_inq_response(uint8_t fec_required)
struct bt_hci_cp_write_extended_inquiry_response *cp;
size_t name_len, eir_len = 240;
uint8_t type;
void *p;

if (!BT_FEAT_EIR(bt_dev.features)) {
return -ENOTSUP;
Expand Down Expand Up @@ -1338,7 +1335,8 @@ int bt_br_write_ext_inq_response(uint8_t fec_required)
/* TODO: Fill in EIR data (Manufacturer Specific Data) */
/* TODO: Fill in EIR data (TX Power) */

net_buf_add(buf, eir_len);
p = net_buf_add(buf, eir_len);
memset(p, 0, eir_len);

return bt_hci_cmd_send_sync(BT_HCI_OP_WRITE_EXTENDED_INQUIRY_RESPONSE, buf, NULL);
}
Expand Down
3 changes: 2 additions & 1 deletion subsys/bluetooth/host/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4557,7 +4557,8 @@ int bt_set_name(const char *name)
}
}

if (IS_ENABLED(CONFIG_BT_CLASSIC)) {
if (IS_ENABLED(CONFIG_BT_CLASSIC) &&
atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
err = bt_br_write_local_name(name);
if (err) {
LOG_WRN("Unable to set BR/EDR name");
Expand Down
Loading