Skip to content

Commit 1e5eeb8

Browse files
Michal Narajowskijhedberg
authored andcommitted
tests: bluetooth: tester: Add Opcodes Aggregator support
- Add entry for client and server in composition data. - Add Client commands to aggregate and send messages. MESH/SR/AGG/BV-02-C requires more key slots. Signed-off-by: Michal Narajowski <[email protected]>
1 parent 51ec246 commit 1e5eeb8

File tree

3 files changed

+119
-11
lines changed

3 files changed

+119
-11
lines changed

tests/bluetooth/tester/overlay-mesh.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ CONFIG_BT_MESH_GATT_PROXY=y
99
CONFIG_BT_MESH_LABEL_COUNT=2
1010
CONFIG_BT_MESH_SUBNET_COUNT=2
1111
CONFIG_BT_MESH_MODEL_GROUP_COUNT=2
12+
CONFIG_BT_MESH_OP_AGG_CLI=y
13+
CONFIG_BT_MESH_OP_AGG_SRV=y
14+
# PTS requires more key slots.
15+
# First one is implicitly taken by Device Key.
16+
CONFIG_BT_MESH_MODEL_KEY_COUNT=3
1217
CONFIG_BT_MESH_APP_KEY_COUNT=4
1318
CONFIG_BT_MESH_IV_UPDATE_TEST=y
1419
CONFIG_BT_MESH_CFG_CLI=y

tests/bluetooth/tester/src/btp/btp_mesh.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,16 @@ struct btp_mesh_models_metadata_get_rp {
835835
uint8_t data[0];
836836
} __packed;
837837

838+
#define BTP_MESH_OPCODES_AGGREGATOR_INIT 0x55
839+
struct btp_mesh_opcodes_aggregator_init_cmd {
840+
uint16_t net_idx;
841+
uint16_t app_idx;
842+
uint16_t dst;
843+
uint16_t elem_addr;
844+
} __packed;
845+
846+
#define BTP_MESH_OPCODES_AGGREGATOR_SEND 0x56
847+
838848
#define BTP_MESH_COMP_CHANGE_PREPARE 0x57
839849

840850
#define BTP_MESH_SET_COMP_ALT 0x58

tests/bluetooth/tester/src/btp_mesh.c

