Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
Message. More...
Data Structures | |
struct | bt_mesh_msg_ctx |
struct | bt_mesh_msg_ack_ctx |
Macros | |
#define | BT_MESH_MIC_SHORT 4 |
#define | BT_MESH_MIC_LONG 8 |
#define | BT_MESH_MODEL_OP_LEN(_op) ((_op) <= 0xff ? 1 : (_op) <= 0xffff ? 2 : 3) |
Helper to determine the length of an opcode. More... | |
#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. More... | |
#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. More... | |
#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. More... | |
Functions | |
void | bt_mesh_model_msg_init (struct net_buf_simple *msg, uint32_t opcode) |
Initialize a model message. More... | |
static void | bt_mesh_msg_ack_ctx_init (struct bt_mesh_msg_ack_ctx *ack) |
Initialize an acknowledged message context. More... | |
static void | bt_mesh_msg_ack_ctx_reset (struct bt_mesh_msg_ack_ctx *ack) |
Reset the synchronization semaphore in an acknowledged message context. More... | |
void | bt_mesh_msg_ack_ctx_clear (struct bt_mesh_msg_ack_ctx *ack) |
Clear parameters of an acknowledged message context. More... | |
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. More... | |
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. More... | |
int | bt_mesh_msg_ack_ctx_wait (struct bt_mesh_msg_ack_ctx *ack, k_timeout_t timeout) |
Wait for a message acknowledge. More... | |
static void | bt_mesh_msg_ack_ctx_rx (struct bt_mesh_msg_ack_ctx *ack) |
Mark a message as acknowledged. More... | |
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. More... | |
Message.
#define BT_MESH_MIC_LONG 8 |
#include <include/bluetooth/mesh/msg.h>
Length of a long Mesh MIC.
#define BT_MESH_MIC_SHORT 4 |
#include <include/bluetooth/mesh/msg.h>
Length of a short Mesh MIC.
#define BT_MESH_MODEL_BUF_DEFINE | ( | _buf, | |
_op, | |||
_payload_len | |||
) | NET_BUF_SIMPLE_DEFINE(_buf, BT_MESH_MODEL_BUF_LEN(_op, (_payload_len))) |
#include <include/bluetooth/mesh/msg.h>
Define a Mesh model message buffer using NET_BUF_SIMPLE_DEFINE.
_buf | Buffer name. |
_op | Opcode of the message. |
_payload_len | Length of the model message payload. |
#define BT_MESH_MODEL_BUF_LEN | ( | _op, | |
_payload_len | |||
) | (BT_MESH_MODEL_OP_LEN(_op) + (_payload_len) + BT_MESH_MIC_SHORT) |
#include <include/bluetooth/mesh/msg.h>
Helper for model message buffer length.
Returns the length of a Mesh model message buffer, including the opcode length and a short MIC.
_op | Opcode of the message. |
_payload_len | Length of the model payload. |
#define BT_MESH_MODEL_BUF_LEN_LONG_MIC | ( | _op, | |
_payload_len | |||
) | (BT_MESH_MODEL_OP_LEN(_op) + (_payload_len) + BT_MESH_MIC_LONG) |
#include <include/bluetooth/mesh/msg.h>
Helper for model message buffer length.
Returns the length of a Mesh model message buffer, including the opcode length and a long MIC.
_op | Opcode of the message. |
_payload_len | Length of the model payload. |
#define BT_MESH_MODEL_OP_LEN | ( | _op | ) | ((_op) <= 0xff ? 1 : (_op) <= 0xffff ? 2 : 3) |
#include <include/bluetooth/mesh/msg.h>
Helper to determine the length of an opcode.
_op | Opcode. |
void bt_mesh_model_msg_init | ( | struct net_buf_simple * | msg, |
uint32_t | opcode | ||
) |
#include <include/bluetooth/mesh/msg.h>
Initialize a model message.
Clears the message buffer contents, and encodes the given opcode. The message buffer will be ready for filling in payload data.
msg | Message buffer. |
opcode | Opcode to encode. |
|
inlinestatic |
#include <include/bluetooth/mesh/msg.h>
Check if the acknowledged message context is initialized with an opcode.
ack | Acknowledged message context. |
void bt_mesh_msg_ack_ctx_clear | ( | struct bt_mesh_msg_ack_ctx * | ack | ) |
#include <include/bluetooth/mesh/msg.h>
Clear parameters of an acknowledged message context.
This function clears the opcode, remote address and user data set by bt_mesh_msg_ack_ctx_prepare.
ack | Acknowledged message context to be cleared. |
|
inlinestatic |
#include <include/bluetooth/mesh/msg.h>
Initialize an acknowledged message context.
Initializes semaphore used for synchronization between bt_mesh_msg_ack_ctx_wait and bt_mesh_msg_ack_ctx_rx calls. Call this function before using bt_mesh_msg_ack_ctx.
ack | Acknowledged message context to initialize. |
bool bt_mesh_msg_ack_ctx_match | ( | const struct bt_mesh_msg_ack_ctx * | ack, |
uint32_t | op, | ||
uint16_t | addr, | ||
void ** | user_data | ||
) |
#include <include/bluetooth/mesh/msg.h>
Check if an opcode and address of a message matches the expected one.
ack | Acknowledged message context to be checked. |
op | OpCode of the incoming message. |
addr | Source address of the incoming message. |
user_data | If not NULL, returns a user data stored in the acknowledged message context by bt_mesh_msg_ack_ctx_prepare. |
int bt_mesh_msg_ack_ctx_prepare | ( | struct bt_mesh_msg_ack_ctx * | ack, |
uint32_t | op, | ||
uint16_t | dst, | ||
void * | user_data | ||
) |
#include <include/bluetooth/mesh/msg.h>
Prepare an acknowledged message context for the incoming message to wait.
This function sets the opcode, remote address of the incoming message and stores the user data. Use this function before calling bt_mesh_msg_ack_ctx_wait.
ack | Acknowledged message context to prepare. |
op | The message OpCode. |
dst | Destination address of the message. |
user_data | User data for the acknowledged message context. |
|
inlinestatic |
#include <include/bluetooth/mesh/msg.h>
Reset the synchronization semaphore in an acknowledged message context.
This function aborts call to bt_mesh_msg_ack_ctx_wait.
ack | Acknowledged message context to be reset. |
|
inlinestatic |
#include <include/bluetooth/mesh/msg.h>
Mark a message as acknowledged.
This function unblocks call to bt_mesh_msg_ack_ctx_wait.
ack | Context of a message to be acknowledged. |
int bt_mesh_msg_ack_ctx_wait | ( | struct bt_mesh_msg_ack_ctx * | ack, |
k_timeout_t | timeout | ||
) |
#include <include/bluetooth/mesh/msg.h>
Wait for a message acknowledge.
This function blocks execution until bt_mesh_msg_ack_ctx_rx is called or by timeout.
ack | Acknowledged message context of the message to wait for. |
timeout | Wait timeout. |