From e90f848d38bf2709345848319b77042d6031fad6 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 1 Apr 2022 16:59:47 +0200 Subject: [PATCH] hci: use hci_le_extended_create_connection if supported for non-whitelist connections --- src/hci.c | 57 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/src/hci.c b/src/hci.c index 40b4077e8..f2b79f694 100644 --- a/src/hci.c +++ b/src/hci.c @@ -5653,20 +5653,49 @@ static bool hci_run_general_pending_commands(void){ log_info("sending hci_le_create_connection"); hci_stack->le_connection_own_addr_type = hci_stack->le_own_addr_type; hci_get_own_address_for_addr_type(hci_stack->le_connection_own_addr_type, hci_stack->le_connection_own_address); - hci_send_cmd(&hci_le_create_connection, - hci_stack->le_connection_scan_interval, // conn scan interval - hci_stack->le_connection_scan_window, // conn scan windows - 0, // don't use whitelist - connection->address_type, // peer address type - connection->address, // peer bd addr - hci_stack->le_connection_own_addr_type, // our addr type: - hci_stack->le_connection_interval_min, // conn interval min - hci_stack->le_connection_interval_max, // conn interval max - hci_stack->le_connection_latency, // conn latency - hci_stack->le_supervision_timeout, // conn latency - hci_stack->le_minimum_ce_length, // min ce length - hci_stack->le_maximum_ce_length // max ce length - ); +#ifdef ENABLE_LE_EXTENDED_ADVERTISING + if (hci_extended_advertising_supported()) { + uint16_t le_connection_scan_interval[1] = { hci_stack->le_connection_scan_interval }; + uint16_t le_connection_scan_window[1] = { hci_stack->le_connection_scan_window }; + uint16_t le_connection_interval_min[1] = { hci_stack->le_connection_interval_min }; + uint16_t le_connection_interval_max[1] = { hci_stack->le_connection_interval_max }; + uint16_t le_connection_latency[1] = { hci_stack->le_connection_latency }; + uint16_t le_supervision_timeout[1] = { hci_stack->le_supervision_timeout }; + uint16_t le_minimum_ce_length[1] = { hci_stack->le_minimum_ce_length }; + uint16_t le_maximum_ce_length[1] = { hci_stack->le_maximum_ce_length }; + hci_send_cmd(&hci_le_extended_create_connection, + 0, // don't use whitelist + hci_stack->le_connection_own_addr_type, // our addr type: + connection->address_type, // peer address type + connection->address, // peer bd addr + 1, // initiating PHY - 1M + le_connection_scan_interval, // conn scan interval + le_connection_scan_window, // conn scan windows + le_connection_interval_min, // conn interval min + le_connection_interval_max, // conn interval max + le_connection_latency, // conn latency + le_supervision_timeout, // conn latency + le_minimum_ce_length, // min ce length + le_maximum_ce_length // max ce length + ); } + else +#endif + { + hci_send_cmd(&hci_le_create_connection, + hci_stack->le_connection_scan_interval, // conn scan interval + hci_stack->le_connection_scan_window, // conn scan windows + 0, // don't use whitelist + connection->address_type, // peer address type + connection->address, // peer bd addr + hci_stack->le_connection_own_addr_type, // our addr type: + hci_stack->le_connection_interval_min, // conn interval min + hci_stack->le_connection_interval_max, // conn interval max + hci_stack->le_connection_latency, // conn latency + hci_stack->le_supervision_timeout, // conn latency + hci_stack->le_minimum_ce_length, // min ce length + hci_stack->le_maximum_ce_length // max ce length + ); + } connection->state = SENT_CREATE_CONNECTION; #endif #endif