Skip to content

Commit

Permalink
Bluetooth: Mesh: light_temp_srv added publication
Browse files Browse the repository at this point in the history
Implemented model publication as specified in Mesh Model Specification
v1.0.1, Section 6.4.4.1. Implemented similar to other publication
services in Bt Mesh. Tested in company own testing environment.

Co-authored-by: Aleksandr Khromykh <[email protected]>
Signed-off-by: Ilija Vorontsov <[email protected]>
  • Loading branch information
IlijaVorontsov and alxelax committed Jan 17, 2025
1 parent e1b6e2a commit 83fe35d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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

0 comments on commit 83fe35d

Please sign in to comment.