diff --git a/CHANGELOG.md b/CHANGELOG.md index c8538f088..f528cdff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Changes March 2020 +### Fixed +- GAP: fixed gap_set_scan_parameters() if issued right before gap_start_scan() + ### Added GATT Client: allow to register for any notification/indication and/or any connection hci_cmd: added hci_read_inquiry_scan_activity and hci_write_inquiry_scan_activity diff --git a/src/hci.c b/src/hci.c index eeba80161..5cbde15ad 100644 --- a/src/hci.c +++ b/src/hci.c @@ -3413,17 +3413,22 @@ static void hci_run(void){ && ((hci_stack->le_own_addr_type == BD_ADDR_TYPE_LE_PUBLIC) || hci_stack->le_random_address_set)){ #ifdef ENABLE_LE_CENTRAL - // handle le scan - if ((hci_stack->le_scanning_enabled != hci_stack->le_scanning_active)){ - hci_stack->le_scanning_active = hci_stack->le_scanning_enabled; - hci_send_cmd(&hci_le_set_scan_enable, hci_stack->le_scanning_enabled, 0); + // parameter change requires scanning to be stopped first + if (hci_stack->le_scan_type != 0xff) { + if (hci_stack->le_scanning_active){ + hci_stack->le_scanning_active = 0; + hci_send_cmd(&hci_le_set_scan_enable, 0, 0); + } else { + int scan_type = (int) hci_stack->le_scan_type; + 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); + } return; } - if (hci_stack->le_scan_type != 0xff){ - // defaults: active scanning, accept all advertisement packets - int scan_type = hci_stack->le_scan_type; - 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); + // finally, we can enable/disable le scan + if ((hci_stack->le_scanning_enabled && !hci_stack->le_scanning_active)){ + hci_stack->le_scanning_active = hci_stack->le_scanning_enabled; + hci_send_cmd(&hci_le_set_scan_enable, hci_stack->le_scanning_enabled, 0); return; } #endif