Bluetooth: Mesh: Fix async behavior of Private Beacon Client API
The Private Beacon Client API requires a response argument to allow to call the API in the asynchronous manner (https://github.com/zephyrproject-rtos/zephyr/pull/56426). Because the removal of the EXPERIMENTAL tag for this API was not released yet, it should be OK to change this API. The EXPERIMENTAL tag has been removed here: https://github.com/zephyrproject-rtos/zephyr/pull/64866 Coverity-CID: 330039 Coverity-CID: 330029 Coverity-CID: 329977 Fixes #65336 Fixes #65338 Fixes #65354 Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
parent
b15611eb28
commit
3bc17d1d18
6 changed files with 56 additions and 36 deletions
|
@ -156,13 +156,14 @@ const struct bt_mesh_model_cb bt_mesh_priv_beacon_cli_cb = {
|
|||
.init = priv_beacon_cli_init,
|
||||
};
|
||||
|
||||
int bt_mesh_priv_beacon_cli_set(uint16_t net_idx, uint16_t addr, struct bt_mesh_priv_beacon *val)
|
||||
int bt_mesh_priv_beacon_cli_set(uint16_t net_idx, uint16_t addr, struct bt_mesh_priv_beacon *val,
|
||||
struct bt_mesh_priv_beacon *rsp)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_DEV(net_idx, addr);
|
||||
const struct bt_mesh_msg_rsp_ctx rsp_ctx = {
|
||||
.ack = &cli->ack_ctx,
|
||||
.op = OP_PRIV_BEACON_STATUS,
|
||||
.user_data = val,
|
||||
.user_data = rsp,
|
||||
.timeout = msg_timeout,
|
||||
};
|
||||
|
||||
|
@ -174,7 +175,7 @@ int bt_mesh_priv_beacon_cli_set(uint16_t net_idx, uint16_t addr, struct bt_mesh_
|
|||
net_buf_simple_add_u8(&buf, val->rand_interval);
|
||||
}
|
||||
|
||||
return bt_mesh_msg_ackd_send(cli->model, &ctx, &buf, val ? &rsp_ctx : NULL);
|
||||
return bt_mesh_msg_ackd_send(cli->model, &ctx, &buf, rsp ? &rsp_ctx : NULL);
|
||||
}
|
||||
|
||||
int bt_mesh_priv_beacon_cli_get(uint16_t net_idx, uint16_t addr, struct bt_mesh_priv_beacon *val)
|
||||
|
@ -193,27 +194,28 @@ int bt_mesh_priv_beacon_cli_get(uint16_t net_idx, uint16_t addr, struct bt_mesh_
|
|||
return bt_mesh_msg_ackd_send(cli->model, &ctx, &buf, val ? &rsp_ctx : NULL);
|
||||
}
|
||||
|
||||
int bt_mesh_priv_beacon_cli_gatt_proxy_set(uint16_t net_idx, uint16_t addr, uint8_t *val)
|
||||
int bt_mesh_priv_beacon_cli_gatt_proxy_set(uint16_t net_idx, uint16_t addr, uint8_t val,
|
||||
uint8_t *rsp)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_DEV(net_idx, addr);
|
||||
const struct bt_mesh_msg_rsp_ctx rsp_ctx = {
|
||||
.ack = &cli->ack_ctx,
|
||||
.op = OP_PRIV_GATT_PROXY_STATUS,
|
||||
.user_data = val,
|
||||
.user_data = rsp,
|
||||
.timeout = msg_timeout,
|
||||
};
|
||||
|
||||
if (!val || (*val != BT_MESH_GATT_PROXY_DISABLED &&
|
||||
*val != BT_MESH_GATT_PROXY_ENABLED)) {
|
||||
if ((val != BT_MESH_GATT_PROXY_DISABLED &&
|
||||
val != BT_MESH_GATT_PROXY_ENABLED)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
BT_MESH_MODEL_BUF_DEFINE(buf, OP_PRIV_GATT_PROXY_SET, 1);
|
||||
bt_mesh_model_msg_init(&buf, OP_PRIV_GATT_PROXY_SET);
|
||||
|
||||
net_buf_simple_add_u8(&buf, *val);
|
||||
net_buf_simple_add_u8(&buf, val);
|
||||
|
||||
return bt_mesh_msg_ackd_send(cli->model, &ctx, &buf, val ? &rsp_ctx : NULL);
|
||||
return bt_mesh_msg_ackd_send(cli->model, &ctx, &buf, rsp ? &rsp_ctx : NULL);
|
||||
}
|
||||
|
||||
int bt_mesh_priv_beacon_cli_gatt_proxy_get(uint16_t net_idx, uint16_t addr, uint8_t *val)
|
||||
|
@ -233,17 +235,18 @@ int bt_mesh_priv_beacon_cli_gatt_proxy_get(uint16_t net_idx, uint16_t addr, uint
|
|||
}
|
||||
|
||||
int bt_mesh_priv_beacon_cli_node_id_set(uint16_t net_idx, uint16_t addr,
|
||||
struct bt_mesh_priv_node_id *val)
|
||||
struct bt_mesh_priv_node_id *val,
|
||||
struct bt_mesh_priv_node_id *rsp)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_DEV(net_idx, addr);
|
||||
const struct bt_mesh_msg_rsp_ctx rsp_ctx = {
|
||||
.ack = &cli->ack_ctx,
|
||||
.op = OP_PRIV_NODE_ID_STATUS,
|
||||
.user_data = val,
|
||||
.user_data = rsp,
|
||||
.timeout = msg_timeout,
|
||||
};
|
||||
|
||||
if (!val || val->net_idx > 0xfff ||
|
||||
if (val->net_idx > 0xfff ||
|
||||
(val->state != BT_MESH_NODE_IDENTITY_STOPPED &&
|
||||
val->state != BT_MESH_NODE_IDENTITY_RUNNING)) {
|
||||
return -EINVAL;
|
||||
|
@ -255,7 +258,7 @@ int bt_mesh_priv_beacon_cli_node_id_set(uint16_t net_idx, uint16_t addr,
|
|||
net_buf_simple_add_le16(&buf, val->net_idx);
|
||||
net_buf_simple_add_u8(&buf, val->state);
|
||||
|
||||
return bt_mesh_msg_ackd_send(cli->model, &ctx, &buf, val ? &rsp_ctx : NULL);
|
||||
return bt_mesh_msg_ackd_send(cli->model, &ctx, &buf, rsp ? &rsp_ctx : NULL);
|
||||
}
|
||||
|
||||
int bt_mesh_priv_beacon_cli_node_id_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
|
||||
|
|
|
@ -48,7 +48,7 @@ static int cmd_priv_beacon_set(const struct shell *sh, size_t argc, char *argv[]
|
|||
|
||||
err = bt_mesh_priv_beacon_cli_set(bt_mesh_shell_target_ctx.net_idx,
|
||||
bt_mesh_shell_target_ctx.dst,
|
||||
&val);
|
||||
&val, &val);
|
||||
if (err) {
|
||||
shell_error(sh, "Failed to send Private Beacon Set (err %d)", err);
|
||||
return 0;
|
||||
|
@ -86,7 +86,7 @@ static int cmd_priv_gatt_proxy_set(const struct shell *sh, size_t argc, char *ar
|
|||
}
|
||||
|
||||
err = bt_mesh_priv_beacon_cli_gatt_proxy_set(bt_mesh_shell_target_ctx.net_idx,
|
||||
bt_mesh_shell_target_ctx.dst, &state);
|
||||
bt_mesh_shell_target_ctx.dst, state, &state);
|
||||
if (err) {
|
||||
shell_error(sh, "Failed to send Private GATT Proxy Set (err %d)", err);
|
||||
return 0;
|
||||
|
@ -130,7 +130,7 @@ static int cmd_priv_node_id_set(const struct shell *sh, size_t argc, char *argv[
|
|||
}
|
||||
|
||||
err = bt_mesh_priv_beacon_cli_node_id_set(bt_mesh_shell_target_ctx.net_idx,
|
||||
bt_mesh_shell_target_ctx.dst, &val);
|
||||
bt_mesh_shell_target_ctx.dst, &val, &val);
|
||||
if (err) {
|
||||
shell_error(sh, "Failed to send Private Node Identity Set (err %d)", err);
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue