Skip to content

Commit e7d0ad2

Browse files
authored
Update BLEScan.cpp (espressif#5241)
Proposed fix to espressif#4627 as a remediation to PR espressif#3995 espressif#3995 introduced that a device detected on BLE would not be entered in vector if a callback has been defined. By doing so, it was not possible anymore to have a counter in a call back (AND device in vector) to limit the number of detected device in a single scan, which could crash ESP32 as a result.
1 parent 77f5044 commit e7d0ad2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libraries/BLE/src/BLEScan.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ void BLEScan::handleGAPEvent(
126126

127127
if (m_pAdvertisedDeviceCallbacks) { // if has callback, no need to record to vector
128128
m_pAdvertisedDeviceCallbacks->onResult(*advertisedDevice);
129-
} else if (!m_wantDuplicates && !found) { // if no callback and not want duplicate, and not already in vector, record it
129+
}
130+
if (!m_wantDuplicates && !found) { // if no callback and not want duplicate, and not already in vector, record it
130131
m_scanResults.m_vectorAdvertisedDevices.insert(std::pair<std::string, BLEAdvertisedDevice*>(advertisedAddress.toString(), advertisedDevice));
131132
shouldDelete = false;
132133
}

0 commit comments

Comments
 (0)