Bluetooth: Add ATT Find Information by Type Value Request skeleton
This adds the defines for Find Information by Type Value PDUs along with initial code to parse them. Change-Id: I9eaf2df390ca6f78530df7f1ae606b588d1fcb2e Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
b6d35d8281
commit
d51985e4ce
2 changed files with 68 additions and 0 deletions
|
@ -149,6 +149,51 @@ invalid_handle:
|
||||||
BT_ATT_ERR_INVALID_HANDLE);
|
BT_ATT_ERR_INVALID_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void att_find_type_req(struct bt_conn *conn, struct bt_buf *data)
|
||||||
|
{
|
||||||
|
struct bt_att_find_type_req *req;
|
||||||
|
uint16_t start_handle, end_handle, type;
|
||||||
|
uint8_t *value;
|
||||||
|
|
||||||
|
if (data->len < sizeof(*req)) {
|
||||||
|
send_err_rsp(conn, BT_ATT_OP_FIND_TYPE_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);
|
||||||
|
type = sys_le16_to_cpu(req->type);
|
||||||
|
value = bt_buf_pull(data, sizeof(*req));
|
||||||
|
|
||||||
|
BT_DBG("start_handle %u end_handle %u type %u\n", start_handle,
|
||||||
|
end_handle, type);
|
||||||
|
|
||||||
|
/* 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_TYPE_REQ, start_handle,
|
||||||
|
BT_ATT_ERR_ATTRIBUTE_NOT_FOUND);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
invalid_handle:
|
||||||
|
send_err_rsp(conn, BT_ATT_OP_FIND_TYPE_REQ, start_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;
|
||||||
|
@ -169,6 +214,9 @@ void bt_att_recv(struct bt_conn *conn, struct bt_buf *buf)
|
||||||
case BT_ATT_OP_FIND_INFO_REQ:
|
case BT_ATT_OP_FIND_INFO_REQ:
|
||||||
att_find_info_req(conn, buf);
|
att_find_info_req(conn, buf);
|
||||||
break;
|
break;
|
||||||
|
case BT_ATT_OP_FIND_TYPE_REQ:
|
||||||
|
att_find_type_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);
|
||||||
|
|
|
@ -101,5 +101,25 @@ struct bt_att_find_info_rsp {
|
||||||
uint8_t info[0];
|
uint8_t info[0];
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
/* Find By Type Value Request */
|
||||||
|
#define BT_ATT_OP_FIND_TYPE_REQ 0x06
|
||||||
|
struct bt_att_find_type_req {
|
||||||
|
uint16_t start_handle;
|
||||||
|
uint16_t end_handle;
|
||||||
|
uint16_t type;
|
||||||
|
uint8_t value[0];
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
struct bt_att_handle_group {
|
||||||
|
uint16_t start_handle;
|
||||||
|
uint16_t end_handle;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
/* Find By Type Value Response */
|
||||||
|
#define BT_ATT_OP_FIND_TYPE_RSP 0x07
|
||||||
|
struct bt_att_find_type_rsp {
|
||||||
|
struct bt_att_handle_group list[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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue