From 1e72a8c850a241b9577931d2bec1ae0dac5c0c81 Mon Sep 17 00:00:00 2001 From: wangcheng Date: Wed, 29 Apr 2020 17:38:47 +0800 Subject: [PATCH] master missing BLE_AUTH_CMPL_EVT after restart --- components/bt/bluedroid/stack/smp/smp_act.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/bt/bluedroid/stack/smp/smp_act.c b/components/bt/bluedroid/stack/smp/smp_act.c index d11506e65..0000c2592 100644 --- a/components/bt/bluedroid/stack/smp/smp_act.c +++ b/components/bt/bluedroid/stack/smp/smp_act.c @@ -1945,8 +1945,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 @@ -1956,6 +1955,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); } }