Bluetooth: Add ATT Write Request skeleton
This adds the defines for Write PDUs along with initial code to parse them. Change-Id: I69d2002b3e6da80037c058f42f543a0ab4765958 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
75aab47603
commit
9e8c1d1326
2 changed files with 36 additions and 0 deletions
|
@ -396,6 +396,29 @@ static void att_read_group_req(struct bt_conn *conn, struct bt_buf *data)
|
|||
return;
|
||||
}
|
||||
|
||||
static void att_write_req(struct bt_conn *conn, struct bt_buf *data)
|
||||
{
|
||||
struct bt_att_write_req *req;
|
||||
uint16_t handle;
|
||||
|
||||
if (data->len < sizeof(*req)) {
|
||||
send_err_rsp(conn, BT_ATT_OP_WRITE_REQ, 0,
|
||||
BT_ATT_ERR_INVALID_PDU);
|
||||
return;
|
||||
}
|
||||
|
||||
req = (void *)data->data;
|
||||
|
||||
handle = sys_le16_to_cpu(req->handle);
|
||||
|
||||
BT_DBG("handle %u\n", handle);
|
||||
|
||||
/* TODO: Generate proper response once a database is defined */
|
||||
|
||||
send_err_rsp(conn, BT_ATT_OP_WRITE_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;
|
||||
|
@ -434,6 +457,9 @@ void bt_att_recv(struct bt_conn *conn, struct bt_buf *buf)
|
|||
case BT_ATT_OP_READ_GROUP_REQ:
|
||||
att_read_group_req(conn, buf);
|
||||
break;
|
||||
case BT_ATT_OP_WRITE_REQ:
|
||||
att_write_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);
|
||||
|
|
|
@ -213,5 +213,15 @@ struct bt_att_read_group_rsp {
|
|||
struct bt_att_group_data data[0];
|
||||
} PACK_STRUCT;
|
||||
|
||||
/* Write Request */
|
||||
#define BT_ATT_OP_WRITE_REQ 0x12
|
||||
struct bt_att_write_req {
|
||||
uint16_t handle;
|
||||
uint8_t value[0];
|
||||
} PACK_STRUCT;
|
||||
|
||||
/* Write Response */
|
||||
#define BT_ATT_OP_WRITE_RSP 0x13
|
||||
|
||||
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