nRF Connect SDK API 2.8.99
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
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
140 uint32_t centilux[LIGHT_CTRL_STATE_COUNT];
141#endif /* CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG */
142};
143
152 atomic_t flags;
154 struct {
160 uint32_t duration;
163 struct k_work_delayable timer;
164
166 struct k_work_delayable action_delay;
170 struct bt_mesh_model_pub pub;
171 /* Publication buffer */
172 struct net_buf_simple pub_buf;
173 /* Publication data */
174 uint8_t pub_data[BT_MESH_MODEL_BUF_LEN(
175 BT_MESH_LIGHT_CTRL_OP_LIGHT_ONOFF_STATUS, 3)];
177 uint16_t resume;
178#if CONFIG_BT_MESH_LIGHT_CTRL_AMB_LIGHT_LEVEL_TIMEOUT
179 /* Time when the last ambient light level report was received. */
180 int64_t amb_light_level_timestamp;
181#endif
183 struct bt_mesh_model_pub setup_pub;
184 /* Publication buffer */
185 struct net_buf_simple setup_pub_buf;
186 /* Publication data */
187 uint8_t setup_pub_data[BT_MESH_MODEL_BUF_LEN(
188 BT_MESH_LIGHT_CTRL_OP_PROP_STATUS,
190
191#if CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG
193 struct bt_mesh_light_ctrl_reg *reg;
195 uint16_t reg_prev;
196#endif /* CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG */
204 const struct bt_mesh_model *model;
206 const struct bt_mesh_model *setup_srv;
207};
208
222
238
250
264
273
286 struct bt_mesh_msg_ctx *ctx);
287
289extern const struct bt_mesh_model_cb _bt_mesh_light_ctrl_srv_cb;
290extern const struct bt_mesh_model_op _bt_mesh_light_ctrl_srv_op[];
291extern const struct bt_mesh_model_cb _bt_mesh_light_ctrl_setup_srv_cb;
292extern const struct bt_mesh_model_op _bt_mesh_light_ctrl_setup_srv_op[];
293extern const struct bt_mesh_onoff_srv_handlers _bt_mesh_light_ctrl_srv_onoff;
296#ifdef __cplusplus
297}
298#endif
299
300#endif /* BT_MESH_LIGHT_CTRL_SRV_H__ */
301
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:150
uint32_t duration
Definition light_ctrl_srv.h:160
struct bt_mesh_onoff_srv onoff
Definition light_ctrl_srv.h:200
uint16_t initial_light
Definition light_ctrl_srv.h:156
const struct bt_mesh_model * model
Definition light_ctrl_srv.h:204
struct k_work_delayable action_delay
Definition light_ctrl_srv.h:166
struct bt_mesh_model_pub setup_pub
Definition light_ctrl_srv.h:183
struct bt_mesh_tid_ctx tid
Definition light_ctrl_srv.h:202
struct net_buf_simple setup_pub_buf
Definition light_ctrl_srv.h:185
atomic_t flags
Definition light_ctrl_srv.h:152
struct bt_mesh_lightness_srv * lightness
Definition light_ctrl_srv.h:198
uint16_t resume
Definition light_ctrl_srv.h:177
uint32_t initial_centilux
Definition light_ctrl_srv.h:158
struct bt_mesh_model_pub pub
Definition light_ctrl_srv.h:170
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:189
uint8_t pub_data[BT_MESH_MODEL_BUF_LEN(BT_MESH_LIGHT_CTRL_OP_LIGHT_ONOFF_STATUS, 3)]
Definition light_ctrl_srv.h:175
struct bt_mesh_light_ctrl_srv::@154 fade
struct bt_mesh_light_ctrl_srv_cfg cfg
Definition light_ctrl_srv.h:168
struct net_buf_simple pub_buf
Definition light_ctrl_srv.h:172
struct k_work_delayable timer
Definition light_ctrl_srv.h:163
const struct bt_mesh_model * setup_srv
Definition light_ctrl_srv.h:206
Light Lightness Control Server instance.
Definition light_ctrl_srv.h:148
Definition lightness_srv.h:181
Definition gen_onoff_srv.h:52
Definition gen_onoff_srv.h:92
Definition model_types.h:46