Skip to content

Commit 0074273

Browse files
PavelVPVde-nordic
authored andcommitted
[nrf fromtree] Bluetooth: Mesh: Use bt_mesh_msg_ackd_send API in LCD Client
Use bt_mesh_msg_ackd_send API in LCD Client. Signed-off-by: Pavel Vasilyev <[email protected]> (cherry picked from commit b99d4db) (cherry picked from commit f375b48)
1 parent 7e63dfc commit 0074273

File tree

1 file changed

+16
-33
lines changed

1 file changed

+16
-33
lines changed

subsys/bluetooth/mesh/large_comp_data_cli.c

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <zephyr/bluetooth/conn.h>
1919
#include <zephyr/bluetooth/mesh.h>
2020

21+
#include "msg.h"
22+
2123
#include <common/bt_str.h>
2224

2325
#define LOG_LEVEL CONFIG_BT_MESH_MODEL_LOG_LEVEL
@@ -115,59 +117,40 @@ const struct bt_mesh_model_cb _bt_mesh_large_comp_data_cli_cb = {
115117
.init = large_comp_data_cli_init,
116118
};
117119

118-
static int cli_prepare(void *param, uint32_t op, uint16_t addr)
119-
{
120-
return bt_mesh_msg_ack_ctx_prepare(&cli.ack_ctx, op, addr, param);
121-
}
122-
123120
int bt_mesh_large_comp_data_get(uint16_t net_idx, uint16_t addr, uint8_t page,
124121
size_t offset, struct net_buf_simple *comp)
125122
{
126123
BT_MESH_MODEL_BUF_DEFINE(msg, OP_LARGE_COMP_DATA_GET, 3);
127124
struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_DEV(net_idx, addr);
128-
int err;
129-
130-
err = cli_prepare(comp, OP_LARGE_COMP_DATA_STATUS, addr);
131-
if (err) {
132-
return err;
133-
}
125+
const struct bt_mesh_msg_rsp_ctx rsp = {
126+
.ack = &cli.ack_ctx,
127+
.op = OP_LARGE_COMP_DATA_STATUS,
128+
.user_data = comp,
129+
.timeout = msg_timeout,
130+
};
134131

135132
bt_mesh_model_msg_init(&msg, OP_LARGE_COMP_DATA_GET);
136133
net_buf_simple_add_u8(&msg, page);
137134
net_buf_simple_add_le16(&msg, offset);
138135

139-
err = bt_mesh_model_send(cli.model, &ctx, &msg, NULL, NULL);
140-
if (err) {
141-
LOG_ERR("model_send() failed (err %d)", err);
142-
bt_mesh_msg_ack_ctx_clear(&cli.ack_ctx);
143-
return err;
144-
}
145-
146-
return bt_mesh_msg_ack_ctx_wait(&cli.ack_ctx, K_MSEC(msg_timeout));
136+
return bt_mesh_msg_ackd_send(cli.model, &ctx, &msg, comp ? &rsp : NULL);
147137
}
148138

149139
int bt_mesh_models_metadata_get(uint16_t net_idx, uint16_t addr, uint8_t page,
150140
size_t offset, struct net_buf_simple *metadata)
151141
{
152142
BT_MESH_MODEL_BUF_DEFINE(msg, OP_MODELS_METADATA_STATUS, 3);
153143
struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_DEV(net_idx, addr);
154-
int err;
155-
156-
err = cli_prepare(metadata, OP_MODELS_METADATA_STATUS, addr);
157-
if (err) {
158-
return err;
159-
}
144+
const struct bt_mesh_msg_rsp_ctx rsp = {
145+
.ack = &cli.ack_ctx,
146+
.op = OP_MODELS_METADATA_STATUS,
147+
.user_data = metadata,
148+
.timeout = msg_timeout,
149+
};
160150

161151
bt_mesh_model_msg_init(&msg, OP_MODELS_METADATA_GET);
162152
net_buf_simple_add_u8(&msg, page);
163153
net_buf_simple_add_le16(&msg, offset);
164154

165-
err = bt_mesh_model_send(cli.model, &ctx, &msg, NULL, NULL);
166-
if (err) {
167-
LOG_ERR("model_send() failed (err %d)", err);
168-
bt_mesh_msg_ack_ctx_clear(&cli.ack_ctx);
169-
return err;
170-
}
171-
172-
return bt_mesh_msg_ack_ctx_wait(&cli.ack_ctx, K_MSEC(msg_timeout));
155+
return bt_mesh_msg_ackd_send(cli.model, &ctx, &msg, metadata ? &rsp : NULL);
173156
}

0 commit comments

Comments
 (0)