mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2025-07-29 18:07:14 +02:00
Fix potential exception when scan is restarted.
If the scan is restarted in NimBLEScan::start, there is a chance that a result from the previous scan arrives and the device is deleted when the callback is called. This change ignores any results that come when the scan has stopped.
This commit is contained in:
@ -54,6 +54,11 @@ int NimBLEScan::handleGapEvent(ble_gap_event* event, void* arg) {
|
||||
(void)arg;
|
||||
NimBLEScan* pScan = NimBLEDevice::getScan();
|
||||
|
||||
if (!pScan->isScanning()) {
|
||||
NIMBLE_LOGI(LOG_TAG, "Scan stopped, ignoring event");
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (event->type) {
|
||||
case BLE_GAP_EVENT_EXT_DISC:
|
||||
case BLE_GAP_EVENT_DISC: {
|
||||
|
Reference in New Issue
Block a user