From 7f7f8a02d028e65fc7f79bd6648ba6ade9383e49 Mon Sep 17 00:00:00 2001 From: wangmengyang Date: Sat, 9 Jun 2018 11:48:19 +0800 Subject: [PATCH] component/bt: retrieve disconnection reason in AVDT when ACL-U link is disconnected --- components/bt/bluedroid/stack/avdt/avdt_l2c.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/bt/bluedroid/stack/avdt/avdt_l2c.c b/components/bt/bluedroid/stack/avdt/avdt_l2c.c index 92e3dcad9d..3227fa69b3 100644 --- a/components/bt/bluedroid/stack/avdt/avdt_l2c.c +++ b/components/bt/bluedroid/stack/avdt/avdt_l2c.c @@ -412,6 +412,7 @@ void avdt_l2c_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed) { tAVDT_TC_TBL *p_tbl; UINT16 disc_rsn = AVDT_DISC_RSN_NORMAL; + tAVDT_CCB *p_ccb; AVDT_TRACE_DEBUG("avdt_l2c_disconnect_ind_cback lcid: %d, ack_needed: %d\n", lcid, ack_needed); /* look up info for this channel */ @@ -420,7 +421,13 @@ void avdt_l2c_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed) /* send L2CAP disconnect response */ L2CA_DisconnectRsp(lcid); } else { - disc_rsn = AVDT_DISC_RSN_ABNORMAL; + if ((p_ccb = avdt_ccb_by_idx(p_tbl->ccb_idx)) != NULL) { + UINT16 rsn = L2CA_GetDisconnectReason(p_ccb->peer_addr, BT_TRANSPORT_BR_EDR); + if (rsn != 0 && rsn != HCI_ERR_PEER_USER) { + disc_rsn = AVDT_DISC_RSN_ABNORMAL; + AVDT_TRACE_EVENT("avdt link disc rsn 0x%x", rsn); + } + } } avdt_ad_tc_close_ind(p_tbl, disc_rsn);