hci: extract hci_discard_connections

This commit is contained in:
Matthias Ringwald 2021-11-04 15:14:57 +01:00
parent 83dc1a9863
commit 1f9eb2cc91

View File

@ -3644,15 +3644,7 @@ void hci_set_control(const btstack_control_t *hardware_control){
hardware_control->init(hci_stack->config);
}
void hci_close(void){
#ifdef ENABLE_CLASSIC
// close remote device db
if (hci_stack->link_key_db) {
hci_stack->link_key_db->close();
}
#endif
static void hci_discard_connections(void){
btstack_linked_list_iterator_t lit;
btstack_linked_list_iterator_init(&lit, &hci_stack->connections);
while (btstack_linked_list_iterator_has_next(&lit)){
@ -3661,6 +3653,18 @@ void hci_close(void){
hci_emit_disconnection_complete(connection->con_handle, 0x16); // terminated by local host
hci_shutdown_connection(connection);
}
}
void hci_close(void){
#ifdef ENABLE_CLASSIC
// close remote device db
if (hci_stack->link_key_db) {
hci_stack->link_key_db->close();
}
#endif
hci_discard_connections();
hci_power_control(HCI_POWER_OFF);