Bluetooth: Add ATT Signed Write Command skeleton

This adds the defines for Signed Write Command along with initial code
to parse it.

Change-Id: I2071163c8468a6580d9a9305095187a140c80a43
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2015-05-08 14:28:42 +03:00 committed by Anas Nashif
commit d3acf5f16a
2 changed files with 33 additions and 0 deletions

View file

@ -438,6 +438,25 @@ static void att_write_cmd(struct bt_conn *conn, struct bt_buf *data)
/* TODO: Perform write once database is defined */
}
static void att_signed_write_cmd(struct bt_conn *conn, struct bt_buf *data)
{
struct bt_att_write_req *req;
uint16_t handle;
if (data->len < sizeof(*req) + sizeof(struct bt_att_signature)) {
return;
}
req = (void *)data->data;
handle = sys_le16_to_cpu(req->handle);
bt_buf_pull(data, sizeof(*req));
BT_DBG("handle %u\n", handle);
/* TODO: Perform write once database is defined */
}
void bt_att_recv(struct bt_conn *conn, struct bt_buf *buf)
{
struct bt_att_hdr *hdr = (void *)buf->data;
@ -482,6 +501,9 @@ void bt_att_recv(struct bt_conn *conn, struct bt_buf *buf)
case BT_ATT_OP_WRITE_CMD:
att_write_cmd(conn, buf);
break;
case BT_ATT_OP_SIGNED_WRITE_CMD:
att_signed_write_cmd(conn, buf);
break;
default:
BT_DBG("Unhandled ATT code %u\n", hdr->code);
send_err_rsp(conn, hdr->code, 0, BT_ATT_ERR_NOT_SUPPORTED);

View file

@ -230,5 +230,16 @@ struct bt_att_write_cmd {
uint8_t value[0];
} PACK_STRUCT;
struct bt_att_signature {
uint8_t value[12];
} PACK_STRUCT;
/* Signed Write Command */
#define BT_ATT_OP_SIGNED_WRITE_CMD 0xD2
struct bt_att_signed_write_req {
uint16_t handle;
uint8_t value[0];
} PACK_STRUCT;
void bt_att_recv(struct bt_conn *conn, struct bt_buf *buf);
struct bt_buf *bt_att_create_pdu(struct bt_conn *conn, uint8_t op, size_t len);