mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-28 06:39:49 +00:00
gap: provide LE Whitelist API via gap_whitelist_add/remove/clear
This commit is contained in:
parent
95e257d9ea
commit
a3b69fde2a
25
src/gap.h
25
src/gap.h
@ -442,6 +442,28 @@ int gap_connection_parameter_range_included(le_connection_parameter_range_t * ex
|
|||||||
*/
|
*/
|
||||||
void gap_set_max_number_peripheral_connections(int max_peripheral_connections);
|
void gap_set_max_number_peripheral_connections(int max_peripheral_connections);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add Device to Whitelist
|
||||||
|
* @param address_typ
|
||||||
|
* @param address
|
||||||
|
* @returns 0 if ok
|
||||||
|
*/
|
||||||
|
uint8_t gap_whitelist_add(bd_addr_type_t address_type, bd_addr_t address);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Remove Device from Whitelist
|
||||||
|
* @param address_typ
|
||||||
|
* @param address
|
||||||
|
* @returns 0 if ok
|
||||||
|
*/
|
||||||
|
uint8_t gap_whitelist_remove(bd_addr_type_t address_type, bd_addr_t address);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clear Whitelist
|
||||||
|
* @returns 0 if ok
|
||||||
|
*/
|
||||||
|
uint8_t gap_whitelist_clear(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Connect to remote LE device
|
* @brief Connect to remote LE device
|
||||||
*/
|
*/
|
||||||
@ -461,6 +483,7 @@ uint8_t gap_connect_cancel(void);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Auto Connection Establishment - Start Connecting to device
|
* @brief Auto Connection Establishment - Start Connecting to device
|
||||||
|
* @deprecated Please setup Whitelist with gap_whitelist_* and start connecting with gap_connect_with_whitelist
|
||||||
* @param address_typ
|
* @param address_typ
|
||||||
* @param address
|
* @param address
|
||||||
* @returns 0 if ok
|
* @returns 0 if ok
|
||||||
@ -469,6 +492,7 @@ uint8_t gap_auto_connection_start(bd_addr_type_t address_typ, bd_addr_t address)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Auto Connection Establishment - Stop Connecting to device
|
* @brief Auto Connection Establishment - Stop Connecting to device
|
||||||
|
* @deprecated Please setup Whitelist with gap_whitelist_* and start connecting with gap_connect_with_whitelist
|
||||||
* @param address_typ
|
* @param address_typ
|
||||||
* @param address
|
* @param address
|
||||||
* @returns 0 if ok
|
* @returns 0 if ok
|
||||||
@ -477,6 +501,7 @@ uint8_t gap_auto_connection_stop(bd_addr_type_t address_typ, bd_addr_t address);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Auto Connection Establishment - Stop everything
|
* @brief Auto Connection Establishment - Stop everything
|
||||||
|
* @deprecated Please setup Whitelist with gap_whitelist_* and start connecting with gap_connect_with_whitelist
|
||||||
* @note Convenience function to stop all active auto connection attempts
|
* @note Convenience function to stop all active auto connection attempts
|
||||||
*/
|
*/
|
||||||
uint8_t gap_auto_connection_stop_all(void);
|
uint8_t gap_auto_connection_stop_all(void);
|
||||||
|
54
src/hci.c
54
src/hci.c
@ -165,7 +165,7 @@ static int hci_have_usb_transport(void);
|
|||||||
#ifdef ENABLE_LE_CENTRAL
|
#ifdef ENABLE_LE_CENTRAL
|
||||||
// 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 void hci_whitelist_remove(bd_addr_type_t address_type, bd_addr_t address);
|
static uint8_t hci_whitelist_remove(bd_addr_type_t address_type, bd_addr_t address);
|
||||||
static hci_connection_t * gap_get_outgoing_connection(void);
|
static hci_connection_t * gap_get_outgoing_connection(void);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@ -5288,7 +5288,7 @@ static uint8_t hci_whitelist_add(bd_addr_type_t address_type, bd_addr_t address)
|
|||||||
return ERROR_CODE_SUCCESS;
|
return ERROR_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hci_whitelist_remove(bd_addr_type_t address_type, bd_addr_t address){
|
static uint8_t hci_whitelist_remove(bd_addr_type_t address_type, bd_addr_t address){
|
||||||
btstack_linked_list_iterator_t it;
|
btstack_linked_list_iterator_t it;
|
||||||
btstack_linked_list_iterator_init(&it, &hci_stack->le_whitelist);
|
btstack_linked_list_iterator_init(&it, &hci_stack->le_whitelist);
|
||||||
while (btstack_linked_list_iterator_has_next(&it)){
|
while (btstack_linked_list_iterator_has_next(&it)){
|
||||||
@ -5298,12 +5298,14 @@ static void hci_whitelist_remove(bd_addr_type_t address_type, bd_addr_t address)
|
|||||||
if (entry->state & LE_WHITELIST_ON_CONTROLLER){
|
if (entry->state & LE_WHITELIST_ON_CONTROLLER){
|
||||||
// remove from controller if already present
|
// remove from controller if already present
|
||||||
entry->state |= LE_WHITELIST_REMOVE_FROM_CONTROLLER;
|
entry->state |= LE_WHITELIST_REMOVE_FROM_CONTROLLER;
|
||||||
continue;
|
} else {
|
||||||
|
// directly remove entry from whitelist
|
||||||
|
btstack_linked_list_iterator_remove(&it);
|
||||||
|
btstack_memory_whitelist_entry_free(entry);
|
||||||
}
|
}
|
||||||
// directly remove entry from whitelist
|
return ERROR_CODE_SUCCESS;
|
||||||
btstack_linked_list_iterator_remove(&it);
|
|
||||||
btstack_memory_whitelist_entry_free(entry);
|
|
||||||
}
|
}
|
||||||
|
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hci_whitelist_clear(void){
|
static void hci_whitelist_clear(void){
|
||||||
@ -5322,6 +5324,46 @@ static void hci_whitelist_clear(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clear Whitelist
|
||||||
|
* @returns 0 if ok
|
||||||
|
*/
|
||||||
|
uint8_t gap_whitelist_clear(void){
|
||||||
|
hci_whitelist_clear();
|
||||||
|
hci_run();
|
||||||
|
return ERROR_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add Device to Whitelist
|
||||||
|
* @param address_typ
|
||||||
|
* @param address
|
||||||
|
* @returns 0 if ok
|
||||||
|
*/
|
||||||
|
uint8_t gap_whitelist_add(bd_addr_type_t address_type, bd_addr_t address){
|
||||||
|
uint8_t status = hci_whitelist_add(address_type, address);
|
||||||
|
if (status){
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
hci_run();
|
||||||
|
return ERROR_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Remove Device from Whitelist
|
||||||
|
* @param address_typ
|
||||||
|
* @param address
|
||||||
|
* @returns 0 if ok
|
||||||
|
*/
|
||||||
|
uint8_t gap_whitelist_remove(bd_addr_type_t address_type, bd_addr_t address){
|
||||||
|
uint8_t status = hci_whitelist_remove(address_type, address);
|
||||||
|
if (status){
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
hci_run();
|
||||||
|
return ERROR_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_LE_CENTRAL
|
#ifdef ENABLE_LE_CENTRAL
|
||||||
/**
|
/**
|
||||||
* @brief Connect with Whitelist
|
* @brief Connect with Whitelist
|
||||||
|
Loading…
x
Reference in New Issue
Block a user