Zephyr Project API 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
access.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2017 Intel Corporation
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_ACCESS_H_
11#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_ACCESS_H_
12
13#include <zephyr/sys/util.h>
16
17/* Internal macros used to initialize array members */
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_UUID_UNASSIGNED_ELT_(IDX, _) NULL
21#define BT_MESH_MODEL_KEYS_UNUSED(_keys) \
22 { LISTIFY(_keys, BT_MESH_KEY_UNUSED_ELT_, (,)) }
23#define BT_MESH_MODEL_GROUPS_UNASSIGNED(_grps) \
24 { LISTIFY(_grps, BT_MESH_ADDR_UNASSIGNED_ELT_, (,)) }
25#if CONFIG_BT_MESH_LABEL_COUNT > 0
26#define BT_MESH_MODEL_UUIDS_UNASSIGNED() \
27 .uuids = (const uint8_t *[]){ LISTIFY(CONFIG_BT_MESH_LABEL_COUNT, \
28 BT_MESH_UUID_UNASSIGNED_ELT_, (,)) },
29#else
30#define BT_MESH_MODEL_UUIDS_UNASSIGNED()
31#endif
32
33#define BT_MESH_MODEL_RUNTIME_INIT(_user_data) \
34 .rt = &(struct bt_mesh_model_rt_ctx){ .user_data = (_user_data) },
35
43#ifdef __cplusplus
44extern "C" {
45#endif
46
51#define BT_MESH_ADDR_UNASSIGNED 0x0000
52#define BT_MESH_ADDR_ALL_NODES 0xffff
53#define BT_MESH_ADDR_RELAYS 0xfffe
54#define BT_MESH_ADDR_FRIENDS 0xfffd
55#define BT_MESH_ADDR_PROXIES 0xfffc
56#define BT_MESH_ADDR_DFW_NODES 0xfffb
57#define BT_MESH_ADDR_IP_NODES 0xfffa
58#define BT_MESH_ADDR_IP_BR_ROUTERS 0xfff9
67#define BT_MESH_KEY_UNUSED 0xffff
68#define BT_MESH_KEY_ANY 0xffff
69#define BT_MESH_KEY_DEV 0xfffe
70#define BT_MESH_KEY_DEV_LOCAL BT_MESH_KEY_DEV
71#define BT_MESH_KEY_DEV_REMOTE 0xfffd
72#define BT_MESH_KEY_DEV_ANY 0xfffc
80#define BT_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000)
84#define BT_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xc000 && (addr) < 0xff00)
88#define BT_MESH_ADDR_IS_FIXED_GROUP(addr) ((addr) >= 0xff00 && (addr) < 0xffff)
92#define BT_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xc000)
96#define BT_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xff00 && (addr) <= 0xfff8)
97
101#define BT_MESH_IS_DEV_KEY(key) (key == BT_MESH_KEY_DEV_LOCAL || \
102 key == BT_MESH_KEY_DEV_REMOTE)
103
105#define BT_MESH_APP_SEG_SDU_MAX 12
106
108#define BT_MESH_APP_UNSEG_SDU_MAX 15
109
111#if defined(CONFIG_BT_MESH_RX_SEG_MAX)
112#define BT_MESH_RX_SEG_MAX CONFIG_BT_MESH_RX_SEG_MAX
113#else
114#define BT_MESH_RX_SEG_MAX 0
115#endif
116
118#if defined(CONFIG_BT_MESH_TX_SEG_MAX)
119#define BT_MESH_TX_SEG_MAX CONFIG_BT_MESH_TX_SEG_MAX
120#else
121#define BT_MESH_TX_SEG_MAX 0
122#endif
123
125#define BT_MESH_TX_SDU_MAX MAX((BT_MESH_TX_SEG_MAX * \
126 BT_MESH_APP_SEG_SDU_MAX), \
127 BT_MESH_APP_UNSEG_SDU_MAX)
128
130#define BT_MESH_RX_SDU_MAX MAX((BT_MESH_RX_SEG_MAX * \
131 BT_MESH_APP_SEG_SDU_MAX), \
132 BT_MESH_APP_UNSEG_SDU_MAX)
133
143#define BT_MESH_ELEM(_loc, _mods, _vnd_mods) \
144{ \
145 .rt = &(struct bt_mesh_elem_rt_ctx) { 0 }, \
146 .loc = (_loc), \
147 .model_count = ARRAY_SIZE(_mods), \
148 .vnd_model_count = ARRAY_SIZE(_vnd_mods), \
149 .models = (_mods), \
150 .vnd_models = (_vnd_mods), \
151}
152
160
167
169 const struct bt_mesh_model * const models;
171 const struct bt_mesh_model * const vnd_models;
172};
173
179#define BT_MESH_MODEL_ID_CFG_SRV 0x0000
181#define BT_MESH_MODEL_ID_CFG_CLI 0x0001
183#define BT_MESH_MODEL_ID_HEALTH_SRV 0x0002
185#define BT_MESH_MODEL_ID_HEALTH_CLI 0x0003
187#define BT_MESH_MODEL_ID_REMOTE_PROV_SRV 0x0004
189#define BT_MESH_MODEL_ID_REMOTE_PROV_CLI 0x0005
191#define BT_MESH_MODEL_ID_BRG_CFG_SRV 0x0008
193#define BT_MESH_MODEL_ID_BRG_CFG_CLI 0x0009
195#define BT_MESH_MODEL_ID_PRIV_BEACON_SRV 0x000a
197#define BT_MESH_MODEL_ID_PRIV_BEACON_CLI 0x000b
199#define BT_MESH_MODEL_ID_SAR_CFG_SRV 0x000e
201#define BT_MESH_MODEL_ID_SAR_CFG_CLI 0x000f
203#define BT_MESH_MODEL_ID_OP_AGG_SRV 0x0010
205#define BT_MESH_MODEL_ID_OP_AGG_CLI 0x0011
207#define BT_MESH_MODEL_ID_LARGE_COMP_DATA_SRV 0x0012
209#define BT_MESH_MODEL_ID_LARGE_COMP_DATA_CLI 0x0013
211#define BT_MESH_MODEL_ID_SOL_PDU_RPL_SRV 0x0014
213#define BT_MESH_MODEL_ID_SOL_PDU_RPL_CLI 0x0015
215#define BT_MESH_MODEL_ID_ON_DEMAND_PROXY_SRV 0x000c
217#define BT_MESH_MODEL_ID_ON_DEMAND_PROXY_CLI 0x000d
227#define BT_MESH_MODEL_ID_GEN_ONOFF_SRV 0x1000
229#define BT_MESH_MODEL_ID_GEN_ONOFF_CLI 0x1001
231#define BT_MESH_MODEL_ID_GEN_LEVEL_SRV 0x1002
233#define BT_MESH_MODEL_ID_GEN_LEVEL_CLI 0x1003
235#define BT_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV 0x1004
237#define BT_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI 0x1005
239#define BT_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV 0x1006
241#define BT_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV 0x1007
243#define BT_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI 0x1008
245#define BT_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV 0x1009
247#define BT_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV 0x100a
249#define BT_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI 0x100b
251#define BT_MESH_MODEL_ID_GEN_BATTERY_SRV 0x100c
253#define BT_MESH_MODEL_ID_GEN_BATTERY_CLI 0x100d
255#define BT_MESH_MODEL_ID_GEN_LOCATION_SRV 0x100e
257#define BT_MESH_MODEL_ID_GEN_LOCATION_SETUPSRV 0x100f
259#define BT_MESH_MODEL_ID_GEN_LOCATION_CLI 0x1010
261#define BT_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV 0x1011
263#define BT_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV 0x1012
265#define BT_MESH_MODEL_ID_GEN_USER_PROP_SRV 0x1013
267#define BT_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV 0x1014
269#define BT_MESH_MODEL_ID_GEN_PROP_CLI 0x1015
271#define BT_MESH_MODEL_ID_SENSOR_SRV 0x1100
273#define BT_MESH_MODEL_ID_SENSOR_SETUP_SRV 0x1101
275#define BT_MESH_MODEL_ID_SENSOR_CLI 0x1102
277#define BT_MESH_MODEL_ID_TIME_SRV 0x1200
279#define BT_MESH_MODEL_ID_TIME_SETUP_SRV 0x1201
281#define BT_MESH_MODEL_ID_TIME_CLI 0x1202
283#define BT_MESH_MODEL_ID_SCENE_SRV 0x1203
285#define BT_MESH_MODEL_ID_SCENE_SETUP_SRV 0x1204
287#define BT_MESH_MODEL_ID_SCENE_CLI 0x1205
289#define BT_MESH_MODEL_ID_SCHEDULER_SRV 0x1206
291#define BT_MESH_MODEL_ID_SCHEDULER_SETUP_SRV 0x1207
293#define BT_MESH_MODEL_ID_SCHEDULER_CLI 0x1208
295#define BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV 0x1300
297#define BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV 0x1301
299#define BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI 0x1302
301#define BT_MESH_MODEL_ID_LIGHT_CTL_SRV 0x1303
303#define BT_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV 0x1304
305#define BT_MESH_MODEL_ID_LIGHT_CTL_CLI 0x1305
307#define BT_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV 0x1306
309#define BT_MESH_MODEL_ID_LIGHT_HSL_SRV 0x1307
311#define BT_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV 0x1308
313#define BT_MESH_MODEL_ID_LIGHT_HSL_CLI 0x1309
315#define BT_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV 0x130a
317#define BT_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV 0x130b
319#define BT_MESH_MODEL_ID_LIGHT_XYL_SRV 0x130c
321#define BT_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV 0x130d
323#define BT_MESH_MODEL_ID_LIGHT_XYL_CLI 0x130e
325#define BT_MESH_MODEL_ID_LIGHT_LC_SRV 0x130f
327#define BT_MESH_MODEL_ID_LIGHT_LC_SETUPSRV 0x1310
329#define BT_MESH_MODEL_ID_LIGHT_LC_CLI 0x1311
339#define BT_MESH_MODEL_ID_BLOB_SRV 0x1400
341#define BT_MESH_MODEL_ID_BLOB_CLI 0x1401
351#define BT_MESH_MODEL_ID_DFU_SRV 0x1402
353#define BT_MESH_MODEL_ID_DFU_CLI 0x1403
355#define BT_MESH_MODEL_ID_DFD_SRV 0x1404
357#define BT_MESH_MODEL_ID_DFD_CLI 0x1405
366
374
384 int (*const func)(const struct bt_mesh_model *model,
385 struct bt_mesh_msg_ctx *ctx,
386 struct net_buf_simple *buf);
387};
388
389#define BT_MESH_MODEL_OP_1(b0) (b0)
390#define BT_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1))
391#define BT_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xc00000) | (cid))
392
394#define BT_MESH_LEN_EXACT(len) (-len)
396#define BT_MESH_LEN_MIN(len) (len)
397
399#define BT_MESH_MODEL_OP_END { 0, 0, NULL }
400
401#if !defined(__cplusplus) || defined(__DOXYGEN__)
408#define BT_MESH_MODEL_NO_OPS ((struct bt_mesh_model_op []) \
409 { BT_MESH_MODEL_OP_END })
410
417#define BT_MESH_MODEL_NONE ((const struct bt_mesh_model []){})
418
436#define BT_MESH_MODEL_CNT_CB(_id, _op, _pub, _user_data, _keys, _grps, _cb) \
437{ \
438 .id = (_id), \
439 BT_MESH_MODEL_RUNTIME_INIT(_user_data) \
440 .pub = _pub, \
441 .keys = (uint16_t []) BT_MESH_MODEL_KEYS_UNUSED(_keys), \
442 .keys_cnt = _keys, \
443 .groups = (uint16_t []) BT_MESH_MODEL_GROUPS_UNASSIGNED(_grps), \
444 .groups_cnt = _grps, \
445 BT_MESH_MODEL_UUIDS_UNASSIGNED() \
446 .op = _op, \
447 .cb = _cb, \
448}
449
468#define BT_MESH_MODEL_CNT_VND_CB(_company, _id, _op, _pub, _user_data, _keys, _grps, _cb) \
469{ \
470 .vnd.company = (_company), \
471 .vnd.id = (_id), \
472 BT_MESH_MODEL_RUNTIME_INIT(_user_data) \
473 .op = _op, \
474 .pub = _pub, \
475 .keys = (uint16_t []) BT_MESH_MODEL_KEYS_UNUSED(_keys), \
476 .keys_cnt = _keys, \
477 .groups = (uint16_t []) BT_MESH_MODEL_GROUPS_UNASSIGNED(_grps), \
478 .groups_cnt = _grps, \
479 BT_MESH_MODEL_UUIDS_UNASSIGNED() \
480 .cb = _cb, \
481}
482
495#define BT_MESH_MODEL_CB(_id, _op, _pub, _user_data, _cb) \
496 BT_MESH_MODEL_CNT_CB(_id, _op, _pub, _user_data, \
497 CONFIG_BT_MESH_MODEL_KEY_COUNT, \
498 CONFIG_BT_MESH_MODEL_GROUP_COUNT, _cb)
499
500
516#if defined(CONFIG_BT_MESH_LARGE_COMP_DATA_SRV)
517#define BT_MESH_MODEL_METADATA_CB(_id, _op, _pub, _user_data, _cb, _metadata) \
518{ \
519 .id = (_id), \
520 BT_MESH_MODEL_RUNTIME_INIT(_user_data) \
521 .pub = _pub, \
522 .keys = (uint16_t []) BT_MESH_MODEL_KEYS_UNUSED(CONFIG_BT_MESH_MODEL_KEY_COUNT), \
523 .keys_cnt = CONFIG_BT_MESH_MODEL_KEY_COUNT, \
524 .groups = (uint16_t []) BT_MESH_MODEL_GROUPS_UNASSIGNED(CONFIG_BT_MESH_MODEL_GROUP_COUNT), \
525 .groups_cnt = CONFIG_BT_MESH_MODEL_GROUP_COUNT, \
526 BT_MESH_MODEL_UUIDS_UNASSIGNED() \
527 .op = _op, \
528 .cb = _cb, \
529 .metadata = _metadata, \
530}
531#else
532#define BT_MESH_MODEL_METADATA_CB(_id, _op, _pub, _user_data, _cb, _metadata) \
533 BT_MESH_MODEL_CB(_id, _op, _pub, _user_data, _cb)
534#endif
535
550#define BT_MESH_MODEL_VND_CB(_company, _id, _op, _pub, _user_data, _cb) \
551 BT_MESH_MODEL_CNT_VND_CB(_company, _id, _op, _pub, _user_data, \
552 CONFIG_BT_MESH_MODEL_KEY_COUNT, \
553 CONFIG_BT_MESH_MODEL_GROUP_COUNT, _cb)
554
571#if defined(CONFIG_BT_MESH_LARGE_COMP_DATA_SRV)
572#define BT_MESH_MODEL_VND_METADATA_CB(_company, _id, _op, _pub, _user_data, _cb, _metadata) \
573{ \
574 .vnd.company = (_company), \
575 .vnd.id = (_id), \
576 BT_MESH_MODEL_RUNTIME_INIT(_user_data) \
577 .op = _op, \
578 .pub = _pub, \
579 .keys = (uint16_t []) BT_MESH_MODEL_KEYS_UNUSED(CONFIG_BT_MESH_MODEL_KEY_COUNT), \
580 .keys_cnt = CONFIG_BT_MESH_MODEL_KEY_COUNT, \
581 .groups = (uint16_t []) BT_MESH_MODEL_GROUPS_UNASSIGNED(CONFIG_BT_MESH_MODEL_GROUP_COUNT), \
582 .groups_cnt = CONFIG_BT_MESH_MODEL_GROUP_COUNT, \
583 BT_MESH_MODEL_UUIDS_UNASSIGNED() \
584 .cb = _cb, \
585 .metadata = _metadata, \
586}
587#else
588#define BT_MESH_MODEL_VND_METADATA_CB(_company, _id, _op, _pub, _user_data, _cb, _metadata) \
589 BT_MESH_MODEL_VND_CB(_company, _id, _op, _pub, _user_data, _cb)
590#endif
602#define BT_MESH_MODEL(_id, _op, _pub, _user_data) \
603 BT_MESH_MODEL_CB(_id, _op, _pub, _user_data, NULL)
604
617#define BT_MESH_MODEL_VND(_company, _id, _op, _pub, _user_data) \
618 BT_MESH_MODEL_VND_CB(_company, _id, _op, _pub, _user_data, NULL)
619#endif /* !defined(__cplusplus) || defined(__DOXYGEN__) */
620
631#define BT_MESH_TRANSMIT(count, int_ms) ((count) | (((int_ms / 10) - 1) << 3))
632
640#define BT_MESH_TRANSMIT_COUNT(transmit) (((transmit) & (uint8_t)BIT_MASK(3)))
641
649#define BT_MESH_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 10)
650
661#define BT_MESH_PUB_TRANSMIT(count, int_ms) BT_MESH_TRANSMIT(count, \
662 (int_ms) / 5)
663
671#define BT_MESH_PUB_TRANSMIT_COUNT(transmit) BT_MESH_TRANSMIT_COUNT(transmit)
672
680#define BT_MESH_PUB_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 50)
681
690#define BT_MESH_PUB_MSG_TOTAL(pub) (BT_MESH_PUB_TRANSMIT_COUNT((pub)->retransmit) + 1)
691
701#define BT_MESH_PUB_MSG_NUM(pub) (BT_MESH_PUB_TRANSMIT_COUNT((pub)->retransmit) + 1 - (pub)->count)
702
762
770#define BT_MESH_MODEL_PUB_DEFINE(_name, _update, _msg_len) \
771 NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \
772 static struct bt_mesh_model_pub _name = { \
773 .msg = &bt_mesh_pub_msg_##_name, \
774 .update = _update, \
775 }
776
783 /* Length of the metadata */
785
786 /* ID of the metadata */
788
789 /* Pointer to raw data */
790 const void * const data;
791};
792
801#define BT_MESH_MODELS_METADATA_ENTRY(_len, _id, _data) \
802 { \
803 .len = (_len), .id = _id, .data = _data, \
804 }
805
807#define BT_MESH_MODELS_METADATA_NONE NULL
808
810#define BT_MESH_MODELS_METADATA_END { 0, 0, NULL }
811
827 int (*const settings_set)(const struct bt_mesh_model *model,
828 const char *name, size_t len_rd,
829 settings_read_cb read_cb, void *cb_arg);
830
843 int (*const start)(const struct bt_mesh_model *model);
844
857 int (*const init)(const struct bt_mesh_model *model);
858
869 void (*const reset)(const struct bt_mesh_model *model);
870
879 void (*const pending_store)(const struct bt_mesh_model *model);
880};
881
889
892 union {
897 };
898
899 /* Model runtime information */
901 uint8_t elem_idx; /* Belongs to Nth element */
902 uint8_t mod_idx; /* Is the Nth model in the element */
903 uint16_t flags; /* Model flags for internal bookkeeping */
904
905#ifdef CONFIG_BT_MESH_MODEL_EXTENSIONS
906 /* Pointer to the next model in a model extension list. */
907 const struct bt_mesh_model *next;
908#endif
911 } * const rt;
912
914 struct bt_mesh_model_pub * const pub;
915
917 uint16_t * const keys;
919
923
924#if (CONFIG_BT_MESH_LABEL_COUNT > 0) || defined(__DOXYGEN__)
926 const uint8_t ** const uuids;
927#endif
928
930 const struct bt_mesh_model_op * const op;
931
933 const struct bt_mesh_model_cb * const cb;
934
935#if defined(CONFIG_BT_MESH_LARGE_COMP_DATA_SRV) || defined(__DOXYGEN__)
936 /* Pointer to the array of model metadata entries. */
938#endif
939};
940
949 void (*start)(uint16_t duration, int err, void *cb_data);
955 void (*end)(int err, void *cb_data);
956};
957
958
960#define BT_MESH_TTL_DEFAULT 0xff
961
963#define BT_MESH_TTL_MAX 0x7f
964
975int bt_mesh_model_send(const struct bt_mesh_model *model,
976 struct bt_mesh_msg_ctx *ctx,
977 struct net_buf_simple *msg,
978 const struct bt_mesh_send_cb *cb,
979 void *cb_data);
980
994int bt_mesh_model_publish(const struct bt_mesh_model *model);
995
1004static inline bool bt_mesh_model_pub_is_retransmission(const struct bt_mesh_model *model)
1005{
1006 return model->pub->count != BT_MESH_PUB_TRANSMIT_COUNT(model->pub->retransmit);
1007}
1008
1015const struct bt_mesh_elem *bt_mesh_model_elem(const struct bt_mesh_model *mod);
1016
1025const struct bt_mesh_model *bt_mesh_model_find(const struct bt_mesh_elem *elem,
1026 uint16_t id);
1027
1037const struct bt_mesh_model *bt_mesh_model_find_vnd(const struct bt_mesh_elem *elem,
1038 uint16_t company, uint16_t id);
1039
1046static inline bool bt_mesh_model_in_primary(const struct bt_mesh_model *mod)
1047{
1048 return (mod->rt->elem_idx == 0);
1049}
1050
1062int bt_mesh_model_data_store(const struct bt_mesh_model *mod, bool vnd,
1063 const char *name, const void *data,
1064 size_t data_len);
1065
1078
1102int bt_mesh_model_extend(const struct bt_mesh_model *extending_mod,
1103 const struct bt_mesh_model *base_mod);
1104
1125int bt_mesh_model_correspond(const struct bt_mesh_model *corresponding_mod,
1126 const struct bt_mesh_model *base_mod);
1127
1135
1144
1153
1163
1186
1193};
1194
1207int bt_mesh_comp2_register(const struct bt_mesh_comp2 *comp2);
1208
1209#ifdef __cplusplus
1210}
1211#endif
1212
1217#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_ACCESS_H_ */
int bt_mesh_model_correspond(const struct bt_mesh_model *corresponding_mod, const struct bt_mesh_model *base_mod)
Let a model correspond to another.
int bt_mesh_model_publish(const struct bt_mesh_model *model)
Send a model publication message.
bool bt_mesh_model_is_extended(const struct bt_mesh_model *model)
Check if model is extended by another model.
#define BT_MESH_PUB_TRANSMIT_COUNT(transmit)
Decode Publish Retransmit count from a given value.
Definition access.h:671
static bool bt_mesh_model_pub_is_retransmission(const struct bt_mesh_model *model)
Check if a message is being retransmitted.
Definition access.h:1004
int bt_mesh_models_metadata_change_prepare(void)
Indicate that the metadata will change on next bootup.
void bt_mesh_model_data_store_schedule(const struct bt_mesh_model *mod)
Schedule the model's user data store in persistent storage.
int bt_mesh_model_send(const 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.
int bt_mesh_comp2_register(const struct bt_mesh_comp2 *comp2)
Register composition data page 2 of the device.
int bt_mesh_comp_change_prepare(void)
Indicate that the composition data will change on next bootup.
const struct bt_mesh_elem * bt_mesh_model_elem(const struct bt_mesh_model *mod)
Get the element that a model belongs to.
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:1046
const 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_data_store(const 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.
const struct bt_mesh_model * bt_mesh_model_find(const struct bt_mesh_elem *elem, uint16_t id)
Find a SIG model.
int bt_mesh_model_extend(const struct bt_mesh_model *extending_mod, const struct bt_mesh_model *base_mod)
Let a model extend another.
ssize_t(* settings_read_cb)(void *cb_arg, void *data, size_t len)
Function used to read the data from the settings storage in h_set handler implementations.
Definition settings.h:61
__SIZE_TYPE__ ssize_t
Definition types.h:28
Message APIs.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Composition data page 2 record.
Definition access.h:1165
uint16_t id
Mesh profile ID.
Definition access.h:1167
uint8_t y
Minor version.
Definition access.h:1173
uint8_t x
Major version.
Definition access.h:1171
const uint8_t * elem_offset
Element offset list.
Definition access.h:1180
uint16_t data_len
Length of additional data.
Definition access.h:1182
uint8_t z
Z version.
Definition access.h:1175
const void * data
Additional data.
Definition access.h:1184
struct bt_mesh_comp2_record::@144 version
Mesh Profile Version.
uint8_t elem_offset_cnt
Element offset count.
Definition access.h:1178
Node Composition data page 2.
Definition access.h:1188
size_t record_cnt
The number of Mesh Profile records on a device.
Definition access.h:1190
const struct bt_mesh_comp2_record * record
List of records.
Definition access.h:1192
Node Composition.
Definition access.h:1155
uint16_t pid
Product ID.
Definition access.h:1157
uint16_t cid
Company ID.
Definition access.h:1156
uint16_t vid
Version ID.
Definition access.h:1158
const struct bt_mesh_elem * elem
List of elements.
Definition access.h:1161
size_t elem_count
The number of elements in this device.
Definition access.h:1160
Mesh Element runtime information.
Definition access.h:156
uint16_t addr
Unicast Address.
Definition access.h:158
Abstraction that describes a Mesh Element.
Definition access.h:154
struct bt_mesh_elem::bt_mesh_elem_rt_ctx rt
const struct bt_mesh_model *const models
The list of SIG models in this element.
Definition access.h:169
const uint16_t loc
Location Descriptor (GATT Bluetooth Namespace Descriptors)
Definition access.h:162
const uint8_t model_count
The number of SIG models in this element.
Definition access.h:164
const struct bt_mesh_model *const vnd_models
The list of vendor models in this element.
Definition access.h:171
const uint8_t vnd_model_count
The number of vendor models in this element.
Definition access.h:166
Vendor model ID.
Definition access.h:883
uint16_t company
Vendor's company ID.
Definition access.h:885
uint16_t id
Model ID.
Definition access.h:887
const struct bt_mesh_model * next
Definition access.h:907
void * user_data
Model-specific user data.
Definition access.h:910
uint8_t mod_idx
Definition access.h:902
uint16_t flags
Definition access.h:903
uint8_t elem_idx
Definition access.h:901
Model callback functions.
Definition access.h:813
int(*const init)(const struct bt_mesh_model *model)
Model init callback.
Definition access.h:857
int(*const settings_set)(const 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:827
void(*const reset)(const struct bt_mesh_model *model)
Model reset callback.
Definition access.h:869
int(*const start)(const struct bt_mesh_model *model)
Callback called when the mesh is started.
Definition access.h:843
void(*const pending_store)(const struct bt_mesh_model *model)
Callback used to store pending model's user data.
Definition access.h:879
Model opcode handler.
Definition access.h:363
const uint32_t opcode
OpCode encoded using the BT_MESH_MODEL_OP_* macros.
Definition access.h:365
const ssize_t len
Message length.
Definition access.h:373
int(*const func)(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
Handler function for this opcode.
Definition access.h:384
Model publication context.
Definition access.h:708
int(* update)(const struct bt_mesh_model *mod)
Callback for updating the publication buffer.
Definition access.h:757
uint16_t key
Publish AppKey Index.
Definition access.h:714
uint16_t retr_update
Call update callback on every retransmission.
Definition access.h:718
uint8_t delayable
Use random delay for publishing.
Definition access.h:726
uint16_t cred
Friendship Credentials Flag.
Definition access.h:715
uint8_t retransmit
Retransmit Count & Interval Steps.
Definition access.h:721
uint16_t addr
Publish Address.
Definition access.h:712
uint8_t count
Transmissions left.
Definition access.h:724
uint8_t period_div
Divisor for the Period.
Definition access.h:723
struct net_buf_simple * msg
Publication buffer, containing the publication message.
Definition access.h:737
uint8_t ttl
Publish Time to Live.
Definition access.h:720
const struct bt_mesh_model * mod
The model the context belongs to.
Definition access.h:710
uint32_t period_start
Start of the current period.
Definition access.h:728
uint16_t send_rel
Force reliable sending (segment acks)
Definition access.h:716
uint16_t fast_period
Use FastPeriodDivisor.
Definition access.h:717
const uint8_t * uuid
Label UUID if Publish Address is Virtual Address.
Definition access.h:713
uint8_t period
Publish Period.
Definition access.h:722
struct k_work_delayable timer
Publish Period Timer.
Definition access.h:760
Abstraction that describes a Mesh Model instance.
Definition access.h:891
const uint8_t **const uuids
List of Label UUIDs the model is subscribed to.
Definition access.h:926
const struct bt_mesh_mod_id_vnd vnd
Vendor model ID.
Definition access.h:896
struct bt_mesh_model::bt_mesh_model_rt_ctx rt
uint16_t *const groups
Subscription List (group or virtual addresses)
Definition access.h:921
const struct bt_mesh_model_op *const op
Opcode handler list.
Definition access.h:930
uint16_t *const keys
AppKey List.
Definition access.h:917
const struct bt_mesh_model_cb *const cb
Model callback structure.
Definition access.h:933
const uint16_t keys_cnt
Definition access.h:918
const uint16_t id
SIG model ID.
Definition access.h:894
const uint16_t groups_cnt
Definition access.h:922
struct bt_mesh_model_pub *const pub
Model Publication.
Definition access.h:914
const struct bt_mesh_models_metadata_entry *const metadata
Definition access.h:937
Models Metadata Entry struct.
Definition access.h:782
const uint16_t len
Definition access.h:784
const void *const data
Definition access.h:790
const uint16_t id
Definition access.h:787
Message sending context.
Definition msg.h:76
Callback structure for monitoring model message sending.
Definition access.h:942
void(* start)(uint16_t duration, int err, void *cb_data)
Handler called at the start of the transmission.
Definition access.h:949
void(* end)(int err, void *cb_data)
Handler called at the end of the transmission.
Definition access.h:955
A structure used to submit work after a delay.
Definition kernel.h:3985
Simple network buffer representation.
Definition net_buf.h:89
Misc utilities.