Lines changed: 104 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,12 @@ static struct bt_mesh_model root_models[] = {
634634
#if defined(CONFIG_BT_MESH_LARGE_COMP_DATA_CLI)
635635
BT_MESH_MODEL_LARGE_COMP_DATA_CLI(&lcd_cli),
636636
#endif
637+
#if defined(CONFIG_BT_MESH_OP_AGG_SRV)
638+
BT_MESH_MODEL_OP_AGG_SRV,
639+
#endif
640+
#if defined(CONFIG_BT_MESH_OP_AGG_CLI)
641+
BT_MESH_MODEL_OP_AGG_CLI,
642+
#endif
637643
#if defined(CONFIG_BT_MESH_RPR_CLI)
638644
BT_MESH_MODEL_RPR_CLI(&rpr_cli),
639645
#endif
@@ -2491,6 +2497,8 @@ static uint8_t config_model_app_bind(const void *cmd, uint16_t cmd_len,
24912497

24922498
LOG_DBG("");
24932499

2500+
bt_mesh_cfg_cli_timeout_set(5000);
2501+
24942502
err = bt_mesh_cfg_cli_mod_app_bind(sys_le16_to_cpu(cp->net_idx),
24952503
sys_le16_to_cpu(cp->address),
24962504
sys_le16_to_cpu(cp->elem_address),
@@ -2934,7 +2942,7 @@ static uint8_t health_fault_clear(const void *cmd, uint16_t cmd_len,
29342942
.addr = sys_le16_to_cpu(cp->address),
29352943
.app_idx = sys_le16_to_cpu(cp->app_idx),
29362944
};
2937-
uint8_t test_id;
2945+
uint8_t test_id = 0;
29382946
size_t fault_count = 16;
29392947
uint8_t faults[fault_count];
29402948
int err;
@@ -2944,7 +2952,20 @@ static uint8_t health_fault_clear(const void *cmd, uint16_t cmd_len,
29442952
if (cp->ack) {
29452953
err = bt_mesh_health_cli_fault_clear(&health_cli, &ctx,
29462954
sys_le16_to_cpu(cp->cid),
2947-
&test_id, faults,
2955+
#if defined(CONFIG_BT_MESH_OP_AGG_CLI)
2956+
bt_mesh_op_agg_cli_seq_is_started() ?
2957+
NULL :
2958+
#endif
2959+
&test_id,
2960+
#if defined(CONFIG_BT_MESH_OP_AGG_CLI)
2961+
bt_mesh_op_agg_cli_seq_is_started() ?
2962+
NULL :
2963+
#endif
2964+
faults,
2965+
#if defined(CONFIG_BT_MESH_OP_AGG_CLI)
2966+
bt_mesh_op_agg_cli_seq_is_started() ?
2967+
NULL :
2968+
#endif
29482969
&fault_count);
29492970
} else {
29502971
err = bt_mesh_health_cli_fault_clear_unack(&health_cli, &ctx,
@@ -2977,20 +2998,37 @@ static uint8_t health_fault_test(const void *cmd, uint16_t cmd_len,
29772998
};
29782999
size_t fault_count = 16;
29793000
uint8_t faults[fault_count];
2980-
uint8_t test_id;
2981-
uint16_t cid;
29823001
int err;
29833002

29843003
LOG_DBG("");
29853004

2986-
test_id = cp->test_id;
2987-
cid = sys_le16_to_cpu(cp->cid);
2988-
29893005
if (cp->ack) {
2990-
err = bt_mesh_health_cli_fault_test(&health_cli, &ctx, cid, test_id, faults,
3006+
err = bt_mesh_health_cli_fault_test(&health_cli, &ctx,
3007+
sys_le16_to_cpu(cp->cid),
3008+
#if defined(CONFIG_BT_MESH_OP_AGG_CLI)
3009+
bt_mesh_op_agg_cli_seq_is_started() ?
3010+
0 :
3011+
#endif
3012+
cp->test_id,
3013+
#if defined(CONFIG_BT_MESH_OP_AGG_CLI)
3014+
bt_mesh_op_agg_cli_seq_is_started() ?
3015+
NULL :
3016+
#endif
3017+
faults,
3018+
#if defined(CONFIG_BT_MESH_OP_AGG_CLI)
3019+
bt_mesh_op_agg_cli_seq_is_started() ?
3020+
NULL :
3021+
#endif
29913022
&fault_count);
3023+
#if defined(CONFIG_BT_MESH_OP_AGG_CLI)
3024+
if (bt_mesh_op_agg_cli_seq_is_started()) {
3025+
fault_count = 0;
3026+
}
3027+
#endif
29923028
} else {
2993-
err = bt_mesh_health_cli_fault_test_unack(&health_cli, &ctx, cid, test_id);
3029+
err = bt_mesh_health_cli_fault_test_unack(&health_cli, &ctx,
3030+
sys_le16_to_cpu(cp->cid),
3031+
cp->test_id);
29943032
}
29953033

29963034
if (err) {
@@ -3001,8 +3039,8 @@ static uint8_t health_fault_test(const void *cmd, uint16_t cmd_len,
30013039
if (cp->ack) {
30023040
struct btp_mesh_health_fault_test_rp *rp = rsp;
30033041

3004-
rp->test_id = test_id;
3005-
rp->cid = sys_cpu_to_le16(cid);
3042+
rp->test_id = cp->test_id;
3043+
rp->cid = cp->cid;
30063044
(void)memcpy(rp->faults, faults, fault_count);
30073045

30083046
*rsp_len = sizeof(*rp) + fault_count;
@@ -3051,6 +3089,10 @@ static uint8_t health_period_set(const void *cmd, uint16_t cmd_len,
30513089

30523090
if (cp->ack) {
30533091
err = bt_mesh_health_cli_period_set(&health_cli, &ctx, cp->divisor,
3092+
#if defined(CONFIG_BT_MESH_OP_AGG_CLI)
3093+
bt_mesh_op_agg_cli_seq_is_started() ?
3094+
NULL :
3095+
#endif
30543096
&updated_divisor);
30553097
} else {
30563098
err = bt_mesh_health_cli_period_set_unack(&health_cli, &ctx, cp->divisor);
@@ -3112,6 +3154,10 @@ static uint8_t health_attention_set(const void *cmd, uint16_t cmd_len,
31123154

31133155
if (cp->ack) {
31143156
err = bt_mesh_health_cli_attention_set(&health_cli, &ctx, cp->attention,
3157+
#if defined(CONFIG_BT_MESH_OP_AGG_CLI)
3158+
bt_mesh_op_agg_cli_seq_is_started() ?
3159+
NULL :
3160+
#endif
31153161
&updated_attention);
31163162
} else {
31173163
err = bt_mesh_health_cli_attention_set_unack(&health_cli, &ctx, cp->attention);
@@ -3133,6 +3179,41 @@ static uint8_t health_attention_set(const void *cmd, uint16_t cmd_len,
31333179
return BTP_STATUS_SUCCESS;
31343180
}
31353181

3182+
#if defined(CONFIG_BT_MESH_OP_AGG_CLI)
3183+
static uint8_t opcodes_aggregator_init(const void *cmd, uint16_t cmd_len,
3184+
void *rsp, uint16_t *rsp_len)
3185+
{
3186+
const struct btp_mesh_opcodes_aggregator_init_cmd *cp = cmd;
3187+
int err;
3188+
3189+
LOG_DBG("");
3190+
3191+
err = bt_mesh_op_agg_cli_seq_start(cp->net_idx, cp->app_idx, cp->dst, cp->elem_addr);
3192+
if (err) {
3193+
LOG_ERR("Failed to init Opcodes Aggregator Context (err %d)", err);
3194+
return BTP_STATUS_FAILED;
3195+
}
3196+
3197+
return BTP_STATUS_SUCCESS;
3198+
}
3199+
3200+
static uint8_t opcodes_aggregator_send(const void *cmd, uint16_t cmd_len,
3201+
void *rsp, uint16_t *rsp_len)
3202+
{
3203+
int err;
3204+
3205+
LOG_DBG("");
3206+
3207+
err = bt_mesh_op_agg_cli_seq_send();
3208+
if (err) {
3209+
LOG_ERR("Failed to send Opcodes Aggregator message (err %d)", err);
3210+
return BTP_STATUS_FAILED;
3211+
}
3212+
3213+
return BTP_STATUS_SUCCESS;
3214+
}
3215+
#endif
3216+
31363217
#if defined(CONFIG_BT_MESH_RPR_CLI)
31373218
static uint8_t rpr_scan_start(const void *cmd, uint16_t cmd_len,
31383219
void *rsp, uint16_t *rsp_len)
@@ -4426,6 +4507,18 @@ static const struct btp_handler handlers[] = {
44264507
.expect_len = sizeof(struct btp_mesh_models_metadata_get_cmd),
44274508
.func = models_metadata_get
44284509
},
4510+
#endif
4511+
#if defined(CONFIG_BT_MESH_OP_AGG_CLI)
4512+
{
4513+
.opcode = BTP_MESH_OPCODES_AGGREGATOR_INIT,
4514+
.expect_len = sizeof(struct btp_mesh_opcodes_aggregator_init_cmd),
4515+
.func = opcodes_aggregator_init
4516+
},
4517+
{
4518+
.opcode = BTP_MESH_OPCODES_AGGREGATOR_SEND,
4519+
.expect_len = 0,
4520+
.func = opcodes_aggregator_send
4521+
},
44294522
#endif
44304523
{
44314524
.opcode = BTP_MESH_COMP_CHANGE_PREPARE,

0 commit comments

Comments
 (0)