Bluetooth: audio: Add possibility to use static broadcast id
Removed the generation of broadcast id inside the stack. It is now up to the application to generate this by itself. The CAP sample has been modified to allow either a static broadcast, or a random one. All of this is handled in the application. Signed-off-by: Fredrik Danebjer <frdn@demant.com>
This commit is contained in:
parent
7e72d46e2e
commit
f970b066d2
25 changed files with 112 additions and 232 deletions
|
@ -388,6 +388,13 @@ Bluetooth Audio
|
|||
do a search-and-replace for ``bt_audio_codec_qos`` to ``bt_bap_qos_cfg`` and
|
||||
``BT_AUDIO_CODEC_QOS`` to ``BT_BAP_QOS_CFG``. (:github:`76633`)
|
||||
|
||||
* The generation of broadcast ID inside of zephyr stack has been removed, it is now up the
|
||||
application to generate a broadcast ID. This means that the application can now fully decide
|
||||
whether to use a static or random broadcast ID. Reusing and statically defining a broadcast ID was
|
||||
added to the Basic Audio Profile in version 1.0.2, which is the basis for this change. All
|
||||
instances of :c:func:`bt_cap_initiator_broadcast_get_id` and
|
||||
:c:func:`bt_bap_broadcast_source_get_id` has been removed(:github:`80228`)
|
||||
|
||||
Bluetooth Classic
|
||||
=================
|
||||
|
||||
|
|
|
@ -2184,22 +2184,6 @@ int bt_bap_broadcast_source_stop(struct bt_bap_broadcast_source *source);
|
|||
*/
|
||||
int bt_bap_broadcast_source_delete(struct bt_bap_broadcast_source *source);
|
||||
|
||||
/**
|
||||
* @brief Get the broadcast ID of a broadcast source
|
||||
*
|
||||
* This will return the 3-octet broadcast ID that should be advertised in the
|
||||
* extended advertising data with @ref BT_UUID_BROADCAST_AUDIO_VAL as @ref BT_DATA_SVC_DATA16.
|
||||
*
|
||||
* See table 3.14 in the Basic Audio Profile v1.0.1 for the structure.
|
||||
*
|
||||
* @param[in] source Pointer to the broadcast source.
|
||||
* @param[out] broadcast_id Pointer to the 3-octet broadcast ID.
|
||||
*
|
||||
* @return Zero on success or (negative) error code otherwise.
|
||||
*/
|
||||
int bt_bap_broadcast_source_get_id(struct bt_bap_broadcast_source *source,
|
||||
uint32_t *const broadcast_id);
|
||||
|
||||
/**
|
||||
* @brief Get the Broadcast Audio Stream Endpoint of a broadcast source
|
||||
*
|
||||
|
|
|
@ -603,23 +603,6 @@ int bt_cap_initiator_broadcast_audio_stop(struct bt_cap_broadcast_source *broadc
|
|||
*/
|
||||
int bt_cap_initiator_broadcast_audio_delete(struct bt_cap_broadcast_source *broadcast_source);
|
||||
|
||||
/**
|
||||
* @brief Get the broadcast ID of a Common Audio Profile broadcast source
|
||||
*
|
||||
* This will return the 3-octet broadcast ID that should be advertised in the
|
||||
* extended advertising data with @ref BT_UUID_BROADCAST_AUDIO_VAL as
|
||||
* @ref BT_DATA_SVC_DATA16.
|
||||
*
|
||||
* See table 3.14 in the Basic Audio Profile v1.0.1 for the structure.
|
||||
*
|
||||
* @param[in] broadcast_source Pointer to the broadcast source.
|
||||
* @param[out] broadcast_id Pointer to the 3-octet broadcast ID.
|
||||
*
|
||||
* @return int 0 if on success, errno on error.
|
||||
*/
|
||||
int bt_cap_initiator_broadcast_get_id(const struct bt_cap_broadcast_source *broadcast_source,
|
||||
uint32_t *const broadcast_id);
|
||||
|
||||
/**
|
||||
* @brief Get the Broadcast Audio Stream Endpoint of a Common Audio Profile broadcast source
|
||||
*
|
||||
|
|
|
@ -45,4 +45,18 @@ config BROADCAST_CODE
|
|||
Setting a non-empty string for this option will encrypt the broadcast using this
|
||||
string as the broadcast code. The length of the string shall be between 1 and 16 octets.
|
||||
|
||||
config STATIC_BROADCAST_ID
|
||||
bool "Use static broadcast ID"
|
||||
default y
|
||||
help
|
||||
Enabling this option will make the application use static broadcast ID, as opposed to a
|
||||
randomly generated one.
|
||||
|
||||
config BROADCAST_ID
|
||||
hex "The static broadcast ID to use"
|
||||
range 0x000000 0xFFFFFF
|
||||
depends on STATIC_BROADCAST_ID
|
||||
help
|
||||
This is the 3-octet broadcast ID advertised if static broadcast IDs are enabled.
|
||||
|
||||
source "Kconfig.zephyr"
|
||||
|
|
|
@ -14,3 +14,4 @@ CONFIG_BT_ISO_TX_BUF_COUNT=6
|
|||
CONFIG_BT_ISO_TX_MTU=60
|
||||
|
||||
CONFIG_BT_DEVICE_NAME="Broadcast Audio Source"
|
||||
CONFIG_BROADCAST_ID=0x123456
|
||||
|
|
|
@ -518,11 +518,15 @@ int main(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
err = bt_bap_broadcast_source_get_id(broadcast_source, &broadcast_id);
|
||||
if (err != 0) {
|
||||
printk("Unable to get broadcast ID: %d\n", err);
|
||||
return 0;
|
||||
#if defined(CONFIG_STATIC_BROADCAST_ID)
|
||||
broadcast_id = CONFIG_BROADCAST_ID;
|
||||
#else
|
||||
err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
if (err) {
|
||||
printk("Unable to generate broadcast ID: %d\n", err);
|
||||
return err;
|
||||
}
|
||||
#endif /* CONFIG_STATIC_BROADCAST_ID */
|
||||
|
||||
/* Setup extended advertising data */
|
||||
net_buf_simple_add_le16(&ad_buf, BT_UUID_BROADCAST_AUDIO_VAL);
|
||||
|
|
|
@ -26,4 +26,18 @@ config SAMPLE_BROADCAST
|
|||
help
|
||||
If set to true, the sample will start advertising syncable audio streams
|
||||
|
||||
config STATIC_BROADCAST_ID
|
||||
bool "Use static broadcast ID"
|
||||
default y
|
||||
help
|
||||
Enabling this option will make the application use static broadcast ID, as opposed to a
|
||||
randomly generated one.
|
||||
|
||||
config BROADCAST_ID
|
||||
hex "The static broadcast ID to use"
|
||||
range 0x000000 0xFFFFFF
|
||||
depends on STATIC_BROADCAST_ID
|
||||
help
|
||||
This is the 3-octet broadcast ID advertised if static broadcast IDs are enabled.
|
||||
|
||||
source "Kconfig.zephyr"
|
||||
|
|
|
@ -23,3 +23,4 @@ CONFIG_BT_BAP_BROADCAST_SOURCE=y
|
|||
# Broadcast sources values if enabled by CONFIG_SAMPLE_BROADCAST
|
||||
CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT=2
|
||||
CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT=1
|
||||
CONFIG_BROADCAST_ID=0x123456
|
||||
|
|
|
@ -133,11 +133,15 @@ static int setup_extended_adv_data(struct bt_cap_broadcast_source *source,
|
|||
uint32_t broadcast_id;
|
||||
int err;
|
||||
|
||||
err = bt_cap_initiator_broadcast_get_id(source, &broadcast_id);
|
||||
if (err != 0) {
|
||||
LOG_ERR("Unable to get broadcast ID: %d", err);
|
||||
#if defined(CONFIG_STATIC_BROADCAST_ID)
|
||||
broadcast_id = CONFIG_BROADCAST_ID;
|
||||
#else
|
||||
err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
if (err) {
|
||||
printk("Unable to generate broadcast ID: %d\n", err);
|
||||
return err;
|
||||
}
|
||||
#endif /* CONFIG_STATIC_BROADCAST_ID */
|
||||
|
||||
/* Setup extended advertising data */
|
||||
net_buf_simple_add_le16(&ad_buf, BT_UUID_BROADCAST_AUDIO_VAL);
|
||||
|
|
20
samples/bluetooth/pbp_public_broadcast_source/Kconfig
Normal file
20
samples/bluetooth/pbp_public_broadcast_source/Kconfig
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Copyright (c) 2024 Demant A/S
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
mainmenu "Bluetooth: PBP Broadcast Audio Source"
|
||||
|
||||
config STATIC_BROADCAST_ID
|
||||
bool "Use static broadcast ID"
|
||||
default y
|
||||
help
|
||||
Enabling this option will make the application use static broadcast ID, as opposed to a
|
||||
randomly generated one.
|
||||
|
||||
config BROADCAST_ID
|
||||
hex "The static broadcast ID to use"
|
||||
range 0x000000 0xFFFFFF
|
||||
depends on STATIC_BROADCAST_ID
|
||||
help
|
||||
This is the 3-octet broadcast ID advertised if static broadcast IDs are enabled.
|
||||
|
||||
source "Kconfig.zephyr"
|
|
@ -24,3 +24,4 @@ CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT=1
|
|||
|
||||
CONFIG_BT_EXT_ADV=y
|
||||
CONFIG_BT_DEVICE_NAME="PBS"
|
||||
CONFIG_STATIC_BROADCAST_ID=n
|
||||
|
|
|
@ -189,12 +189,15 @@ static int setup_extended_adv_data(struct bt_cap_broadcast_source *source,
|
|||
uint32_t broadcast_id;
|
||||
int err;
|
||||
|
||||
err = bt_cap_initiator_broadcast_get_id(source, &broadcast_id);
|
||||
if (err != 0) {
|
||||
printk("Unable to get broadcast ID: %d\n", err);
|
||||
|
||||
#if defined(CONFIG_STATIC_BROADCAST_ID)
|
||||
broadcast_id = CONFIG_BROADCAST_ID;
|
||||
#else
|
||||
err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
if (err) {
|
||||
printk("Unable to generate broadcast ID: %d\n", err);
|
||||
return err;
|
||||
}
|
||||
#endif /* CONFIG_STATIC_BROADCAST_ID */
|
||||
|
||||
/* Setup extended advertising data */
|
||||
ext_ad[0].type = BT_DATA_GAP_APPEARANCE;
|
||||
|
|
|
@ -172,9 +172,9 @@ static int setup_extended_adv_data(struct bt_cap_broadcast_source *source,
|
|||
uint32_t broadcast_id;
|
||||
int err;
|
||||
|
||||
err = bt_cap_initiator_broadcast_get_id(source, &broadcast_id);
|
||||
if (err != 0) {
|
||||
printk("Unable to get broadcast ID: %d\n", err);
|
||||
err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
if (err) {
|
||||
printk("Unable to generate broadcast ID: %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
@ -450,36 +450,6 @@ static bool encode_base(struct bt_bap_broadcast_source *source, struct net_buf_s
|
|||
return true;
|
||||
}
|
||||
|
||||
static int generate_broadcast_id(struct bt_bap_broadcast_source *source)
|
||||
{
|
||||
bool unique;
|
||||
|
||||
do {
|
||||
int err;
|
||||
|
||||
err = bt_rand(&source->broadcast_id,
|
||||
BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Ensure uniqueness */
|
||||
unique = true;
|
||||
for (int i = 0; i < ARRAY_SIZE(broadcast_sources); i++) {
|
||||
if (&broadcast_sources[i] == source) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (broadcast_sources[i].broadcast_id == source->broadcast_id) {
|
||||
unique = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (!unique);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void broadcast_source_cleanup(struct bt_bap_broadcast_source *source)
|
||||
{
|
||||
struct bt_bap_broadcast_subgroup *subgroup, *next_subgroup;
|
||||
|
@ -830,12 +800,6 @@ int bt_bap_broadcast_source_create(struct bt_bap_broadcast_source_param *param,
|
|||
}
|
||||
}
|
||||
|
||||
err = generate_broadcast_id(source);
|
||||
if (err != 0) {
|
||||
LOG_DBG("Could not generate broadcast id: %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Finalize state changes and store information */
|
||||
broadcast_source_set_state(source, BT_BAP_EP_STATE_QOS_CONFIGURED);
|
||||
source->qos = qos;
|
||||
|
@ -852,8 +816,6 @@ int bt_bap_broadcast_source_create(struct bt_bap_broadcast_source_param *param,
|
|||
sizeof(source->broadcast_code));
|
||||
}
|
||||
|
||||
LOG_DBG("Broadcasting with ID 0x%6X", source->broadcast_id);
|
||||
|
||||
*out_source = source;
|
||||
|
||||
return 0;
|
||||
|
@ -1197,32 +1159,6 @@ int bt_bap_broadcast_source_delete(struct bt_bap_broadcast_source *source)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_bap_broadcast_source_get_id(struct bt_bap_broadcast_source *source,
|
||||
uint32_t *const broadcast_id)
|
||||
{
|
||||
enum bt_bap_ep_state broadcast_state;
|
||||
|
||||
CHECKIF(source == NULL) {
|
||||
LOG_DBG("source is NULL");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
CHECKIF(broadcast_id == NULL) {
|
||||
LOG_DBG("broadcast_id is NULL");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
broadcast_state = broadcast_source_get_state(source);
|
||||
if (broadcast_state == BT_BAP_EP_STATE_IDLE) {
|
||||
LOG_DBG("Broadcast source invalid state: %u", broadcast_state);
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
*broadcast_id = source->broadcast_id;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_bap_broadcast_source_get_base(struct bt_bap_broadcast_source *source,
|
||||
struct net_buf_simple *base_buf)
|
||||
{
|
||||
|
|
|
@ -108,7 +108,6 @@ struct bt_bap_broadcast_source {
|
|||
uint8_t stream_count;
|
||||
uint8_t packing;
|
||||
bool encryption;
|
||||
uint32_t broadcast_id; /* 24 bit */
|
||||
|
||||
struct bt_iso_big *big;
|
||||
struct bt_bap_qos_cfg *qos;
|
||||
|
|
|
@ -322,17 +322,6 @@ int bt_cap_initiator_broadcast_audio_delete(struct bt_cap_broadcast_source *broa
|
|||
return err;
|
||||
}
|
||||
|
||||
int bt_cap_initiator_broadcast_get_id(const struct bt_cap_broadcast_source *broadcast_source,
|
||||
uint32_t *const broadcast_id)
|
||||
{
|
||||
CHECKIF(broadcast_source == NULL) {
|
||||
LOG_DBG("broadcast_source is NULL");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return bt_bap_broadcast_source_get_id(broadcast_source->bap_broadcast, broadcast_id);
|
||||
}
|
||||
|
||||
int bt_cap_initiator_broadcast_get_base(struct bt_cap_broadcast_source *broadcast_source,
|
||||
struct net_buf_simple *base_buf)
|
||||
{
|
||||
|
|
|
@ -4329,9 +4329,9 @@ static ssize_t nonconnectable_ad_data_add(struct bt_data *data_array,
|
|||
uint32_t broadcast_id;
|
||||
int err;
|
||||
|
||||
err = bt_bap_broadcast_source_get_id(default_source.bap_source, &broadcast_id);
|
||||
err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
if (err != 0) {
|
||||
printk("Unable to get broadcast ID: %d\n", err);
|
||||
printk("Unable to generate broadcast ID: %d\n", err);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -1447,9 +1447,9 @@ static ssize_t nonconnectable_ad_data_add(struct bt_data *data_array, const size
|
|||
uint32_t broadcast_id;
|
||||
int err;
|
||||
|
||||
err = bt_cap_initiator_broadcast_get_id(default_source.cap_source, &broadcast_id);
|
||||
if (err != 0) {
|
||||
printk("Unable to get broadcast ID: %d\n", err);
|
||||
err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
if (err) {
|
||||
printk("Unable to generate broadcast ID: %d\n", err);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -1163,79 +1163,6 @@ ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_delete_inval_doub
|
|||
zassert_not_equal(0, err, "Did not fail with deleting already deleting source");
|
||||
}
|
||||
|
||||
ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_get_id)
|
||||
{
|
||||
struct bt_bap_broadcast_source_param *create_param = fixture->param;
|
||||
uint32_t broadcast_id;
|
||||
int err;
|
||||
|
||||
printk("Creating broadcast source with %zu subgroups with %zu streams\n",
|
||||
create_param->params_count, fixture->stream_cnt);
|
||||
|
||||
err = bt_bap_broadcast_source_create(create_param, &fixture->source);
|
||||
zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
|
||||
|
||||
err = bt_bap_broadcast_source_get_id(fixture->source, &broadcast_id);
|
||||
zassert_equal(0, err, "Unable to get broadcast ID: err %d", err);
|
||||
|
||||
err = bt_bap_broadcast_source_delete(fixture->source);
|
||||
zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
|
||||
fixture->source = NULL;
|
||||
}
|
||||
|
||||
ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_get_id_inval_source_null)
|
||||
{
|
||||
uint32_t broadcast_id;
|
||||
int err;
|
||||
|
||||
err = bt_bap_broadcast_source_get_id(NULL, &broadcast_id);
|
||||
zassert_not_equal(0, err, "Did not fail with null source");
|
||||
}
|
||||
|
||||
ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_get_id_inval_id_null)
|
||||
{
|
||||
struct bt_bap_broadcast_source_param *create_param = fixture->param;
|
||||
int err;
|
||||
|
||||
printk("Creating broadcast source with %zu subgroups with %zu streams\n",
|
||||
create_param->params_count, fixture->stream_cnt);
|
||||
|
||||
err = bt_bap_broadcast_source_create(create_param, &fixture->source);
|
||||
zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
|
||||
|
||||
err = bt_bap_broadcast_source_get_id(fixture->source, NULL);
|
||||
zassert_not_equal(0, err, "Did not fail with null ID");
|
||||
|
||||
err = bt_bap_broadcast_source_delete(fixture->source);
|
||||
zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
|
||||
fixture->source = NULL;
|
||||
}
|
||||
|
||||
ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_get_id_inval_state)
|
||||
{
|
||||
struct bt_bap_broadcast_source_param *create_param = fixture->param;
|
||||
struct bt_bap_broadcast_source *source;
|
||||
uint32_t broadcast_id;
|
||||
int err;
|
||||
|
||||
printk("Creating broadcast source with %zu subgroups with %zu streams\n",
|
||||
create_param->params_count, fixture->stream_cnt);
|
||||
|
||||
err = bt_bap_broadcast_source_create(create_param, &fixture->source);
|
||||
zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
|
||||
|
||||
source = fixture->source;
|
||||
|
||||
err = bt_bap_broadcast_source_delete(fixture->source);
|
||||
zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
|
||||
fixture->source = NULL;
|
||||
|
||||
err = bt_bap_broadcast_source_get_id(source, &broadcast_id);
|
||||
zassert_not_equal(0, err, "Did not fail with deleted broadcast source");
|
||||
}
|
||||
|
||||
|
||||
|
||||
ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_get_base_single_bis)
|
||||
{
|
||||
struct bt_bap_broadcast_source_param *create_param = fixture->param;
|
||||
|
|
|
@ -298,6 +298,7 @@ uint8_t btp_bap_broadcast_source_setup(const void *cmd, uint16_t cmd_len,
|
|||
const struct btp_bap_broadcast_source_setup_cmd *cp = cmd;
|
||||
struct btp_bap_broadcast_source_setup_rp *rp = rsp;
|
||||
struct bt_le_adv_param param = *BT_LE_EXT_ADV_NCONN;
|
||||
uint32_t broadcast_id;
|
||||
|
||||
/* Only one local source/BIG supported for now */
|
||||
struct btp_bap_broadcast_local_source *source = &local_source;
|
||||
|
@ -338,16 +339,16 @@ uint8_t btp_bap_broadcast_source_setup(const void *cmd, uint16_t cmd_len,
|
|||
return BTP_STATUS_FAILED;
|
||||
}
|
||||
|
||||
err = bt_bap_broadcast_source_get_id(source->bap_broadcast, &source->broadcast_id);
|
||||
if (err != 0) {
|
||||
LOG_DBG("Unable to get broadcast ID: %d", err);
|
||||
err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
if (err) {
|
||||
LOG_DBG("Unable to generate broadcast ID: %d\n", err);
|
||||
|
||||
return BTP_STATUS_FAILED;
|
||||
}
|
||||
|
||||
/* Setup extended advertising data */
|
||||
net_buf_simple_add_le16(&ad_buf, BT_UUID_BROADCAST_AUDIO_VAL);
|
||||
net_buf_simple_add_le24(&ad_buf, source->broadcast_id);
|
||||
net_buf_simple_add_le24(&ad_buf, broadcast_id);
|
||||
base_ad[0].type = BT_DATA_SVC_DATA16;
|
||||
base_ad[0].data_len = ad_buf.len;
|
||||
base_ad[0].data = ad_buf.data;
|
||||
|
@ -387,7 +388,7 @@ uint8_t btp_bap_broadcast_source_setup(const void *cmd, uint16_t cmd_len,
|
|||
}
|
||||
|
||||
rp->gap_settings = gap_settings;
|
||||
sys_put_le24(source->broadcast_id, rp->broadcast_id);
|
||||
sys_put_le24(broadcast_id, rp->broadcast_id);
|
||||
*rsp_len = sizeof(*rp) + 1;
|
||||
|
||||
return BTP_STATUS_SUCCESS;
|
||||
|
|
|
@ -534,6 +534,7 @@ static int cap_broadcast_source_adv_setup(struct btp_bap_broadcast_local_source
|
|||
{
|
||||
int err;
|
||||
struct bt_le_adv_param param = *BT_LE_EXT_ADV_NCONN;
|
||||
uint32_t broadcast_id;
|
||||
|
||||
NET_BUF_SIMPLE_DEFINE(ad_buf, BT_UUID_SIZE_16 + BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
NET_BUF_SIMPLE_DEFINE(base_buf, 128);
|
||||
|
@ -542,9 +543,9 @@ static int cap_broadcast_source_adv_setup(struct btp_bap_broadcast_local_source
|
|||
struct bt_data base_ad[2];
|
||||
struct bt_data per_ad;
|
||||
|
||||
err = bt_cap_initiator_broadcast_get_id(source->cap_broadcast, &source->broadcast_id);
|
||||
if (err != 0) {
|
||||
LOG_DBG("Unable to get broadcast ID: %d", err);
|
||||
err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
if (err) {
|
||||
printk("Unable to generate broadcast ID: %d\n", err);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -321,18 +321,6 @@ static int setup_broadcast_source(struct bt_bap_broadcast_source **source, bool
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void test_broadcast_source_get_id(struct bt_bap_broadcast_source *source,
|
||||
uint32_t *broadcast_id_out)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = bt_bap_broadcast_source_get_id(source, broadcast_id_out);
|
||||
if (err != 0) {
|
||||
FAIL("Unable to get broadcast ID: %d\n", err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void test_broadcast_source_get_base(struct bt_bap_broadcast_source *source,
|
||||
struct net_buf_simple *base_buf)
|
||||
{
|
||||
|
@ -373,7 +361,11 @@ static int setup_extended_adv(struct bt_bap_broadcast_source *source, struct bt_
|
|||
return err;
|
||||
}
|
||||
|
||||
test_broadcast_source_get_id(source, &broadcast_id);
|
||||
err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
if (err) {
|
||||
printk("Unable to generate broadcast ID: %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Setup extended advertising data */
|
||||
net_buf_simple_add_le16(&ad_buf, BT_UUID_BROADCAST_AUDIO_VAL);
|
||||
|
|
|
@ -249,9 +249,9 @@ static void setup_extended_adv_data(struct bt_cap_broadcast_source *source,
|
|||
uint32_t broadcast_id;
|
||||
int err;
|
||||
|
||||
err = bt_cap_initiator_broadcast_get_id(source, &broadcast_id);
|
||||
if (err != 0) {
|
||||
FAIL("Unable to get broadcast ID: %d\n", err);
|
||||
err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
if (err) {
|
||||
FAIL("Unable to generate broadcast ID: %d\n", err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1055,9 +1055,9 @@ static void setup_extended_adv_data(struct bt_cap_broadcast_source *source,
|
|||
uint32_t broadcast_id;
|
||||
int err;
|
||||
|
||||
err = bt_cap_initiator_broadcast_get_id(source, &broadcast_id);
|
||||
if (err != 0) {
|
||||
FAIL("Unable to get broadcast ID: %d\n", err);
|
||||
err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
if (err) {
|
||||
FAIL("Unable to generate broadcast ID: %d\n", err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -135,10 +135,9 @@ static int setup_extended_adv_data(struct bt_cap_broadcast_source *source,
|
|||
uint32_t broadcast_id;
|
||||
int err;
|
||||
|
||||
err = bt_cap_initiator_broadcast_get_id(source, &broadcast_id);
|
||||
if (err != 0) {
|
||||
printk("Unable to get broadcast ID: %d\n", err);
|
||||
|
||||
err = bt_rand(&broadcast_id, BT_AUDIO_BROADCAST_ID_SIZE);
|
||||
if (err) {
|
||||
FAIL("Unable to generate broadcast ID: %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue