support presence detection for HA app: Catch minor id 40004

This commit is contained in:
technyon
2023-12-30 04:57:10 +01:00
parent 060d82e734
commit 8314a507fa
3 changed files with 26 additions and 3 deletions

View File

@@ -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

View File

@@ -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 ? "" : "***";
}

View File

@@ -2,6 +2,10 @@
#include "PreferencesKeys.h"
#include "Logger.h"
#include "CharBuffer.h"
#include <NimBLEDevice.h>
#include <NimBLEAdvertisedDevice.h>
#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
{