Skip to content

Commit 2ce80f1

Browse files
ChangNicekartben
authored andcommitted
samples: Bluetooth: make bap_broadcast_source work with google pixel
Broadcast name used for scaning device that displays information on the available broadcast sources. Signed-off-by: Chang An <[email protected]>
1 parent db8f991 commit 2ce80f1

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

samples/bluetooth/bap_broadcast_source/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ config BROADCAST_ID
6464
help
6565
This is the 3-octet broadcast ID advertised if static broadcast IDs are enabled.
6666

67+
config BROADCAST_NAME
68+
string "Bluetooth broadcast name"
69+
default BT_DEVICE_NAME
70+
help
71+
Bluetooth broadcast name. Can be used for scanning device that displays information on the
72+
available broadcast sources. Name length range is 4 to 32.
73+
6774
# Source common USB sample options used to initialize new experimental USB device stack.
6875
# The scope of these options is limited to USB samples in project tree,
6976
# you cannot use them in your own application.

samples/bluetooth/bap_broadcast_source/src/main.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
#include <zephyr/usb/usbd.h>
3434

3535
BUILD_ASSERT(strlen(CONFIG_BROADCAST_CODE) <= BT_ISO_BROADCAST_CODE_SIZE, "Invalid broadcast code");
36+
BUILD_ASSERT(IN_RANGE(strlen(CONFIG_BROADCAST_NAME), BT_AUDIO_BROADCAST_NAME_LEN_MIN,
37+
BT_AUDIO_BROADCAST_NAME_LEN_MAX),
38+
"Invalid broadcast name");
3639

3740
/* When BROADCAST_ENQUEUE_COUNT > 1 we can enqueue enough buffers to ensure that
3841
* the controller is never idle
@@ -559,7 +562,7 @@ int main(void)
559562
/* Broadcast Audio Streaming Endpoint advertising data */
560563
NET_BUF_SIMPLE_DEFINE(ad_buf, BT_UUID_SIZE_16 + BT_AUDIO_BROADCAST_ID_SIZE);
561564
NET_BUF_SIMPLE_DEFINE(base_buf, 128);
562-
struct bt_data ext_ad[2];
565+
struct bt_data ext_ad[3];
563566
struct bt_data per_ad;
564567
uint32_t broadcast_id;
565568

@@ -602,7 +605,11 @@ int main(void)
602605
ext_ad[0].data = ad_buf.data;
603606
ext_ad[1] = (struct bt_data)BT_DATA(BT_DATA_NAME_COMPLETE, CONFIG_BT_DEVICE_NAME,
604607
sizeof(CONFIG_BT_DEVICE_NAME) - 1);
605-
err = bt_le_ext_adv_set_data(adv, ext_ad, 2, NULL, 0);
608+
/* Broadcast name used for scanning device that displays information on the */
609+
/* available broadcast sources. */
610+
ext_ad[2] = (struct bt_data)BT_DATA(BT_DATA_BROADCAST_NAME, CONFIG_BROADCAST_NAME,
611+
sizeof(CONFIG_BROADCAST_NAME) - 1);
612+
err = bt_le_ext_adv_set_data(adv, ext_ad, 3, NULL, 0);
606613
if (err != 0) {
607614
printk("Failed to set extended advertising data: %d\n", err);
608615
return 0;

0 commit comments

Comments
 (0)