Skip to content

Commit 74680d5

Browse files
Frodevankoffes
authored andcommitted
[nrf fromtree] tests: bluetooth: tester: Fix CSIS/SR/SP/BV-07-C
This particular test-case requires bttester to respond with an OOB procedure SIRK only error. To enable this response, the BTP command to set SIRK mode has been extended with a new selection. Signed-off-by: Frode van der Meeren <frode.vandermeeren@nordicsemi.no> (cherry picked from commit 03bfafe)
1 parent 997c2c1 commit 74680d5

File tree

3 files changed

+35
-19
lines changed

3 files changed

+35
-19
lines changed

tests/bluetooth/tester/src/audio/btp/btp_csis.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#include <zephyr/bluetooth/audio/csip.h>
1313

1414
/* CSIS commands */
15+
#define BTP_CSIS_SIRK_TYPE_PLAINTEXT 0x00
16+
#define BTP_CSIS_SIRK_TYPE_ENCRYPTED 0x01
17+
#define BTP_CSIS_SIRK_TYPE_OOB_ONLY 0x02
18+
1519
#define BTP_CSIS_READ_SUPPORTED_COMMANDS 0x01
1620
struct btp_csis_read_supported_commands_rp {
1721
uint8_t data[0];
@@ -33,7 +37,7 @@ struct btp_csis_get_member_rsi_rp {
3337
uint8_t rsi[BT_CSIP_RSI_SIZE];
3438
} __packed;
3539

36-
#define BTP_CSIS_ENC_SIRK_TYPE 0x04
37-
struct btp_csis_sirk_type_cmd {
38-
uint8_t encrypted;
40+
#define BTP_CSIS_SET_SIRK_TYPE 0x04
41+
struct btp_csis_sirk_set_type_cmd {
42+
uint8_t type;
3943
} __packed;

tests/bluetooth/tester/src/audio/btp_csis.c

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_BTTESTER_LOG_LEVEL);
2424
#define BTP_STATUS_VAL(err) (err) ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS
2525

2626
static struct bt_csip_set_member_svc_inst *csis_svc_inst;
27-
static bool enc_sirk;
27+
static uint8_t sirk_read_response;
2828

2929
static uint8_t csis_supported_commands(const void *cmd, uint16_t cmd_len,
3030
void *rsp, uint16_t *rsp_len)
@@ -65,13 +65,27 @@ static uint8_t csis_get_member_rsi(const void *cmd, uint16_t cmd_len,
6565
return BTP_STATUS_VAL(err);
6666
}
6767

68-
static uint8_t csis_sirk_type(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len)
68+
static uint8_t csis_set_sirk_type(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len)
6969
{
70-
const struct btp_csis_sirk_type_cmd *cp = cmd;
71-
72-
enc_sirk = cp->encrypted != 0U;
73-
74-
LOG_DBG("SIRK type: %s", enc_sirk ? "encrypted" : "plain text");
70+
const struct btp_csis_sirk_set_type_cmd *cp = cmd;
71+
72+
switch (cp->type) {
73+
case BTP_CSIS_SIRK_TYPE_PLAINTEXT:
74+
LOG_DBG("SIRK type: plain text");
75+
sirk_read_response = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT;
76+
break;
77+
case BTP_CSIS_SIRK_TYPE_ENCRYPTED:
78+
LOG_DBG("SIRK type: encrypted");
79+
sirk_read_response = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT_ENC;
80+
break;
81+
case BTP_CSIS_SIRK_TYPE_OOB_ONLY:
82+
LOG_DBG("SIRK type: OOB procedure only");
83+
sirk_read_response = BT_CSIP_READ_SIRK_REQ_RSP_OOB_ONLY;
84+
break;
85+
default:
86+
LOG_ERR("Unknown SIRK type: %u", cp->type);
87+
return BTP_STATUS_FAILED;
88+
}
7589

7690
return BTP_STATUS_SUCCESS;
7791
}
@@ -94,9 +108,9 @@ static const struct btp_handler csis_handlers[] = {
94108
.func = csis_get_member_rsi,
95109
},
96110
{
97-
.opcode = BTP_CSIS_ENC_SIRK_TYPE,
98-
.expect_len = sizeof(struct btp_csis_sirk_type_cmd),
99-
.func = csis_sirk_type,
111+
.opcode = BTP_CSIS_SET_SIRK_TYPE,
112+
.expect_len = sizeof(struct btp_csis_sirk_set_type_cmd),
113+
.func = csis_set_sirk_type,
100114
},
101115
};
102116

@@ -108,11 +122,7 @@ static void lock_changed_cb(struct bt_conn *conn, struct bt_csip_set_member_svc_
108122

109123
static uint8_t sirk_read_cb(struct bt_conn *conn, struct bt_csip_set_member_svc_inst *svc_inst)
110124
{
111-
if (enc_sirk) {
112-
return BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT_ENC;
113-
} else {
114-
return BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT;
115-
}
125+
return sirk_read_response;
116126
}
117127

118128
static struct bt_csip_set_member_cb csis_cb = {
@@ -132,6 +142,8 @@ uint8_t tester_init_csis(void)
132142
};
133143
int err = bt_csip_set_member_register(&register_params, &csis_svc_inst);
134144

145+
sirk_read_response = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT;
146+
135147
tester_register_command_handlers(BTP_SERVICE_ID_CSIS, csis_handlers,
136148
ARRAY_SIZE(csis_handlers));
137149

tests/bsim/bluetooth/tester/src/bsim_btp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ static bool is_valid_csis_packet_len(const struct btp_hdr *hdr, struct net_buf_s
12361236
return buf_simple->len == 0U;
12371237
case BTP_CSIS_GET_MEMBER_RSI:
12381238
return buf_simple->len == sizeof(struct btp_csis_get_member_rsi_rp);
1239-
case BTP_CSIS_ENC_SIRK_TYPE:
1239+
case BTP_CSIS_SET_SIRK_TYPE:
12401240
return buf_simple->len == 0U;
12411241

12421242
/* No events */

0 commit comments

Comments
 (0)