nRF Connect SDK API 2.8.99
Loading...
Searching...
No Matches
gen_plvl_srv.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
14#ifndef BT_MESH_GEN_PLVL_SRV_H__
15#define BT_MESH_GEN_PLVL_SRV_H__
16
17#include <zephyr/bluetooth/mesh.h>
18
23#if IS_ENABLED(CONFIG_EMDS) && IS_ENABLED(CONFIG_BT_SETTINGS)
24#include "emds/emds.h"
25#endif
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31struct bt_mesh_plvl_srv;
32
39#define BT_MESH_PLVL_SRV_INIT(_handlers) \
40 { \
41 .lvl = BT_MESH_LVL_SRV_INIT(&bt_mesh_plvl_srv_lvl_handlers), \
42 .ponoff = BT_MESH_PONOFF_SRV_INIT( \
43 &bt_mesh_plvl_srv_onoff_handlers, NULL, NULL), \
44 .handlers = _handlers, \
45 }
46
53#define BT_MESH_MODEL_PLVL_SRV(_srv) \
54 BT_MESH_MODEL_LVL_SRV(&(_srv)->lvl), \
55 BT_MESH_MODEL_PONOFF_SRV(&(_srv)->ponoff), \
56 BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV, \
57 _bt_mesh_plvl_srv_op, &(_srv)->pub, \
58 BT_MESH_MODEL_USER_DATA( \
59 struct bt_mesh_plvl_srv, _srv), \
60 &_bt_mesh_plvl_srv_cb), \
61 BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV, \
62 _bt_mesh_plvl_setup_srv_op, NULL, \
63 BT_MESH_MODEL_USER_DATA( \
64 struct bt_mesh_plvl_srv, _srv), \
65 &_bt_mesh_plvl_setup_srv_cb)
66
85 void (*const power_set)(struct bt_mesh_plvl_srv *srv,
86 struct bt_mesh_msg_ctx *ctx,
87 const struct bt_mesh_plvl_set *set,
88 struct bt_mesh_plvl_status *rsp);
89
99 void (*const power_get)(struct bt_mesh_plvl_srv *srv,
100 struct bt_mesh_msg_ctx *ctx,
101 struct bt_mesh_plvl_status *rsp);
102
114 void (*const default_update)(struct bt_mesh_plvl_srv *srv,
115 struct bt_mesh_msg_ctx *ctx,
116 uint16_t old_default, uint16_t new_default);
117
133 void (*const range_update)(struct bt_mesh_plvl_srv *srv,
134 struct bt_mesh_msg_ctx *ctx,
135 const struct bt_mesh_plvl_range *old_range,
136 const struct bt_mesh_plvl_range *new_range);
137};
138
150 const struct bt_mesh_model *plvl_model;
152 const struct bt_mesh_model *plvl_setup_model;
154 struct bt_mesh_model_pub pub;
155 /* Publication buffer */
156 struct net_buf_simple pub_buf;
157 /* Publication data */
158 uint8_t pub_data[BT_MESH_MODEL_BUF_LEN(
159 BT_MESH_PLVL_OP_LEVEL_STATUS,
160 BT_MESH_PLVL_MSG_MAXLEN_LEVEL_STATUS)];
165
170 struct __packed {
172 uint16_t last;
174 bool is_on;
176
177#if IS_ENABLED(CONFIG_EMDS) && IS_ENABLED(CONFIG_BT_SETTINGS)
180#endif
181};
182
202 struct bt_mesh_msg_ctx *ctx,
203 const struct bt_mesh_plvl_status *status);
204
206extern const struct bt_mesh_model_cb _bt_mesh_plvl_srv_cb;
207extern const struct bt_mesh_model_cb _bt_mesh_plvl_setup_srv_cb;
208extern const struct bt_mesh_model_op _bt_mesh_plvl_srv_op[];
209extern const struct bt_mesh_model_op _bt_mesh_plvl_setup_srv_op[];
210extern const struct bt_mesh_lvl_srv_handlers bt_mesh_plvl_srv_lvl_handlers;
211extern const struct bt_mesh_onoff_srv_handlers bt_mesh_plvl_srv_onoff_handlers;
214#ifdef __cplusplus
215}
216#endif
217
218#endif /* BT_MESH_GEN_PLVL_SRV_H__ */
219
int bt_mesh_plvl_srv_pub(struct bt_mesh_plvl_srv *srv, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_plvl_status *status)
Publish the current Power state.
Definition gen_lvl_srv.h:52
Definition gen_lvl_srv.h:143
Definition gen_onoff_srv.h:52
Definition gen_plvl.h:53
Definition gen_plvl.h:25
void(*const default_update)(struct bt_mesh_plvl_srv *srv, struct bt_mesh_msg_ctx *ctx, uint16_t old_default, uint16_t new_default)
The Default Power state has changed.
Definition gen_plvl_srv.h:114
void(*const power_set)(struct bt_mesh_plvl_srv *srv, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_plvl_set *set, struct bt_mesh_plvl_status *rsp)
Set the Power state.
Definition gen_plvl_srv.h:85
void(*const power_get)(struct bt_mesh_plvl_srv *srv, struct bt_mesh_msg_ctx *ctx, struct bt_mesh_plvl_status *rsp)
Get the current Power state.
Definition gen_plvl_srv.h:99
void(*const range_update)(struct bt_mesh_plvl_srv *srv, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_plvl_range *old_range, const struct bt_mesh_plvl_range *new_range)
The Power Range state has changed.
Definition gen_plvl_srv.h:133
Definition gen_plvl_srv.h:68
struct bt_mesh_model_pub pub
Definition gen_plvl_srv.h:154
struct net_buf_simple pub_buf
Definition gen_plvl_srv.h:156
uint16_t last
Definition gen_plvl_srv.h:172
struct bt_mesh_plvl_range range
Definition gen_plvl_srv.h:167
uint8_t pub_data[BT_MESH_MODEL_BUF_LEN(BT_MESH_PLVL_OP_LEVEL_STATUS, BT_MESH_PLVL_MSG_MAXLEN_LEVEL_STATUS)]
Definition gen_plvl_srv.h:160
const struct bt_mesh_model * plvl_model
Definition gen_plvl_srv.h:150
struct bt_mesh_tid_ctx tid
Definition gen_plvl_srv.h:162
struct bt_mesh_ponoff_srv ponoff
Definition gen_plvl_srv.h:148
const struct bt_mesh_plvl_srv_handlers *const handlers
Definition gen_plvl_srv.h:164
uint16_t default_power
Definition gen_plvl_srv.h:169
const struct bt_mesh_model * plvl_setup_model
Definition gen_plvl_srv.h:152
struct bt_mesh_plvl_srv::@153 transient
bool is_on
Definition gen_plvl_srv.h:174
struct bt_mesh_lvl_srv lvl
Definition gen_plvl_srv.h:146
Definition gen_plvl_srv.h:144
Definition gen_plvl.h:39
Definition gen_ponoff_srv.h:74
Definition model_types.h:46
Definition emds.h:46
Definition emds.h:31