att: Add encode/decode execute write support

Add functions for encoding/decoding Execute Write Request and
Response PDUs.
This commit is contained in:
Eder Ruiz Maria 2012-07-30 13:38:09 -04:00 committed by Johan Hedberg
parent 3be0d8feef
commit f5cf20bb06
2 changed files with 37 additions and 0 deletions

View File

@ -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;
}

View File

@ -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);