hci: extract hci_send_le_create_connection

This commit is contained in:
Matthias Ringwald 2022-11-23 17:46:25 +01:00
parent 327c57e11a
commit 327f7f07c0

View File

@ -5584,6 +5584,53 @@ static void hci_le_scan_stop(void){
hci_send_cmd(&hci_le_set_scan_enable, 0, 0);
}
}
static void hci_send_le_create_connection(const hci_connection_t *connection) {
#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
);
}
}
#endif
#ifdef ENABLE_LE_PERIPHERAL
@ -6632,49 +6679,7 @@ 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);
#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
);
}
hci_send_le_create_connection(connection);
connection->state = SENT_CREATE_CONNECTION;
#endif
#endif