diff --git a/Config.h b/Config.h index 6fcddd4..aec0998 100644 --- a/Config.h +++ b/Config.h @@ -1,6 +1,6 @@ #pragma once -#define NUKI_HUB_VERSION "8.28" +#define NUKI_HUB_VERSION "8.29-pre-1" #define MQTT_QOS_LEVEL 1 #define MQTT_CLEAN_SESSIONS false diff --git a/PreferencesKeys.h b/PreferencesKeys.h index a620e6f..9bd0c94 100644 --- a/PreferencesKeys.h +++ b/PreferencesKeys.h @@ -96,11 +96,11 @@ private: { return s == "" ? "" : "***"; } - const String redact(const int i) const + const String redact(const int32_t i) const { return i == 0 ? "" : "***"; } - const String redact(const uint i) const + const String redact(const uint32_t i) const { return i == 0 ? "" : "***"; } diff --git a/PresenceDetection.cpp b/PresenceDetection.cpp index 45a8702..6f702d5 100644 --- a/PresenceDetection.cpp +++ b/PresenceDetection.cpp @@ -2,6 +2,10 @@ #include "PreferencesKeys.h" #include "Logger.h" #include "CharBuffer.h" +#include +#include +#include "NimBLEBeacon.h" +#include "NukiUtils.h" PresenceDetection::PresenceDetection(Preferences* preferences, BleScanner::Scanner *bleScanner, Network* network, char* buffer, size_t bufferSize) : _preferences(preferences), @@ -173,6 +177,25 @@ void PresenceDetection::onResult(NimBLEAdvertisedDevice *device) _devices[addr] = pdDevice; } + else if (device->haveManufacturerData()) + { + std::string strManufacturerData = device->getManufacturerData(); + + uint8_t cManufacturerData[100]; + strManufacturerData.copy((char *)cManufacturerData, std::min(strManufacturerData.length(), sizeof(cManufacturerData)), 0); + + if (strManufacturerData.length() == 25 && cManufacturerData[0] == 0x4C && cManufacturerData[1] == 0x00) + { + BLEBeacon oBeacon = BLEBeacon(); + oBeacon.setData(strManufacturerData); + + if(ENDIAN_CHANGE_U16(oBeacon.getMinor()) == 40004) + { + pdDevice.timestamp = millis(); + _devices[addr] = pdDevice; + } + } + } } else {