Bluetooth: Add ATT Write Command skeleton
This adds the defines for Write Command along with initial code to parse it. Change-Id: Ifabcfa8efb54b5135a540718fb60d9a656cd088c Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
9e8c1d1326
commit
75f56d9e07
2 changed files with 29 additions and 0 deletions
|
@ -410,6 +410,7 @@ static void att_write_req(struct bt_conn *conn, struct bt_buf *data)
|
|||
req = (void *)data->data;
|
||||
|
||||
handle = sys_le16_to_cpu(req->handle);
|
||||
bt_buf_pull(data, sizeof(*req));
|
||||
|
||||
BT_DBG("handle %u\n", handle);
|
||||
|
||||
|
@ -419,6 +420,24 @@ static void att_write_req(struct bt_conn *conn, struct bt_buf *data)
|
|||
BT_ATT_ERR_INVALID_HANDLE);
|
||||
}
|
||||
|
||||
static void att_write_cmd(struct bt_conn *conn, struct bt_buf *data)
|
||||
{
|
||||
struct bt_att_write_req *req;
|
||||
uint16_t handle;
|
||||
|
||||
if (data->len < sizeof(*req)) {
|
||||
return;
|
||||
}
|
||||
|
||||
req = (void *)data->data;
|
||||
|
||||
handle = sys_le16_to_cpu(req->handle);
|
||||
|
||||
BT_DBG("handle %u\n", handle);
|
||||
|
||||
/* TODO: Perform write once database is defined */
|
||||
}
|
||||
|
||||
void bt_att_recv(struct bt_conn *conn, struct bt_buf *buf)
|
||||
{
|
||||
struct bt_att_hdr *hdr = (void *)buf->data;
|
||||
|
@ -460,6 +479,9 @@ void bt_att_recv(struct bt_conn *conn, struct bt_buf *buf)
|
|||
case BT_ATT_OP_WRITE_REQ:
|
||||
att_write_req(conn, buf);
|
||||
break;
|
||||
case BT_ATT_OP_WRITE_CMD:
|
||||
att_write_cmd(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);
|
||||
|
|
|
@ -223,5 +223,12 @@ struct bt_att_write_req {
|
|||
/* Write Response */
|
||||
#define BT_ATT_OP_WRITE_RSP 0x13
|
||||
|
||||
/* Write Command */
|
||||
#define BT_ATT_OP_WRITE_CMD 0x52
|
||||
struct bt_att_write_cmd {
|
||||
uint16_t handle;
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue