Skip to content

Commit

Permalink
[BT] copy advertised device to avoid concurrent data access. (#1537)
Browse files Browse the repository at this point in the history
Co-authored-by: h2zero <[email protected]>
  • Loading branch information
1technophile and h2zero authored Mar 16, 2023
1 parent 17ce2de commit 33ea56b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main/ZgatewayBT.ino
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,10 @@ static int taskCore = 0;

class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
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));
delete (ad);
}
}
};
Expand Down Expand Up @@ -597,6 +599,7 @@ void procBLETask(void* pvParameters) {

if (BTConfig.filterConnectable && device->connect) {
Log.notice(F("Filtered connectable device" CR));
delete (advertisedDevice);
continue;
}

Expand Down Expand Up @@ -636,6 +639,7 @@ void procBLETask(void* pvParameters) {
Log.trace(F("Filtered MAC device" CR));
}
}
delete (advertisedDevice);
}
}

Expand Down

0 comments on commit 33ea56b

Please sign in to comment.