]> granicus.if.org Git - esp-idf/commitdiff
Merge branch 'bugfix/btdm_disconnect_fail_during_pairing' into 'master'
authorJiang Jiang Jian <jack@espressif.com>
Wed, 27 Dec 2017 10:03:13 +0000 (18:03 +0800)
committerJiang Jiang Jian <jack@espressif.com>
Wed, 27 Dec 2017 10:05:24 +0000 (18:05 +0800)
component/bt: Fix bug of disconnected fail during pairing

See merge request !1672

components/bt/bluedroid/stack/smp/smp_l2c.c

index d7b7a68815b9214a6c9831b77d1ea8d94421005f..24093d64cea14e92634955a96922100434f17ee7 100644 (file)
@@ -69,8 +69,12 @@ void smp_l2cap_if_init (void)
     fixed_reg.pL2CA_FixedTxComplete_Cb = smp_tx_complete_callback;
 
     fixed_reg.pL2CA_FixedCong_Cb = NULL;    /* do not handle congestion on this channel */
-    fixed_reg.default_idle_tout  = 60;      /* set 60 seconds timeout, 0xffff default idle timeout */
-
+    fixed_reg.default_idle_tout  = 0;       /* set 0 seconds timeout, 0xffff default idle timeout.
+                                            This timeout is used to wait for the end of the pairing
+                                            and then make a disconnect request, setting a larger value
+                                            will cause the disconnect event to go back up for a long time.
+                                            Set to 0 will be disconnected directly, and it will come up
+                                            pairing failure, so it will not cause adverse effects. */
     L2CA_RegisterFixedChannel (L2CAP_SMP_CID, &fixed_reg);
 #if (CLASSIC_BT_INCLUDED == TRUE)
     fixed_reg.pL2CA_FixedConn_Cb = smp_br_connect_callback;
@@ -158,7 +162,7 @@ static void smp_data_received(UINT16 channel, BD_ADDR bd_addr, BT_HDR *p_buf)
 
     /* reject the pairing request if there is an on-going SMP pairing */
     if (SMP_OPCODE_PAIRING_REQ == cmd || SMP_OPCODE_SEC_REQ == cmd) {
-        if ((p_cb->state == SMP_STATE_IDLE) && (p_cb->br_state == SMP_BR_STATE_IDLE) && 
+        if ((p_cb->state == SMP_STATE_IDLE) && (p_cb->br_state == SMP_BR_STATE_IDLE) &&
             !(p_cb->flags & SMP_PAIR_FLAGS_WE_STARTED_DD)) {
             p_cb->role = L2CA_GetBleConnRole(bd_addr);
             memcpy(&p_cb->pairing_bda[0], bd_addr, BD_ADDR_LEN);