Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bluetooth: Mesh: Add Model Publication and Optimize Light Temp SRV
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.
Usefull hints from Aleksandr Khromykh.

Signed-off-by: Ilija Vorontsov <ilija.vorontsov@loytec.com>
IlijaVorontsov committed Jan 17, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent e1b6e2a commit 95cf766
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
@@ -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. */
17 changes: 16 additions & 1 deletion subsys/bluetooth/mesh/light_temp_srv.c
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 95cf766

Please sign in to comment.