Skip to content

Commit db7bb2c

Browse files
Thalleycarlescufi
authored andcommitted
tests: Bluetooth: Audio: Add unicast client CP notification bsim testing
Adds waiting for the control point operation callbacks in the unicast client BSIM test, ensuring that the callbacks work, but also testing that the server is correctly sending them. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 88644a7 commit db7bb2c

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

tests/bluetooth/bsim/audio/src/bap_unicast_client_test.c

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static atomic_t flag_stream_qos_configured;
3131
CREATE_FLAG(flag_stream_enabled);
3232
CREATE_FLAG(flag_stream_started);
3333
CREATE_FLAG(flag_stream_released);
34+
CREATE_FLAG(flag_operation_success);
3435

3536
static void stream_configured(struct bt_bap_stream *stream,
3637
const struct bt_codec_qos_pref *pref)
@@ -112,9 +113,98 @@ static void available_contexts_cb(struct bt_conn *conn,
112113
printk("snk ctx %u src ctx %u\n", snk_ctx, src_ctx);
113114
}
114115

116+
117+
static void config_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
118+
enum bt_bap_ascs_reason reason)
119+
{
120+
printk("stream %p config operation rsp_code %u reason %u\n", stream, rsp_code, reason);
121+
122+
if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS) {
123+
SET_FLAG(flag_operation_success);
124+
}
125+
}
126+
127+
static void qos_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
128+
enum bt_bap_ascs_reason reason)
129+
{
130+
printk("stream %p qos operation rsp_code %u reason %u\n", stream, rsp_code, reason);
131+
132+
if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS) {
133+
SET_FLAG(flag_operation_success);
134+
}
135+
}
136+
137+
static void enable_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
138+
enum bt_bap_ascs_reason reason)
139+
{
140+
printk("stream %p enable operation rsp_code %u reason %u\n", stream, rsp_code, reason);
141+
142+
if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS) {
143+
SET_FLAG(flag_operation_success);
144+
}
145+
}
146+
147+
static void start_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
148+
enum bt_bap_ascs_reason reason)
149+
{
150+
printk("stream %p start operation rsp_code %u reason %u\n", stream, rsp_code, reason);
151+
152+
if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS) {
153+
SET_FLAG(flag_operation_success);
154+
}
155+
}
156+
157+
static void stop_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
158+
enum bt_bap_ascs_reason reason)
159+
{
160+
printk("stream %p stop operation rsp_code %u reason %u\n", stream, rsp_code, reason);
161+
162+
if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS) {
163+
SET_FLAG(flag_operation_success);
164+
}
165+
}
166+
167+
static void disable_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
168+
enum bt_bap_ascs_reason reason)
169+
{
170+
printk("stream %p disable operation rsp_code %u reason %u\n", stream, rsp_code, reason);
171+
172+
if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS) {
173+
SET_FLAG(flag_operation_success);
174+
}
175+
}
176+
177+
static void metadata_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
178+
enum bt_bap_ascs_reason reason)
179+
{
180+
printk("stream %p metadata operation rsp_code %u reason %u\n", stream, rsp_code, reason);
181+
182+
if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS) {
183+
SET_FLAG(flag_operation_success);
184+
}
185+
}
186+
187+
static void release_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
188+
enum bt_bap_ascs_reason reason)
189+
{
190+
printk("stream %p release operation rsp_code %u reason %u\n", stream, rsp_code, reason);
191+
192+
if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS) {
193+
SET_FLAG(flag_operation_success);
194+
}
195+
}
196+
115197
const struct bt_bap_unicast_client_cb unicast_client_cbs = {
116198
.location = unicast_client_location_cb,
117199
.available_contexts = available_contexts_cb,
200+
.config = config_cb,
201+
.qos = qos_cb,
202+
.enable = enable_cb,
203+
.start = start_cb,
204+
.stop = stop_cb,
205+
.disable = disable_cb,
206+
.metadata = metadata_cb,
207+
.release = release_cb,
118208
};
119209

120210
static void add_remote_sink(struct bt_bap_ep *ep, uint8_t index)
@@ -267,6 +357,7 @@ static int codec_configure_stream(struct bt_bap_stream *stream, struct bt_bap_ep
267357
int err;
268358

269359
UNSET_FLAG(flag_stream_codec_configured);
360+
UNSET_FLAG(flag_operation_success);
270361

271362
err = bt_bap_stream_config(default_conn, stream, ep,
272363
&preset_16_2_1.codec);
@@ -276,6 +367,7 @@ static int codec_configure_stream(struct bt_bap_stream *stream, struct bt_bap_ep
276367
}
277368

278369
WAIT_FOR_FLAG(flag_stream_codec_configured);
370+
WAIT_FOR_FLAG(flag_operation_success);
279371

280372
return 0;
281373
}
@@ -393,6 +485,7 @@ static size_t release_streams(size_t stream_cnt)
393485
break;
394486
}
395487

488+
UNSET_FLAG(flag_operation_success);
396489
UNSET_FLAG(flag_stream_released);
397490

398491
err = bt_bap_stream_release(&g_streams[i]);
@@ -401,6 +494,7 @@ static size_t release_streams(size_t stream_cnt)
401494
return 0;
402495
}
403496

497+
WAIT_FOR_FLAG(flag_operation_success);
404498
WAIT_FOR_FLAG(flag_stream_released);
405499
}
406500

0 commit comments

Comments
 (0)