mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-26 13:44:23 +08:00
Add encode/decode for write response
The encode/decode functions for Write Response operations were created to keep consistency with the rest of GATT API.
This commit is contained in:
parent
32d7daf120
commit
ec141a423b
21
attrib/att.c
21
attrib/att.c
@ -526,6 +526,27 @@ uint16_t dec_write_req(const uint8_t *pdu, int len, uint16_t *handle,
|
||||
return len;
|
||||
}
|
||||
|
||||
uint16_t enc_write_resp(uint8_t *pdu, int len)
|
||||
{
|
||||
if (pdu == NULL)
|
||||
return 0;
|
||||
|
||||
pdu[0] = ATT_OP_WRITE_RESP;
|
||||
|
||||
return sizeof(pdu[0]);
|
||||
}
|
||||
|
||||
uint16_t dec_write_resp(const uint8_t *pdu, int len)
|
||||
{
|
||||
if (pdu == NULL)
|
||||
return 0;
|
||||
|
||||
if (pdu[0] != ATT_OP_WRITE_RESP)
|
||||
return 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
uint16_t enc_read_req(uint16_t handle, uint8_t *pdu, int len)
|
||||
{
|
||||
const uint16_t min_len = sizeof(pdu[0]) + sizeof(handle);
|
||||
|
@ -215,6 +215,8 @@ uint16_t enc_write_req(uint16_t handle, const uint8_t *value, int vlen,
|
||||
uint8_t *pdu, int len);
|
||||
uint16_t dec_write_req(const uint8_t *pdu, int len, uint16_t *handle,
|
||||
uint8_t *value, int *vlen);
|
||||
uint16_t enc_write_resp(uint8_t *pdu, int len);
|
||||
uint16_t dec_write_resp(const uint8_t *pdu, int len);
|
||||
uint16_t enc_read_req(uint16_t handle, uint8_t *pdu, int len);
|
||||
uint16_t enc_read_blob_req(uint16_t handle, uint16_t offset, uint8_t *pdu,
|
||||
int len);
|
||||
|
@ -601,9 +601,7 @@ static uint16_t write_value(struct gatt_channel *channel, uint16_t handle,
|
||||
memcpy(&uuid, &a->uuid, sizeof(uuid_t));
|
||||
attrib_db_update(handle, &uuid, value, vlen);
|
||||
|
||||
pdu[0] = ATT_OP_WRITE_RESP;
|
||||
|
||||
return sizeof(pdu[0]);
|
||||
return enc_write_resp(pdu, len);
|
||||
}
|
||||
|
||||
static uint16_t mtu_exchange(struct gatt_channel *channel, uint16_t mtu,
|
||||
|
Loading…
Reference in New Issue
Block a user