14#ifndef BT_MESH_LIGHTNESS_SRV_H__
15#define BT_MESH_LIGHTNESS_SRV_H__
17#include <zephyr/bluetooth/mesh.h>
23#if IS_ENABLED(CONFIG_EMDS) && IS_ENABLED(CONFIG_BT_SETTINGS)
39#define BT_MESH_LIGHTNESS_SRV_INIT(_handlers) \
41 .lvl = BT_MESH_LVL_SRV_INIT( \
42 &_bt_mesh_lightness_srv_lvl_handlers), \
43 .ponoff = BT_MESH_PONOFF_SRV_INIT( \
44 &_bt_mesh_lightness_srv_onoff_handlers, NULL, NULL), \
45 .handlers = _handlers, \
57#define BT_MESH_MODEL_LIGHTNESS_SRV(_srv, ...) \
58 BT_MESH_MODEL_LVL_SRV(&(_srv)->lvl), \
59 BT_MESH_MODEL_PONOFF_SRV(&(_srv)->ponoff), \
60 BT_MESH_MODEL_METADATA_CB(BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV, \
61 _bt_mesh_lightness_srv_op, &(_srv)->pub, \
62 BT_MESH_MODEL_USER_DATA(struct bt_mesh_lightness_srv, \
64 &_bt_mesh_lightness_srv_cb, __VA_ARGS__), \
65 BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV, \
66 _bt_mesh_lightness_setup_srv_op, NULL, \
67 BT_MESH_MODEL_USER_DATA(struct bt_mesh_lightness_srv, \
69 &_bt_mesh_lightness_setup_srv_cb)
72#define BT_MESH_LIGHT_PURPOSE_METADATA_ID 0x0002
75#define BT_MESH_LIGHT_LIGHTNESS_RANGE_METADATA_ID 0x0003
82#define BT_MESH_LIGHT_PURPOSE_METADATA(light_purpose) \
83 BT_MESH_MODELS_METADATA_ENTRY(2, BT_MESH_LIGHT_PURPOSE_METADATA_ID, \
84 ((uint16_t[]){(light_purpose)}))
92#define BT_MESH_LIGHT_LIGHTNESS_RANGE_METADATA(range_min, range_max) \
93 BT_MESH_MODELS_METADATA_ENTRY(4, BT_MESH_LIGHT_LIGHTNESS_RANGE_METADATA_ID, \
94 ((uint16_t[]){(range_min), (range_max)}))
119 struct bt_mesh_msg_ctx *ctx,
137 struct bt_mesh_msg_ctx *ctx,
152 struct bt_mesh_msg_ctx *ctx,
153 uint16_t old_default, uint16_t new_default);
193 struct bt_mesh_model_pub
pub;
198 BT_MESH_LIGHTNESS_OP_STATUS,
199 BT_MESH_LIGHTNESS_MSG_MAXLEN_STATUS)];
218#if IS_ENABLED(CONFIG_EMDS) && IS_ENABLED(CONFIG_BT_SETTINGS)
223#if defined(CONFIG_BT_MESH_LIGHT_CTRL_SRV)
260 struct bt_mesh_msg_ctx *ctx,
264extern const struct bt_mesh_model_cb _bt_mesh_lightness_srv_cb;
265extern const struct bt_mesh_model_cb _bt_mesh_lightness_setup_srv_cb;
266extern const struct bt_mesh_model_op _bt_mesh_lightness_srv_op[];
267extern const struct bt_mesh_model_op _bt_mesh_lightness_setup_srv_op[];
269 _bt_mesh_lightness_srv_lvl_handlers;
271 _bt_mesh_lightness_srv_onoff_handlers;
int bt_mesh_lightness_srv_pub(struct bt_mesh_lightness_srv *srv, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_lightness_status *status)
Publish the current Light state.
static uint16_t bt_mesh_lightness_clamp(const struct bt_mesh_lightness_srv *srv, uint16_t lightness)
Clamp lightness to lightness range.
Definition: lightness_srv.h:235
struct bt_mesh_lightness_srv * lightness
Definition: light_ctrl_srv.h:208
Light Lightness Control Server instance.
Definition: light_ctrl_srv.h:153
uint16_t max
Definition: lightness.h:60
uint16_t min
Definition: lightness.h:59
Definition: lightness.h:58
Definition: lightness.h:30
void(*const range_update)(struct bt_mesh_lightness_srv *srv, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_lightness_range *old_range, const struct bt_mesh_lightness_range *new_range)
The Light Range state has changed.
Definition: lightness_srv.h:170
void(*const light_set)(struct bt_mesh_lightness_srv *srv, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_lightness_set *set, struct bt_mesh_lightness_status *rsp)
Set the Light state.
Definition: lightness_srv.h:118
void(*const default_update)(struct bt_mesh_lightness_srv *srv, struct bt_mesh_msg_ctx *ctx, uint16_t old_default, uint16_t new_default)
The Default Light state has changed.
Definition: lightness_srv.h:151
void(*const light_get)(struct bt_mesh_lightness_srv *srv, struct bt_mesh_msg_ctx *ctx, struct bt_mesh_lightness_status *rsp)
Get the current Light state.
Definition: lightness_srv.h:136
Definition: lightness_srv.h:97
uint16_t delta_start
Definition: lightness_srv.h:210
uint8_t pub_data[BT_MESH_MODEL_BUF_LEN(BT_MESH_LIGHTNESS_OP_STATUS, BT_MESH_LIGHTNESS_MSG_MAXLEN_STATUS)]
Definition: lightness_srv.h:199
struct net_buf_simple pub_buf
Definition: lightness_srv.h:195
const struct bt_mesh_model * lightness_setup_model
Definition: lightness_srv.h:191
struct bt_mesh_light_ctrl_srv * ctrl
Definition: lightness_srv.h:225
uint16_t default_light
Definition: lightness_srv.h:208
const struct bt_mesh_model * lightness_model
Definition: lightness_srv.h:189
const struct bt_mesh_lightness_srv_handlers *const handlers
Definition: lightness_srv.h:203
struct bt_mesh_lightness_srv::@156 transient
uint16_t last
Definition: lightness_srv.h:213
atomic_t flags
Definition: lightness_srv.h:187
struct bt_mesh_lightness_range range
Definition: lightness_srv.h:206
struct bt_mesh_ponoff_srv ponoff
Definition: lightness_srv.h:185
struct bt_mesh_model_pub pub
Definition: lightness_srv.h:193
bool is_on
Definition: lightness_srv.h:215
struct bt_mesh_lvl_srv lvl
Definition: lightness_srv.h:183
struct bt_mesh_tid_ctx tid
Definition: lightness_srv.h:201
Definition: lightness_srv.h:181
Definition: lightness.h:44
Definition: gen_lvl_srv.h:52
Definition: gen_lvl_srv.h:143
Definition: gen_onoff_srv.h:52
Definition: gen_ponoff_srv.h:74
Definition: model_types.h:46