Bluetooth: ATT: Fix canceling ATT timeout upon response
For some write requests, such as CCC, the code doesn't use an ATT request context but we still need to clear the request timeout when the response comes. Move the k_delayed_work_cancel() call to the right place and add some debug logs that helped pinpoint this issue. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
8068b9ad65
commit
a7ebfa948b
1 changed files with 10 additions and 4 deletions
|
@ -97,6 +97,8 @@ static struct bt_att bt_req_pool[CONFIG_BLUETOOTH_MAX_CONN];
|
|||
|
||||
static void att_req_destroy(struct bt_att_req *req)
|
||||
{
|
||||
BT_DBG("req %p", req);
|
||||
|
||||
if (req->buf) {
|
||||
net_buf_unref(req->buf);
|
||||
}
|
||||
|
@ -148,7 +150,7 @@ static void att_req_sent(struct bt_conn *conn)
|
|||
{
|
||||
struct bt_att *att = att_get(conn);
|
||||
|
||||
BT_DBG("conn %p att %p", conn, att);
|
||||
BT_DBG("conn %p att %p att->req %p", conn, att, att->req);
|
||||
|
||||
k_sem_give(&att->tx_sem);
|
||||
|
||||
|
@ -299,14 +301,14 @@ static u8_t att_handle_rsp(struct bt_att *att, void *pdu, u16_t len, u8_t err)
|
|||
|
||||
BT_DBG("err %u len %u: %s", err, len, bt_hex(pdu, len));
|
||||
|
||||
/* Cancel timeout if ongoing */
|
||||
k_delayed_work_cancel(&att->timeout_work);
|
||||
|
||||
if (!att->req) {
|
||||
BT_WARN("No pending ATT request");
|
||||
goto process;
|
||||
}
|
||||
|
||||
/* Cancel timeout if ongoing */
|
||||
k_delayed_work_cancel(&att->timeout_work);
|
||||
|
||||
/* Release original buffer */
|
||||
if (att->req->buf) {
|
||||
net_buf_unref(att->req->buf);
|
||||
|
@ -2166,6 +2168,8 @@ int bt_att_send(struct bt_conn *conn, struct net_buf *buf)
|
|||
|
||||
hdr = (void *)buf->data;
|
||||
|
||||
BT_DBG("code 0x%02x", hdr->code);
|
||||
|
||||
if (hdr->code == BT_ATT_OP_SIGNED_WRITE_CMD) {
|
||||
int err;
|
||||
|
||||
|
@ -2211,6 +2215,8 @@ void bt_att_req_cancel(struct bt_conn *conn, struct bt_att_req *req)
|
|||
{
|
||||
struct bt_att *att;
|
||||
|
||||
BT_DBG("req %p", req);
|
||||
|
||||
if (!conn || !req) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue