]> granicus.if.org Git - esp-idf/commitdiff
component/bt: stop to initiate AVDTP connection on failure of A2DP service discovery
authorwangmengyang <wangmengyang@espressif.com>
Fri, 7 Sep 2018 04:03:33 +0000 (12:03 +0800)
committerbot <bot@espressif.com>
Mon, 10 Sep 2018 03:35:58 +0000 (03:35 +0000)
In opening state of AVDTP connection, if SDP client fails to get valid A2DP service record\
from peer SDP server, then do not initiate AVDTP connection request

components/bt/bluedroid/bta/av/bta_av_aact.c
components/bt/bluedroid/bta/av/bta_av_ssm.c
components/bt/bluedroid/bta/av/include/bta_av_int.h

index 06c5022b2bb76c259f478d3a736bb7f5410fc69f..badcfce5ade97de3d3374efd5496d501d0e40824 100644 (file)
@@ -143,6 +143,7 @@ const tBTA_AV_SACT bta_av_a2d_action[] = {
     bta_av_role_res,        /* BTA_AV_ROLE_RES */
     bta_av_delay_co,        /* BTA_AV_DELAY_CO */
     bta_av_open_at_inc,     /* BTA_AV_OPEN_AT_INC */
+    bta_av_open_fail_sdp,   /* BTA_AV_OPEN_FAIL_SDP */
     NULL
 };
 
@@ -1060,6 +1061,35 @@ void bta_av_free_sdb(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
     utl_freebuf((void **) &p_scb->p_disc_db);
 }
 
+/*******************************************************************************
+**
+** Function         bta_av_open_fail_sdp
+**
+** Description      report BTA_AV_OPEN_EVT with service discovery failed status
+**
+** Returns          void
+**
+*******************************************************************************/
+void bta_av_open_fail_sdp(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
+{
+    tBTA_AV_OPEN open;
+
+    bdcpy(open.bd_addr, p_scb->peer_addr);
+    open.chnl   = p_scb->chnl;
+    open.hndl   = p_scb->hndl;
+    open.status = BTA_AV_FAIL_SDP;
+
+    if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC ) {
+        open.sep = AVDT_TSEP_SNK;
+    } else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK ) {
+        open.sep = AVDT_TSEP_SRC;
+    }
+
+    (*bta_av_cb.p_cback)(BTA_AV_OPEN_EVT, (tBTA_AV *) &open);
+
+    UNUSED(p_data);
+}
+
 /*******************************************************************************
 **
 ** Function         bta_av_config_ind
index 45fa9242bead7aa10344ac48c253f811eb97896f..ad21e8763e912f12e4c03fd65bce844c1a5c4d5a 100644 (file)
@@ -94,6 +94,7 @@ enum {
     BTA_AV_ROLE_RES,
     BTA_AV_DELAY_CO,
     BTA_AV_OPEN_AT_INC,
+    BTA_AV_OPEN_FAIL_SDP,
     BTA_AV_NUM_SACTIONS
 };
 
@@ -199,7 +200,7 @@ static const UINT8 bta_av_sst_opening[][BTA_AV_NUM_COLS] = {
     /* CI_SETCONFIG_OK_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
     /* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
     /* SDP_DISC_OK_EVT */       {BTA_AV_CONNECT_REQ,    BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
-    /* SDP_DISC_FAIL_EVT */     {BTA_AV_CONNECT_REQ,    BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
+    /* SDP_DISC_FAIL_EVT */     {BTA_AV_FREE_SDB,       BTA_AV_OPEN_FAIL_SDP,  BTA_AV_INIT_SST },
     /* STR_DISC_OK_EVT */       {BTA_AV_DISC_RESULTS,   BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
     /* STR_DISC_FAIL_EVT */     {BTA_AV_OPEN_FAILED,    BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
     /* STR_GETCAP_OK_EVT */     {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
index 7fc6643f9f229ca614e2ff557ef4e7349f6ee071..16b3f38dfe777201d6fb3f4dc019a7ce32c5d70d 100644 (file)
@@ -661,6 +661,7 @@ extern void bta_av_switch_role (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
 extern void bta_av_role_res (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
 extern void bta_av_delay_co (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
 extern void bta_av_open_at_inc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
+extern void bta_av_open_fail_sdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
 
 /* ssm action functions - vdp specific */
 extern void bta_av_do_disc_vdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);