Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions subsys/bluetooth/audio/bap_scan_delegator.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static bool bis_syncs_unique_or_no_pref(uint32_t requested_bis_syncs,
return true;
}

return (requested_bis_syncs & aggregated_bis_syncs) != 0U;
return (requested_bis_syncs & aggregated_bis_syncs) == 0U;
}

static bool valid_bis_sync_request(uint32_t requested_bis_syncs, uint32_t aggregated_bis_syncs)
Expand Down Expand Up @@ -938,8 +938,7 @@ static int scan_delegator_mod_src(struct bt_conn *conn,
bis_sync_change_requested = true;
}

if (!valid_bis_sync_request(internal_state->requested_bis_sync[i],
aggregated_bis_syncs)) {
if (!valid_bis_sync_request(requested_bis_sync[i], aggregated_bis_syncs)) {
LOG_DBG("Invalid BIS Sync request[%d]", i);
ret = BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED);
goto unlock_return;
Expand Down
6 changes: 4 additions & 2 deletions subsys/bluetooth/audio/csip_set_member.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,10 @@ static void csip_security_changed(struct bt_conn *conn, bt_security_t level,
return;
}

/* Check if client is set with FLAG_NOTIFY_LOCK */
if (atomic_test_bit(client->flags, FLAG_NOTIFY_LOCK)) {
/* Check if client has pending notifications */
if (atomic_test_bit(client->flags, FLAG_NOTIFY_LOCK) ||
atomic_test_bit(client->flags, FLAG_NOTIFY_SIRK) ||
atomic_test_bit(client->flags, FLAG_NOTIFY_SIZE)) {
notify_work_reschedule(K_NO_WAIT);
break;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/bluetooth/tester/overlay-le-audio.conf
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ CONFIG_BT_HAS_CLIENT=y
# CSIS
CONFIG_BT_CSIP_SET_MEMBER=y
CONFIG_BT_CSIP_SET_MEMBER_ENC_SIRK_SUPPORT=y
CONFIG_BT_CSIP_SET_MEMBER_SIRK_NOTIFIABLE=y
CONFIG_BT_CSIP_SET_MEMBER_SIZE_NOTIFIABLE=y

# CSIP
CONFIG_BT_CSIP_SET_COORDINATOR=y
Expand Down
21 changes: 18 additions & 3 deletions tests/bluetooth/tester/src/audio/btp/btp_csis.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#include <zephyr/bluetooth/audio/csip.h>

/* CSIS commands */
#define BTP_CSIS_SIRK_TYPE_PLAINTEXT 0x00
#define BTP_CSIS_SIRK_TYPE_ENCRYPTED 0x01
#define BTP_CSIS_SIRK_TYPE_OOB_ONLY 0x02

Check notice on line 18 in tests/bluetooth/tester/src/audio/btp/btp_csis.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

tests/bluetooth/tester/src/audio/btp/btp_csis.h:18 -#define BTP_CSIS_SIRK_TYPE_PLAINTEXT 0x00 -#define BTP_CSIS_SIRK_TYPE_ENCRYPTED 0x01 -#define BTP_CSIS_SIRK_TYPE_OOB_ONLY 0x02 +#define BTP_CSIS_SIRK_TYPE_PLAINTEXT 0x00 +#define BTP_CSIS_SIRK_TYPE_ENCRYPTED 0x01 +#define BTP_CSIS_SIRK_TYPE_OOB_ONLY 0x02
#define BTP_CSIS_READ_SUPPORTED_COMMANDS 0x01
struct btp_csis_read_supported_commands_rp {
uint8_t data[0];
Expand All @@ -33,7 +37,18 @@
uint8_t rsi[BT_CSIP_RSI_SIZE];
} __packed;

#define BTP_CSIS_ENC_SIRK_TYPE 0x04
struct btp_csis_sirk_type_cmd {
uint8_t encrypted;
#define BTP_CSIS_SET_SIRK_TYPE 0x04
struct btp_csis_sirk_set_type_cmd {

Check notice on line 41 in tests/bluetooth/tester/src/audio/btp/btp_csis.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

tests/bluetooth/tester/src/audio/btp/btp_csis.h:41 -#define BTP_CSIS_SET_SIRK_TYPE 0x04 +#define BTP_CSIS_SET_SIRK_TYPE 0x04
uint8_t type;
} __packed;

#define BTP_CSIS_SET_SIRK 0x05
struct btp_csis_set_sirk_cmd {
uint8_t sirk[BT_CSIP_SIRK_SIZE];
} __packed;

#define BTP_CSIS_SET_SET_SIZE 0x06
struct btp_csis_set_set_size_cmd {
uint8_t set_size;
uint8_t rank;
} __packed;
9 changes: 9 additions & 0 deletions tests/bluetooth/tester/src/audio/btp/btp_vcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include <stdint.h>

#define BTP_VCS_REGISTER_FLAG_MUTED BIT(0)

Check notice on line 12 in tests/bluetooth/tester/src/audio/btp/btp_vcs.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

tests/bluetooth/tester/src/audio/btp/btp_vcs.h:12 -#define BTP_VCS_REGISTER_FLAG_MUTED BIT(0) +#define BTP_VCS_REGISTER_FLAG_MUTED BIT(0)
#define BTP_VCS_READ_SUPPORTED_COMMANDS 0x01
struct btp_vcs_read_supported_commands_rp {
uint8_t data[0];
Expand All @@ -22,3 +24,10 @@
#define BTP_VCS_VOL_DOWN 0x04
#define BTP_VCS_MUTE 0x05
#define BTP_VCS_UNMUTE 0x06

#define BTP_VCS_REGISTER 0x07
struct btp_vcs_register_cmd {

Check notice on line 29 in tests/bluetooth/tester/src/audio/btp/btp_vcs.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

tests/bluetooth/tester/src/audio/btp/btp_vcs.h:29 -#define BTP_VCS_REGISTER 0x07 +#define BTP_VCS_REGISTER 0x07
uint8_t step;
uint8_t flags;
uint8_t volume;
} __packed;
31 changes: 17 additions & 14 deletions tests/bluetooth/tester/src/audio/btp_bap_broadcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,8 @@ static int pa_sync_req_cb(struct bt_conn *conn,
bt_addr_le_copy(&broadcaster->address, &recv_state->addr);
}

broadcast_source_to_sync = broadcaster;

broadcaster->sink_recv_state = recv_state;

btp_send_pas_sync_req_ev(conn, recv_state->src_id, recv_state->adv_sid,
Expand Down Expand Up @@ -1380,20 +1382,6 @@ uint8_t btp_bap_broadcast_sink_sync(const void *cmd, uint16_t cmd_len, void *rsp

LOG_DBG("");

broadcaster = remote_broadcaster_find(&cp->address, broadcast_id);
if (broadcaster == NULL) {
broadcaster = remote_broadcaster_alloc();
if (broadcaster == NULL) {
LOG_ERR("Failed to allocate broadcast source");
return BTP_STATUS_FAILED;
}

broadcaster->broadcast_id = broadcast_id;
bt_addr_le_copy(&broadcaster->address, &cp->address);
}

broadcast_source_to_sync = broadcaster;

if (IS_ENABLED(CONFIG_BT_PER_ADV_SYNC_TRANSFER_RECEIVER) && cp->past_avail) {
/* The Broadcast Assistant supports PAST transfer, and it has found
* a Broadcaster for us. Let's sync to the Broadcaster PA with the PAST.
Expand Down Expand Up @@ -1421,7 +1409,22 @@ uint8_t btp_bap_broadcast_sink_sync(const void *cmd, uint16_t cmd_len, void *rsp
create_params.sid = cp->advertiser_sid;
create_params.skip = cp->skip;
create_params.timeout = cp->sync_timeout;

err = tester_gap_padv_create_sync(&create_params);

broadcaster = remote_broadcaster_find(&cp->address, broadcast_id);
if (broadcaster == NULL) {
broadcaster = remote_broadcaster_alloc();
if (broadcaster == NULL) {
LOG_ERR("Failed to allocate broadcast source");
return BTP_STATUS_FAILED;
}

broadcaster->broadcast_id = broadcast_id;
bt_addr_le_copy(&broadcaster->address, &cp->address);
}

broadcast_source_to_sync = broadcaster;
}

if (err != 0) {
Expand Down
7 changes: 6 additions & 1 deletion tests/bluetooth/tester/src/audio/btp_bap_unicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ static void stream_configured_cb(struct bt_bap_stream *stream,

u_stream->conn_id = bt_conn_index(stream->conn);
u_conn = &connections[u_stream->conn_id];
u_stream->ase_id = info.id;

stream_state_changed(stream);
}
Expand Down Expand Up @@ -1272,6 +1271,12 @@ static int client_configure_codec(struct btp_bap_unicast_connection *u_conn, str
memcpy(&stream->codec_cfg, codec_cfg, sizeof(*codec_cfg));
err = bt_bap_stream_config(conn, stream_unicast_to_bap(stream), ep,
&stream->codec_cfg);

if (err == 0) {
stream->ase_id = ase_id;
} else {
stream->in_use = false;
}
} else {
/* Reconfigure a stream */
memcpy(&stream->codec_cfg, codec_cfg, sizeof(*codec_cfg));
Expand Down
82 changes: 68 additions & 14 deletions tests/bluetooth/tester/src/audio/btp_csis.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_BTTESTER_LOG_LEVEL);
#define BTP_STATUS_VAL(err) (err) ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS

static struct bt_csip_set_member_svc_inst *csis_svc_inst;
static bool enc_sirk;
static uint8_t sirk_read_response;

static uint8_t csis_supported_commands(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
Expand Down Expand Up @@ -65,15 +65,61 @@ static uint8_t csis_get_member_rsi(const void *cmd, uint16_t cmd_len,
return BTP_STATUS_VAL(err);
}

static uint8_t csis_sirk_type(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len)
static uint8_t csis_set_sirk_type(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len)
{
const struct btp_csis_sirk_type_cmd *cp = cmd;
const struct btp_csis_sirk_set_type_cmd *cp = cmd;

switch (cp->type) {
case BTP_CSIS_SIRK_TYPE_PLAINTEXT:
LOG_DBG("SIRK type: plain text");
sirk_read_response = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT;
break;
case BTP_CSIS_SIRK_TYPE_ENCRYPTED:
LOG_DBG("SIRK type: encrypted");
sirk_read_response = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT_ENC;
break;
case BTP_CSIS_SIRK_TYPE_OOB_ONLY:
LOG_DBG("SIRK type: OOB procedure only");
sirk_read_response = BT_CSIP_READ_SIRK_REQ_RSP_OOB_ONLY;
break;
default:
LOG_ERR("Unknown SIRK type: %u", cp->type);
return BTP_STATUS_FAILED;
}

enc_sirk = cp->encrypted != 0U;
return BTP_STATUS_SUCCESS;
}

LOG_DBG("SIRK type: %s", enc_sirk ? "encrypted" : "plain text");
static uint8_t csis_set_sirk(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len)
{
const struct btp_csis_set_sirk_cmd *cp = cmd;
int err = -ENOENT;

return BTP_STATUS_SUCCESS;
LOG_DBG("Setting new SIRK");

if (csis_svc_inst != NULL) {
err = bt_csip_set_member_sirk(csis_svc_inst, cp->sirk);
} else {
LOG_DBG("No CSIS instance registered");
}

return BTP_STATUS_VAL(err);
}

static uint8_t csis_set_set_size(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len)
{
const struct btp_csis_set_set_size_cmd *cp = cmd;
int err = -ENOENT;

LOG_DBG("Setting new set size %u and rank %u", cp->set_size, cp->rank);

if (csis_svc_inst != NULL) {
err = bt_csip_set_member_set_size_and_rank(csis_svc_inst, cp->set_size, cp->rank);
} else {
LOG_DBG("No CSIS instance registered");
}

return BTP_STATUS_VAL(err);
}

static const struct btp_handler csis_handlers[] = {
Expand All @@ -94,9 +140,19 @@ static const struct btp_handler csis_handlers[] = {
.func = csis_get_member_rsi,
},
{
.opcode = BTP_CSIS_ENC_SIRK_TYPE,
.expect_len = sizeof(struct btp_csis_sirk_type_cmd),
.func = csis_sirk_type,
.opcode = BTP_CSIS_SET_SIRK_TYPE,
.expect_len = sizeof(struct btp_csis_sirk_set_type_cmd),
.func = csis_set_sirk_type,
},
{
.opcode = BTP_CSIS_SET_SIRK,
.expect_len = sizeof(struct btp_csis_set_sirk_cmd),
.func = csis_set_sirk,
},
{
.opcode = BTP_CSIS_SET_SET_SIZE,
.expect_len = sizeof(struct btp_csis_set_set_size_cmd),
.func = csis_set_set_size,
},
};

Expand All @@ -108,11 +164,7 @@ static void lock_changed_cb(struct bt_conn *conn, struct bt_csip_set_member_svc_

static uint8_t sirk_read_cb(struct bt_conn *conn, struct bt_csip_set_member_svc_inst *svc_inst)
{
if (enc_sirk) {
return BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT_ENC;
} else {
return BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT;
}
return sirk_read_response;
}

static struct bt_csip_set_member_cb csis_cb = {
Expand All @@ -132,6 +184,8 @@ uint8_t tester_init_csis(void)
};
int err = bt_csip_set_member_register(&register_params, &csis_svc_inst);

sirk_read_response = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT;

tester_register_command_handlers(BTP_SERVICE_ID_CSIS, csis_handlers,
ARRAY_SIZE(csis_handlers));

Expand Down
72 changes: 51 additions & 21 deletions tests/bluetooth/tester/src/audio/btp_vcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,43 @@
return BTP_STATUS_SUCCESS;
}

static void set_register_params(uint8_t gain_mode, uint8_t step,
bool muted, uint8_t volume);

static uint8_t register_vcs(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
{

Check notice on line 148 in tests/bluetooth/tester/src/audio/btp_vcp.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

tests/bluetooth/tester/src/audio/btp_vcp.c:148 -static void set_register_params(uint8_t gain_mode, uint8_t step, - bool muted, uint8_t volume); - -static uint8_t register_vcs(const void *cmd, uint16_t cmd_len, - void *rsp, uint16_t *rsp_len) +static void set_register_params(uint8_t gain_mode, uint8_t step, bool muted, uint8_t volume); + +static uint8_t register_vcs(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len)
static bool vcs_registered_flag;
const struct btp_vcs_register_cmd *cp = cmd;
int err;

LOG_DBG("Registering VCS");

if (vcs_registered_flag) {
return BTP_STATUS_FAILED;
}

bool muted = (cp->flags & BTP_VCS_REGISTER_FLAG_MUTED) != 0;

set_register_params(BT_AICS_MODE_MANUAL, cp->step, muted, cp->volume);

err = bt_vcp_vol_rend_register(&vcp_register_param);
if (err != 0) {
return BTP_STATUS_FAILED;
}

err = bt_vcp_vol_rend_included_get(&included);
if (err != 0) {
return BTP_STATUS_FAILED;
}

aics_server_instance.aics_cnt = included.aics_cnt;
aics_server_instance.aics = included.aics;
vcs_registered_flag = true;

return BTP_STATUS_SUCCESS;
}

static void vcs_state_cb(struct bt_conn *conn, int err, uint8_t volume, uint8_t mute)
{
LOG_DBG("VCP state cb err (%d)", err);
Expand Down Expand Up @@ -187,6 +224,11 @@
.expect_len = 0,
.func = unmute,
},
{
.opcode = BTP_VCS_REGISTER,
.expect_len = sizeof(struct btp_vcs_register_cmd),
.func = register_vcs,
},
};

/* Volume Offset Control Service */
Expand Down Expand Up @@ -463,8 +505,9 @@
};

/* General profile handling */
static void set_register_params(uint8_t gain_mode)
static void set_register_params(uint8_t gain_mode, uint8_t step,
bool muted, uint8_t volume)
{

Check notice on line 510 in tests/bluetooth/tester/src/audio/btp_vcp.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

tests/bluetooth/tester/src/audio/btp_vcp.c:510 -static void set_register_params(uint8_t gain_mode, uint8_t step, - bool muted, uint8_t volume) +static void set_register_params(uint8_t gain_mode, uint8_t step, bool muted, uint8_t volume)
char input_desc[CONFIG_BT_VCP_VOL_REND_AICS_INSTANCE_COUNT]
[BT_AICS_MAX_INPUT_DESCRIPTION_SIZE];
char output_desc[CONFIG_BT_VCP_VOL_REND_VOCS_INSTANCE_COUNT]
Expand Down Expand Up @@ -495,31 +538,18 @@
vcp_register_param.aics_param[i].cb = &aics_server_cb;
}

vcp_register_param.step = 1;
vcp_register_param.mute = BT_VCP_STATE_UNMUTED;
vcp_register_param.volume = 100;
vcp_register_param.step = step;
if (muted) {
vcp_register_param.mute = BT_VCP_STATE_MUTED;
} else {
vcp_register_param.mute = BT_VCP_STATE_UNMUTED;
}
vcp_register_param.volume = volume;
vcp_register_param.cb = &vcs_cb;
}

uint8_t tester_init_vcs(void)
{
int err;

set_register_params(BT_AICS_MODE_MANUAL);

err = bt_vcp_vol_rend_register(&vcp_register_param);
if (err) {
return BTP_STATUS_FAILED;
}

err = bt_vcp_vol_rend_included_get(&included);
if (err) {
return BTP_STATUS_FAILED;
}

aics_server_instance.aics_cnt = included.aics_cnt;
aics_server_instance.aics = included.aics;

tester_register_command_handlers(BTP_SERVICE_ID_VCS, vcs_handlers,
ARRAY_SIZE(vcs_handlers));

Expand Down
Loading
Loading