[BT] copy advertised device to avoid concurrent data access. (#1537)
Co-authored-by: h2zero <powellperalata@gmail.com>
This commit is contained in:
1 parent
17ce2debce
commit
33ea56bf12
1 file changed
+5
-1
+5
-1
@@ -563,8 +563,10 @@ static int taskCore = 0;
|
|||||||
|
|
||||||
class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
|
class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
|
||||||
void onResult(BLEAdvertisedDevice* advertisedDevice) {
|
void onResult(BLEAdvertisedDevice* advertisedDevice) {
|
||||||
if (xQueueSend(BLEQueue, &advertisedDevice, 0) != pdTRUE) {
|
BLEAdvertisedDevice* ad = new BLEAdvertisedDevice(*advertisedDevice);
|
||||||
|
if (xQueueSend(BLEQueue, &ad, 0) != pdTRUE) {
|
||||||
Log.error(F("BLEQueue full" CR));
|
Log.error(F("BLEQueue full" CR));
|
||||||
|
delete (ad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -597,6 +599,7 @@ void procBLETask(void* pvParameters) {
|
|||||||
|
|
||||||
if (BTConfig.filterConnectable && device->connect) {
|
if (BTConfig.filterConnectable && device->connect) {
|
||||||
Log.notice(F("Filtered connectable device" CR));
|
Log.notice(F("Filtered connectable device" CR));
|
||||||
|
delete (advertisedDevice);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -636,6 +639,7 @@ void procBLETask(void* pvParameters) {
|
|||||||
Log.trace(F("Filtered MAC device" CR));
|
Log.trace(F("Filtered MAC device" CR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete (advertisedDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user