From a6c79cfe0f72ffee1b7e0a69a7384c2a4e37b442 Mon Sep 17 00:00:00 2001 From: zhiweijian Date: Mon, 2 Apr 2018 15:33:04 +0800 Subject: [PATCH] Component/bt: do not update connection params when already have keys in slave --- components/bt/bluedroid/stack/btm/btm_ble.c | 6 ++++++ components/bt/bluedroid/stack/include/btm_int.h | 1 + components/bt/bluedroid/stack/smp/smp_act.c | 5 +++++ components/bt/bluedroid/stack/smp/smp_utils.c | 9 ++++++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/components/bt/bluedroid/stack/btm/btm_ble.c b/components/bt/bluedroid/stack/btm/btm_ble.c index 9dc9191f4e..507e3e7f64 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble.c +++ b/components/bt/bluedroid/stack/btm/btm_ble.c @@ -1447,6 +1447,12 @@ tBTM_STATUS btm_ble_set_encryption (BD_ADDR bd_addr, void *p_ref_data, UINT8 lin } } + // already have encrypted information, do not need to update connection parameters + if(link_role == BTM_ROLE_SLAVE && (p_rec->ble.key_type & BTM_LE_KEY_PENC)) { + p_rec->ble.skip_update_conn_param = true; + } else { + p_rec->ble.skip_update_conn_param = false; + } if (SMP_Pair(bd_addr) == SMP_STARTED) { cmd = BTM_CMD_STARTED; p_rec->sec_state = BTM_SEC_STATE_AUTHENTICATING; diff --git a/components/bt/bluedroid/stack/include/btm_int.h b/components/bt/bluedroid/stack/include/btm_int.h index 79a10cf714..c45e88f063 100644 --- a/components/bt/bluedroid/stack/include/btm_int.h +++ b/components/bt/bluedroid/stack/include/btm_int.h @@ -485,6 +485,7 @@ typedef struct { #if SMP_INCLUDED == TRUE tBTM_LE_KEY_TYPE key_type; /* bit mask of valid key types in record */ tBTM_SEC_BLE_KEYS keys; /* LE device security info in slave rode */ + bool skip_update_conn_param; /* skip update connection paraams or not*/ #endif #if (BLE_PRIVACY_SPT == TRUE) tBLE_ADDR_TYPE current_addr_type; /* current adv addr type*/ diff --git a/components/bt/bluedroid/stack/smp/smp_act.c b/components/bt/bluedroid/stack/smp/smp_act.c index 99f248accf..10c8821f5d 100644 --- a/components/bt/bluedroid/stack/smp/smp_act.c +++ b/components/bt/bluedroid/stack/smp/smp_act.c @@ -1389,6 +1389,11 @@ void smp_idle_terminate(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) *******************************************************************************/ void smp_fast_conn_param(tSMP_CB *p_cb, tSMP_INT_DATA *p_data) { + tBTM_SEC_DEV_REC *p_rec = btm_find_dev (p_cb->pairing_bda); + if(p_rec && p_rec->ble.skip_update_conn_param) { + //do nothing + return; + } /* Disable L2CAP connection parameter updates while bonding since some peripherals are not able to revert to fast connection parameters during the start of service discovery. Connection paramter updates diff --git a/components/bt/bluedroid/stack/smp/smp_utils.c b/components/bt/bluedroid/stack/smp/smp_utils.c index aa596df1d5..ba039bfcb4 100644 --- a/components/bt/bluedroid/stack/smp/smp_utils.c +++ b/components/bt/bluedroid/stack/smp/smp_utils.c @@ -951,6 +951,7 @@ void smp_proc_pairing_cmpl(tSMP_CB *p_cb) tSMP_EVT_DATA evt_data = {0}; tSMP_CALLBACK *p_callback = p_cb->p_callback; BD_ADDR pairing_bda; + tBTM_SEC_DEV_REC *p_rec; SMP_TRACE_DEBUG ("smp_proc_pairing_cmpl \n"); @@ -975,7 +976,13 @@ void smp_proc_pairing_cmpl(tSMP_CB *p_cb) memcpy (pairing_bda, p_cb->pairing_bda, BD_ADDR_LEN); if (p_cb->role == HCI_ROLE_SLAVE) { - L2CA_EnableUpdateBleConnParams(p_cb->pairing_bda, TRUE); + p_rec = btm_find_dev (p_cb->pairing_bda); + if(p_rec && p_rec->ble.skip_update_conn_param) { + //clear flag + p_rec->ble.skip_update_conn_param = false; + } else { + L2CA_EnableUpdateBleConnParams(p_cb->pairing_bda, TRUE); + } } smp_reset_control_value(p_cb); -- 2.40.0