Bluetooth: audio: test: add test for long write

Added a test for long write, long read, and notifications

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
This commit is contained in:
Andries Kruithof 2023-12-19 14:46:40 +01:00 committed by Carles Cufí
parent 3ef1b045ce
commit b7078286d2
3 changed files with 39 additions and 1 deletions

View file

@ -113,6 +113,7 @@ CONFIG_BT_OTS_CLIENT=y
# Broadcast Audio Scan Service and client # Broadcast Audio Scan Service and client
CONFIG_BT_BAP_SCAN_DELEGATOR=y CONFIG_BT_BAP_SCAN_DELEGATOR=y
CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN=255
CONFIG_BT_BAP_BROADCAST_ASSISTANT=y CONFIG_BT_BAP_BROADCAST_ASSISTANT=y
# Hearing Access # Hearing Access

View file

@ -11,6 +11,7 @@
#include <zephyr/bluetooth/audio/bap.h> #include <zephyr/bluetooth/audio/bap.h>
#include "../../../../../subsys/bluetooth/host/hci_core.h" #include "../../../../../subsys/bluetooth/host/hci_core.h"
#include "common.h" #include "common.h"
#include "bap_common.h"
extern enum bst_result_t bst_result; extern enum bst_result_t bst_result;
@ -36,6 +37,8 @@ static bt_addr_le_t g_broadcaster_addr;
static struct bt_le_scan_recv_info g_broadcaster_info; static struct bt_le_scan_recv_info g_broadcaster_info;
static struct bt_le_per_adv_sync *g_pa_sync; static struct bt_le_per_adv_sync *g_pa_sync;
static uint8_t metadata[] = {BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_VENDOR, LONG_META)};
static const char *phy2str(uint8_t phy) static const char *phy2str(uint8_t phy)
{ {
switch (phy) { switch (phy) {
@ -424,6 +427,38 @@ static void test_bass_mod_source(void)
mod_src_param.pa_interval = g_broadcaster_info.interval; mod_src_param.pa_interval = g_broadcaster_info.interval;
subgroup.bis_sync = BIT(1) | BIT(2); /* Indexes 1 and 2 */ subgroup.bis_sync = BIT(1) | BIT(2); /* Indexes 1 and 2 */
subgroup.metadata_len = 0; subgroup.metadata_len = 0;
err = bt_bap_broadcast_assistant_mod_src(default_conn, &mod_src_param);
if (err != 0) {
FAIL("Could not modify source (err %d)\n", err);
return;
}
WAIT_FOR_FLAG(flag_cb_called);
WAIT_FOR_FLAG(flag_write_complete);
printk("Source added, waiting for server to PA sync\n");
WAIT_FOR_FLAG(flag_state_synced)
printk("Server PA synced\n");
}
static void test_bass_mod_source_long_meta(void)
{
int err;
struct bt_bap_broadcast_assistant_mod_src_param mod_src_param = { 0 };
struct bt_bap_scan_delegator_subgroup subgroup = { 0 };
printk("Long write\n");
UNSET_FLAG(flag_cb_called);
UNSET_FLAG(flag_write_complete);
mod_src_param.src_id = g_src_id;
mod_src_param.num_subgroups = 1;
mod_src_param.pa_sync = true;
mod_src_param.subgroups = &subgroup;
mod_src_param.pa_interval = g_broadcaster_info.interval;
subgroup.bis_sync = BIT(1) | BIT(2);
subgroup.metadata_len = sizeof(metadata);
memcpy(subgroup.metadata, metadata, sizeof(metadata));
err = bt_bap_broadcast_assistant_mod_src(default_conn, &mod_src_param); err = bt_bap_broadcast_assistant_mod_src(default_conn, &mod_src_param);
if (err != 0) { if (err != 0) {
FAIL("Could not modify source (err %d)\n", err); FAIL("Could not modify source (err %d)\n", err);
@ -525,6 +560,7 @@ static void test_main_client_sync(void)
test_bass_create_pa_sync(); test_bass_create_pa_sync();
test_bass_add_source(); test_bass_add_source();
test_bass_mod_source(); test_bass_mod_source();
test_bass_mod_source_long_meta();
test_bass_broadcast_code(); test_bass_broadcast_code();
printk("Waiting for receive state with BIS sync\n"); printk("Waiting for receive state with BIS sync\n");

View file

@ -29,7 +29,8 @@
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, \ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, \
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, \ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, \
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, \ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, \
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, \
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87
#define LONG_META_LEN (sizeof((uint8_t []){LONG_META}) + 1U) /* Size of data + type */ #define LONG_META_LEN (sizeof((uint8_t []){LONG_META}) + 1U) /* Size of data + type */