From 049402ae8da354eb6036d50d593b58c35da27be4 Mon Sep 17 00:00:00 2001 From: wangcheng Date: Wed, 13 May 2020 19:56:24 +0800 Subject: [PATCH] master missing BLE_AUTH_CMPL_EVT after restart --- components/bt/host/bluedroid/stack/smp/smp_act.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/bt/host/bluedroid/stack/smp/smp_act.c b/components/bt/host/bluedroid/stack/smp/smp_act.c index 9c3247e68..9f821b591 100644 --- a/components/bt/host/bluedroid/stack/smp/smp_act.c +++ b/components/bt/host/bluedroid/stack/smp/smp_act.c @@ -1990,9 +1990,7 @@ void smp_link_encrypted(BD_ADDR bda, UINT8 encr_enable) } smp_sm_event(&smp_cb, SMP_ENCRYPTED_EVT, &encr_enable); - } - else if(p_dev_rec && !p_dev_rec->enc_init_by_we){ - + } else if (p_dev_rec && !p_dev_rec->role_master && !p_dev_rec->enc_init_by_we ){ /* if enc_init_by_we is false, it means that client initiates encryption before slave calls esp_ble_set_encryption() we need initiate pairing_bda and p_cb->role then encryption, for example iPhones @@ -2002,6 +2000,12 @@ void smp_link_encrypted(BD_ADDR bda, UINT8 encr_enable) p_cb->role = HCI_ROLE_SLAVE; p_dev_rec->enc_init_by_we = FALSE; smp_sm_event(&smp_cb, SMP_ENCRYPTED_EVT, &encr_enable); + } else if (p_dev_rec && p_dev_rec->role_master && p_dev_rec->enc_init_by_we){ + memcpy(&smp_cb.pairing_bda[0], bda, BD_ADDR_LEN); + p_cb->state = SMP_STATE_ENCRYPTION_PENDING; + p_cb->role = HCI_ROLE_MASTER; + p_dev_rec->enc_init_by_we = FALSE; + smp_sm_event(&smp_cb, SMP_ENCRYPTED_EVT, &encr_enable); } }