mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
- fix data length update failed
- fix no callback when the value being used is the same as the value to be set
This commit is contained in:
parent
9d82fc4447
commit
c6897a43ce
@ -5338,19 +5338,39 @@ void bta_dm_ble_set_scan_rsp_raw (tBTA_DM_MSG *p_data)
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data)
|
void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data)
|
||||||
{
|
{
|
||||||
|
UINT8 status = BTM_SUCCESS;
|
||||||
tACL_CONN *p_acl_cb = btm_bda_to_acl(p_data->ble_set_data_length.remote_bda, BT_TRANSPORT_LE);
|
tACL_CONN *p_acl_cb = btm_bda_to_acl(p_data->ble_set_data_length.remote_bda, BT_TRANSPORT_LE);
|
||||||
if (p_acl_cb == NULL) {
|
if (p_acl_cb == NULL) {
|
||||||
APPL_TRACE_ERROR("%s error: Invalid connection remote_bda.", __func__);
|
APPL_TRACE_ERROR("%s error: Invalid connection remote_bda.", __func__);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
if(p_acl_cb->data_len_updating) {
|
||||||
|
// aleady have one cmd
|
||||||
|
if(p_acl_cb->data_len_waiting) {
|
||||||
|
status = BTM_ILLEGAL_ACTION;
|
||||||
|
} else {
|
||||||
|
// save the command
|
||||||
|
p_acl_cb->p_set_data_len_cback_waiting = p_data->ble_set_data_length.p_set_pkt_data_cback;
|
||||||
|
p_acl_cb->tx_len_waiting = p_data->ble_set_data_length.tx_data_length;
|
||||||
|
p_acl_cb->data_len_waiting = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
p_acl_cb->p_set_pkt_data_cback = p_data->ble_set_data_length.p_set_pkt_data_cback;
|
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
|
||||||
UINT8 status = BTM_SetBleDataLength(p_data->ble_set_data_length.remote_bda,
|
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);
|
p_data->ble_set_data_length.tx_data_length);
|
||||||
|
}
|
||||||
if (status != BTM_SUCCESS) {
|
if (status != BTM_SUCCESS) {
|
||||||
APPL_TRACE_ERROR("%s failed\n", __FUNCTION__);
|
APPL_TRACE_ERROR("%s failed\n", __FUNCTION__);
|
||||||
}
|
}
|
||||||
if (p_data->ble_set_data_length.p_set_pkt_data_cback) {
|
if (p_data->ble_set_data_length.p_set_pkt_data_cback && status != BTM_SUCCESS) {
|
||||||
if (p_acl_cb->data_length_params.tx_len == 0){
|
if (p_acl_cb->data_length_params.tx_len == 0){
|
||||||
uint16_t length = controller_get_interface()->get_acl_data_size_ble();
|
uint16_t length = controller_get_interface()->get_acl_data_size_ble();
|
||||||
p_acl_cb->data_length_params.rx_len = length;
|
p_acl_cb->data_length_params.rx_len = length;
|
||||||
|
@ -936,6 +936,7 @@ void btm_read_remote_version_complete (UINT8 *p)
|
|||||||
if (HCI_LE_DATA_LEN_EXT_SUPPORTED(p_acl_cb->peer_le_features)) {
|
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_length = controller_get_interface()->get_ble_default_data_packet_length();
|
||||||
uint16_t data_txtime = controller_get_interface()->get_ble_default_data_packet_txtime();
|
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);
|
btsnd_hcic_ble_set_data_length(p_acl_cb->hci_handle, data_length, data_txtime);
|
||||||
}
|
}
|
||||||
l2cble_notify_le_connection (p_acl_cb->remote_addr);
|
l2cble_notify_le_connection (p_acl_cb->remote_addr);
|
||||||
|
@ -4139,6 +4139,7 @@ void btm_ble_read_remote_features_complete(UINT8 *p)
|
|||||||
if (HCI_LE_DATA_LEN_EXT_SUPPORTED(p_acl_cb->peer_le_features)) {
|
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_length = controller_get_interface()->get_ble_default_data_packet_length();
|
||||||
uint16_t data_txtime = controller_get_interface()->get_ble_default_data_packet_txtime();
|
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);
|
btsnd_hcic_ble_set_data_length(p_acl_cb->hci_handle, data_length, data_txtime);
|
||||||
}
|
}
|
||||||
l2cble_notify_le_connection (p_acl_cb->remote_addr);
|
l2cble_notify_le_connection (p_acl_cb->remote_addr);
|
||||||
|
@ -126,6 +126,11 @@ UINT8 active_remote_addr_type; /* local device address type fo
|
|||||||
BD_FEATURES peer_le_features; /* Peer LE Used features mask for the device */
|
BD_FEATURES peer_le_features; /* Peer LE Used features mask for the device */
|
||||||
tBTM_SET_PKT_DATA_LENGTH_CBACK *p_set_pkt_data_cback;
|
tBTM_SET_PKT_DATA_LENGTH_CBACK *p_set_pkt_data_cback;
|
||||||
tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS data_length_params;
|
tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS data_length_params;
|
||||||
|
BOOLEAN data_len_updating;
|
||||||
|
// data len update cmd cache
|
||||||
|
BOOLEAN data_len_waiting;
|
||||||
|
tBTM_SET_PKT_DATA_LENGTH_CBACK *p_set_data_len_cback_waiting;
|
||||||
|
UINT16 tx_len_waiting;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} tACL_CONN;
|
} tACL_CONN;
|
||||||
|
@ -1124,13 +1124,33 @@ void l2cble_process_data_length_change_event(UINT16 handle, UINT16 tx_data_len,
|
|||||||
}
|
}
|
||||||
|
|
||||||
tACL_CONN *p_acl = btm_handle_to_acl(handle);
|
tACL_CONN *p_acl = btm_handle_to_acl(handle);
|
||||||
|
tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS data_length_params;
|
||||||
|
data_length_params.rx_len = rx_data_len;
|
||||||
|
data_length_params.tx_len = tx_data_len;
|
||||||
|
p_acl->data_length_params = data_length_params;
|
||||||
if (p_acl != NULL && p_acl->p_set_pkt_data_cback){
|
if (p_acl != NULL && p_acl->p_set_pkt_data_cback){
|
||||||
tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS data_length_params;
|
|
||||||
data_length_params.rx_len = tx_data_len;
|
|
||||||
data_length_params.tx_len = rx_data_len;
|
|
||||||
p_acl->data_length_params = data_length_params;
|
|
||||||
(*p_acl->p_set_pkt_data_cback)(BTM_SUCCESS, &data_length_params);
|
(*p_acl->p_set_pkt_data_cback)(BTM_SUCCESS, &data_length_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(p_acl) {
|
||||||
|
p_acl->data_len_updating = false;
|
||||||
|
if(p_acl->data_len_waiting) {
|
||||||
|
p_acl->data_len_waiting = false;
|
||||||
|
p_acl->p_set_pkt_data_cback = p_acl->p_set_data_len_cback_waiting;
|
||||||
|
p_acl->p_set_data_len_cback_waiting = NULL;
|
||||||
|
// if value is same, triger callback directly
|
||||||
|
if(p_acl->tx_len_waiting == p_acl->data_length_params.tx_len) {
|
||||||
|
if(p_acl->p_set_pkt_data_cback) {
|
||||||
|
(*p_acl->p_set_pkt_data_cback)(BTM_SUCCESS, &p_acl->data_length_params);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p_acl->data_len_updating = true;
|
||||||
|
/* always set the TxTime to be max, as controller does not care for now */
|
||||||
|
btsnd_hcic_ble_set_data_length(handle, p_acl->tx_len_waiting,
|
||||||
|
BTM_BLE_DATA_TX_TIME_MAX);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user