nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
light_ctrl_srv.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
14#ifndef BT_MESH_LIGHT_CTRL_SRV_H__
15#define BT_MESH_LIGHT_CTRL_SRV_H__
16
17#include <zephyr/bluetooth/mesh.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
31
32#if defined(CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG)
43#define BT_MESH_LIGHT_CTRL_SRV_INIT_WITH_REG(_lightness_srv, _reg) \
44 { \
45 .cfg = BT_MESH_LIGHT_CTRL_SRV_CFG_INIT, \
46 .onoff = BT_MESH_ONOFF_SRV_INIT( \
47 &_bt_mesh_light_ctrl_srv_onoff), \
48 .lightness = _lightness_srv, \
49 .reg = _reg \
50 }
51#endif
52
64#if CONFIG_BT_MESH_LIGHT_CTRL_REG_SPEC && CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG
65#define BT_MESH_LIGHT_CTRL_SRV_INIT(_lightness_srv) \
66 BT_MESH_LIGHT_CTRL_SRV_INIT_WITH_REG( \
67 _lightness_srv, \
68 &(&((struct bt_mesh_light_ctrl_reg_spec) \
69 BT_MESH_LIGHT_CTRL_REG_SPEC_INIT))->reg)
70#else
71#define BT_MESH_LIGHT_CTRL_SRV_INIT(_lightness_srv) \
72 { \
73 .cfg = BT_MESH_LIGHT_CTRL_SRV_CFG_INIT, \
74 .onoff = BT_MESH_ONOFF_SRV_INIT( \
75 &_bt_mesh_light_ctrl_srv_onoff), \
76 .lightness = _lightness_srv \
77 }
78#endif
79
86#define BT_MESH_MODEL_LIGHT_CTRL_SRV(_srv) \
87 BT_MESH_MODEL_ONOFF_SRV(&(_srv)->onoff), \
88 BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_LIGHT_LC_SRV, \
89 _bt_mesh_light_ctrl_srv_op, &(_srv)->pub, \
90 BT_MESH_MODEL_USER_DATA( \
91 struct bt_mesh_light_ctrl_srv, _srv), \
92 &_bt_mesh_light_ctrl_srv_cb), \
93 BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_LIGHT_LC_SETUPSRV, \
94 _bt_mesh_light_ctrl_setup_srv_op, \
95 &(_srv)->setup_pub, \
96 BT_MESH_MODEL_USER_DATA( \
97 struct bt_mesh_light_ctrl_srv, _srv), \
98 &_bt_mesh_light_ctrl_setup_srv_cb)
99
115
118};
119
125 uint32_t fade_on;
127 uint32_t on;
129 uint32_t fade_prolong;
131 uint32_t prolong;
138#if CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG
139#ifdef CONFIG_BT_MESH_SENSOR_USE_LEGACY_SENSOR_VALUE
141 struct sensor_value lux[LIGHT_CTRL_STATE_COUNT];
142#else
144 uint32_t centilux[LIGHT_CTRL_STATE_COUNT];
145#endif /* CONFIG_BT_MESH_SENSOR_USE_LEGACY_SENSOR_VALUE */
146#endif /* CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG */
147};
148
157 atomic_t flags;
159 struct {
162#ifdef CONFIG_BT_MESH_SENSOR_USE_LEGACY_SENSOR_VALUE
164 struct sensor_value initial_lux;
165#else
168#endif
170 uint32_t duration;
173 struct k_work_delayable timer;
174
176 struct k_work_delayable action_delay;
180 struct bt_mesh_model_pub pub;
181 /* Publication buffer */
182 struct net_buf_simple pub_buf;
183 /* Publication data */
184 uint8_t pub_data[BT_MESH_MODEL_BUF_LEN(
185 BT_MESH_LIGHT_CTRL_OP_LIGHT_ONOFF_STATUS, 3)];
187 uint16_t resume;
188#if CONFIG_BT_MESH_LIGHT_CTRL_AMB_LIGHT_LEVEL_TIMEOUT
189 /* Time when the last ambient light level report was received. */
190 int64_t amb_light_level_timestamp;
191#endif
193 struct bt_mesh_model_pub setup_pub;
194 /* Publication buffer */
195 struct net_buf_simple setup_pub_buf;
196 /* Publication data */
197 uint8_t setup_pub_data[BT_MESH_MODEL_BUF_LEN(
198 BT_MESH_LIGHT_CTRL_OP_PROP_STATUS,
200
201#if CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG
203 struct bt_mesh_light_ctrl_reg *reg;
205 uint16_t reg_prev;
206#endif /* CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG */
214 const struct bt_mesh_model *model;
216 const struct bt_mesh_model *setup_srv;
217};
218
232
248
260
274
283
296 struct bt_mesh_msg_ctx *ctx);
297
299extern const struct bt_mesh_model_cb _bt_mesh_light_ctrl_srv_cb;
300extern const struct bt_mesh_model_op _bt_mesh_light_ctrl_srv_op[];
301extern const struct bt_mesh_model_cb _bt_mesh_light_ctrl_setup_srv_cb;
302extern const struct bt_mesh_model_op _bt_mesh_light_ctrl_setup_srv_op[];
303extern const struct bt_mesh_onoff_srv_handlers _bt_mesh_light_ctrl_srv_onoff;
306#ifdef __cplusplus
307}
308#endif
309
310#endif /* BT_MESH_LIGHT_CTRL_SRV_H__ */
311
int bt_mesh_light_ctrl_srv_on(struct bt_mesh_light_ctrl_srv *srv)
Turn the light on.
int bt_mesh_light_ctrl_srv_off(struct bt_mesh_light_ctrl_srv *srv)
Manually turn the light off.
bt_mesh_light_ctrl_srv_state
Definition: light_ctrl_srv.h:101
@ LIGHT_CTRL_STATE_COUNT
Definition: light_ctrl_srv.h:117
@ LIGHT_CTRL_STATE_PROLONG
Definition: light_ctrl_srv.h:114
@ LIGHT_CTRL_STATE_ON
Definition: light_ctrl_srv.h:110
@ LIGHT_CTRL_STATE_STANDBY
Definition: light_ctrl_srv.h:106
int bt_mesh_light_ctrl_srv_disable(struct bt_mesh_light_ctrl_srv *srv)
Disable the Light Lightness Control Server.
int bt_mesh_light_ctrl_srv_enable(struct bt_mesh_light_ctrl_srv *srv)
Enable the Light Lightness Control Server.
int bt_mesh_light_ctrl_srv_pub(struct bt_mesh_light_ctrl_srv *srv, struct bt_mesh_msg_ctx *ctx)
Publish the current OnOff state.
bool bt_mesh_light_ctrl_srv_is_on(struct bt_mesh_light_ctrl_srv *srv)
Check if the Light Lightness Control Server has turned the light on.
#define CONFIG_BT_MESH_SENSOR_CHANNEL_ENCODED_SIZE_MAX
Definition: sensor.h:26
Definition: light_ctrl_reg.h:41
uint32_t fade_standby_auto
Definition: light_ctrl_srv.h:133
uint32_t fade_prolong
Definition: light_ctrl_srv.h:129
uint32_t prolong
Definition: light_ctrl_srv.h:131
uint32_t fade_on
Definition: light_ctrl_srv.h:125
uint32_t fade_standby_manual
Definition: light_ctrl_srv.h:135
uint32_t occupancy_delay
Definition: light_ctrl_srv.h:123
uint32_t on
Definition: light_ctrl_srv.h:127
uint16_t light[LIGHT_CTRL_STATE_COUNT]
Definition: light_ctrl_srv.h:137
Definition: light_ctrl_srv.h:121
enum bt_mesh_light_ctrl_srv_state state
Definition: light_ctrl_srv.h:155
uint32_t duration
Definition: light_ctrl_srv.h:170
struct bt_mesh_onoff_srv onoff
Definition: light_ctrl_srv.h:210
uint16_t initial_light
Definition: light_ctrl_srv.h:161
const struct bt_mesh_model * model
Definition: light_ctrl_srv.h:214
struct k_work_delayable action_delay
Definition: light_ctrl_srv.h:176
struct bt_mesh_model_pub setup_pub
Definition: light_ctrl_srv.h:193
struct bt_mesh_tid_ctx tid
Definition: light_ctrl_srv.h:212
struct net_buf_simple setup_pub_buf
Definition: light_ctrl_srv.h:195
atomic_t flags
Definition: light_ctrl_srv.h:157
struct bt_mesh_light_ctrl_srv::@149 fade
struct bt_mesh_lightness_srv * lightness
Definition: light_ctrl_srv.h:208
uint16_t resume
Definition: light_ctrl_srv.h:187
uint32_t initial_centilux
Definition: light_ctrl_srv.h:167
struct bt_mesh_model_pub pub
Definition: light_ctrl_srv.h:180
uint8_t setup_pub_data[BT_MESH_MODEL_BUF_LEN(BT_MESH_LIGHT_CTRL_OP_PROP_STATUS, 2+CONFIG_BT_MESH_SENSOR_CHANNEL_ENCODED_SIZE_MAX)]
Definition: light_ctrl_srv.h:199
uint8_t pub_data[BT_MESH_MODEL_BUF_LEN(BT_MESH_LIGHT_CTRL_OP_LIGHT_ONOFF_STATUS, 3)]
Definition: light_ctrl_srv.h:185
struct bt_mesh_light_ctrl_srv_cfg cfg
Definition: light_ctrl_srv.h:178
struct net_buf_simple pub_buf
Definition: light_ctrl_srv.h:182
struct k_work_delayable timer
Definition: light_ctrl_srv.h:173
const struct bt_mesh_model * setup_srv
Definition: light_ctrl_srv.h:216
Light Lightness Control Server instance.
Definition: light_ctrl_srv.h:153
Definition: lightness_srv.h:181
Definition: gen_onoff_srv.h:52
Definition: gen_onoff_srv.h:92
Definition: model_types.h:46