Skip to content

Commit

Permalink
tests: bluetooth: tester: Move bt_mesh_init call to BTP_MESH_INIT cmd
Browse files Browse the repository at this point in the history
In some RPR tests we need to pass alternative composition data when
testing CDP128. When bt_mesh_init is called from mesh service
registration callback, we can't pass any arguments. Therefore we need
to move bt_mesh_init call out from mesh service registration to
BTP_MESH_INIT command.

Signed-off-by: Pavel Vasilyev <[email protected]>
  • Loading branch information
PavelVPV authored and carlescufi committed Oct 5, 2023
1 parent 4b0e730 commit 2445e55
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
4 changes: 4 additions & 0 deletions tests/bluetooth/tester/src/btp/btp_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ struct btp_mesh_provision_node_cmd_v2 {
} __packed;

#define BTP_MESH_INIT 0x04
struct btp_mesh_init_cmd {
bool comp_alt;
} __packed;

#define BTP_MESH_RESET 0x05
#define BTP_MESH_INPUT_NUMBER 0x06
struct btp_mesh_input_number_cmd {
Expand Down
32 changes: 17 additions & 15 deletions tests/bluetooth/tester/src/btp_mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1242,8 +1242,24 @@ static uint8_t provision_adv(const void *cmd, uint16_t cmd_len,
static uint8_t init(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
{
const struct btp_mesh_init_cmd *cp = cmd;
int err;

if (!cp->comp_alt) {
LOG_WRN("Loading default comp data");
err = bt_mesh_init(&prov, &comp);
} else {
LOG_WRN("Loading alternative comp data");
#ifdef CONFIG_BT_MESH_LARGE_COMP_DATA_SRV
health_srv.metadata = health_srv_meta_alt;
#endif
err = bt_mesh_init(&prov, &comp_alt);
}

if (err) {
return BTP_STATUS_FAILED;
}

LOG_DBG("");

if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
Expand Down Expand Up @@ -4403,7 +4419,7 @@ static const struct btp_handler handlers[] = {
},
{
.opcode = BTP_MESH_INIT,
.expect_len = 0,
.expect_len = sizeof(struct btp_mesh_init_cmd),
.func = init,
},
{
Expand Down Expand Up @@ -5208,26 +5224,12 @@ BT_MESH_LPN_CB_DEFINE(lpn_cb) = {

uint8_t tester_init_mesh(void)
{
int err;

if (IS_ENABLED(CONFIG_BT_TESTING)) {
bt_test_cb_register(&bt_test_cb);
}

tester_register_command_handlers(BTP_SERVICE_ID_MESH, handlers,
ARRAY_SIZE(handlers));
if (default_comp) {
err = bt_mesh_init(&prov, &comp);
} else {
#ifdef CONFIG_BT_MESH_LARGE_COMP_DATA_SRV
health_srv.metadata = health_srv_meta_alt;
#endif
err = bt_mesh_init(&prov, &comp_alt);
}

if (err) {
return BTP_STATUS_FAILED;
}

return BTP_STATUS_SUCCESS;
}
Expand Down

0 comments on commit 2445e55

Please sign in to comment.