From b3bc60183da7d219ea383981ba8acc67d86b299f Mon Sep 17 00:00:00 2001 From: lly Date: Mon, 2 Sep 2019 12:06:20 +0800 Subject: [PATCH] ble_mesh: rename ble mesh client model variables and functions --- .../btc/btc_ble_mesh_config_model.c | 4 +- .../btc/btc_ble_mesh_generic_model.c | 6 +- .../btc/btc_ble_mesh_health_model.c | 4 +- .../btc/btc_ble_mesh_lighting_model.c | 6 +- .../bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c | 54 +++++++------- .../btc/btc_ble_mesh_sensor_model.c | 6 +- .../btc/btc_ble_mesh_time_scene_model.c | 6 +- components/bt/esp_ble_mesh/mesh_core/access.c | 4 +- .../bt/esp_ble_mesh/mesh_core/cfg_cli.c | 2 +- .../bt/esp_ble_mesh/mesh_core/health_cli.c | 4 +- .../esp_ble_mesh/mesh_core/include/cfg_cli.h | 4 +- .../mesh_core/include/health_cli.h | 6 +- .../bt/esp_ble_mesh/mesh_core/transport.c | 2 +- .../mesh_models/client/client_common.c | 35 +++++---- .../mesh_models/client/generic_client.c | 10 +-- .../client/include/client_common.h | 73 +++++++++++-------- .../client/include/generic_client.h | 24 +++--- .../client/include/lighting_client.h | 18 ++--- .../client/include/sensor_client.h | 8 +- .../client/include/time_scene_client.h | 14 ++-- .../mesh_models/client/lighting_client.c | 10 +-- .../mesh_models/client/sensor_client.c | 8 +- .../mesh_models/client/time_scene_client.c | 10 +-- .../mesh_models/common/include/mesh_common.h | 2 +- .../mesh_models/common/mesh_common.c | 6 +- 25 files changed, 168 insertions(+), 158 deletions(-) diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c index 0937721bb2..30257a5c6a 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c @@ -389,7 +389,7 @@ void btc_mesh_cfg_client_call_handler(btc_msg_t *msg) cfg_client_cb.params = arg->cfg_client_get_state.params; role_param.model = (struct bt_mesh_model *)cfg_client_cb.params->model; role_param.role = cfg_client_cb.params->msg_role; - if (bt_mesh_set_model_role(&role_param)) { + if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } @@ -405,7 +405,7 @@ void btc_mesh_cfg_client_call_handler(btc_msg_t *msg) cfg_client_cb.params = arg->cfg_client_set_state.params; role_param.model = (struct bt_mesh_model *)cfg_client_cb.params->model; role_param.role = cfg_client_cb.params->msg_role; - if (bt_mesh_set_model_role(&role_param)) { + if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c index 761fbeebe5..fc0854a42a 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c @@ -443,7 +443,7 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg) esp_ble_mesh_generic_client_cb_param_t generic_client_cb = {0}; esp_ble_mesh_client_common_param_t *params = NULL; btc_ble_mesh_generic_client_args_t *arg = NULL; - struct bt_mesh_common_param common = {0}; + bt_mesh_client_common_param_t common = {0}; bt_mesh_role_param_t role_param = {0}; if (!msg || !msg->arg) { @@ -458,7 +458,7 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg) 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_model_role(&role_param)) { + if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } @@ -487,7 +487,7 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg) 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_model_role(&role_param)) { + if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c index 1f6d88340b..f5a176af88 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c @@ -489,7 +489,7 @@ void btc_mesh_health_client_call_handler(btc_msg_t *msg) health_client_cb.params = arg->health_client_get_state.params; role_param.model = (struct bt_mesh_model *)health_client_cb.params->model; role_param.role = health_client_cb.params->msg_role; - if (bt_mesh_set_model_role(&role_param)) { + if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } @@ -506,7 +506,7 @@ void btc_mesh_health_client_call_handler(btc_msg_t *msg) health_client_cb.params = arg->health_client_set_state.params; role_param.model = (struct bt_mesh_model *)health_client_cb.params->model; role_param.role = health_client_cb.params->msg_role; - if (bt_mesh_set_model_role(&role_param)) { + if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c index d07dba47a0..9a1b57edf3 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c @@ -283,7 +283,7 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg) esp_ble_mesh_light_client_cb_param_t light_client_cb = {0}; esp_ble_mesh_client_common_param_t *params = NULL; btc_ble_mesh_light_client_args_t *arg = NULL; - struct bt_mesh_common_param common = {0}; + bt_mesh_client_common_param_t common = {0}; bt_mesh_role_param_t role_param = {0}; if (!msg || !msg->arg) { @@ -298,7 +298,7 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg) 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_model_role(&role_param)) { + if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } @@ -327,7 +327,7 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg) 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_model_role(&role_param)) { + if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c index e1517d6bb3..4d11458dc3 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c @@ -299,8 +299,8 @@ static void btc_ble_mesh_client_model_op_cb(struct bt_mesh_model *model, struct net_buf_simple *buf) { esp_ble_mesh_model_cb_param_t mesh_param = {0}; - bt_mesh_client_common_t *client_param = NULL; - bt_mesh_internal_data_t *data = NULL; + bt_mesh_client_user_data_t *client_param = NULL; + bt_mesh_client_internal_data_t *data = NULL; bt_mesh_client_node_t *node = NULL; btc_msg_t msg = {0}; bt_status_t ret; @@ -310,14 +310,14 @@ static void btc_ble_mesh_client_model_op_cb(struct bt_mesh_model *model, return; } - client_param = (bt_mesh_client_common_t *)model->user_data; - data = (bt_mesh_internal_data_t *)client_param->internal_data; + client_param = (bt_mesh_client_user_data_t *)model->user_data; + data = (bt_mesh_client_internal_data_t *)client_param->internal_data; if (!data) { LOG_ERROR("%s, Client internal_data is NULL", __func__); return; } - node = bt_mesh_is_model_message_publish(model, ctx, buf, false); + node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, false); if (node == NULL) { msg.act = ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT; mesh_param.client_recv_publish_msg.opcode = mesh_opcode; @@ -594,8 +594,8 @@ static void btc_prov_register_complete_cb(int err_code) static void btc_client_model_timeout_cb(struct k_work *work) { esp_ble_mesh_model_cb_param_t mesh_param = {0}; - bt_mesh_client_common_t *client_param = NULL; - bt_mesh_internal_data_t *data = NULL; + bt_mesh_client_user_data_t *client_param = NULL; + bt_mesh_client_internal_data_t *data = NULL; bt_mesh_client_node_t *node = NULL; btc_msg_t msg = {0}; bt_status_t ret; @@ -606,8 +606,8 @@ static void btc_client_model_timeout_cb(struct k_work *work) return; } - client_param = (bt_mesh_client_common_t *)node->ctx.model->user_data; - data = (bt_mesh_internal_data_t *)client_param->internal_data; + client_param = (bt_mesh_client_user_data_t *)node->ctx.model->user_data; + data = (bt_mesh_client_internal_data_t *)client_param->internal_data; if (!data) { LOG_ERROR("%s, Client internal_data is NULL", __func__); return; @@ -986,7 +986,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_GEN_ONOFF_CLI: { model->op = ((esp_ble_mesh_model_op_t *)gen_onoff_cli_op); - bt_mesh_gen_onoff_cli_t *cli = (bt_mesh_gen_onoff_cli_t *)model->user_data; + bt_mesh_gen_onoff_client_t *cli = (bt_mesh_gen_onoff_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_generic_client_publish_callback; } @@ -994,7 +994,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_GEN_LEVEL_CLI: { model->op = ((esp_ble_mesh_model_op_t *)gen_level_cli_op); - bt_mesh_gen_level_cli_t *cli = (bt_mesh_gen_level_cli_t *)model->user_data; + bt_mesh_gen_level_client_t *cli = (bt_mesh_gen_level_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_generic_client_publish_callback; } @@ -1002,7 +1002,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI: { model->op = ((esp_ble_mesh_model_op_t *)gen_def_trans_time_cli_op); - bt_mesh_gen_def_trans_time_cli_t *cli = (bt_mesh_gen_def_trans_time_cli_t *)model->user_data; + bt_mesh_gen_def_trans_time_client_t *cli = (bt_mesh_gen_def_trans_time_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_generic_client_publish_callback; } @@ -1010,7 +1010,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI: { model->op = ((esp_ble_mesh_model_op_t *)gen_power_onoff_cli_op); - bt_mesh_gen_power_onoff_cli_t *cli = (bt_mesh_gen_power_onoff_cli_t *)model->user_data; + bt_mesh_gen_power_onoff_client_t *cli = (bt_mesh_gen_power_onoff_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_generic_client_publish_callback; } @@ -1018,7 +1018,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI: { model->op = ((esp_ble_mesh_model_op_t *)gen_power_level_cli_op); - bt_mesh_gen_power_level_cli_t *cli = (bt_mesh_gen_power_level_cli_t *)model->user_data; + bt_mesh_gen_power_level_client_t *cli = (bt_mesh_gen_power_level_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_generic_client_publish_callback; } @@ -1026,7 +1026,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_GEN_BATTERY_CLI: { model->op = ((esp_ble_mesh_model_op_t *)gen_battery_cli_op); - bt_mesh_gen_battery_cli_t *cli = (bt_mesh_gen_battery_cli_t *)model->user_data; + bt_mesh_gen_battery_client_t *cli = (bt_mesh_gen_battery_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_generic_client_publish_callback; } @@ -1034,7 +1034,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_GEN_LOCATION_CLI: { model->op = ((esp_ble_mesh_model_op_t *)gen_location_cli_op); - bt_mesh_gen_location_cli_t *cli = (bt_mesh_gen_location_cli_t *)model->user_data; + bt_mesh_gen_location_client_t *cli = (bt_mesh_gen_location_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_generic_client_publish_callback; } @@ -1042,7 +1042,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_GEN_PROP_CLI: { model->op = ((esp_ble_mesh_model_op_t *)gen_property_cli_op); - bt_mesh_gen_property_cli_t *cli = (bt_mesh_gen_property_cli_t *)model->user_data; + bt_mesh_gen_property_client_t *cli = (bt_mesh_gen_property_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_generic_client_publish_callback; } @@ -1050,7 +1050,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI: { model->op = ((esp_ble_mesh_model_op_t *)light_lightness_cli_op); - bt_mesh_light_lightness_cli_t *cli = (bt_mesh_light_lightness_cli_t *)model->user_data; + bt_mesh_light_lightness_client_t *cli = (bt_mesh_light_lightness_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_light_client_publish_callback; } @@ -1058,7 +1058,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_LIGHT_CTL_CLI: { model->op = ((esp_ble_mesh_model_op_t *)light_ctl_cli_op); - bt_mesh_light_ctl_cli_t *cli = (bt_mesh_light_ctl_cli_t *)model->user_data; + bt_mesh_light_ctl_client_t *cli = (bt_mesh_light_ctl_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_light_client_publish_callback; } @@ -1066,7 +1066,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_LIGHT_HSL_CLI: { model->op = ((esp_ble_mesh_model_op_t *)light_hsl_cli_op); - bt_mesh_light_hsl_cli_t *cli = (bt_mesh_light_hsl_cli_t *)model->user_data; + bt_mesh_light_hsl_client_t *cli = (bt_mesh_light_hsl_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_light_client_publish_callback; } @@ -1074,7 +1074,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_LIGHT_XYL_CLI: { model->op = ((esp_ble_mesh_model_op_t *)light_xyl_cli_op); - bt_mesh_light_xyl_cli_t *cli = (bt_mesh_light_xyl_cli_t *)model->user_data; + bt_mesh_light_xyl_client_t *cli = (bt_mesh_light_xyl_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_light_client_publish_callback; } @@ -1082,7 +1082,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_LIGHT_LC_CLI: { model->op = ((esp_ble_mesh_model_op_t *)light_lc_cli_op); - bt_mesh_light_lc_cli_t *cli = (bt_mesh_light_lc_cli_t *)model->user_data; + bt_mesh_light_lc_client_t *cli = (bt_mesh_light_lc_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_light_client_publish_callback; } @@ -1098,7 +1098,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_TIME_CLI: { model->op = ((esp_ble_mesh_model_op_t *)time_cli_op); - bt_mesh_time_scene_client_t *cli = (bt_mesh_time_scene_client_t *)model->user_data; + bt_mesh_time_client_t *cli = (bt_mesh_time_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_time_scene_client_publish_callback; } @@ -1106,7 +1106,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_SCENE_CLI: { model->op = ((esp_ble_mesh_model_op_t *)scene_cli_op); - bt_mesh_time_scene_client_t *cli = (bt_mesh_time_scene_client_t *)model->user_data; + bt_mesh_scene_client_t *cli = (bt_mesh_scene_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_time_scene_client_publish_callback; } @@ -1114,7 +1114,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_SCHEDULER_CLI: { model->op = ((esp_ble_mesh_model_op_t *)scheduler_cli_op); - bt_mesh_time_scene_client_t *cli = (bt_mesh_time_scene_client_t *)model->user_data; + bt_mesh_scheduler_client_t *cli = (bt_mesh_scheduler_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_mesh_time_scene_client_publish_callback; } @@ -1429,7 +1429,7 @@ void btc_mesh_model_call_handler(btc_msg_t *msg) 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_model_role(&common)) { + if (bt_mesh_set_client_model_role(&common)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } @@ -1467,7 +1467,7 @@ void btc_mesh_model_call_handler(btc_msg_t *msg) arg->model_send.ctx->srv_send = false; common.model = (struct bt_mesh_model *)(arg->model_send.model); common.role = arg->model_send.device_role; - if (bt_mesh_set_model_role(&common)) { + if (bt_mesh_set_client_model_role(&common)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c index b9f3de6bde..df267023a7 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c @@ -534,7 +534,7 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg) esp_ble_mesh_sensor_client_cb_param_t sensor_client_cb = {0}; esp_ble_mesh_client_common_param_t *params = NULL; btc_ble_mesh_sensor_client_args_t *arg = NULL; - struct bt_mesh_common_param common = {0}; + bt_mesh_client_common_param_t common = {0}; bt_mesh_role_param_t role_param = {0}; if (!msg || !msg->arg) { @@ -549,7 +549,7 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg) 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_model_role(&role_param)) { + if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } @@ -578,7 +578,7 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg) 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_model_role(&role_param)) { + if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c index 4f03567dc9..907c1430ff 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c @@ -285,7 +285,7 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg) esp_ble_mesh_time_scene_client_cb_param_t time_scene_client_cb = {0}; btc_ble_mesh_time_scene_client_args_t *arg = NULL; esp_ble_mesh_client_common_param_t *params = NULL; - struct bt_mesh_common_param common = {0}; + bt_mesh_client_common_param_t common = {0}; bt_mesh_role_param_t role_param = {0}; if (!msg || !msg->arg) { @@ -300,7 +300,7 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg) 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_model_role(&role_param)) { + if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } @@ -329,7 +329,7 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg) 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_model_role(&role_param)) { + if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); return; } diff --git a/components/bt/esp_ble_mesh/mesh_core/access.c b/components/bt/esp_ble_mesh/mesh_core/access.c index 6184d30091..d8365ecdd5 100644 --- a/components/bt/esp_ble_mesh/mesh_core/access.c +++ b/components/bt/esp_ble_mesh/mesh_core/access.c @@ -740,7 +740,7 @@ static int model_send(struct bt_mesh_model *model, tx->ctx->app_idx, tx->ctx->addr); BT_DBG("len %u: %s", msg->len, bt_hex(msg->data, msg->len)); - role = bt_mesh_get_model_role(model, tx->ctx->srv_send); + role = bt_mesh_get_device_role(model, tx->ctx->srv_send); if (role == ROLE_NVAL) { BT_ERR("%s, Failed to get model role", __func__); return -EINVAL; @@ -819,7 +819,7 @@ int bt_mesh_model_send(struct bt_mesh_model *model, struct bt_mesh_subnet *sub = NULL; u8_t role; - role = bt_mesh_get_model_role(model, ctx->srv_send); + role = bt_mesh_get_device_role(model, ctx->srv_send); if (role == ROLE_NVAL) { BT_ERR("%s, Failed to get model role", __func__); return -EINVAL; diff --git a/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c b/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c index aa2daf0da8..7e2f717b43 100644 --- a/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c +++ b/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c @@ -139,7 +139,7 @@ static void cfg_client_cancel(struct bt_mesh_model *model, /* If it is a publish message, sent to the user directly. */ buf.data = (u8_t *)status; buf.len = (u16_t)len; - node = bt_mesh_is_model_message_publish(model, ctx, &buf, true); + node = bt_mesh_is_client_recv_publish_msg(model, ctx, &buf, true); if (!node) { BT_DBG("Unexpected config status message 0x%x", ctx->recv_op); } else { diff --git a/components/bt/esp_ble_mesh/mesh_core/health_cli.c b/components/bt/esp_ble_mesh/mesh_core/health_cli.c index c66e42afcd..05e47cd295 100644 --- a/components/bt/esp_ble_mesh/mesh_core/health_cli.c +++ b/components/bt/esp_ble_mesh/mesh_core/health_cli.c @@ -95,7 +95,7 @@ static void health_client_cancel(struct bt_mesh_model *model, /* If it is a publish message, sent to the user directly. */ buf.data = (u8_t *)status; buf.len = (u16_t)len; - node = bt_mesh_is_model_message_publish(model, ctx, &buf, true); + node = bt_mesh_is_client_recv_publish_msg(model, ctx, &buf, true); if (!node) { BT_DBG("Unexpected health status message 0x%x", ctx->recv_op); } else { @@ -169,7 +169,7 @@ static void health_current_status(struct bt_mesh_model *model, bt_hex(buf->data, buf->len)); /* Health current status is a publish message, sent to the user directly. */ - if (!(node = bt_mesh_is_model_message_publish(model, ctx, buf, true))) { + if (!(node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true))) { return; } diff --git a/components/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h b/components/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h index 8f46a045ad..5bf8b2032f 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h @@ -23,8 +23,8 @@ */ /* Config client model common structure */ -typedef bt_mesh_client_common_t bt_mesh_config_client_t; -typedef bt_mesh_internal_data_t config_internal_data_t; +typedef bt_mesh_client_user_data_t bt_mesh_config_client_t; +typedef bt_mesh_client_internal_data_t config_internal_data_t; extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[]; diff --git a/components/bt/esp_ble_mesh/mesh_core/include/health_cli.h b/components/bt/esp_ble_mesh/mesh_core/include/health_cli.h index b1e1b693d0..4f080766cd 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/health_cli.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/health_cli.h @@ -23,10 +23,8 @@ */ /* Health client model common structure */ -typedef bt_mesh_client_common_t bt_mesh_health_client_t; -typedef bt_mesh_internal_data_t health_internal_data_t; - -typedef bt_mesh_internal_data_t health_client_internal_data_t; +typedef bt_mesh_client_user_data_t bt_mesh_health_client_t; +typedef bt_mesh_client_internal_data_t health_internal_data_t; extern const struct bt_mesh_model_op bt_mesh_health_cli_op[]; diff --git a/components/bt/esp_ble_mesh/mesh_core/transport.c b/components/bt/esp_ble_mesh/mesh_core/transport.c index 0902783515..98f93cb04e 100644 --- a/components/bt/esp_ble_mesh/mesh_core/transport.c +++ b/components/bt/esp_ble_mesh/mesh_core/transport.c @@ -474,7 +474,7 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg, tx->ctx->app_idx, tx->ctx->addr); BT_DBG("len %u: %s", msg->len, bt_hex(msg->data, msg->len)); - role = bt_mesh_get_model_role(tx->ctx->model, tx->ctx->srv_send); + role = bt_mesh_get_device_role(tx->ctx->model, tx->ctx->srv_send); if (role == ROLE_NVAL) { BT_ERR("%s, Failed to get model role", __func__); return -EINVAL; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/client_common.c b/components/bt/esp_ble_mesh/mesh_models/client/client_common.c index 8802e424cc..c2590935bc 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/client_common.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/client_common.c @@ -25,13 +25,13 @@ #include "mesh.h" #include "client_common.h" -bt_mesh_client_node_t *bt_mesh_is_model_message_publish(struct bt_mesh_model *model, +bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( + struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, - bool need_pub) + struct net_buf_simple *buf, bool need_pub) { - bt_mesh_internal_data_t *data = NULL; - bt_mesh_client_common_t *cli = NULL; + bt_mesh_client_internal_data_t *data = NULL; + bt_mesh_client_user_data_t *cli = NULL; bt_mesh_client_node_t *node = NULL; u32_t rsp; @@ -40,7 +40,7 @@ bt_mesh_client_node_t *bt_mesh_is_model_message_publish(struct bt_mesh_model *mo return NULL; } - cli = (bt_mesh_client_common_t *)model->user_data; + cli = (bt_mesh_client_user_data_t *)model->user_data; if (!cli) { BT_ERR("%s, Clinet user_data is NULL", __func__); return NULL; @@ -65,7 +65,7 @@ bt_mesh_client_node_t *bt_mesh_is_model_message_publish(struct bt_mesh_model *mo * message, then the message is from another element and * push it to application layer. */ - data = (bt_mesh_internal_data_t *)cli->internal_data; + data = (bt_mesh_client_internal_data_t *)cli->internal_data; if (!data) { BT_ERR("%s, Client internal_data is NULL", __func__); return NULL; @@ -172,8 +172,8 @@ int bt_mesh_client_send_msg(struct bt_mesh_model *model, const struct bt_mesh_send_cb *cb, void *cb_data) { - bt_mesh_internal_data_t *internal = NULL; - bt_mesh_client_common_t *cli = NULL; + bt_mesh_client_internal_data_t *internal = NULL; + bt_mesh_client_user_data_t *cli = NULL; bt_mesh_client_node_t *node = NULL; int err; @@ -182,9 +182,9 @@ int bt_mesh_client_send_msg(struct bt_mesh_model *model, return -EINVAL; } - cli = (bt_mesh_client_common_t *)model->user_data; + cli = (bt_mesh_client_user_data_t *)model->user_data; __ASSERT(cli, "Invalid client value when sent client msg."); - internal = (bt_mesh_internal_data_t *)cli->internal_data; + internal = (bt_mesh_client_internal_data_t *)cli->internal_data; __ASSERT(internal, "Invalid internal value when sent client msg."); if (!need_ack) { @@ -224,8 +224,8 @@ int bt_mesh_client_send_msg(struct bt_mesh_model *model, int bt_mesh_client_init(struct bt_mesh_model *model) { - bt_mesh_internal_data_t *data = NULL; - bt_mesh_client_common_t *cli = NULL; + bt_mesh_client_internal_data_t *data = NULL; + bt_mesh_client_user_data_t *cli = NULL; if (!model) { BT_ERR("%s, Invalid parameter", __func__); @@ -244,7 +244,7 @@ int bt_mesh_client_init(struct bt_mesh_model *model) } /* TODO: call osi_free() when deinit function is invoked */ - data = osi_calloc(sizeof(bt_mesh_internal_data_t)); + data = osi_calloc(sizeof(bt_mesh_client_internal_data_t)); if (!data) { BT_ERR("%s, Failed to allocate memory", __func__); return -ENOMEM; @@ -275,16 +275,16 @@ int bt_mesh_client_free_node(sys_slist_t *queue, bt_mesh_client_node_t *node) return 0; } -int bt_mesh_set_model_role(bt_mesh_role_param_t *common) +int bt_mesh_set_client_model_role(bt_mesh_role_param_t *common) { - bt_mesh_client_common_t *client = NULL; + bt_mesh_client_user_data_t *client = NULL; if (!common || !common->model || !common->model->user_data) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } - client = (bt_mesh_client_common_t *)common->model->user_data; + client = (bt_mesh_client_user_data_t *)common->model->user_data; switch (common->role) { #if CONFIG_BLE_MESH_NODE @@ -315,4 +315,3 @@ int bt_mesh_set_model_role(bt_mesh_role_param_t *common) return 0; } - diff --git a/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c b/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c index 9e963095dd..32860a603d 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c @@ -535,7 +535,7 @@ static void generic_status(struct bt_mesh_model *model, buf->data = val; buf->len = len; - node = bt_mesh_is_model_message_publish(model, ctx, buf, true); + node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true); if (!node) { BT_DBG("Unexpected generic status message 0x%x", rsp); } else { @@ -687,7 +687,7 @@ const struct bt_mesh_model_op gen_property_cli_op[] = { BLE_MESH_MODEL_OP_END, }; -static int gen_get_state(struct bt_mesh_common_param *common, void *value) +static int gen_get_state(bt_mesh_client_common_param_t *common, void *value) { NET_BUF_SIMPLE_DEFINE(msg, BLE_MESH_GEN_GET_STATE_MSG_LEN); int err; @@ -736,7 +736,7 @@ static int gen_get_state(struct bt_mesh_common_param *common, void *value) return err; } -static int gen_set_state(struct bt_mesh_common_param *common, +static int gen_set_state(bt_mesh_client_common_param_t *common, void *value, u16_t value_len, bool need_ack) { struct net_buf_simple *msg = NULL; @@ -918,7 +918,7 @@ end: return err; } -int bt_mesh_generic_client_get_state(struct bt_mesh_common_param *common, void *get, void *status) +int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status) { bt_mesh_generic_client_t *client = NULL; @@ -981,7 +981,7 @@ int bt_mesh_generic_client_get_state(struct bt_mesh_common_param *common, void * return gen_get_state(common, get); } -int bt_mesh_generic_client_set_state(struct bt_mesh_common_param *common, void *set, void *status) +int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status) { bt_mesh_generic_client_t *client = NULL; u16_t length = 0; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h b/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h index 55d78831d3..384d08a05d 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h @@ -17,17 +17,23 @@ #include "mesh_access.h" -/** Mesh Client Model Context */ +/** Client model opcode pair table */ typedef struct { - u32_t cli_op; /* The client opcode */ - u32_t status_op; /* The server status opcode corresponding to the client opcode */ + u32_t cli_op; /* Client message opcode */ + u32_t status_op; /* Corresponding status message opcode */ } bt_mesh_client_op_pair_t; -/** Mesh Client Model Context */ +/** Client model user data context */ typedef struct { + /** Pointer to the client model */ struct bt_mesh_model *model; - int op_pair_size; /* the size of op_pair */ + + /** Size of the opcode pair table */ + int op_pair_size; + + /** Pointer to the opcode pair table */ const bt_mesh_client_op_pair_t *op_pair; + /** * @brief This function is a callback function used to push the received unsolicited * messages to the application layer. @@ -40,26 +46,42 @@ typedef struct { * @return None */ void (*publish_status)(u32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); - void *internal_data; /* Pointer of the structure of internal data */ - u8_t msg_role; /* device role of the tx message */ -} bt_mesh_client_common_t; + /** Pointer to the internal data of client model */ + void *internal_data; + + /** Role of the device to which the client model belongs */ + u8_t msg_role; +} bt_mesh_client_user_data_t; + +/** Client model internal data context */ typedef struct { sys_slist_t queue; -} bt_mesh_internal_data_t; +} bt_mesh_client_internal_data_t; +/** Client model sending message related context */ typedef struct { sys_snode_t client_node; - struct bt_mesh_msg_ctx ctx; - u32_t opcode; /* Indicate the opcode of the message sending */ - u32_t op_pending; /* Indicate the status message waiting for */ - struct k_delayed_work timer; /* Message send Timer. Only for stack-internal use. */ + struct bt_mesh_msg_ctx ctx; /* Message context */ + u32_t opcode; /* Message opcode */ + u32_t op_pending; /* Expected status message opcode */ + struct k_delayed_work timer; /* Time used to get response. Only for internal use. */ } bt_mesh_client_node_t; +/** Client model sending message parameters */ +typedef struct { + u32_t opcode; /* Message opcode */ + 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 */ + const struct bt_mesh_send_cb *cb; /* User defined callback function */ + void *cb_data; /* User defined callback value */ +} bt_mesh_client_common_param_t; + int bt_mesh_client_init(struct bt_mesh_model *model); /** - * @brief Check the msg is a publish msg or not + * @brief Check if the msg received by client model is a publish msg or not * * @param model Mesh (client) Model that the message belongs to. * @param ctx Message context, includes keys, TTL, etc. @@ -67,10 +89,10 @@ int bt_mesh_client_init(struct bt_mesh_model *model); * @param need_pub Indicate if the msg sent to app layer as a publish msg * @return 0 on success, or (negative) error code on failure. */ -bt_mesh_client_node_t *bt_mesh_is_model_message_publish(struct bt_mesh_model *model, +bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( + struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, - bool need_pub); + struct net_buf_simple *buf, bool need_pub); bool bt_mesh_client_find_opcode_in_list(sys_slist_t *list, u32_t opcode); @@ -94,18 +116,9 @@ enum { FAST_PROV, }; -#define ROLE_NVAL 0xFF +#define ROLE_NVAL 0xFF -struct bt_mesh_common_param { - u32_t opcode; /* Message opcode */ - struct bt_mesh_model *model; /* Pointer to cli structure */ - struct bt_mesh_msg_ctx ctx; /* Message context */ - s32_t msg_timeout; /* Time to get response messages */ - const struct bt_mesh_send_cb *cb; /* User defined callback function */ - void *cb_data; /* Data as parameter of the cb function */ -}; - -typedef struct bt_mesh_role_param { +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; @@ -113,11 +126,11 @@ typedef struct bt_mesh_role_param { /** * @brief This function copies node_index for stack internal use. * - * @param[in] common: Pointer to the struct bt_mesh_role_param structure + * @param[in] common: Pointer to the bt_mesh_role_param_t structure * * @return Zero - success, otherwise - fail */ -int bt_mesh_set_model_role(bt_mesh_role_param_t *common); +int bt_mesh_set_client_model_role(bt_mesh_role_param_t *common); #endif /* _MODEL_COMMON_H_ */ diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h b/components/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h index b3cee9c756..e697e25716 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h @@ -25,8 +25,8 @@ #include "client_common.h" /* Generic client model common structure */ -typedef bt_mesh_client_common_t bt_mesh_generic_client_t; -typedef bt_mesh_internal_data_t generic_internal_data_t; +typedef bt_mesh_client_user_data_t bt_mesh_generic_client_t; +typedef bt_mesh_client_internal_data_t generic_internal_data_t; /* Generic OnOff Client Model Context */ extern const struct bt_mesh_model_op gen_onoff_cli_op[]; @@ -45,7 +45,7 @@ extern const struct bt_mesh_model_op gen_onoff_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, \ gen_onoff_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_gen_onoff_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_gen_onoff_client_t; struct bt_mesh_gen_onoff_status { bool op_en; /* Indicate whether optional parameters included */ @@ -79,7 +79,7 @@ extern const struct bt_mesh_model_op gen_level_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, \ gen_level_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_gen_level_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_gen_level_client_t; struct bt_mesh_gen_level_status { bool op_en; /* Indicate whether optional parameters included */ @@ -130,7 +130,7 @@ extern const struct bt_mesh_model_op gen_def_trans_time_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, \ gen_def_trans_time_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_gen_def_trans_time_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_gen_def_trans_time_client_t; struct bt_mesh_gen_def_trans_time_set { u8_t trans_time; /* The value of the Generic Default Transition Time state */ @@ -157,7 +157,7 @@ extern const struct bt_mesh_model_op gen_power_onoff_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, \ gen_power_onoff_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_gen_power_onoff_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_gen_power_onoff_client_t; struct bt_mesh_gen_onpowerup_set { u8_t onpowerup; /* The value of the Generic OnPowerUp state */ @@ -184,7 +184,7 @@ extern const struct bt_mesh_model_op gen_power_level_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, \ gen_power_level_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_gen_power_level_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_gen_power_level_client_t; struct bt_mesh_gen_power_level_status { bool op_en; /* Indicate whether optional parameters included */ @@ -241,7 +241,7 @@ extern const struct bt_mesh_model_op gen_battery_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, \ gen_battery_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_gen_battery_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_gen_battery_client_t; struct bt_mesh_gen_battery_status { u32_t battery_level : 8; /* Value of Generic Battery Level state */ @@ -267,7 +267,7 @@ extern const struct bt_mesh_model_op gen_location_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, \ gen_location_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_gen_location_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_gen_location_client_t; struct bt_mesh_gen_loc_global_status { s32_t global_latitude; /* Global Coordinates (Latitude) */ @@ -314,7 +314,7 @@ extern const struct bt_mesh_model_op gen_property_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_PROP_CLI, \ gen_property_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_gen_property_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_gen_property_client_t; struct bt_mesh_gen_user_properties_status { struct net_buf_simple *user_property_ids; /* Buffer contains a sequence of N User Property IDs */ @@ -475,7 +475,7 @@ int bt_mesh_gen_property_cli_init(struct bt_mesh_model *model, bool primary); * * @return Zero-success, other-fail */ -int bt_mesh_generic_client_get_state(struct bt_mesh_common_param *common, void *get, void *status); +int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status); /** * @brief This function is called to set generic states. @@ -486,6 +486,6 @@ int bt_mesh_generic_client_get_state(struct bt_mesh_common_param *common, void * * * @return Zero-success, other-fail */ -int bt_mesh_generic_client_set_state(struct bt_mesh_common_param *common, void *set, void *status); +int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status); #endif /* _GENERIC_CLIENT_H_ */ diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h b/components/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h index bd2b735a6e..8502052155 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h @@ -25,8 +25,8 @@ #include "client_common.h" /* Light client model common structure */ -typedef bt_mesh_client_common_t bt_mesh_light_client_t; -typedef bt_mesh_internal_data_t light_internal_data_t; +typedef bt_mesh_client_user_data_t bt_mesh_light_client_t; +typedef bt_mesh_client_internal_data_t light_internal_data_t; /* Light Lightness Client Model Context */ extern const struct bt_mesh_model_op light_lightness_cli_op[]; @@ -45,7 +45,7 @@ extern const struct bt_mesh_model_op light_lightness_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, \ light_lightness_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_light_lightness_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_light_lightness_client_t; struct bt_mesh_light_lightness_status { bool op_en; /* Indicate whether optional parameters included */ @@ -117,7 +117,7 @@ extern const struct bt_mesh_model_op light_ctl_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, \ light_ctl_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_light_ctl_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_light_ctl_client_t; struct bt_mesh_light_ctl_status { bool op_en; /* Indicate whether optional parameters included */ @@ -196,7 +196,7 @@ extern const struct bt_mesh_model_op light_hsl_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, \ light_hsl_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_light_hsl_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_light_hsl_client_t; struct bt_mesh_light_hsl_status { bool op_en; /* Indicate whether optional parameters included */ @@ -298,7 +298,7 @@ extern const struct bt_mesh_model_op light_xyl_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, \ light_xyl_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_light_xyl_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_light_xyl_client_t; struct bt_mesh_light_xyl_status { bool op_en; /* Indicate whether optional parameters included */ @@ -370,7 +370,7 @@ extern const struct bt_mesh_model_op light_lc_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_LC_CLI, \ light_lc_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_light_lc_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_light_lc_client_t; struct bt_mesh_light_lc_mode_status { u8_t mode; /* The present value of the Light LC Mode state */ @@ -476,7 +476,7 @@ int bt_mesh_light_lc_cli_init(struct bt_mesh_model *model, bool primary); * * @return Zero-success, other-fail */ -int bt_mesh_light_client_get_state(struct bt_mesh_common_param *common, void *get, void *status); +int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status); /** * @brief This function is called to set light states. @@ -487,6 +487,6 @@ int bt_mesh_light_client_get_state(struct bt_mesh_common_param *common, void *ge * * @return Zero-success, other-fail */ -int bt_mesh_light_client_set_state(struct bt_mesh_common_param *common, void *set, void *status); +int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status); #endif /* _LIGHTING_CLIENT_H_ */ diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h b/components/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h index 14b450513e..39855bd9a7 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h @@ -41,8 +41,8 @@ extern const struct bt_mesh_model_op sensor_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_SENSOR_CLI, \ sensor_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_sensor_client_t; -typedef bt_mesh_internal_data_t sensor_internal_data_t; +typedef bt_mesh_client_user_data_t bt_mesh_sensor_client_t; +typedef bt_mesh_client_internal_data_t sensor_internal_data_t; struct bt_mesh_sensor_descriptor_status { struct net_buf_simple *descriptor; /* Sequence of 8-octet sensor descriptors (optional) */ @@ -151,7 +151,7 @@ int bt_mesh_sensor_cli_init(struct bt_mesh_model *model, bool primary); * * @return Zero-success, other-fail */ -int bt_mesh_sensor_client_get_state(struct bt_mesh_common_param *common, void *get, void *status); +int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status); /** * @brief This function is called to set sensor states. @@ -162,6 +162,6 @@ int bt_mesh_sensor_client_get_state(struct bt_mesh_common_param *common, void *g * * @return Zero-success, other-fail */ -int bt_mesh_sensor_client_set_state(struct bt_mesh_common_param *common, void *set, void *status); +int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status); #endif /* _SENSOR_CLIENT_H_ */ diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h b/components/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h index b6c8d18bf0..182316e05d 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h @@ -25,8 +25,8 @@ #include "client_common.h" /* Time scene client model common structure */ -typedef bt_mesh_client_common_t bt_mesh_time_scene_client_t; -typedef bt_mesh_internal_data_t time_scene_internal_data_t; +typedef bt_mesh_client_user_data_t bt_mesh_time_scene_client_t; +typedef bt_mesh_client_internal_data_t time_scene_internal_data_t; /* Time Client Model Context */ extern const struct bt_mesh_model_op time_cli_op[]; @@ -45,7 +45,7 @@ extern const struct bt_mesh_model_op time_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_TIME_CLI, \ time_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_time_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_time_client_t; struct bt_mesh_time_status { u8_t tai_seconds[5]; /* The current TAI time in seconds */ @@ -115,7 +115,7 @@ extern const struct bt_mesh_model_op scene_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_SCENE_CLI, \ scene_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_scene_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_scene_client_t; struct bt_mesh_scene_status { bool op_en; /* Indicate whether optional parameters included */ @@ -164,7 +164,7 @@ extern const struct bt_mesh_model_op scheduler_cli_op[]; BLE_MESH_MODEL(BLE_MESH_MODEL_ID_SCHEDULER_CLI, \ scheduler_cli_op, cli_pub, cli_data) -typedef bt_mesh_client_common_t bt_mesh_scheduler_cli_t; +typedef bt_mesh_client_user_data_t bt_mesh_scheduler_client_t; struct bt_mesh_scheduler_status { u16_t schedules; /* Bit field indicating defined Actions in the Schedule Register */ @@ -241,7 +241,7 @@ int bt_mesh_scheduler_cli_init(struct bt_mesh_model *model, bool primary); * * @return Zero-success, other-fail */ -int bt_mesh_time_scene_client_get_state(struct bt_mesh_common_param *common, void *get, void *status); +int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status); /** * @brief This function is called to set scene states. @@ -252,6 +252,6 @@ int bt_mesh_time_scene_client_get_state(struct bt_mesh_common_param *common, voi * * @return Zero-success, other-fail */ -int bt_mesh_time_scene_client_set_state(struct bt_mesh_common_param *common, void *set, void *status); +int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status); #endif /* _TIME_SCENE_CLIENT_H_ */ diff --git a/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c b/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c index 8f0481b86d..d71f3ccce5 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c @@ -650,7 +650,7 @@ static void light_status(struct bt_mesh_model *model, buf->data = val; buf->len = len; - node = bt_mesh_is_model_message_publish(model, ctx, buf, true); + node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true); if (!node) { BT_DBG("Unexpected light status message 0x%x", rsp); } else { @@ -770,7 +770,7 @@ const struct bt_mesh_model_op light_lc_cli_op[] = { BLE_MESH_MODEL_OP_END, }; -static int light_get_state(struct bt_mesh_common_param *common, void *value) +static int light_get_state(bt_mesh_client_common_param_t *common, void *value) { NET_BUF_SIMPLE_DEFINE(msg, BLE_MESH_LIGHT_GET_STATE_MSG_LEN); int err; @@ -801,7 +801,7 @@ static int light_get_state(struct bt_mesh_common_param *common, void *value) return err; } -static int light_set_state(struct bt_mesh_common_param *common, +static int light_set_state(bt_mesh_client_common_param_t *common, void *value, u16_t value_len, bool need_ack) { struct net_buf_simple *msg = NULL; @@ -1042,7 +1042,7 @@ end: return err; } -int bt_mesh_light_client_get_state(struct bt_mesh_common_param *common, void *get, void *status) +int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status) { bt_mesh_light_client_t *client = NULL; @@ -1095,7 +1095,7 @@ int bt_mesh_light_client_get_state(struct bt_mesh_common_param *common, void *ge return light_get_state(common, get); } -int bt_mesh_light_client_set_state(struct bt_mesh_common_param *common, void *set, void *status) +int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status) { bt_mesh_light_client_t *client = NULL; u16_t length = 0; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c b/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c index 26ea1f8d7e..2187f18551 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c @@ -262,7 +262,7 @@ static void sensor_status(struct bt_mesh_model *model, buf->data = val; buf->len = len; - node = bt_mesh_is_model_message_publish(model, ctx, buf, true); + node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true); if (!node) { BT_DBG("Unexpected sensor status message 0x%x", rsp); } else { @@ -352,7 +352,7 @@ const struct bt_mesh_model_op sensor_cli_op[] = { BLE_MESH_MODEL_OP_END, }; -static int sensor_act_state(struct bt_mesh_common_param *common, +static int sensor_act_state(bt_mesh_client_common_param_t *common, void *value, u16_t value_len, bool need_ack) { struct net_buf_simple *msg = NULL; @@ -460,7 +460,7 @@ end: return err; } -int bt_mesh_sensor_client_get_state(struct bt_mesh_common_param *common, void *get, void *status) +int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status) { bt_mesh_sensor_client_t *client = NULL; u16_t length = 0; @@ -525,7 +525,7 @@ int bt_mesh_sensor_client_get_state(struct bt_mesh_common_param *common, void *g return sensor_act_state(common, get, length, true); } -int bt_mesh_sensor_client_set_state(struct bt_mesh_common_param *common, void *set, void *status) +int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status) { bt_mesh_sensor_client_t *client = NULL; u16_t length = 0; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c b/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c index 921c504ae3..3632c653b0 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c @@ -299,7 +299,7 @@ static void time_scene_status(struct bt_mesh_model *model, buf->data = val; buf->len = len; - node = bt_mesh_is_model_message_publish(model, ctx, buf, true); + node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true); if (!node) { BT_DBG("Unexpected time scene status message 0x%x", rsp); } else { @@ -369,7 +369,7 @@ const struct bt_mesh_model_op scheduler_cli_op[] = { BLE_MESH_MODEL_OP_END, }; -static int time_scene_get_state(struct bt_mesh_common_param *common, void *value) +static int time_scene_get_state(bt_mesh_client_common_param_t *common, void *value) { NET_BUF_SIMPLE_DEFINE(msg, BLE_MESH_SCENE_GET_STATE_MSG_LEN); int err; @@ -400,7 +400,7 @@ static int time_scene_get_state(struct bt_mesh_common_param *common, void *value return err; } -static int time_scene_set_state(struct bt_mesh_common_param *common, +static int time_scene_set_state(bt_mesh_client_common_param_t *common, void *value, u16_t value_len, bool need_ack) { struct net_buf_simple *msg = NULL; @@ -497,7 +497,7 @@ end: return err; } -int bt_mesh_time_scene_client_get_state(struct bt_mesh_common_param *common, void *get, void *status) +int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status) { bt_mesh_time_scene_client_t *client = NULL; @@ -535,7 +535,7 @@ int bt_mesh_time_scene_client_get_state(struct bt_mesh_common_param *common, voi return time_scene_get_state(common, get); } -int bt_mesh_time_scene_client_set_state(struct bt_mesh_common_param *common, void *set, void *status) +int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status) { bt_mesh_time_scene_client_t *client = NULL; u16_t length = 0; diff --git a/components/bt/esp_ble_mesh/mesh_models/common/include/mesh_common.h b/components/bt/esp_ble_mesh/mesh_models/common/include/mesh_common.h index 501450c272..2355bf0f3d 100644 --- a/components/bt/esp_ble_mesh/mesh_models/common/include/mesh_common.h +++ b/components/bt/esp_ble_mesh/mesh_models/common/include/mesh_common.h @@ -56,6 +56,6 @@ void bt_mesh_free_buf(struct net_buf_simple *buf); * * @return 0 - Node, 1 - Provisioner */ -u8_t bt_mesh_get_model_role(struct bt_mesh_model *model, bool srv_send); +u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send); #endif /* _MESH_COMMON_H_ */ \ No newline at end of file diff --git a/components/bt/esp_ble_mesh/mesh_models/common/mesh_common.c b/components/bt/esp_ble_mesh/mesh_models/common/mesh_common.c index 9e7185d451..704e540a20 100644 --- a/components/bt/esp_ble_mesh/mesh_models/common/mesh_common.c +++ b/components/bt/esp_ble_mesh/mesh_models/common/mesh_common.c @@ -46,9 +46,9 @@ void bt_mesh_free_buf(struct net_buf_simple *buf) } } -u8_t bt_mesh_get_model_role(struct bt_mesh_model *model, bool srv_send) +u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send) { - bt_mesh_client_common_t *client = NULL; + bt_mesh_client_user_data_t *client = NULL; if (srv_send) { BT_DBG("%s, Message is sent by a server model", __func__); @@ -60,7 +60,7 @@ u8_t bt_mesh_get_model_role(struct bt_mesh_model *model, bool srv_send) return ROLE_NVAL; } - client = (bt_mesh_client_common_t *)model->user_data; + client = (bt_mesh_client_user_data_t *)model->user_data; return client->msg_role; }