tests: bluetooth: tester: Move bt_mesh_init call to BTP_MESH_INIT cmd
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 <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
parent
4b0e730fb1
commit
2445e55cd4
@ -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 {
|
||||
|
||||
@ -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)) {
|
||||
@ -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,
|
||||
},
|
||||
{
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user