hci: extract hci_whitelist_free

This commit is contained in:
Matthias Ringwald 2021-11-04 11:46:15 +01:00
parent d420eb705d
commit 83dc1a9863

View File

@ -173,6 +173,7 @@ static void hci_trigger_remote_features_for_connection(hci_connection_t * connec
// called from test/ble_client/advertising_data_parser.c // called from test/ble_client/advertising_data_parser.c
void le_handle_advertisement_report(uint8_t *packet, uint16_t size); void le_handle_advertisement_report(uint8_t *packet, uint16_t size);
static uint8_t hci_whitelist_remove(bd_addr_type_t address_type, const bd_addr_t address); static uint8_t hci_whitelist_remove(bd_addr_type_t address_type, const bd_addr_t address);
static void hci_whitelist_free(void);
static hci_connection_t * gap_get_outgoing_connection(void); static hci_connection_t * gap_get_outgoing_connection(void);
#endif #endif
#endif #endif
@ -5006,16 +5007,7 @@ static void hci_run(void){
#ifdef ENABLE_BLE #ifdef ENABLE_BLE
#ifdef ENABLE_LE_CENTRAL #ifdef ENABLE_LE_CENTRAL
// free whitelist entries hci_whitelist_free();
{
btstack_linked_list_iterator_t lit;
btstack_linked_list_iterator_init(&lit, &hci_stack->le_whitelist);
while (btstack_linked_list_iterator_has_next(&lit)){
whitelist_entry_t * entry = (whitelist_entry_t*) btstack_linked_list_iterator_next(&lit);
btstack_linked_list_remove(&hci_stack->le_whitelist, (btstack_linked_item_t *) entry);
btstack_memory_whitelist_entry_free(entry);
}
}
#endif #endif
#endif #endif
// close all open connections // close all open connections
@ -6242,6 +6234,17 @@ static void hci_whitelist_clear(void){
} }
} }
// free all entries unconditionally
static void hci_whitelist_free(void){
btstack_linked_list_iterator_t lit;
btstack_linked_list_iterator_init(&lit, &hci_stack->le_whitelist);
while (btstack_linked_list_iterator_has_next(&lit)){
whitelist_entry_t * entry = (whitelist_entry_t*) btstack_linked_list_iterator_next(&lit);
btstack_linked_list_remove(&hci_stack->le_whitelist, (btstack_linked_item_t *) entry);
btstack_memory_whitelist_entry_free(entry);
}
}
/** /**
* @brief Clear Whitelist * @brief Clear Whitelist
* @return 0 if ok * @return 0 if ok