10#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_ACCESS_H_
11#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_ACCESS_H_
18#define BT_MESH_KEY_UNUSED_ELT_(IDX, _) BT_MESH_KEY_UNUSED,
19#define BT_MESH_ADDR_UNASSIGNED_ELT_(IDX, _) BT_MESH_ADDR_UNASSIGNED,
20#define BT_MESH_MODEL_KEYS_UNUSED \
21 { UTIL_LISTIFY(CONFIG_BT_MESH_MODEL_KEY_COUNT, \
22 BT_MESH_KEY_UNUSED_ELT_) }
23#define BT_MESH_MODEL_GROUPS_UNASSIGNED \
24 { UTIL_LISTIFY(CONFIG_BT_MESH_MODEL_GROUP_COUNT, \
25 BT_MESH_ADDR_UNASSIGNED_ELT_) }
38#define BT_MESH_ADDR_UNASSIGNED 0x0000
39#define BT_MESH_ADDR_ALL_NODES 0xffff
40#define BT_MESH_ADDR_PROXIES 0xfffc
41#define BT_MESH_ADDR_FRIENDS 0xfffd
42#define BT_MESH_ADDR_RELAYS 0xfffe
44#define BT_MESH_KEY_UNUSED 0xffff
45#define BT_MESH_KEY_ANY 0xffff
46#define BT_MESH_KEY_DEV 0xfffe
47#define BT_MESH_KEY_DEV_LOCAL BT_MESH_KEY_DEV
48#define BT_MESH_KEY_DEV_REMOTE 0xfffd
49#define BT_MESH_KEY_DEV_ANY 0xfffc
51#define BT_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000)
52#define BT_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xc000 && (addr) <= 0xff00)
53#define BT_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xc000)
54#define BT_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xff00 && (addr) <= 0xfffb)
56#define BT_MESH_IS_DEV_KEY(key) (key == BT_MESH_KEY_DEV_LOCAL || \
57 key == BT_MESH_KEY_DEV_REMOTE)
60#define BT_MESH_APP_SEG_SDU_MAX 12
62#define BT_MESH_TX_SDU_MAX (CONFIG_BT_MESH_TX_SEG_MAX * \
63 BT_MESH_APP_SEG_SDU_MAX)
65#define BT_MESH_RX_SDU_MAX (CONFIG_BT_MESH_RX_SEG_MAX * \
66 BT_MESH_APP_SEG_SDU_MAX)
77#define BT_MESH_ELEM(_loc, _mods, _vnd_mods) \
80 .model_count = ARRAY_SIZE(_mods), \
81 .vnd_model_count = ARRAY_SIZE(_vnd_mods), \
83 .vnd_models = (_vnd_mods), \
105#define BT_MESH_MODEL_ID_CFG_SRV 0x0000
106#define BT_MESH_MODEL_ID_CFG_CLI 0x0001
107#define BT_MESH_MODEL_ID_HEALTH_SRV 0x0002
108#define BT_MESH_MODEL_ID_HEALTH_CLI 0x0003
111#define BT_MESH_MODEL_ID_GEN_ONOFF_SRV 0x1000
112#define BT_MESH_MODEL_ID_GEN_ONOFF_CLI 0x1001
113#define BT_MESH_MODEL_ID_GEN_LEVEL_SRV 0x1002
114#define BT_MESH_MODEL_ID_GEN_LEVEL_CLI 0x1003
115#define BT_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV 0x1004
116#define BT_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI 0x1005
117#define BT_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV 0x1006
118#define BT_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV 0x1007
119#define BT_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI 0x1008
120#define BT_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV 0x1009
121#define BT_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV 0x100a
122#define BT_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI 0x100b
123#define BT_MESH_MODEL_ID_GEN_BATTERY_SRV 0x100c
124#define BT_MESH_MODEL_ID_GEN_BATTERY_CLI 0x100d
125#define BT_MESH_MODEL_ID_GEN_LOCATION_SRV 0x100e
126#define BT_MESH_MODEL_ID_GEN_LOCATION_SETUPSRV 0x100f
127#define BT_MESH_MODEL_ID_GEN_LOCATION_CLI 0x1010
128#define BT_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV 0x1011
129#define BT_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV 0x1012
130#define BT_MESH_MODEL_ID_GEN_USER_PROP_SRV 0x1013
131#define BT_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV 0x1014
132#define BT_MESH_MODEL_ID_GEN_PROP_CLI 0x1015
133#define BT_MESH_MODEL_ID_SENSOR_SRV 0x1100
134#define BT_MESH_MODEL_ID_SENSOR_SETUP_SRV 0x1101
135#define BT_MESH_MODEL_ID_SENSOR_CLI 0x1102
136#define BT_MESH_MODEL_ID_TIME_SRV 0x1200
137#define BT_MESH_MODEL_ID_TIME_SETUP_SRV 0x1201
138#define BT_MESH_MODEL_ID_TIME_CLI 0x1202
139#define BT_MESH_MODEL_ID_SCENE_SRV 0x1203
140#define BT_MESH_MODEL_ID_SCENE_SETUP_SRV 0x1204
141#define BT_MESH_MODEL_ID_SCENE_CLI 0x1205
142#define BT_MESH_MODEL_ID_SCHEDULER_SRV 0x1206
143#define BT_MESH_MODEL_ID_SCHEDULER_SETUP_SRV 0x1207
144#define BT_MESH_MODEL_ID_SCHEDULER_CLI 0x1208
145#define BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV 0x1300
146#define BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV 0x1301
147#define BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI 0x1302
148#define BT_MESH_MODEL_ID_LIGHT_CTL_SRV 0x1303
149#define BT_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV 0x1304
150#define BT_MESH_MODEL_ID_LIGHT_CTL_CLI 0x1305
151#define BT_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV 0x1306
152#define BT_MESH_MODEL_ID_LIGHT_HSL_SRV 0x1307
153#define BT_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV 0x1308
154#define BT_MESH_MODEL_ID_LIGHT_HSL_CLI 0x1309
155#define BT_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV 0x130a
156#define BT_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV 0x130b
157#define BT_MESH_MODEL_ID_LIGHT_XYL_SRV 0x130c
158#define BT_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV 0x130d
159#define BT_MESH_MODEL_ID_LIGHT_XYL_CLI 0x130e
160#define BT_MESH_MODEL_ID_LIGHT_LC_SRV 0x130f
161#define BT_MESH_MODEL_ID_LIGHT_LC_SETUPSRV 0x1310
162#define BT_MESH_MODEL_ID_LIGHT_LC_CLI 0x1311
191#define BT_MESH_MODEL_OP_1(b0) (b0)
192#define BT_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1))
193#define BT_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xc00000) | (cid))
196#define BT_MESH_LEN_EXACT(len) (-len)
198#define BT_MESH_LEN_MIN(len) (len)
201#define BT_MESH_MODEL_OP_END { 0, 0, NULL }
203#define BT_MESH_MODEL_NO_OPS ((struct bt_mesh_model_op []) \
204 { BT_MESH_MODEL_OP_END })
207#define BT_MESH_MODEL_NONE ((struct bt_mesh_model []){})
219#define BT_MESH_MODEL_CB(_id, _op, _pub, _user_data, _cb) \
223 .keys = BT_MESH_MODEL_KEYS_UNUSED, \
224 .groups = BT_MESH_MODEL_GROUPS_UNASSIGNED, \
227 .user_data = _user_data, \
241#define BT_MESH_MODEL_VND_CB(_company, _id, _op, _pub, _user_data, _cb) \
243 .vnd.company = (_company), \
247 .keys = BT_MESH_MODEL_KEYS_UNUSED, \
248 .groups = BT_MESH_MODEL_GROUPS_UNASSIGNED, \
249 .user_data = _user_data, \
263#define BT_MESH_MODEL(_id, _op, _pub, _user_data) \
264 BT_MESH_MODEL_CB(_id, _op, _pub, _user_data, NULL)
276#define BT_MESH_MODEL_VND(_company, _id, _op, _pub, _user_data) \
277 BT_MESH_MODEL_VND_CB(_company, _id, _op, _pub, _user_data, NULL)
290#define BT_MESH_TRANSMIT(count, int_ms) ((count) | (((int_ms / 10) - 1) << 3))
300#define BT_MESH_TRANSMIT_COUNT(transmit) (((transmit) & (uint8_t)BIT_MASK(3)))
310#define BT_MESH_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 10)
323#define BT_MESH_PUB_TRANSMIT(count, int_ms) BT_MESH_TRANSMIT(count, \
334#define BT_MESH_PUB_TRANSMIT_COUNT(transmit) BT_MESH_TRANSMIT_COUNT(transmit)
344#define BT_MESH_PUB_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 50)
407#define BT_MESH_MODEL_PUB_DEFINE(_name, _update, _msg_len) \
408 NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \
409 static struct bt_mesh_model_pub _name = { \
410 .msg = &bt_mesh_pub_msg_##_name, \
430 const char *name,
size_t len_rd,
511#ifdef CONFIG_BT_MESH_MODEL_EXTENSIONS
539#define BT_MESH_TTL_DEFAULT 0xff
542#define BT_MESH_TTL_MAX 0x7f
629 const char *name,
const void *
data,
void
Definition: eswifi_shell.c:15
bool bt_mesh_model_is_extended(struct bt_mesh_model *model)
Check if model is extended by another model.
struct bt_mesh_elem * bt_mesh_model_elem(struct bt_mesh_model *mod)
Get the element that a model belongs to.
struct bt_mesh_model * bt_mesh_model_find_vnd(const struct bt_mesh_elem *elem, uint16_t company, uint16_t id)
Find a vendor model.
int bt_mesh_model_publish(struct bt_mesh_model *model)
Send a model publication message.
struct bt_mesh_model * bt_mesh_model_find(const struct bt_mesh_elem *elem, uint16_t id)
Find a SIG model.
static bool bt_mesh_model_in_primary(const struct bt_mesh_model *mod)
Get whether the model is in the primary element of the device.
Definition: access.h:612
int bt_mesh_model_data_store(struct bt_mesh_model *mod, bool vnd, const char *name, const void *data, size_t data_len)
Immediately store the model's user data in persistent storage.
int bt_mesh_model_extend(struct bt_mesh_model *extending_mod, struct bt_mesh_model *base_mod)
Let a model extend another.
int bt_mesh_model_send(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *msg, const struct bt_mesh_send_cb *cb, void *cb_data)
Send an Access Layer message.
ssize_t(* settings_read_cb)(void *cb_arg, void *data, size_t len)
Definition: settings.h:57
__SIZE_TYPE__ ssize_t
Definition: types.h:28
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
uint16_t pid
Definition: access.h:665
uint16_t cid
Definition: access.h:664
uint16_t vid
Definition: access.h:666
struct bt_mesh_elem * elem
Definition: access.h:669
size_t elem_count
Definition: access.h:668
struct bt_mesh_model *const models
Definition: access.h:99
const uint16_t loc
Definition: access.h:92
const uint8_t model_count
Definition: access.h:94
struct bt_mesh_model *const vnd_models
Definition: access.h:101
uint16_t addr
Definition: access.h:89
const uint8_t vnd_model_count
Definition: access.h:96
uint16_t company
Definition: access.h:477
uint16_t id
Definition: access.h:479
int(*const settings_set)(struct bt_mesh_model *model, const char *name, size_t len_rd, settings_read_cb read_cb, void *cb_arg)
Set value handler of user data tied to the model.
Definition: access.h:429
void(*const reset)(struct bt_mesh_model *model)
Model reset callback.
Definition: access.h:471
int(*const start)(struct bt_mesh_model *model)
Callback called when the mesh is started.
Definition: access.h:445
int(*const init)(struct bt_mesh_model *model)
Model init callback.
Definition: access.h:459
const uint32_t opcode
Definition: access.h:167
const ssize_t len
Definition: access.h:175
int(*const func)(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
Handler function for this opcode.
Definition: access.h:186
uint16_t key
Definition: access.h:356
int(* update)(struct bt_mesh_model *mod)
Callback for updating the publication buffer.
Definition: access.h:393
uint16_t cred
Definition: access.h:357
uint8_t retransmit
Definition: access.h:362
uint16_t addr
Definition: access.h:355
uint8_t count
Definition: access.h:365
uint8_t period_div
Definition: access.h:364
struct net_buf_simple * msg
Publication buffer, containing the publication message.
Definition: access.h:376
struct bt_mesh_model * mod
Definition: access.h:353
uint8_t ttl
Definition: access.h:361
uint32_t period_start
Definition: access.h:367
uint16_t send_rel
Definition: access.h:358
uint16_t fast_period
Definition: access.h:359
uint8_t period
Definition: access.h:363
struct k_work_delayable timer
Definition: access.h:396
uint8_t elem_idx
Definition: access.h:492
const struct bt_mesh_mod_id_vnd vnd
Definition: access.h:488
uint16_t keys[CONFIG_BT_MESH_MODEL_KEY_COUNT]
Definition: access.h:500
const struct bt_mesh_model_op *const op
Definition: access.h:506
uint16_t groups[CONFIG_BT_MESH_MODEL_GROUP_COUNT]
Definition: access.h:503
void * user_data
Definition: access.h:517
const struct bt_mesh_model_cb *const cb
Definition: access.h:509
uint16_t flags
Definition: access.h:494
const uint16_t id
Definition: access.h:486
uint8_t mod_idx
Definition: access.h:493
struct bt_mesh_model * next
Definition: access.h:513
struct bt_mesh_model_pub *const pub
Definition: access.h:497
void(* start)(uint16_t duration, int err, void *cb_data)
Handler called at the start of the transmission.
Definition: access.h:528
void(* end)(int err, void *cb_data)
Handler called at the end of the transmission.
Definition: access.h:534
A structure used to submit work after a delay.
Definition: kernel.h:3651
Simple network buffer representation.
Definition: buf.h:87
static fdata_t data[2]
Definition: test_fifo_contexts.c:15