Bluetooth: Add bt_att_create_pdu
Add bt_att_create_pdu which works similarly to bt_l2cap_create_pdu eliminating some duplicated when generating ATT PDUs. Change-Id: I30b89effbae887f4032ba1d1e380a763c3556869 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
7ab174d202
commit
7cbb4e6f4b
2 changed files with 18 additions and 6 deletions
|
@ -48,18 +48,13 @@ static void send_err_rsp(struct bt_conn *conn, uint8_t req, uint16_t handle,
|
|||
uint8_t err)
|
||||
{
|
||||
struct bt_att_error_rsp *rsp;
|
||||
struct bt_att_hdr *hdr;
|
||||
struct bt_buf *buf;
|
||||
|
||||
buf = bt_l2cap_create_pdu(conn, BT_L2CAP_CID_ATT,
|
||||
sizeof(*hdr) + sizeof(*rsp));
|
||||
buf = bt_att_create_pdu(conn, BT_ATT_OP_ERROR_RSP, sizeof(*rsp));
|
||||
if (!buf) {
|
||||
return;
|
||||
}
|
||||
|
||||
hdr = (void *)bt_buf_add(buf, sizeof(*hdr));
|
||||
hdr->code = BT_ATT_OP_ERROR_RSP;
|
||||
|
||||
rsp = (void *)bt_buf_add(buf, sizeof(*rsp));
|
||||
rsp->request = req;
|
||||
rsp->handle = sys_cpu_to_le16(handle);
|
||||
|
@ -91,3 +86,19 @@ void bt_att_recv(struct bt_conn *conn, struct bt_buf *buf)
|
|||
done:
|
||||
bt_buf_put(buf);
|
||||
}
|
||||
|
||||
struct bt_buf *bt_att_create_pdu(struct bt_conn *conn, uint8_t op, size_t len)
|
||||
{
|
||||
struct bt_att_hdr *hdr;
|
||||
struct bt_buf *buf;
|
||||
|
||||
buf = bt_l2cap_create_pdu(conn, BT_L2CAP_CID_ATT, sizeof(*hdr) + len);
|
||||
if (!buf) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hdr = (void *)bt_buf_add(buf, sizeof(*hdr));
|
||||
hdr->code = op;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue