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 /* bt_mesh_model.flags */ 14 enum { 15 BT_MESH_MOD_BIND_PENDING = BIT(0), 16 BT_MESH_MOD_SUB_PENDING = BIT(1), 17 BT_MESH_MOD_PUB_PENDING = BIT(2), 18 BT_MESH_MOD_EXTENDED = BIT(3), 19 BT_MESH_MOD_DEVKEY_ONLY = BIT(4), 20 BT_MESH_MOD_DATA_PENDING = BIT(5), 21 }; 22 23 void bt_mesh_elem_register(struct bt_mesh_elem *elem, uint8_t count); 24 25 uint8_t bt_mesh_elem_count(void); 26 size_t bt_mesh_comp_page_size(uint8_t page); 27 int bt_mesh_comp_data_get_page_0(struct net_buf_simple *buf, size_t offset); 28 size_t bt_mesh_metadata_page_0_size(void); 29 int bt_mesh_metadata_get_page_0(struct net_buf_simple *buf, size_t offset); 30 31 /* Find local element based on unicast address */ 32 struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr); 33 34 bool bt_mesh_has_addr(uint16_t addr); 35 bool bt_mesh_model_has_key(struct bt_mesh_model *mod, uint16_t key); 36 37 void bt_mesh_model_extensions_walk(struct bt_mesh_model *root, 38 enum bt_mesh_walk (*cb)(struct bt_mesh_model *mod, 39 void *user_data), 40 void *user_data); 41 42 uint16_t *bt_mesh_model_find_group(struct bt_mesh_model **mod, uint16_t addr); 43 const uint8_t **bt_mesh_model_find_uuid(struct bt_mesh_model **mod, const uint8_t *uuid); 44 45 void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod, 46 struct bt_mesh_elem *elem, 47 bool vnd, bool primary, 48 void *user_data), 49 void *user_data); 50 51 int32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod); 52 53 void bt_mesh_comp_provision(uint16_t addr); 54 void bt_mesh_comp_unprovision(void); 55 56 uint16_t bt_mesh_primary_addr(void); 57 58 const struct bt_mesh_comp *bt_mesh_comp_get(void); 59 60 struct bt_mesh_model *bt_mesh_model_get(bool vnd, uint8_t elem_idx, uint8_t mod_idx); 61 62 int bt_mesh_model_recv(struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); 63 64 int bt_mesh_comp_register(const struct bt_mesh_comp *comp); 65 int bt_mesh_comp_store(void); 66 int bt_mesh_comp_read(struct net_buf_simple *buf, uint8_t page); 67 uint8_t bt_mesh_comp_parse_page(struct net_buf_simple *buf); 68 69 int bt_mesh_models_metadata_store(void); 70 int bt_mesh_models_metadata_read(struct net_buf_simple *buf, size_t offset); 71 72 void bt_mesh_comp_data_pending_clear(void); 73 void bt_mesh_comp_data_clear(void); 74 int bt_mesh_comp_data_get_page(struct net_buf_simple *buf, size_t page, size_t offset); 75 76 void bt_mesh_model_pending_store(void); 77 void bt_mesh_model_bind_store(struct bt_mesh_model *mod); 78 void bt_mesh_model_sub_store(struct bt_mesh_model *mod); 79 void bt_mesh_model_pub_store(struct bt_mesh_model *mod); 80 void bt_mesh_model_settings_commit(void); 81 82 /** @brief Register a callback function hook for mesh model messages. 83 * 84 * Register a callback function to act as a hook for receiving mesh model layer messages 85 * directly to the application without having instantiated the relevant models. 86 * 87 * @param cb A pointer to the callback function. 88 */ 89 void bt_mesh_msg_cb_set(void (*cb)(uint32_t opcode, struct bt_mesh_msg_ctx *ctx, 90 struct net_buf_simple *buf)); 91 92 /** @brief Send a mesh model message. 93 * 94 * Send a mesh model layer message out into the mesh network without having instantiated 95 * the relevant mesh models. 96 * 97 * @param ctx The Bluetooth mesh message context. 98 * @param buf The message payload. 99 * 100 * @return 0 on success or negative error code on failure. 101 */ 102 int bt_mesh_access_send(struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, uint16_t src_addr, 103 const struct bt_mesh_send_cb *cb, void *cb_data); 104