Skip to content

Commit

Permalink
[GVH] Fix Ibeacon display (#77)
Browse files Browse the repository at this point in the history
* [RMAC] Add random mac filtering for device update

* [GVH] Fix Ibeacon display

Fix Ibeacon display as name for the GVH devices
  • Loading branch information
1technophile authored Apr 13, 2023
1 parent f9bcab3 commit 2935163
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
10 changes: 4 additions & 6 deletions src/DeviceManager_advertisement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"]));

Expand Down Expand Up @@ -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"]));

Expand Down
11 changes: 6 additions & 5 deletions src/DeviceManager_theengs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ Device * DeviceManager::createTheengsDevice_fromAdv(const QBluetoothDeviceInfo &
const QList<quint16> &manufacturerIds = deviceInfo.manufacturerIds();
for (const auto id: manufacturerIds)
{
if (deviceModelID.isEmpty() == false) break;

ArduinoJson::DynamicJsonDocument doc(4096);
doc["id"] = deviceInfo.address().toString().toStdString();
Expand All @@ -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;
}
Expand All @@ -164,7 +163,6 @@ Device * DeviceManager::createTheengsDevice_fromAdv(const QBluetoothDeviceInfo &
const QList<QBluetoothUuid> &serviceIds = deviceInfo.serviceIds();
for (const auto id: serviceIds)
{
if (deviceModelID.isEmpty() == false) break;

ArduinoJson::DynamicJsonDocument doc(4096);
doc["id"] = deviceInfo.address().toString().toStdString();
Expand All @@ -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"]);
Expand Down

0 comments on commit 2935163

Please sign in to comment.