Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Model Publication in Light CTL Temperature Server #19496

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/bluetooth/mesh/light_temp_srv.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ struct bt_mesh_light_temp_srv {
const struct bt_mesh_light_ctl_srv *ctl;
/** Publish parameters. */
struct bt_mesh_model_pub pub;
/* Publication buffer */
struct net_buf_simple pub_buf;
/* Publication data */
uint8_t pub_data[BT_MESH_MODEL_BUF_LEN(
BT_MESH_LIGHT_CTL_STATUS, BT_MESH_LIGHT_CTL_MSG_MAXLEN_STATUS)];
/** Transaction ID tracker for the set messages. */
struct bt_mesh_tid_ctx prev_transaction;
/** Handler function structure. */
Expand Down
17 changes: 16 additions & 1 deletion subsys/bluetooth/mesh/light_temp_srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,29 @@ static void light_temp_srv_reset(struct bt_mesh_light_temp_srv *srv)
srv->range.max = BT_MESH_LIGHT_TEMP_MAX;
}

static int update_handler(const struct bt_mesh_model *model)
{
struct bt_mesh_light_temp_srv *srv = model->rt->user_data;
struct bt_mesh_light_temp_status status = { 0 };

srv->handlers->get(srv, NULL, &status);
encode_status(srv->pub.msg, &status);

return 0;
}

static int bt_mesh_light_temp_srv_init(const struct bt_mesh_model *model)
{
struct bt_mesh_light_temp_srv *srv = model->rt->user_data;
int err;

srv->model = model;
light_temp_srv_reset(srv);
net_buf_simple_init(srv->pub.msg, 0);

srv->pub.msg = &srv->pub_buf;
srv->pub.update = update_handler;
net_buf_simple_init_with_data(&srv->pub_buf, srv->pub_data,
sizeof(srv->pub_data));

#if IS_ENABLED(CONFIG_BT_SETTINGS) && IS_ENABLED(CONFIG_EMDS)
srv->emds_entry.entry.id = EMDS_MODEL_ID(model);
Expand Down