1 /*  Bluetooth Mesh */
2 
3 /*
4  * SPDX-FileCopyrightText: 2017 Intel Corporation
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #ifndef _ACCESS_H_
10 #define _ACCESS_H_
11 
12 #include "net.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /* bt_mesh_model.flags */
19 enum {
20     BLE_MESH_MOD_BIND_PENDING = BIT(0),
21     BLE_MESH_MOD_SUB_PENDING = BIT(1),
22     BLE_MESH_MOD_PUB_PENDING = BIT(2),
23 };
24 
25 void bt_mesh_elem_register(struct bt_mesh_elem *elem, uint8_t count);
26 
27 uint8_t bt_mesh_elem_count(void);
28 
29 /* Find local element based on unicast or group address */
30 struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr);
31 
32 uint16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, uint16_t addr);
33 
34 bool bt_mesh_fixed_group_match(uint16_t addr);
35 
36 void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
37                                         struct bt_mesh_elem *elem,
38                                         bool vnd, bool primary,
39                                         void *user_data),
40                            void *user_data);
41 
42 int32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod);
43 
44 void bt_mesh_comp_provision(uint16_t addr);
45 void bt_mesh_comp_unprovision(void);
46 
47 uint16_t bt_mesh_primary_addr(void);
48 
49 const struct bt_mesh_comp *bt_mesh_comp_get(void);
50 
51 struct bt_mesh_model *bt_mesh_model_get(bool vnd, uint8_t elem_idx, uint8_t mod_idx);
52 
53 void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf);
54 
55 int bt_mesh_comp_register(const struct bt_mesh_comp *comp);
56 int bt_mesh_comp_deregister(void);
57 
58 struct bt_mesh_subnet *bt_mesh_tx_netkey_get(uint8_t role, uint16_t net_idx);
59 
60 const uint8_t *bt_mesh_tx_devkey_get(uint8_t role, uint16_t dst);
61 
62 struct bt_mesh_app_key *bt_mesh_tx_appkey_get(uint8_t role, uint16_t app_idx);
63 
64 size_t bt_mesh_rx_netkey_size(void);
65 
66 struct bt_mesh_subnet *bt_mesh_rx_netkey_get(size_t index);
67 
68 size_t bt_mesh_rx_devkey_size(void);
69 
70 const uint8_t *bt_mesh_rx_devkey_get(size_t index, uint16_t src);
71 
72 size_t bt_mesh_rx_appkey_size(void);
73 
74 struct bt_mesh_app_key *bt_mesh_rx_appkey_get(size_t index);
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif /* _ACCESS_H_ */
81