- fix data length update failed

- fix no callback when the value being used is the same as the value to be set
pull/7307/head
zwj 2021-06-11 16:29:52 +08:00
rodzic 2ee9140e94
commit d8474a92bf
5 zmienionych plików z 54 dodań i 7 usunięć

Wyświetl plik

@ -5354,19 +5354,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)
{
UINT8 status = BTM_SUCCESS;
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) {
APPL_TRACE_ERROR("%s error: Invalid connection remote_bda.", __func__);
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 {
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);
}
UINT8 status = BTM_SetBleDataLength(p_data->ble_set_data_length.remote_bda,
return;
}
status = BTM_SetBleDataLength(p_data->ble_set_data_length.remote_bda,
p_data->ble_set_data_length.tx_data_length);
}
if (status != BTM_SUCCESS) {
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){
uint16_t length = controller_get_interface()->get_acl_data_size_ble();
p_acl_cb->data_length_params.rx_len = length;

Wyświetl plik

@ -954,6 +954,7 @@ 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);
}
l2cble_notify_le_connection (p_acl_cb->remote_addr);

Wyświetl plik

@ -4199,6 +4199,7 @@ void btm_ble_read_remote_features_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);
}
l2cble_notify_le_connection (p_acl_cb->remote_addr);

Wyświetl plik

@ -158,6 +158,11 @@ UINT8 active_remote_addr_type; /* local device address type fo
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_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
tBTM_PM_MCB *p_pm_mode_db; /* Pointer to PM mode control block per ACL link */

Wyświetl plik

@ -1217,13 +1217,33 @@ void l2cble_process_data_length_change_event(UINT16 handle, UINT16 tx_data_len,
}
tACL_CONN *p_acl = btm_handle_to_acl(handle);
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;
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){
(*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);
}
}
}
/*******************************************************************************