Bluetooth: Add ATT Find Information Request skeleton
This adds the defines for Find Information PDUs along with initial code to parse them. Change-Id: If34533cca4a1a554ca3f119c7639a1167dae0ff2 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
94fc5b27c5
commit
b6d35d8281
2 changed files with 71 additions and 0 deletions
|
@ -109,6 +109,46 @@ static void att_mtu_req(struct bt_conn *conn, struct bt_buf *data)
|
|||
bt_conn_send(conn, buf);
|
||||
}
|
||||
|
||||
static void att_find_info_req(struct bt_conn *conn, struct bt_buf *data)
|
||||
{
|
||||
struct bt_att_find_info_req *req;
|
||||
uint16_t start_handle, end_handle;
|
||||
|
||||
if (data->len != sizeof(*req)) {
|
||||
send_err_rsp(conn, BT_ATT_OP_FIND_INFO_REQ, 0,
|
||||
BT_ATT_ERR_INVALID_PDU);
|
||||
return;
|
||||
}
|
||||
|
||||
req = (void *)data->data;
|
||||
|
||||
start_handle = sys_le16_to_cpu(req->start_handle);
|
||||
end_handle = sys_le16_to_cpu(req->end_handle);
|
||||
|
||||
BT_DBG("start_handle %u end_handle %u\n", start_handle, end_handle);
|
||||
|
||||
/* Handle 0 is invalid */
|
||||
if (!start_handle || !end_handle) {
|
||||
start_handle = 0;
|
||||
goto invalid_handle;
|
||||
}
|
||||
|
||||
/* Check if range is valid */
|
||||
if (start_handle > end_handle) {
|
||||
goto invalid_handle;
|
||||
}
|
||||
|
||||
/* TODO: Generate proper response once a database is defined */
|
||||
|
||||
send_err_rsp(conn, BT_ATT_OP_FIND_INFO_REQ, start_handle,
|
||||
BT_ATT_ERR_ATTRIBUTE_NOT_FOUND);
|
||||
return;
|
||||
|
||||
invalid_handle:
|
||||
send_err_rsp(conn, BT_ATT_OP_FIND_INFO_REQ, start_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;
|
||||
|
@ -126,6 +166,9 @@ void bt_att_recv(struct bt_conn *conn, struct bt_buf *buf)
|
|||
case BT_ATT_OP_MTU_REQ:
|
||||
att_mtu_req(conn, buf);
|
||||
break;
|
||||
case BT_ATT_OP_FIND_INFO_REQ:
|
||||
att_find_info_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);
|
||||
|
|
|
@ -73,5 +73,33 @@ struct bt_att_exchange_mtu_rsp {
|
|||
uint16_t mtu;
|
||||
} PACK_STRUCT;
|
||||
|
||||
/* Find Information Request */
|
||||
#define BT_ATT_OP_FIND_INFO_REQ 0x04
|
||||
struct bt_att_find_info_req {
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
} PACK_STRUCT;
|
||||
|
||||
/* Format field values for BT_ATT_OP_FIND_INFO_RSP */
|
||||
#define BT_ATT_INFO_1 0x01
|
||||
#define BT_ATT_INFO_2 0x02
|
||||
|
||||
struct bt_att_info_1 {
|
||||
uint16_t handle;
|
||||
uint16_t uuid;
|
||||
} PACK_STRUCT;
|
||||
|
||||
struct bt_att_info_2 {
|
||||
uint16_t handle;
|
||||
uint8_t uuid[16];
|
||||
} PACK_STRUCT;
|
||||
|
||||
/* Find Information Response */
|
||||
#define BT_ATT_OP_FIND_INFO_RSP 0x05
|
||||
struct bt_att_find_info_rsp {
|
||||
uint8_t format;
|
||||
uint8_t info[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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue