diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..44e504f Binary files /dev/null and b/.DS_Store differ diff --git a/src/ESP32-mqtt-room.ino b/src/ESP32-mqtt-room.ino index 93506ea..3d25cf7 100644 --- a/src/ESP32-mqtt-room.ino +++ b/src/ESP32-mqtt-room.ino @@ -318,6 +318,25 @@ bool reportDevice(BLEAdvertisedDevice advertisedDevice) { String mac_address = advertisedDevice.getAddress().toString().c_str(); mac_address.replace(":",""); mac_address.toLowerCase(); + + + //Check scanned MAC Address against a list of allowed MAC Addresses + + if (allowedListCheck) { + bool allowedListFound = false; + for (uint32_t x = 0; x < allowedListNumberOfItems; x++) { + if (mac_address == allowedList[x]) { + allowedListFound = true; + } + } + + if (allowedListFound == false) { + return false; + } + } + // -------------- + + // Serial.print("mac:\t"); // Serial.println(mac_address); int rssi = advertisedDevice.getRSSI(); diff --git a/src/Settings.h b/src/Settings.h index 0d28014..5cbc637 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -49,3 +49,10 @@ // MQTT topic for sensor values from HTU21D temperature and humidity sensor //#define htuSensorTopic "presence_nodes/" hostname "/sensor" + + +//List of allowed MAC Addresses for MQTT Publish. All others will be ignored. +//Feature is disabled by default. +#define allowedListCheck false +String allowedList[] = {"11223344aabb", "11223344aabb"}; +uint32_t allowedListNumberOfItems = 2;