diff --git a/net/bluetooth/att.c b/net/bluetooth/att.c index 689ba239c6f..a5dbe1fd295 100644 --- a/net/bluetooth/att.c +++ b/net/bluetooth/att.c @@ -290,6 +290,30 @@ static void att_read_req(struct bt_conn *conn, struct bt_buf *data) 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) { 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: att_read_req(conn, buf); break; + case BT_ATT_OP_READ_BLOB_REQ: + att_read_blob_req(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); diff --git a/net/bluetooth/att.h b/net/bluetooth/att.h index 67fbdedf570..4e89768d11b 100644 --- a/net/bluetooth/att.h +++ b/net/bluetooth/att.h @@ -165,5 +165,18 @@ struct bt_att_read_rsp { uint8_t value[0]; } 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); struct bt_buf *bt_att_create_pdu(struct bt_conn *conn, uint8_t op, size_t len);