NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
Bluetooth Mesh Message API

Bluetooth Mesh Message API. More...

Classes

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.
 
#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.
 

Functions

void bt_mesh_model_msg_init (struct os_mbuf *msg, uint32_t opcode)
 Initialize a model message.
 
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.
 
int bt_mesh_msg_ack_ctx_wait (struct bt_mesh_msg_ack_ctx *ack, int32_t timeout)
 Wait for a message acknowledge.
 
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

Bluetooth Mesh Message API.

Macro Definition Documentation

◆ BT_MESH_MIC_LONG

#define BT_MESH_MIC_LONG   8

Length of a long Mesh MIC.

◆ BT_MESH_MIC_SHORT

#define BT_MESH_MIC_SHORT   4

Length of a short Mesh MIC.

◆ BT_MESH_MODEL_BUF_LEN

#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.

Returns the length of a Mesh model message buffer, including the opcode length and a short MIC.

Parameters
_opOpcode of the message.
_payload_lenLength of the model payload.

◆ BT_MESH_MODEL_BUF_LEN_LONG_MIC

#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.

Returns the length of a Mesh model message buffer, including the opcode length and a long MIC.

Parameters
_opOpcode of the message.
_payload_lenLength of the model payload.

◆ BT_MESH_MODEL_OP_LEN

#define BT_MESH_MODEL_OP_LEN (   _op)    ((_op) <= 0xff ? 1 : (_op) <= 0xffff ? 2 : 3)

Helper to determine the length of an opcode.

Parameters
_opOpcode.

Function Documentation

◆ bt_mesh_model_msg_init()

void bt_mesh_model_msg_init ( struct os_mbuf msg,
uint32_t  opcode 
)

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.

Parameters
msgMessage buffer.
opcodeOpcode to encode.

◆ bt_mesh_msg_ack_ctx_clear()

void bt_mesh_msg_ack_ctx_clear ( struct bt_mesh_msg_ack_ctx ack)

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.

Parameters
ackAcknowledged message context to be cleared.

◆ bt_mesh_msg_ack_ctx_match()

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.

Parameters
ackAcknowledged message context to be checked.
opOpCode of the incoming message.
addrSource address of the incoming message.
user_dataIf not NULL, returns a user data stored in the acknowledged message context by bt_mesh_msg_ack_ctx_prepare.
Returns
true if the incoming message matches the expected one, false otherwise.

◆ 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 
)

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.

Parameters
ackAcknowledged message context to prepare.
opThe message OpCode.
dstDestination address of the message.
user_dataUser data for the acknowledged message context.
Returns
0 on success, or (negative) error code on failure.

◆ bt_mesh_msg_ack_ctx_wait()

int bt_mesh_msg_ack_ctx_wait ( struct bt_mesh_msg_ack_ctx ack,
int32_t  timeout 
)

Wait for a message acknowledge.

This function blocks execution until bt_mesh_msg_ack_ctx_rx is called or by timeout.

Parameters
ackAcknowledged message context of the message to wait for.
timeoutWait timeout.
Returns
0 on success, or (negative) error code on failure.