Line data Source code
1 0 : /*
2 : * Copyright (c) 2021 Nordic Semiconductor ASA
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : #ifndef BT_MESH_LARGE_COMP_DATA_CLI_H__
8 : #define BT_MESH_LARGE_COMP_DATA_CLI_H__
9 :
10 : #include <zephyr/bluetooth/mesh.h>
11 :
12 : #ifdef __cplusplus
13 : extern "C" {
14 : #endif
15 :
16 : /**
17 : * @defgroup bt_mesh_large_comp_data_cli Large Composition Data Client model
18 : * @ingroup bt_mesh
19 : * @{
20 : */
21 :
22 : struct bt_mesh_large_comp_data_cli;
23 :
24 : /** Large Composition Data response. */
25 1 : struct bt_mesh_large_comp_data_rsp {
26 : /** Page number. */
27 1 : uint8_t page;
28 : /** Offset within the page. */
29 1 : uint16_t offset;
30 : /** Total size of the page. */
31 1 : uint16_t total_size;
32 : /** Pointer to allocated buffer for storing received data. */
33 1 : struct net_buf_simple *data;
34 : };
35 :
36 : /** Large Composition Data Status messages callbacks */
37 1 : struct bt_mesh_large_comp_data_cli_cb {
38 : /** @brief Optional callback for Large Composition Data Status message.
39 : *
40 : * Handles received Large Composition Data Status messages from a Large Composition Data
41 : * Server.
42 : *
43 : * If the content of @c rsp is needed after exiting this callback, a user should
44 : * deep copy it.
45 : *
46 : * @param cli Large Composition Data Client context.
47 : * @param addr Address of the sender.
48 : * @param rsp Response received from the server.
49 : */
50 1 : void (*large_comp_data_status)(struct bt_mesh_large_comp_data_cli *cli, uint16_t addr,
51 : struct bt_mesh_large_comp_data_rsp *rsp);
52 :
53 : /** @brief Optional callback for Models Metadata Status message.
54 : *
55 : * Handles received Models Metadata Status messages from a Large Composition Data
56 : * Server.
57 : *
58 : * If the content of @c rsp is needed after exiting this callback, a user should
59 : * deep copy it.
60 : *
61 : * @param cli Large Composition Data Client context.
62 : * @param addr Address of the sender.
63 : * @param rsp Response received from the server.
64 : */
65 1 : void (*models_metadata_status)(struct bt_mesh_large_comp_data_cli *cli, uint16_t addr,
66 : struct bt_mesh_large_comp_data_rsp *rsp);
67 : };
68 :
69 : /** Large Composition Data Client model context */
70 1 : struct bt_mesh_large_comp_data_cli {
71 : /** Model entry pointer. */
72 1 : const struct bt_mesh_model *model;
73 :
74 : /** Internal parameters for tracking message responses. */
75 1 : struct bt_mesh_msg_ack_ctx ack_ctx;
76 :
77 : /** Optional callback for Large Composition Data Status messages. */
78 1 : const struct bt_mesh_large_comp_data_cli_cb *cb;
79 : };
80 :
81 : /**
82 : *
83 : * @brief Large Composition Data Client model Composition Data entry.
84 : *
85 : * @param cli_data Pointer to a @ref bt_mesh_large_comp_data_cli instance.
86 : */
87 1 : #define BT_MESH_MODEL_LARGE_COMP_DATA_CLI(cli_data) \
88 : BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_LARGE_COMP_DATA_CLI, \
89 : _bt_mesh_large_comp_data_cli_op, NULL, cli_data, \
90 : &_bt_mesh_large_comp_data_cli_cb)
91 :
92 : /** @brief Send Large Composition Data Get message.
93 : *
94 : * This API is used to read a portion of a Composition Data Page.
95 : *
96 : * This API can be used asynchronously by setting @p rsp as NULL. This way, the
97 : * method will not wait for a response and will return immediately after sending
98 : * the command.
99 : *
100 : * When @c rsp is set, the user is responsible for providing a buffer for the
101 : * Composition Data in @ref bt_mesh_large_comp_data_rsp::data. If a buffer is
102 : * not provided, the metadata won't be copied.
103 : *
104 : * @param net_idx Network index to encrypt with.
105 : * @param addr Target node element address.
106 : * @param page Composition Data Page to read.
107 : * @param offset Offset within the Composition Data Page.
108 : * @param rsp Pointer to a struct storing the received response from
109 : * the server, or NULL to not wait for a response.
110 : *
111 : * @return 0 on success, or (negative) error code on failure.
112 : */
113 1 : int bt_mesh_large_comp_data_get(uint16_t net_idx, uint16_t addr, uint8_t page,
114 : size_t offset, struct bt_mesh_large_comp_data_rsp *rsp);
115 :
116 : /** @brief Send Models Metadata Get message.
117 : *
118 : * This API is used to read a portion of a Models Metadata Page.
119 : *
120 : * This API can be used asynchronously by setting @p rsp as NULL. This way, the
121 : * method will not wait for a response and will return immediately after sending
122 : * the command.
123 : *
124 : * When @c rsp is set, a user is responsible for providing a buffer for
125 : * metadata in @ref bt_mesh_large_comp_data_rsp::data. If a buffer is not
126 : * provided, the metadata won't be copied.
127 : *
128 : * @param net_idx Network index to encrypt with.
129 : * @param addr Target node element address.
130 : * @param page Models Metadata Page to read.
131 : * @param offset Offset within the Models Metadata Page.
132 : * @param rsp Pointer to a struct storing the received response from
133 : * the server, or NULL to not wait for a response.
134 : *
135 : * @return 0 on success, or (negative) error code on failure.
136 : */
137 1 : int bt_mesh_models_metadata_get(uint16_t net_idx, uint16_t addr, uint8_t page,
138 : size_t offset, struct bt_mesh_large_comp_data_rsp *rsp);
139 :
140 : /** @cond INTERNAL_HIDDEN */
141 : extern const struct bt_mesh_model_op _bt_mesh_large_comp_data_cli_op[];
142 : extern const struct bt_mesh_model_cb _bt_mesh_large_comp_data_cli_cb;
143 : /** @endcond */
144 :
145 : /**
146 : * @}
147 : */
148 :
149 : #ifdef __cplusplus
150 : }
151 : #endif
152 :
153 : #endif /* BT_MESH_LARGE_COMP_DATA_CLI_H__ */
|