Skip to content

Commit 285a073

Browse files
Jamie McCraenashif
authored andcommitted
Bluetooth: host: Fix non-extended adverts not being limited to 31 bytes
Fixes an issue whereby the application is configured for extended advertising mode but advertises in legacy mode with a large device name which should be limited to 31 bytes Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
1 parent 439c5ce commit 285a073

File tree

1 file changed

+10
-2
lines changed
  • subsys/bluetooth/host

1 file changed

+10
-2
lines changed

subsys/bluetooth/host/adv.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ static int hci_set_adv_ext_complete(struct bt_le_ext_adv *adv, uint16_t hci_op,
413413
struct bt_hci_cp_le_set_ext_adv_data *set_data;
414414
struct net_buf *buf;
415415
int err;
416+
uint8_t max_data_size;
416417

417418
buf = bt_hci_cmd_create(hci_op, sizeof(*set_data));
418419
if (!buf) {
@@ -422,8 +423,15 @@ static int hci_set_adv_ext_complete(struct bt_le_ext_adv *adv, uint16_t hci_op,
422423
set_data = net_buf_add(buf, sizeof(*set_data));
423424
(void)memset(set_data, 0, sizeof(*set_data));
424425

425-
err = set_data_add_complete(set_data->data, BT_HCI_LE_EXT_ADV_FRAG_MAX_LEN,
426-
ad, ad_len, &set_data->len);
426+
if (atomic_test_bit(adv->flags, BT_ADV_EXT_ADV)) {
427+
max_data_size = BT_HCI_LE_EXT_ADV_FRAG_MAX_LEN;
428+
} else {
429+
max_data_size = BT_GAP_ADV_MAX_ADV_DATA_LEN;
430+
}
431+
432+
err = set_data_add_complete(set_data->data, max_data_size, ad, ad_len,
433+
&set_data->len);
434+
427435
if (err) {
428436
net_buf_unref(buf);
429437
return err;

0 commit comments

Comments
 (0)