Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set scan_duplicate in BLE scan params #4126

Merged
merged 2 commits into from Oct 1, 2020

Conversation

buxtronix
Copy link
Contributor

This value is uninitialised and as such can be a random (and invalid) value. It's needs to be set per the espressif documentation here:

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/bluetooth/esp_gap_ble.html#_CPPv4N21esp_ble_scan_params_t14scan_duplicateE

This PR sets it to DUPLICATE_DISABLE. Chosen as this is needed to ensure all scan data is populated in the scan callback, per this comment in the IDF:

https://github.com/espressif/esp-idf/blob/master/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c#L3591

"//if scan duplicate is enabled, the adv packet without scan response is allowed to report to higher layer"

We don't want it to report to the higher layer (ie BLEScan.cpp) unless it has the active scan response.

Seems to resolve #3770 #3677 and possibly others.

@chegewara
Copy link
Contributor

Strange, i never needed that to get duplicates in v1.0.4, but maybe in master it is set to true in idf.

@h2zero
Copy link
Contributor

h2zero commented Jul 2, 2020

From my testing in NimBLE this will you get a lot of spam packets (and callbacks) if disabled (0x0), better make sure wantDuplicates in BLEScan::setAdvertisedDeviceCallbacks is false.

Although it may work different in bluedroid, but I doubt it, the same command is sent to the controller.

You should consider adding a method to BLEScan in this PR to allow the app to control this.
Here is what I have in the NimBLE library:

void NimBLEScan::setDuplicateFilter(bool active) {
    m_scan_params.filter_duplicates = active;
} // setDuplicateFilter

@buxtronix
Copy link
Contributor Author

setAdvertisedDeviceCallbacks already contains a parameter wantDuplicates, which is whether to filter dupes in BLEScan.

@me-no-dev me-no-dev merged commit 4f48cac into espressif:master Oct 1, 2020
shymega pushed a commit to open-morphs/esp32_cpp_wrapper that referenced this pull request Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scanning for bluetooth-devices works only once
4 participants