nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
gen_dtt_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
15#ifndef BT_MESH_GEN_DTT_SRV_H__
16#define BT_MESH_GEN_DTT_SRV_H__
17
18#include <zephyr/bluetooth/mesh.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26struct bt_mesh_dtt_srv;
27
35#define BT_MESH_DTT_SRV_INIT(_update) \
36 { \
37 .update = _update, \
38 }
39
46#define BT_MESH_MODEL_DTT_SRV(_srv) \
47 BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV, \
48 _bt_mesh_dtt_srv_op, &(_srv)->pub, \
49 BT_MESH_MODEL_USER_DATA(struct bt_mesh_dtt_srv, \
50 _srv), \
51 &_bt_mesh_dtt_srv_cb)
52
57
70 void (*const update)(struct bt_mesh_dtt_srv *srv,
71 struct bt_mesh_msg_ctx *ctx,
72 uint32_t old_transition_time,
73 uint32_t new_transition_time);
75 const struct bt_mesh_model *model;
77 struct bt_mesh_model_pub pub;
78 /* Publication buffer */
79 struct net_buf_simple pub_buf;
80 /* Publication data */
81 uint8_t pub_data[BT_MESH_MODEL_BUF_LEN(BT_MESH_DTT_OP_STATUS,
82 BT_MESH_DTT_MSG_LEN_STATUS)];
83};
84
94void bt_mesh_dtt_srv_set(struct bt_mesh_dtt_srv *srv, uint32_t transition_time);
95
108 struct bt_mesh_msg_ctx *ctx);
109
121struct bt_mesh_dtt_srv *bt_mesh_dtt_srv_get(const struct bt_mesh_elem *elem);
122
130static inline bool
131bt_mesh_dtt_srv_transition_get(const struct bt_mesh_model *model,
132 struct bt_mesh_model_transition *transition)
133{
134 struct bt_mesh_dtt_srv *srv;
135
136 if (IS_ENABLED(CONFIG_BT_MESH_DTT_SRV)) {
137 srv = bt_mesh_dtt_srv_get(bt_mesh_model_elem(model));
138 } else {
139 srv = NULL;
140 }
141
142 transition->time = srv ? srv->transition_time : 0;
143 transition->delay = 0;
144 return (srv != NULL);
145}
146
148extern const struct bt_mesh_model_op _bt_mesh_dtt_srv_op[];
149extern const struct bt_mesh_model_cb _bt_mesh_dtt_srv_cb;
152#ifdef __cplusplus
153}
154#endif
155
156#endif /* BT_MESH_GEN_DTT_SRV_H__ */
157
int bt_mesh_dtt_srv_pub(struct bt_mesh_dtt_srv *srv, struct bt_mesh_msg_ctx *ctx)
Publish the current transition time.
struct bt_mesh_dtt_srv * bt_mesh_dtt_srv_get(const struct bt_mesh_elem *elem)
Find the Generic DTT server over multiple elements.
static bool bt_mesh_dtt_srv_transition_get(const struct bt_mesh_model *model, struct bt_mesh_model_transition *transition)
Get the default transition parameters for the given model.
Definition: gen_dtt_srv.h:131
void bt_mesh_dtt_srv_set(struct bt_mesh_dtt_srv *srv, uint32_t transition_time)
Set the Default Transition Time of the DTT server.
struct net_buf_simple pub_buf
Definition: gen_dtt_srv.h:79
const struct bt_mesh_model * model
Definition: gen_dtt_srv.h:75
uint32_t transition_time
Definition: gen_dtt_srv.h:56
void(*const update)(struct bt_mesh_dtt_srv *srv, struct bt_mesh_msg_ctx *ctx, uint32_t old_transition_time, uint32_t new_transition_time)
Update handler for the transition time state.
Definition: gen_dtt_srv.h:70
uint8_t pub_data[BT_MESH_MODEL_BUF_LEN(BT_MESH_DTT_OP_STATUS, BT_MESH_DTT_MSG_LEN_STATUS)]
Definition: gen_dtt_srv.h:82
struct bt_mesh_model_pub pub
Definition: gen_dtt_srv.h:77
Definition: gen_dtt_srv.h:54
uint32_t delay
Definition: model_types.h:39
uint32_t time
Definition: model_types.h:38
Definition: model_types.h:37