Skip to content

Commit

Permalink
Bluetooth: ATT: Fix handling to EATT channels
Browse files Browse the repository at this point in the history
EATT channels use bt_l2cap_chan_send which does return the number of
bytes sent on success not 0 as bt_l2cap_send.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information
Vudentz authored and jhedberg committed Aug 4, 2020
1 parent f72aef1 commit 6c7a387
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions subsys/bluetooth/host/att.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ static int chan_send(struct bt_att_chan *chan, struct net_buf *buf,

if (IS_ENABLED(CONFIG_BT_EATT) &&
atomic_test_bit(chan->flags, ATT_ENHANCED)) {
int err;

/* Check if sent is pending already, if it does it cannot be
* modified so the operation will need to be queued.
*/
Expand All @@ -174,7 +176,15 @@ static int chan_send(struct bt_att_chan *chan, struct net_buf *buf,
return -EAGAIN;
}

return bt_l2cap_chan_send(&chan->chan.chan, buf);
/* bt_l2cap_chan_send does actually return the number of bytes
* that could be sent immediatelly.
*/
err = bt_l2cap_chan_send(&chan->chan.chan, buf);
if (err < 0) {
return err;
}

return 0;
}

if (hdr->code == BT_ATT_OP_SIGNED_WRITE_CMD) {
Expand Down Expand Up @@ -233,7 +243,7 @@ static int chan_req_send(struct bt_att_chan *chan, struct bt_att_req *req)

/* Keep a reference for resending in case of an error */
err = chan_send(chan, net_buf_ref(req->buf), NULL);
if (err < 0) {
if (err) {
net_buf_unref(req->buf);
chan->req = NULL;
}
Expand Down

0 comments on commit 6c7a387

Please sign in to comment.