From 8acada0608ee03ea803b1c16b568a17af5df3e1c Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Tue, 26 Mar 2024 13:55:38 +0100 Subject: [PATCH] Bluetooth: Audio: Shell: clear static buffers for ad data The buffers for the PBP advertising data as well as the buffers for the BASE periodic advertising data were not cleared, so calling the functions multiple times would simply append the data rather than just setting the new data. Signed-off-by: Emil Gydesen --- subsys/bluetooth/audio/shell/bap.c | 2 ++ subsys/bluetooth/audio/shell/cap_initiator.c | 2 ++ subsys/bluetooth/audio/shell/pbp.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/subsys/bluetooth/audio/shell/bap.c b/subsys/bluetooth/audio/shell/bap.c index db5d76888ff..49cca9941c5 100644 --- a/subsys/bluetooth/audio/shell/bap.c +++ b/subsys/bluetooth/audio/shell/bap.c @@ -3740,6 +3740,8 @@ ssize_t audio_pa_data_add(struct bt_data *data_array, NET_BUF_SIMPLE_DEFINE_STATIC(base_buf, UINT8_MAX); int err; + net_buf_simple_reset(&base_buf); + err = bt_bap_broadcast_source_get_base(default_source.bap_source, &base_buf); if (err != 0) { printk("Unable to get BASE: %d\n", err); diff --git a/subsys/bluetooth/audio/shell/cap_initiator.c b/subsys/bluetooth/audio/shell/cap_initiator.c index 6343e973178..813bff1a041 100644 --- a/subsys/bluetooth/audio/shell/cap_initiator.c +++ b/subsys/bluetooth/audio/shell/cap_initiator.c @@ -1459,6 +1459,8 @@ ssize_t cap_initiator_pa_data_add(struct bt_data *data_array, const size_t data_ NET_BUF_SIMPLE_DEFINE_STATIC(base_buf, UINT8_MAX); int err; + net_buf_simple_reset(&base_buf); + err = bt_cap_initiator_broadcast_get_base(default_source.cap_source, &base_buf); if (err != 0) { printk("Unable to get BASE: %d\n", err); diff --git a/subsys/bluetooth/audio/shell/pbp.c b/subsys/bluetooth/audio/shell/pbp.c index 9519fd19274..1eb3e630660 100644 --- a/subsys/bluetooth/audio/shell/pbp.c +++ b/subsys/bluetooth/audio/shell/pbp.c @@ -48,6 +48,8 @@ size_t pbp_ad_data_add(struct bt_data data[], size_t data_size) { int err; + net_buf_simple_reset(&pbp_ad_buf); + err = bt_pbp_get_announcement(pba_metadata, ARRAY_SIZE(pba_metadata), pbp_features,