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;
}
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;
}
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) {
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;
}
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;
}
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;
}
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;
}
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) {
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;
}
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;
}
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;
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;
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;
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;
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
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;
}
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;
}
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) {
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;
}
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;
}
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) {
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;
}
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;
}
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;
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;
/* 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 {
/* 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 {
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;
}
*/
/* 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[];
*/
/* 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[];
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;
#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;
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;
* 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;
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;
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) {
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__);
}
/* 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;
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
return 0;
}
-
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 {
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;
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;
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;
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;
#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.
* @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.
* @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);
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;
/**
* @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_ */
#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[];
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 */
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 */
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 */
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 */
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 */
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 */
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) */
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 */
*
* @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.
*
* @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_ */
#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[];
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 */
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 */
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 */
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 */
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 */
*
* @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.
*
* @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_ */
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) */
*
* @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.
*
* @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_ */
#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[];
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 */
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 */
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 */
*
* @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.
*
* @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_ */
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 {
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;
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;
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;
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;
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 {
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;
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;
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;
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 {
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;
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;
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;
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;
*
* @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
}
}
-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__);
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;
}