1 /*
2  * Copyright (c) 2017 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /* Tree walk return codes */
8 enum bt_mesh_walk {
9 	BT_MESH_WALK_STOP,
10 	BT_MESH_WALK_CONTINUE,
11 };
12 
13 void bt_mesh_elem_register(struct bt_mesh_elem *elem, uint8_t count);
14 
15 uint8_t bt_mesh_elem_count(void);
16 
17 /* Find local element based on unicast address */
18 struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr);
19 
20 bool bt_mesh_has_addr(uint16_t addr);
21 bool bt_mesh_model_has_key(struct bt_mesh_model *mod, uint16_t key);
22 
23 void bt_mesh_model_extensions_walk(struct bt_mesh_model *root,
24 				   enum bt_mesh_walk (*cb)(struct bt_mesh_model *mod,
25 							   void *user_data),
26 				   void *user_data);
27 
28 uint16_t *bt_mesh_model_find_group(struct bt_mesh_model **mod, uint16_t addr);
29 
30 void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
31 					struct bt_mesh_elem *elem,
32 					bool vnd, bool primary,
33 					void *user_data),
34 			   void *user_data);
35 
36 int32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod);
37 
38 void bt_mesh_comp_provision(uint16_t addr);
39 void bt_mesh_comp_unprovision(void);
40 
41 uint16_t bt_mesh_primary_addr(void);
42 
43 const struct bt_mesh_comp *bt_mesh_comp_get(void);
44 
45 struct bt_mesh_model *bt_mesh_model_get(bool vnd, uint8_t elem_idx, uint8_t mod_idx);
46 
47 void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf);
48 
49 int bt_mesh_comp_register(const struct bt_mesh_comp *comp);
50 
51 void bt_mesh_model_pending_store(void);
52 void bt_mesh_model_bind_store(struct bt_mesh_model *mod);
53 void bt_mesh_model_sub_store(struct bt_mesh_model *mod);
54 void bt_mesh_model_pub_store(struct bt_mesh_model *mod);
55 void bt_mesh_model_settings_commit(void);
56 
57 /** @brief Register a callback function hook for mesh model messages.
58  *
59  * Register a callback function to act as a hook for recieving mesh model layer messages
60  * directly to the application without having instantiated the relevant models.
61  *
62  * @param cb A pointer to the callback function.
63  */
64 void bt_mesh_msg_cb_set(void (*cb)(uint32_t opcode, struct bt_mesh_msg_ctx *ctx,
65 			struct net_buf_simple *buf));
66 
67 /** @brief Send a mesh model message.
68  *
69  * Send a mesh model layer message out into the mesh network without having instantiated
70  * the relevant mesh models.
71  *
72  * @param ctx The Bluetooth mesh message context.
73  * @param buf The message payload.
74  *
75  * @return 0 on success or negative error code on failure.
76  */
77 int bt_mesh_msg_send(struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, uint16_t src_addr,
78 		     const struct bt_mesh_send_cb *cb, void *cb_data);
79