Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
msg.h File Reference

Message APIs. More...

#include <zephyr/kernel.h>
#include <zephyr/net/buf.h>

Go to the source code of this file.

Data Structures

struct  bt_mesh_msg_ctx
 Message sending context. More...
 
struct  bt_mesh_msg_ack_ctx
 Acknowledged message context for tracking the status of model messages pending a response. More...
 

Macros

#define BT_MESH_MIC_SHORT   4
 Length of a short Mesh MIC.
 
#define BT_MESH_MIC_LONG   8
 Length of a long Mesh MIC.
 
#define BT_MESH_MODEL_OP_LEN(_op)   ((_op) <= 0xff ? 1 : (_op) <= 0xffff ? 2 : 3)
 Helper to determine the length of an opcode.
 
#define BT_MESH_MODEL_BUF_LEN(_op, _payload_len)    (BT_MESH_MODEL_OP_LEN(_op) + (_payload_len) + BT_MESH_MIC_SHORT)
 Helper for model message buffer length.
 
#define BT_MESH_MODEL_BUF_LEN_LONG_MIC(_op, _payload_len)    (BT_MESH_MODEL_OP_LEN(_op) + (_payload_len) + BT_MESH_MIC_LONG)
 Helper for model message buffer length.
 
#define BT_MESH_MODEL_BUF_DEFINE(_buf, _op, _payload_len)    NET_BUF_SIMPLE_DEFINE(_buf, BT_MESH_MODEL_BUF_LEN(_op, (_payload_len)))
 Define a Mesh model message buffer using NET_BUF_SIMPLE_DEFINE.
 
#define BT_MESH_MSG_CTX_INIT(net_key_idx, app_key_idx, dst, ttl)
 Helper for bt_mesh_msg_ctx structure initialization.
 
#define BT_MESH_MSG_CTX_INIT_APP(app_key_idx, dst)    BT_MESH_MSG_CTX_INIT(0, app_key_idx, dst, BT_MESH_TTL_DEFAULT)
 Helper for bt_mesh_msg_ctx structure initialization secured with Application Key.
 
#define BT_MESH_MSG_CTX_INIT_DEV(net_key_idx, dst)    BT_MESH_MSG_CTX_INIT(net_key_idx, BT_MESH_KEY_DEV_REMOTE, dst, BT_MESH_TTL_DEFAULT)
 Helper for bt_mesh_msg_ctx structure initialization secured with Device Key of a remote device.
 
#define BT_MESH_MSG_CTX_INIT_PUB(pub)
 Helper for bt_mesh_msg_ctx structure initialization using Model Publication context.
 

Functions

void bt_mesh_model_msg_init (struct net_buf_simple *msg, uint32_t opcode)
 Initialize a model message.
 
static void bt_mesh_msg_ack_ctx_init (struct bt_mesh_msg_ack_ctx *ack)
 Initialize an acknowledged message context.
 
static void bt_mesh_msg_ack_ctx_reset (struct bt_mesh_msg_ack_ctx *ack)
 Reset the synchronization semaphore in an acknowledged message context.
 
void bt_mesh_msg_ack_ctx_clear (struct bt_mesh_msg_ack_ctx *ack)
 Clear parameters of an acknowledged message context.
 
int bt_mesh_msg_ack_ctx_prepare (struct bt_mesh_msg_ack_ctx *ack, uint32_t op, uint16_t dst, void *user_data)
 Prepare an acknowledged message context for the incoming message to wait.
 
static bool bt_mesh_msg_ack_ctx_busy (struct bt_mesh_msg_ack_ctx *ack)
 Check if the acknowledged message context is initialized with an opcode.
 
int bt_mesh_msg_ack_ctx_wait (struct bt_mesh_msg_ack_ctx *ack, k_timeout_t timeout)
 Wait for a message acknowledge.
 
static void bt_mesh_msg_ack_ctx_rx (struct bt_mesh_msg_ack_ctx *ack)
 Mark a message as acknowledged.
 
bool bt_mesh_msg_ack_ctx_match (const struct bt_mesh_msg_ack_ctx *ack, uint32_t op, uint16_t addr, void **user_data)
 Check if an opcode and address of a message matches the expected one.
 

Detailed Description

Message APIs.