mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ble_mesh: stack: Move client role set to the msg function
This commit is contained in:
parent
964f372d58
commit
bc19eb2506
@ -416,6 +416,7 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BEACON_GET:
|
||||
@ -495,6 +496,7 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BEACON_SET:
|
||||
@ -623,7 +625,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_config_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_cfg_client_cb_param_t cb = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@ -635,14 +636,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE: {
|
||||
cb.params = arg->cfg_client_get_state.params;
|
||||
|
||||
role_param.model = (struct bt_mesh_model *)cb.params->model;
|
||||
role_param.role = cb.params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
|
||||
cb.error_code = btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params,
|
||||
arg->cfg_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
@ -652,14 +645,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE: {
|
||||
cb.params = arg->cfg_client_set_state.params;
|
||||
|
||||
role_param.model = (struct bt_mesh_model *)cb.params->model;
|
||||
role_param.role = cb.params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
|
||||
cb.error_code = btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params,
|
||||
arg->cfg_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
|
@ -454,7 +454,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
btc_ble_mesh_generic_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_generic_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@ -466,14 +465,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE: {
|
||||
params = arg->generic_client_get_state.params;
|
||||
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -482,6 +473,7 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->generic_client_get_state.params;
|
||||
cb.error_code = bt_mesh_generic_client_get_state(&common, arg->generic_client_get_state.get_state);
|
||||
@ -493,14 +485,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE: {
|
||||
params = arg->generic_client_set_state.params;
|
||||
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -509,6 +493,7 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->generic_client_set_state.params;
|
||||
cb.error_code = bt_mesh_generic_client_set_state(&common, arg->generic_client_set_state.set_state);
|
||||
|
@ -335,6 +335,7 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
|
||||
@ -369,6 +370,7 @@ static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
|
||||
@ -399,7 +401,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_health_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_health_client_cb_param_t cb = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@ -411,14 +412,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: {
|
||||
cb.params = arg->health_client_get_state.params;
|
||||
|
||||
role_param.model = (struct bt_mesh_model *)cb.params->model;
|
||||
role_param.role = cb.params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
|
||||
cb.error_code = btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
|
||||
arg->health_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
@ -429,14 +422,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE: {
|
||||
cb.params = arg->health_client_set_state.params;
|
||||
|
||||
role_param.model = (struct bt_mesh_model *)cb.params->model;
|
||||
role_param.role = cb.params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
|
||||
cb.error_code = btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
|
||||
arg->health_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
|
@ -298,7 +298,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
|
||||
btc_ble_mesh_lighting_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_light_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@ -310,14 +309,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE: {
|
||||
params = arg->light_client_get_state.params;
|
||||
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -326,6 +317,7 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->light_client_get_state.params;
|
||||
cb.error_code = bt_mesh_light_client_get_state(&common, arg->light_client_get_state.get_state);
|
||||
@ -337,14 +329,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: {
|
||||
params = arg->light_client_set_state.params;
|
||||
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -353,6 +337,7 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->light_client_set_state.params;
|
||||
cb.error_code = bt_mesh_light_client_set_state(&common, arg->light_client_set_state.set_state);
|
||||
|
@ -1978,11 +1978,11 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_MODEL_PUBLISH: {
|
||||
if (arg->model_publish.device_role == PROVISIONER) {
|
||||
bt_mesh_role_param_t common = {0};
|
||||
common.model = (struct bt_mesh_model *)(arg->model_publish.model);
|
||||
common.role = arg->model_publish.device_role;
|
||||
if (bt_mesh_set_client_model_role(&common)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
/* Currently Provisioner only supports client model */
|
||||
err = bt_mesh_set_client_model_role((struct bt_mesh_model *)arg->model_publish.model,
|
||||
arg->model_publish.device_role);
|
||||
if (err) {
|
||||
BT_ERR("Failed to set client role");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2008,7 +2008,6 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND: {
|
||||
bt_mesh_role_param_t common = {0};
|
||||
/* arg->model_send.length contains opcode & message, plus extra 4-bytes TransMIC */
|
||||
struct net_buf_simple *buf = bt_mesh_alloc_buf(arg->model_send.length + BLE_MESH_MIC_SHORT);
|
||||
if (!buf) {
|
||||
@ -2016,12 +2015,6 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
net_buf_simple_add_mem(buf, arg->model_send.data, arg->model_send.length);
|
||||
common.model = (struct bt_mesh_model *)(arg->model_send.model);
|
||||
common.role = arg->model_send.device_role;
|
||||
if (bt_mesh_set_client_model_role(&common)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
bt_mesh_client_common_param_t param = {
|
||||
.opcode = arg->model_send.opcode,
|
||||
.model = (struct bt_mesh_model *)arg->model_send.model,
|
||||
@ -2032,6 +2025,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
|
||||
.ctx.send_ttl = arg->model_send.ctx->send_ttl,
|
||||
.ctx.srv_send = false,
|
||||
.msg_timeout = arg->model_send.msg_timeout,
|
||||
.msg_role = arg->model_send.device_role,
|
||||
};
|
||||
err = bt_mesh_client_send_msg(¶m, buf, arg->model_send.need_rsp,
|
||||
btc_ble_mesh_client_model_timeout_cb);
|
||||
|
@ -536,7 +536,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
||||
btc_ble_mesh_sensor_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_sensor_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@ -548,14 +547,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE: {
|
||||
params = arg->sensor_client_get_state.params;
|
||||
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -564,6 +555,7 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->sensor_client_get_state.params;
|
||||
cb.error_code = bt_mesh_sensor_client_get_state(&common, arg->sensor_client_get_state.get_state);
|
||||
@ -575,14 +567,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE: {
|
||||
params = arg->sensor_client_set_state.params;
|
||||
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -591,6 +575,7 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->sensor_client_set_state.params;
|
||||
cb.error_code = bt_mesh_sensor_client_set_state(&common, arg->sensor_client_set_state.set_state);
|
||||
|
@ -300,7 +300,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
esp_ble_mesh_client_common_param_t *params = NULL;
|
||||
esp_ble_mesh_time_scene_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@ -312,14 +311,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE: {
|
||||
params = arg->time_scene_client_get_state.params;
|
||||
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -328,6 +319,7 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->time_scene_client_get_state.params;
|
||||
cb.error_code = bt_mesh_time_scene_client_get_state(&common, arg->time_scene_client_get_state.get_state);
|
||||
@ -339,14 +331,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE: {
|
||||
params = arg->time_scene_client_set_state.params;
|
||||
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -355,6 +339,7 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->time_scene_client_set_state.params;
|
||||
cb.error_code = bt_mesh_time_scene_client_set_state(&common, arg->time_scene_client_set_state.set_state);
|
||||
|
@ -282,6 +282,11 @@ int bt_mesh_client_send_msg(bt_mesh_client_common_param_t *param,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (bt_mesh_set_client_model_role(param->model, param->msg_role)) {
|
||||
BT_ERR("Failed to set client role");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (!need_ack) {
|
||||
/* If this is an unack message, send it directly. */
|
||||
return bt_mesh_model_send(param->model, ¶m->ctx, msg, param->cb, param->cb_data);
|
||||
@ -499,43 +504,26 @@ int bt_mesh_client_clear_list(void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_set_client_model_role(bt_mesh_role_param_t *common)
|
||||
int bt_mesh_set_client_model_role(struct bt_mesh_model *model, u8_t role)
|
||||
{
|
||||
bt_mesh_client_user_data_t *client = NULL;
|
||||
|
||||
if (!common || !common->model || !common->model->user_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
if (!model) {
|
||||
BT_ERR("Invalid client model");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
client = (bt_mesh_client_user_data_t *)common->model->user_data;
|
||||
|
||||
switch (common->role) {
|
||||
#if CONFIG_BLE_MESH_NODE
|
||||
case NODE:
|
||||
/* no matter if provisioner is enabled/disabled , node role can be used to send messages */
|
||||
client->msg_role = NODE;
|
||||
break;
|
||||
#endif
|
||||
#if CONFIG_BLE_MESH_PROVISIONER
|
||||
case PROVISIONER:
|
||||
/* if provisioner is not enabled, provisioner role can't be used to send messages */
|
||||
if (!bt_mesh_is_provisioner_en()) {
|
||||
BT_ERR("Provisioner is disabled");
|
||||
return -EINVAL;
|
||||
}
|
||||
client->msg_role = PROVISIONER;
|
||||
break;
|
||||
#endif
|
||||
#if CONFIG_BLE_MESH_FAST_PROV
|
||||
case FAST_PROV:
|
||||
client->msg_role = FAST_PROV;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
BT_WARN("Unknown model role 0x%02x", common->role);
|
||||
client = (bt_mesh_client_user_data_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("Invalid client user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (role >= ROLE_NVAL) {
|
||||
BT_ERR("Invalid client role 0x%02x", role);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
client->msg_role = role;
|
||||
return 0;
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ typedef struct {
|
||||
struct bt_mesh_model *model; /* Pointer to the client model */
|
||||
struct bt_mesh_msg_ctx ctx; /* Message context */
|
||||
s32_t msg_timeout; /* Time to get corresponding response */
|
||||
u8_t msg_role; /* Role (Node/Provisioner) of the device */
|
||||
const struct bt_mesh_send_cb *cb; /* User defined callback function */
|
||||
void *cb_data; /* User defined callback value */
|
||||
} bt_mesh_client_common_param_t;
|
||||
@ -112,19 +113,15 @@ int bt_mesh_client_free_node(bt_mesh_client_node_t *node);
|
||||
|
||||
int bt_mesh_client_clear_list(void *data);
|
||||
|
||||
typedef struct {
|
||||
struct bt_mesh_model *model; /* The client model structure */
|
||||
u8_t role; /* Role of the device - Node/Provisioner */
|
||||
} bt_mesh_role_param_t;
|
||||
|
||||
/**
|
||||
* @brief This function copies node_index for stack internal use.
|
||||
* @brief Set role of the client model for internal use.
|
||||
*
|
||||
* @param[in] common: Pointer to the bt_mesh_role_param_t structure
|
||||
* @param[in] model: Pointer to the client model
|
||||
* @param[in] role: Role of the device
|
||||
*
|
||||
* @return Zero - success, otherwise - fail
|
||||
*/
|
||||
int bt_mesh_set_client_model_role(bt_mesh_role_param_t *common);
|
||||
int bt_mesh_set_client_model_role(struct bt_mesh_model *model, u8_t role);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user