Merge branch 'bugfix/btdm_send_data_length_req_after_read_feature_complete' into 'master'

component/bt: send data length request by host after read feature complete

See merge request !1639
This commit is contained in:
Jiang Jiang Jian 2017-12-19 20:18:50 +08:00
commit 04e1195f41
10 changed files with 38 additions and 11 deletions

View file

@ -66,6 +66,7 @@ static uint8_t ble_resolving_list_max_size;
static uint8_t ble_supported_states[BLE_SUPPORTED_STATES_SIZE];
static bt_device_features_t features_ble;
static uint16_t ble_suggested_default_data_length;
static uint16_t ble_suggested_default_data_txtime;
static bool readable;
static bool ble_supported;
@ -228,7 +229,8 @@ static void start_up(void)
response = AWAIT_COMMAND(packet_factory->make_ble_read_suggested_default_data_length());
packet_parser->parse_ble_read_suggested_default_data_length_response(
response,
&ble_suggested_default_data_length);
&ble_suggested_default_data_length,
&ble_suggested_default_data_txtime);
}
// Set the ble event mask next
@ -404,6 +406,13 @@ static uint16_t get_ble_suggested_default_data_length(void)
return ble_suggested_default_data_length;
}
static uint16_t get_ble_suggested_default_data_txtime(void)
{
assert(readable);
assert(ble_supported);
return ble_suggested_default_data_txtime;
}
static uint16_t get_acl_buffer_count_classic(void)
{
assert(readable);
@ -472,6 +481,7 @@ static const controller_t interface = {
get_acl_packet_size_classic,
get_acl_packet_size_ble,
get_ble_suggested_default_data_length,
get_ble_suggested_default_data_txtime,
get_acl_buffer_count_classic,
get_acl_buffer_count_ble,

View file

@ -69,6 +69,7 @@ typedef struct controller_t {
uint16_t (*get_acl_packet_size_ble)(void);
uint16_t (*get_ble_default_data_packet_length)(void);
uint16_t (*get_ble_default_data_packet_txtime)(void);
// Get the number of acl packets the controller can buffer.
uint16_t (*get_acl_buffer_count_classic)(void);

View file

@ -183,12 +183,13 @@ static void parse_ble_read_resolving_list_size_response(
static void parse_ble_read_suggested_default_data_length_response(
BT_HDR *response,
uint16_t *ble_default_packet_length_ptr)
uint16_t *ble_default_packet_length_ptr,
uint16_t *ble_default_packet_txtime_ptr)
{
uint8_t *stream = read_command_complete_header(response, HCI_BLE_READ_DEFAULT_DATA_LENGTH, 2 /* bytes after */);
STREAM_TO_UINT8(*ble_default_packet_length_ptr, stream);
STREAM_TO_UINT16(*ble_default_packet_length_ptr, stream);
STREAM_TO_UINT16(*ble_default_packet_txtime_ptr, stream);
buffer_allocator->free(response);
}

View file

@ -90,7 +90,8 @@ typedef struct {
void (*parse_ble_read_suggested_default_data_length_response)(
BT_HDR *response,
uint16_t *ble_default_packet_length_ptr
uint16_t *ble_default_packet_length_ptr,
uint16_t *ble_default_packet_txtime_ptr
);
} hci_packet_parser_t;

View file

@ -906,6 +906,11 @@ void btm_read_remote_version_complete (UINT8 *p)
}
#if BLE_INCLUDED == TRUE
if (p_acl_cb->transport == BT_TRANSPORT_LE) {
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();
btsnd_hcic_ble_set_data_length(p_acl_cb->hci_handle, data_length, data_txtime);
}
l2cble_notify_le_connection (p_acl_cb->remote_addr);
}
#endif

View file

@ -812,7 +812,7 @@ tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length)
}
if (!HCI_LE_DATA_LEN_EXT_SUPPORTED(p_acl->peer_le_features)) {
BTM_TRACE_DEBUG("%s failed, peer does not support request", __FUNCTION__);
BTM_TRACE_ERROR("%s failed, peer does not support request", __FUNCTION__);
return BTM_PEER_LE_DATA_LEN_UNSUPPORTED;
}

View file

@ -3472,9 +3472,13 @@ void btm_ble_read_remote_features_complete(UINT8 *p)
if (p_acl_cb->link_role == HCI_ROLE_MASTER){
btsnd_hcic_rmt_ver_req (p_acl_cb->hci_handle);
}
else{
if (p_acl_cb->transport == BT_TRANSPORT_LE) {
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();
btsnd_hcic_ble_set_data_length(p_acl_cb->hci_handle, data_length, data_txtime);
}
l2cble_notify_le_connection (p_acl_cb->remote_addr);
}
}

View file

@ -988,8 +988,10 @@ void gatt_process_mtu_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT16 len, UINT
p_tcb->payload_size = mtu;
}
}
l2cble_set_fixed_channel_tx_data_length(p_tcb->peer_bda, L2CAP_ATT_CID, p_tcb->payload_size);
/* host will set packet data length to 251 automatically if remote device support set packet data length,
so l2cble_set_fixed_channel_tx_data_length() is not necessary.
l2cble_set_fixed_channel_tx_data_length(p_tcb->peer_bda, L2CAP_ATT_CID, p_tcb->payload_size);
*/
gatt_end_operation(p_clcb, status, NULL);
}
/*******************************************************************************

View file

@ -949,7 +949,10 @@ static void gatts_process_mtu_req (tGATT_TCB *p_tcb, UINT16 len, UINT8 *p_data)
p_tcb->payload_size = mtu;
}
l2cble_set_fixed_channel_tx_data_length(p_tcb->peer_bda, L2CAP_ATT_CID, p_tcb->payload_size);
/* host will set packet data length to 251 automatically if remote device support set packet data length,
so l2cble_set_fixed_channel_tx_data_length() is not necessary.
l2cble_set_fixed_channel_tx_data_length(p_tcb->peer_bda, L2CAP_ATT_CID, p_tcb->payload_size);
*/
if ((p_buf = attp_build_sr_msg(p_tcb, GATT_RSP_MTU, (tGATT_SR_MSG *) &p_tcb->payload_size)) != NULL) {
attp_send_sr_msg (p_tcb, p_buf);

@ -1 +1 @@
Subproject commit 4b4ff28683982cee0b89e1e7a4480c2abfb00f0c
Subproject commit cfff26955edbf837c497ef9d1dc60fc1e5a1608e