mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
fix(ble/bluedroid): Fixed BLE SMP state machine inconsistency on disconnection
This commit is contained in:
@ -1553,7 +1553,7 @@ void smp_fast_conn_param(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
|||||||
}
|
}
|
||||||
/* Disable L2CAP connection parameter updates while bonding since
|
/* Disable L2CAP connection parameter updates while bonding since
|
||||||
some peripherals are not able to revert to fast connection parameters
|
some peripherals are not able to revert to fast connection parameters
|
||||||
during the start of service discovery. Connection paramter updates
|
during the start of service discovery. Connection parameter updates
|
||||||
get enabled again once service discovery completes. */
|
get enabled again once service discovery completes. */
|
||||||
#if (BT_MULTI_CONNECTION_ENBALE == FALSE)
|
#if (BT_MULTI_CONNECTION_ENBALE == FALSE)
|
||||||
L2CA_EnableUpdateBleConnParams(p_cb->pairing_bda, FALSE);
|
L2CA_EnableUpdateBleConnParams(p_cb->pairing_bda, FALSE);
|
||||||
@ -1648,6 +1648,8 @@ void smp_process_local_nonce(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
|||||||
/* slave calculates and sends local commitment */
|
/* slave calculates and sends local commitment */
|
||||||
smp_calculate_local_commitment(p_cb);
|
smp_calculate_local_commitment(p_cb);
|
||||||
smp_send_commitment(p_cb, NULL);
|
smp_send_commitment(p_cb, NULL);
|
||||||
|
/* Ensure the connection is still active */
|
||||||
|
if (smp_get_state() == SMP_STATE_IDLE) return;
|
||||||
/* slave has to wait for peer nonce */
|
/* slave has to wait for peer nonce */
|
||||||
smp_set_state(SMP_STATE_WAIT_NONCE);
|
smp_set_state(SMP_STATE_WAIT_NONCE);
|
||||||
} else { /* i.e. master */
|
} else { /* i.e. master */
|
||||||
@ -1658,6 +1660,8 @@ void smp_process_local_nonce(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
|||||||
p_cb->selected_association_model);
|
p_cb->selected_association_model);
|
||||||
p_cb->flags &= ~SMP_PAIR_FLAG_HAVE_PEER_COMM;
|
p_cb->flags &= ~SMP_PAIR_FLAG_HAVE_PEER_COMM;
|
||||||
smp_send_rand(p_cb, NULL);
|
smp_send_rand(p_cb, NULL);
|
||||||
|
/* Ensure the connection is still active */
|
||||||
|
if (smp_get_state() == SMP_STATE_IDLE) return;
|
||||||
smp_set_state(SMP_STATE_WAIT_NONCE);
|
smp_set_state(SMP_STATE_WAIT_NONCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1672,6 +1676,8 @@ void smp_process_local_nonce(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
|||||||
if (p_cb->flags & SMP_PAIR_FLAG_HAVE_PEER_COMM) {
|
if (p_cb->flags & SMP_PAIR_FLAG_HAVE_PEER_COMM) {
|
||||||
/* master commitment is already received */
|
/* master commitment is already received */
|
||||||
smp_send_commitment(p_cb, NULL);
|
smp_send_commitment(p_cb, NULL);
|
||||||
|
/* Ensure the connection is still active */
|
||||||
|
if (smp_get_state() == SMP_STATE_IDLE) return;
|
||||||
smp_set_state(SMP_STATE_WAIT_NONCE);
|
smp_set_state(SMP_STATE_WAIT_NONCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1679,6 +1685,8 @@ void smp_process_local_nonce(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
|||||||
case SMP_MODEL_SEC_CONN_OOB:
|
case SMP_MODEL_SEC_CONN_OOB:
|
||||||
if (p_cb->role == HCI_ROLE_MASTER) {
|
if (p_cb->role == HCI_ROLE_MASTER) {
|
||||||
smp_send_rand(p_cb, NULL);
|
smp_send_rand(p_cb, NULL);
|
||||||
|
/* Ensure the connection is still active */
|
||||||
|
if (smp_get_state() == SMP_STATE_IDLE) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
smp_set_state(SMP_STATE_WAIT_NONCE);
|
smp_set_state(SMP_STATE_WAIT_NONCE);
|
||||||
@ -2002,7 +2010,7 @@ void smp_link_encrypted(BD_ADDR bda, UINT8 encr_enable)
|
|||||||
SMP_TRACE_DEBUG("%s encr_enable=%d\n", __func__, encr_enable);
|
SMP_TRACE_DEBUG("%s encr_enable=%d\n", __func__, encr_enable);
|
||||||
|
|
||||||
if (memcmp(&smp_cb.pairing_bda[0], bda, BD_ADDR_LEN) == 0) {
|
if (memcmp(&smp_cb.pairing_bda[0], bda, BD_ADDR_LEN) == 0) {
|
||||||
/* encryption completed with STK, remmeber the key size now, could be overwite
|
/* encryption completed with STK, remember the key size now, could be overwrite
|
||||||
* when key exchange happens */
|
* when key exchange happens */
|
||||||
if (p_cb->loc_enc_size != 0 && encr_enable) {
|
if (p_cb->loc_enc_size != 0 && encr_enable) {
|
||||||
/* update the link encryption key size if a SMP pairing just performed */
|
/* update the link encryption key size if a SMP pairing just performed */
|
||||||
|
Reference in New Issue
Block a user