mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-23 11:43:24 +00:00
hci: postpone hci remote features query until requested by l2cap
This commit is contained in:
parent
903b29f987
commit
d6596031ae
14
src/hci.c
14
src/hci.c
@ -2710,9 +2710,6 @@ static void event_handler(uint8_t *packet, uint16_t size){
|
||||
conn->state = OPEN;
|
||||
conn->con_handle = little_endian_read_16(packet, 3);
|
||||
|
||||
// queue get remote feature
|
||||
conn->bonding_flags |= BONDING_REQUEST_REMOTE_FEATURES_PAGE_0;
|
||||
|
||||
// queue set supervision timeout if we're master
|
||||
if ((hci_stack->link_supervision_timeout != HCI_LINK_SUPERVISION_TIMEOUT_DEFAULT) && (conn->role == HCI_ROLE_MASTER)){
|
||||
connectionSetAuthenticationFlags(conn, AUTH_FLAG_WRITE_SUPERVISION_TIMEOUT);
|
||||
@ -5602,6 +5599,17 @@ bool hci_remote_features_available(hci_con_handle_t handle){
|
||||
return (connection->bonding_flags & BONDING_RECEIVED_REMOTE_FEATURES) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger remote supported features query
|
||||
*/
|
||||
void hci_remote_features_query(hci_con_handle_t con_handle){
|
||||
hci_connection_t * connection = hci_connection_for_handle(con_handle);
|
||||
if (!connection) return;
|
||||
if ((connection->bonding_flags & BONDING_RECEIVED_REMOTE_FEATURES) != 0) return;
|
||||
connection->bonding_flags |= BONDING_REQUEST_REMOTE_FEATURES_PAGE_0;
|
||||
hci_run();
|
||||
}
|
||||
|
||||
// GAP API
|
||||
/**
|
||||
* @bbrief enable/disable bonding. default is enabled
|
||||
|
@ -1335,6 +1335,12 @@ bool hci_non_flushable_packet_boundary_flag_supported(void);
|
||||
* Check if remote supported features query has completed
|
||||
*/
|
||||
bool hci_remote_features_available(hci_con_handle_t con_handle);
|
||||
|
||||
/**
|
||||
* Trigger remote supported features query
|
||||
*/
|
||||
void hci_remote_features_query(hci_con_handle_t con_handle);
|
||||
|
||||
/**
|
||||
* Check if extended SCO Link is supported
|
||||
*/
|
||||
|
12
src/l2cap.c
12
src/l2cap.c
@ -637,7 +637,9 @@ uint8_t l2cap_create_ertm_channel(btstack_packet_handler_t packet_handler, bd_ad
|
||||
// check if remote supported fearures are already received
|
||||
if (hci_remote_features_available(conn->con_handle)) {
|
||||
l2cap_handle_remote_supported_features_received(channel);
|
||||
}
|
||||
} else {
|
||||
hci_remote_features_query(conn->con_handle);
|
||||
};
|
||||
}
|
||||
|
||||
l2cap_run();
|
||||
@ -1938,8 +1940,9 @@ static void l2cap_handle_connection_complete(hci_con_handle_t con_handle, l2cap_
|
||||
log_info("connection complete con_handle %04x - for channel %p cid 0x%04x", (int) con_handle, channel, channel->local_cid);
|
||||
// success, start l2cap handshake
|
||||
channel->con_handle = con_handle;
|
||||
// check remote SSP feature first
|
||||
// we require remote features to check SSP
|
||||
channel->state = L2CAP_STATE_WAIT_REMOTE_SUPPORTED_FEATURES;
|
||||
hci_remote_features_query(con_handle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2117,6 +2120,8 @@ uint8_t l2cap_create_channel(btstack_packet_handler_t channel_packet_handler, bd
|
||||
if (hci_remote_features_available(conn->con_handle)) {
|
||||
// simulate remote features received
|
||||
l2cap_handle_remote_supported_features_received(channel);
|
||||
} else {
|
||||
hci_remote_features_query(conn->con_handle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2664,10 +2669,11 @@ static void l2cap_handle_connection_request(hci_con_handle_t handle, uint8_t sig
|
||||
btstack_linked_list_add_tail(&l2cap_channels, (btstack_linked_item_t *) channel);
|
||||
|
||||
// send conn resp pending if remote supported features have not been received yet
|
||||
if (hci_remote_features_available(hci_connection->con_handle)) {
|
||||
if (hci_remote_features_available(handle)) {
|
||||
l2cap_handle_remote_supported_features_received(channel);
|
||||
} else {
|
||||
channel->state_var |= L2CAP_CHANNEL_STATE_VAR_SEND_CONN_RESP_PEND;
|
||||
hci_remote_features_query(handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user