Restart BLE controller

This commit is contained in:
iranl
2025-06-15 21:13:45 +02:00
parent b60bbf032f
commit f8b68ff2fa
14 changed files with 384 additions and 114 deletions

View File

@@ -20,6 +20,16 @@ Scanner::Scanner(int reservedSubscribers) {
subscribers.reserve(reservedSubscribers);
}
Scanner::~Scanner() {
Serial.println("Destroying scanner");
bleScan->stop();
Serial.println("bleScan stopped");
bleScan->clearResults();
Serial.println("bleScan results cleared");
bleScan = nullptr;
Serial.println("bleScan nulled");
}
void Scanner::initialize(const std::string& deviceName, const bool wantDuplicates, const uint16_t interval, const uint16_t window) {
if (!BLEDevice::isInitialized()) {
if (wantDuplicates) {

View File

@@ -25,7 +25,7 @@ namespace BleScanner {
class Scanner : public Publisher, BLEAdvertisedDeviceCallbacks {
public:
Scanner(int reservedSubscribers = 10);
~Scanner() = default;
~Scanner();
static Scanner& instance() {
static Scanner* scanner = new Scanner(); // only initialized once on first call