From 293516309edf85353690cfc003b34bf365203250 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 13 Apr 2023 17:48:21 -0500 Subject: [PATCH] [GVH] Fix Ibeacon display (#77) * [RMAC] Add random mac filtering for device update * [GVH] Fix Ibeacon display Fix Ibeacon display as name for the GVH devices --- src/DeviceManager_advertisement.cpp | 10 ++++------ src/DeviceManager_theengs.cpp | 11 ++++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/DeviceManager_advertisement.cpp b/src/DeviceManager_advertisement.cpp index 344cef0..cd448a1 100644 --- a/src/DeviceManager_advertisement.cpp +++ b/src/DeviceManager_advertisement.cpp @@ -96,9 +96,8 @@ void DeviceManager::updateBleDevice(const QBluetoothDeviceInfo &info, serializeJson(obj, output); //qDebug() << "output:" << output.c_str(); - if (doc["model_id"] == "IBEACON") continue; - if (doc["model_id"] == "MS-CDP") continue; - if (doc["model_id"] == "GAEN") continue; + // Do not process devices with random macs or IBEACONS packets + if (doc["type"] == "RMAC" || doc["model_id"] == "IBEACON") continue; dd->setTheengsModelId(QString::fromStdString(doc["model"]), QString::fromStdString(doc["model_id"])); @@ -155,9 +154,8 @@ void DeviceManager::updateBleDevice(const QBluetoothDeviceInfo &info, serializeJson(obj, output); //qDebug() << "output:" << output.c_str(); - if (doc["model_id"] == "IBEACON") continue; - if (doc["model_id"] == "MS-CDP") continue; - if (doc["model_id"] == "GAEN") continue; + // Do not process devices with random macs + if (doc["type"] == "RMAC") continue; dd->setTheengsModelId(QString::fromStdString(doc["model"]), QString::fromStdString(doc["model_id"])); diff --git a/src/DeviceManager_theengs.cpp b/src/DeviceManager_theengs.cpp index 46a96a5..b3d861f 100644 --- a/src/DeviceManager_theengs.cpp +++ b/src/DeviceManager_theengs.cpp @@ -129,7 +129,6 @@ Device * DeviceManager::createTheengsDevice_fromAdv(const QBluetoothDeviceInfo & const QList &manufacturerIds = deviceInfo.manufacturerIds(); for (const auto id: manufacturerIds) { - if (deviceModelID.isEmpty() == false) break; ArduinoJson::DynamicJsonDocument doc(4096); doc["id"] = deviceInfo.address().toString().toStdString(); @@ -141,15 +140,15 @@ Device * DeviceManager::createTheengsDevice_fromAdv(const QBluetoothDeviceInfo & if (dec.decodeBLEJson(obj) >= 0) { + // Do not process devices with random macs or IBEACONS packets + if (doc["type"] == "RMAC" || doc["model_id"] == "IBEACON") continue; + deviceModel = QString::fromStdString(doc["model"]); deviceModelID = QString::fromStdString(doc["model_id"]); deviceTags = QString::fromStdString(doc["tag"]); deviceTypes = QString::fromStdString(doc["type"]); deviceProps = QString::fromStdString(dec.getTheengProperties(deviceModelID.toLatin1())); - // Do not process devices with random macs - if (deviceTypes == "RMAC") continue; - qDebug() << "addDevice() FOUND [mfd] :" << deviceModel << deviceModelID << deviceTags << deviceTypes << deviceProps; break; } @@ -164,7 +163,6 @@ Device * DeviceManager::createTheengsDevice_fromAdv(const QBluetoothDeviceInfo & const QList &serviceIds = deviceInfo.serviceIds(); for (const auto id: serviceIds) { - if (deviceModelID.isEmpty() == false) break; ArduinoJson::DynamicJsonDocument doc(4096); doc["id"] = deviceInfo.address().toString().toStdString(); @@ -177,6 +175,9 @@ Device * DeviceManager::createTheengsDevice_fromAdv(const QBluetoothDeviceInfo & if (dec.decodeBLEJson(obj) >= 0) { + // Do not process devices with random macs + if (doc["type"] == "RMAC") continue; + deviceModel = QString::fromStdString(doc["model"]); deviceModelID = QString::fromStdString(doc["model_id"]); deviceTags = QString::fromStdString(doc["tag"]);