Bluetooth: Add bt_buf_pull_le16 helper
bt_buf_pull_le16 convert the initial 16 bits to little endian. Change-Id: I6f6e9d63fc19b0579d9f445e15e975929fc63ba9 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
009899116d
commit
d1b61254f3
2 changed files with 13 additions and 0 deletions
|
@ -106,6 +106,9 @@ uint8_t *bt_buf_push(struct bt_buf *buf, size_t len);
|
|||
/* Remove data from the beginning of the buffer */
|
||||
uint8_t *bt_buf_pull(struct bt_buf *buf, size_t len);
|
||||
|
||||
/* Remove and convert 16 bits from the beginning of the buffer */
|
||||
uint16_t bt_buf_pull_le16(struct bt_buf *buf);
|
||||
|
||||
/* Returns how much free space there is at the end of the buffer */
|
||||
size_t bt_buf_tailroom(struct bt_buf *buf);
|
||||
|
||||
|
|
|
@ -185,6 +185,16 @@ uint8_t *bt_buf_pull(struct bt_buf *buf, size_t len)
|
|||
return buf->data += len;
|
||||
}
|
||||
|
||||
uint16_t bt_buf_pull_le16(struct bt_buf *buf)
|
||||
{
|
||||
uint16_t value;
|
||||
|
||||
value = UNALIGNED_GET((uint16_t *)buf->data);
|
||||
bt_buf_pull(buf, sizeof(value));
|
||||
|
||||
return sys_cpu_to_le16(value);
|
||||
}
|
||||
|
||||
size_t bt_buf_headroom(struct bt_buf *buf)
|
||||
{
|
||||
return buf->data - buf->buf;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue