diff --git a/btcontrol.ino b/btcontrol.ino index b8178c5..8842a06 100644 --- a/btcontrol.ino +++ b/btcontrol.ino @@ -18,6 +18,7 @@ #define FRAMES_PER_SECOND 24 #define MAX_VANISH_COUNTER 50 +#define MAX_MONITOR_DEVICES 10 CRGB leds[NUM_LEDS]; @@ -29,13 +30,17 @@ std::map deviceDatabase; std::mutex callBackMutex; +CRGBPalette16 MyPalette; + class AdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks { void onResult(BLEAdvertisedDevice advertisedDevice) { String addr = advertisedDevice.getAddress().toString(); String color = String("0x"+addr.substring(9,11)+addr.substring(12,14)+addr.substring(15,17)); color.toUpperCase(); color[1] = 'x'; - deviceDatabase[color] = MAX_VANISH_COUNTER; + if (deviceDatabase.contains(color) || deviceDatabase.size() + 1 < MAX_MONITOR_DEVICES) { + deviceDatabase[color] = MAX_VANISH_COUNTER; + } Serial.printf("Address: %s RSSI: %d TX Power: %d Calculated color: %s \n", addr.c_str(), advertisedDevice.getRSSI(), advertisedDevice.getTXPower(), color.c_str()); for(int i=0; i