diff --git a/include/bluetooth/mesh/light_temp_srv.h b/include/bluetooth/mesh/light_temp_srv.h index 4762c6201f89..111a213fb1bc 100644 --- a/include/bluetooth/mesh/light_temp_srv.h +++ b/include/bluetooth/mesh/light_temp_srv.h @@ -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. */ diff --git a/subsys/bluetooth/mesh/light_temp_srv.c b/subsys/bluetooth/mesh/light_temp_srv.c index 5fbe1ca71009..9bd2c2ac8b33 100644 --- a/subsys/bluetooth/mesh/light_temp_srv.c +++ b/subsys/bluetooth/mesh/light_temp_srv.c @@ -394,6 +394,17 @@ 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; @@ -401,7 +412,11 @@ static int bt_mesh_light_temp_srv_init(const struct bt_mesh_model *model) 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);