1 /* 2 * Copyright (c) 2022 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** @brief Send a model message. 8 * 9 * Sends a model message with the given context. If the message context is NULL, this 10 * updates the publish message, and publishes with the configured publication parameters. 11 * 12 * @param model Model to send the message on. 13 * @param ctx Message context, or NULL to send with the configured publish parameters. 14 * @param buf Message to send. 15 * 16 * @retval 0 The message was sent successfully. 17 * @retval -ENOTSUP A message context was not provided and publishing is not supported. 18 * @retval -EADDRNOTAVAIL A message context was not provided and publishing is not configured. 19 * @retval -EAGAIN The device has not been provisioned. 20 */ 21 int bt_mesh_msg_send(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, 22 struct net_buf_simple *buf); 23 24 /** 25 * Message response context. 26 */ 27 struct bt_mesh_msg_rsp_ctx { 28 struct bt_mesh_msg_ack_ctx *ack; /**< Acknowledged message context. */ 29 uint32_t op; /**< Opcode we're waiting for. */ 30 void *user_data; /**< User specific parameter. */ 31 int32_t timeout; /**< Response timeout in milliseconds. */ 32 }; 33 34 /** @brief Send an acknowledged model message. 35 * 36 * Sends a model message with the given context. If the message context is NULL, this 37 * updates the publish message, and publishes with the configured publication parameters. 38 * 39 * If a response context is provided, the call blocks for the time specified in 40 * the response context, or until @ref bt_mesh_msg_ack_ctx_rx is called. 41 * 42 * @param model Model to send the message on. 43 * @param ctx Message context, or NULL to send with the configured publish parameters. 44 * @param buf Message to send. 45 * @param rsp Message response context, or NULL if no response is expected. 46 * 47 * @retval 0 The message was sent successfully. 48 * @retval -EBUSY A blocking request is already in progress. 49 * @retval -ENOTSUP A message context was not provided and publishing is not supported. 50 * @retval -EADDRNOTAVAIL A message context was not provided and publishing is not configured. 51 * @retval -EAGAIN The device has not been provisioned. 52 * @retval -ETIMEDOUT The request timed out without a response. 53 */ 54 int bt_mesh_msg_ackd_send(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, 55 struct net_buf_simple *buf, const struct bt_mesh_msg_rsp_ctx *rsp); 56