Skip to content

Commit 7b0ba0f

Browse files
Thalleycarlescufi
authored andcommitted
Bluetooth: Audio: Fix missing path_id for unicast server
The codec->path_id supplied to the capabilities were not being used for the endpoint codec. Important note: This only works if there is a single capability per codec ID per direction. This limitation is also an existing limitation in the current implementation of capabilities.c. Signed-off-by: Emil Gydesen <[email protected]>
1 parent f9d1607 commit 7b0ba0f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

subsys/bluetooth/audio/ascs.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <zephyr/bluetooth/conn.h>
2020
#include <zephyr/bluetooth/gatt.h>
2121
#include <zephyr/bluetooth/audio/audio.h>
22+
#include <zephyr/bluetooth/audio/capabilities.h>
2223

2324
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_ASCS)
2425
#define LOG_MODULE_NAME bt_ascs
@@ -1246,14 +1247,21 @@ static int ascs_ep_set_codec(struct bt_audio_ep *ep, uint8_t id, uint16_t cid,
12461247
uint16_t vid, struct net_buf_simple *buf,
12471248
uint8_t len, struct bt_codec *codec)
12481249
{
1250+
struct bt_audio_capability *cap;
1251+
sys_slist_t *capabilities;
12491252
struct net_buf_simple ad;
12501253

12511254
if (ep == NULL && codec == NULL) {
12521255
return -EINVAL;
12531256
}
12541257

1255-
BT_DBG("ep %p codec id 0x%02x cid 0x%04x vid 0x%04x len %u", ep, id,
1256-
cid, vid, len);
1258+
BT_DBG("ep %p dir %u codec id 0x%02x cid 0x%04x vid 0x%04x len %u",
1259+
ep, ep->dir, id, cid, vid, len);
1260+
1261+
capabilities = bt_audio_capability_get(ep->dir);
1262+
if (capabilities == NULL) {
1263+
return -ENOENT;
1264+
}
12571265

12581266
if (codec == NULL) {
12591267
codec = &ep->codec;
@@ -1264,6 +1272,13 @@ static int ascs_ep_set_codec(struct bt_audio_ep *ep, uint8_t id, uint16_t cid,
12641272
codec->vid = vid;
12651273
codec->data_count = 0;
12661274

1275+
SYS_SLIST_FOR_EACH_CONTAINER(capabilities, cap, _node) {
1276+
if (codec->id == cap->codec->id) {
1277+
codec->path_id = cap->codec->path_id;
1278+
break;
1279+
}
1280+
}
1281+
12671282
if (len == 0) {
12681283
return 0;
12691284
}

0 commit comments

Comments
 (0)