Skip to content

Commit d02a89a

Browse files
committed
Don't call scan result callback if it was already called.
1 parent 726b405 commit d02a89a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/NimBLEScan.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ NimBLEScan::NimBLEScan() {
3434
m_scan_params.itvl = 0; // This is defined as the time interval from when the Controller started its last LE scan until it begins the subsequent LE scan. (units=0.625 msec)
3535
m_scan_params.window = 0; // The duration of the LE scan. LE_Scan_Window shall be less than or equal to LE_Scan_Interval (units=0.625 msec)
3636
m_scan_params.limited = 0; // If set, only discover devices in limited discoverable mode.
37-
m_scan_params.filter_duplicates = 0; // If set, the controller ignores all but the first advertisement from each device.
37+
m_scan_params.filter_duplicates = 1; // If set, the controller ignores all but the first advertisement from each device.
3838
m_pAdvertisedDeviceCallbacks = nullptr;
3939
m_ignoreResults = false;
4040
m_pTaskData = nullptr;
@@ -134,6 +134,10 @@ NimBLEScan::~NimBLEScan() {
134134
event_type == BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP));
135135

136136
if (pScan->m_pAdvertisedDeviceCallbacks) {
137+
if (pScan->m_scan_params.filter_duplicates && advertisedDevice->m_callbackSent) {
138+
return 0;
139+
}
140+
137141
// If not active scanning or scan response is not available
138142
// or extended advertisement scanning, report the result to the callback now.
139143
if(pScan->m_scan_params.passive || !isLegacyAdv ||

0 commit comments

Comments
 (0)