From 4d5261379594861b8c224786aef8a8ac65405736 Mon Sep 17 00:00:00 2001 From: xiewenxiang Date: Wed, 8 Sep 2021 19:37:25 +0800 Subject: [PATCH] component/bt: fix data length update failed --- .../bt/host/bluedroid/bta/dm/bta_dm_act.c | 18 ++++++++++-------- .../bt/host/bluedroid/stack/btm/btm_acl.c | 6 ++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c index da29114cef..125d5eb699 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -5287,6 +5287,16 @@ void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data) APPL_TRACE_ERROR("%s error: Invalid connection remote_bda.", __func__); return; } + + p_acl_cb->p_set_pkt_data_cback = p_data->ble_set_data_length.p_set_pkt_data_cback; + // if the value of the data length is same, triger callback directly + if(p_data->ble_set_data_length.tx_data_length == p_acl_cb->data_length_params.tx_len) { + if(p_data->ble_set_data_length.p_set_pkt_data_cback) { + (*p_data->ble_set_data_length.p_set_pkt_data_cback)(status, &p_acl_cb->data_length_params); + } + return; + } + if(p_acl_cb->data_len_updating) { // aleady have one cmd if(p_acl_cb->data_len_waiting) { @@ -5299,14 +5309,6 @@ void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data) return; } } else { - p_acl_cb->p_set_pkt_data_cback = p_data->ble_set_data_length.p_set_pkt_data_cback; - // if the value of the data length is same, triger callback directly - if(p_data->ble_set_data_length.tx_data_length == p_acl_cb->data_length_params.tx_len) { - if(p_data->ble_set_data_length.p_set_pkt_data_cback) { - (*p_data->ble_set_data_length.p_set_pkt_data_cback)(status, &p_acl_cb->data_length_params); - } - return; - } status = BTM_SetBleDataLength(p_data->ble_set_data_length.remote_bda, p_data->ble_set_data_length.tx_data_length); } diff --git a/components/bt/host/bluedroid/stack/btm/btm_acl.c b/components/bt/host/bluedroid/stack/btm/btm_acl.c index 05ace76f5f..7be59dc62e 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/host/bluedroid/stack/btm/btm_acl.c @@ -936,8 +936,10 @@ void btm_read_remote_version_complete (UINT8 *p) if (HCI_LE_DATA_LEN_EXT_SUPPORTED(p_acl_cb->peer_le_features)) { uint16_t data_length = controller_get_interface()->get_ble_default_data_packet_length(); uint16_t data_txtime = controller_get_interface()->get_ble_default_data_packet_txtime(); - p_acl_cb->data_len_updating = true; - btsnd_hcic_ble_set_data_length(p_acl_cb->hci_handle, data_length, data_txtime); + if (data_length != p_acl_cb->data_length_params.tx_len) { + p_acl_cb->data_len_updating = true; + btsnd_hcic_ble_set_data_length(p_acl_cb->hci_handle, data_length, data_txtime); + } } l2cble_notify_le_connection (p_acl_cb->remote_addr); } else {