Bluetooth: Add ATT Read Blob Request skeleton

This adds the defines for Read Blob PDUs along with initial code to
parse them.

Change-Id: I5a2a2e2e32bf44d98ce928b3d57ad7f05059a927
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2015-05-07 12:20:13 +03:00 committed by Anas Nashif
commit eedc01d6d5
2 changed files with 40 additions and 0 deletions

View file

@ -290,6 +290,30 @@ static void att_read_req(struct bt_conn *conn, struct bt_buf *data)
BT_ATT_ERR_ATTRIBUTE_NOT_FOUND); BT_ATT_ERR_ATTRIBUTE_NOT_FOUND);
} }
static void att_read_blob_req(struct bt_conn *conn, struct bt_buf *data)
{
struct bt_att_read_blob_req *req;
uint16_t handle, offset;
if (data->len != sizeof(*req)) {
send_err_rsp(conn, BT_ATT_OP_READ_BLOB_REQ, 0,
BT_ATT_ERR_INVALID_PDU);
return;
}
req = (void *)data->data;
handle = sys_le16_to_cpu(req->handle);
offset = sys_le16_to_cpu(req->offset);
BT_DBG("handle %u offset %u\n", handle, offset);
/* TODO: Generate proper response once a database is defined */
send_err_rsp(conn, BT_ATT_OP_READ_BLOB_REQ, handle,
BT_ATT_ERR_INVALID_HANDLE);
}
void bt_att_recv(struct bt_conn *conn, struct bt_buf *buf) void bt_att_recv(struct bt_conn *conn, struct bt_buf *buf)
{ {
struct bt_att_hdr *hdr = (void *)buf->data; struct bt_att_hdr *hdr = (void *)buf->data;
@ -319,6 +343,9 @@ void bt_att_recv(struct bt_conn *conn, struct bt_buf *buf)
case BT_ATT_OP_READ_REQ: case BT_ATT_OP_READ_REQ:
att_read_req(conn, buf); att_read_req(conn, buf);
break; break;
case BT_ATT_OP_READ_BLOB_REQ:
att_read_blob_req(conn, buf);
break;
default: default:
BT_DBG("Unhandled ATT code %u\n", hdr->code); BT_DBG("Unhandled ATT code %u\n", hdr->code);
send_err_rsp(conn, hdr->code, 0, BT_ATT_ERR_NOT_SUPPORTED); send_err_rsp(conn, hdr->code, 0, BT_ATT_ERR_NOT_SUPPORTED);

View file

@ -165,5 +165,18 @@ struct bt_att_read_rsp {
uint8_t value[0]; uint8_t value[0];
} PACK_STRUCT; } PACK_STRUCT;
/* Read Blob Request */
#define BT_ATT_OP_READ_BLOB_REQ 0x0c
struct bt_att_read_blob_req {
uint16_t handle;
uint16_t offset;
} PACK_STRUCT;
/* Read Blob Response */
#define BT_ATT_OP_READ_BLOB_RSP 0x0d
struct bt_att_read_blob_rsp {
uint8_t value[0];
} PACK_STRUCT;
void bt_att_recv(struct bt_conn *conn, struct bt_buf *buf); 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); struct bt_buf *bt_att_create_pdu(struct bt_conn *conn, uint8_t op, size_t len);