gap: new gap_set_scan_params allows to specify scanning filter policy

This commit is contained in:
Matthias Ringwald 2020-08-14 17:06:11 +02:00
parent d32b3f05f5
commit 5a1ca52e61
3 changed files with 16 additions and 3 deletions

View File

@ -286,6 +286,16 @@ int gap_mitm_protection_required_for_security_level(gap_security_level_t level)
/** /**
* @brief Set parameters for LE Scan * @brief Set parameters for LE Scan
* @param scan_type 0 = passive, 1 = active
* @param scan_interval range 0x0004..0x4000, unit 0.625 ms
* @param scan_window range 0x0004..0x4000, unit 0.625 ms
* @param scanning_filter_policy 0 = all devices, 1 = all from whitelist
*/
void gap_set_scan_params(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, uint8_t scanning_filter_policy);
/**
* @brief Set parameters for LE Scan
* @deprecated Use gap_set_scan_params instead
*/ */
void gap_set_scan_parameters(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window); void gap_set_scan_parameters(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window);

View File

@ -2967,6 +2967,7 @@ static void hci_state_reset(void){
#ifdef ENABLE_LE_CENTRAL #ifdef ENABLE_LE_CENTRAL
hci_stack->le_scanning_active = 0; hci_stack->le_scanning_active = 0;
hci_stack->le_scan_type = 0xff; hci_stack->le_scan_type = 0xff;
hci_stack->le_scan_filter_policy = 0;
hci_stack->le_connecting_state = LE_CONNECTING_IDLE; hci_stack->le_connecting_state = LE_CONNECTING_IDLE;
hci_stack->le_connecting_request = LE_CONNECTING_IDLE; hci_stack->le_connecting_request = LE_CONNECTING_IDLE;
hci_stack->le_whitelist = 0; hci_stack->le_whitelist = 0;
@ -3623,7 +3624,8 @@ static bool hci_run_general_gap_le(void){
} else { } else {
int scan_type = (int) hci_stack->le_scan_type; int scan_type = (int) hci_stack->le_scan_type;
hci_stack->le_scan_type = 0xff; hci_stack->le_scan_type = 0xff;
hci_send_cmd(&hci_le_set_scan_parameters, scan_type, hci_stack->le_scan_interval, hci_stack->le_scan_window, hci_stack->le_own_addr_type, 0); hci_send_cmd(&hci_le_set_scan_parameters, scan_type, hci_stack->le_scan_interval, hci_stack->le_scan_window,
hci_stack->le_own_addr_type, hci_stack->le_scan_filter_policy);
} }
return true; return true;
} }

View File

@ -896,6 +896,7 @@ typedef struct {
// buffer for le scan type command - 0xff not set // buffer for le scan type command - 0xff not set
uint8_t le_scan_type; uint8_t le_scan_type;
uint8_t le_scan_filter_policy;
uint16_t le_scan_interval; uint16_t le_scan_interval;
uint16_t le_scan_window; uint16_t le_scan_window;