ble_mesh: Add net_buf_simple_init_with_data [Zephyr]

This commit is contained in:
lly 2020-05-15 10:33:24 +08:00
parent f990d725f4
commit c2589b0b57
2 changed files with 21 additions and 0 deletions

View file

@ -152,6 +152,18 @@ static inline void net_buf_simple_init(struct net_buf_simple *buf,
buf->len = 0; buf->len = 0;
} }
/**
* @brief Initialize a net_buf_simple object with data.
*
* Initialized buffer object with external data.
*
* @param buf Buffer to initialize.
* @param data External data pointer
* @param size Amount of data the pointed data buffer if able to fit.
*/
void net_buf_simple_init_with_data(struct net_buf_simple *buf,
void *data, size_t size);
/** /**
* @brief Reset buffer * @brief Reset buffer
* *

View file

@ -383,6 +383,15 @@ void net_buf_reset(struct net_buf *buf)
net_buf_simple_reset(&buf->b); net_buf_simple_reset(&buf->b);
} }
void net_buf_simple_init_with_data(struct net_buf_simple *buf,
void *data, size_t size)
{
buf->__buf = data;
buf->data = data;
buf->size = size;
buf->len = size;
}
void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve) void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve)
{ {
NET_BUF_ASSERT(buf); NET_BUF_ASSERT(buf);