support presence detection for HA app: Catch minor id 40004
This commit is contained in:
2
Config.h
2
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
|
||||
|
||||
@@ -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 ? "" : "***";
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user