mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-12-11 13:04:10 +08:00
att: Add encode/decode execute write support
Add functions for encoding/decoding Execute Write Request and Response PDUs.
This commit is contained in:
parent
3be0d8feef
commit
f5cf20bb06
35
attrib/att.c
35
attrib/att.c
@ -1028,3 +1028,38 @@ uint16_t dec_prep_write_resp(const uint8_t *pdu, int len, uint16_t *handle,
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
uint16_t enc_exec_write_req(uint8_t flags, uint8_t *pdu, int len)
|
||||
{
|
||||
const uint16_t min_len = sizeof(pdu[0]) + sizeof(flags);
|
||||
|
||||
if (pdu == NULL)
|
||||
return 0;
|
||||
|
||||
if (len < min_len)
|
||||
return 0;
|
||||
|
||||
if (flags > 1)
|
||||
return 0;
|
||||
|
||||
pdu[0] = ATT_OP_EXEC_WRITE_REQ;
|
||||
pdu[1] = flags;
|
||||
|
||||
return min_len;
|
||||
}
|
||||
|
||||
uint16_t dec_exec_write_resp(const uint8_t *pdu, int len)
|
||||
{
|
||||
const uint16_t min_len = sizeof(pdu[0]);
|
||||
|
||||
if (pdu == NULL)
|
||||
return 0;
|
||||
|
||||
if (len < min_len)
|
||||
return 0;
|
||||
|
||||
if (pdu[0] != ATT_OP_EXEC_WRITE_RESP)
|
||||
return 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
@ -261,3 +261,5 @@ uint16_t enc_prep_write_req(uint16_t handle, uint16_t offset,
|
||||
const uint8_t *value, int vlen, uint8_t *pdu, int len);
|
||||
uint16_t dec_prep_write_resp(const uint8_t *pdu, int len, uint16_t *handle,
|
||||
uint16_t *offset, uint8_t *value, int *vlen);
|
||||
uint16_t enc_exec_write_req(uint8_t flags, uint8_t *pdu, int len);
|
||||
uint16_t dec_exec_write_resp(const uint8_t *pdu, int len);
|
||||
|
Loading…
Reference in New Issue
Block a user