diff --git a/src/DeviceManager.cpp b/src/DeviceManager.cpp index e989f9a..82ee2f0 100644 --- a/src/DeviceManager.cpp +++ b/src/DeviceManager.cpp @@ -1312,7 +1312,7 @@ bool DeviceManager::isBleDeviceBlacklisted(const QString &addr) void DeviceManager::addBleDevice(const QBluetoothDeviceInfo &info) { - //qDebug() << "DeviceManager::addBleDevice()" << " > NAME" << info.name() << " > RSSI" << info.rssi(); + qDebug() << "DeviceManager::addBleDevice()" << " > NAME" << info.name() << " > RSSI" << info.rssi(); // Various sanity checks { diff --git a/src/DeviceManager_advertisement.cpp b/src/DeviceManager_advertisement.cpp index 7515153..f826bed 100644 --- a/src/DeviceManager_advertisement.cpp +++ b/src/DeviceManager_advertisement.cpp @@ -45,11 +45,8 @@ void DeviceManager::updateBleDevice(const QBluetoothDeviceInfo &info, Q_UNUSED(updatedFields) // We don't use QBluetoothDeviceInfo::Fields, it's unreliable if (info.rssi() >= 0) return; // we probably just hit the device cache - //if (info.isCached()) return; // we probably just hit the device cache if ((info.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) == false) return; // not a BLE device if (m_devices_blacklist.contains(info.address().toString())) return; // device is blacklisted - //if (info.name().isEmpty()) return; // skip beacons - if (info.name().replace('-', ':') == info.address().toString()) return; // skip beacons for (auto d: qAsConst(m_devices_model->m_devices)) // KNOWN DEVICES //////// { @@ -72,7 +69,7 @@ void DeviceManager::updateBleDevice(const QBluetoothDeviceInfo &info, { //qDebug() << info.name() << info.address() << Qt::hex // << "ID" << id - // << "manufacturer data" << Qt::dec << info.manufacturerData(id).count() << Qt::hex + // << "manufacturer data" << Qt::dec << info.manufacturerData(id).size() << Qt::hex // << "bytes:" << info.manufacturerData(id).toHex(); dd->parseAdvertisementData(DeviceUtils::BLE_ADV_MANUFACTURERDATA, @@ -118,7 +115,7 @@ void DeviceManager::updateBleDevice(const QBluetoothDeviceInfo &info, { //std::string input; //serializeJson(doc, input); - //qDebug() << "input :" << input.c_str(); + //qDebug() << "decodeBLEJson(mfd1) error:" << input.c_str(); } } @@ -127,7 +124,7 @@ void DeviceManager::updateBleDevice(const QBluetoothDeviceInfo &info, { //qDebug() << info.name() << info.address() << Qt::hex // << "ID" << id - // << "service data" << Qt::dec << info.serviceData(id).count() << Qt::hex + // << "service data" << Qt::dec << info.serviceData(id).size() << Qt::hex // << "bytes:" << info.serviceData(id).toHex(); dd->parseAdvertisementData(DeviceUtils::BLE_ADV_MANUFACTURERDATA, @@ -175,7 +172,7 @@ void DeviceManager::updateBleDevice(const QBluetoothDeviceInfo &info, { //std::string input; //serializeJson(doc, input); - //qDebug() << "input :" << input.c_str(); + //qDebug() << "decodeBLEJson(svd1) error:" << input.c_str(); } } @@ -225,7 +222,7 @@ void DeviceManager::updateBleDevice(const QBluetoothDeviceInfo &info, { //qDebug() << info.name() << info.address() << Qt::hex // << "ID" << id - // << "manufacturer data" << Qt::dec << info.manufacturerData(id).count() << Qt::hex + // << "manufacturer data" << Qt::dec << info.manufacturerData(id).size() << Qt::hex // << "bytes:" << info.manufacturerData(id).toHex(); ArduinoJson::DynamicJsonDocument doc(2048); @@ -255,6 +252,12 @@ void DeviceManager::updateBleDevice(const QBluetoothDeviceInfo &info, status = true; } + else + { + //std::string input; + //serializeJson(doc, input); + //qDebug() << "decodeBLEJson(mfd2) error:" << input.c_str(); + } } const QList &serviceIds = info.serviceIds(); @@ -262,7 +265,7 @@ void DeviceManager::updateBleDevice(const QBluetoothDeviceInfo &info, { //qDebug() << info.name() << info.address() << Qt::hex // << "ID" << id - // << "service data" << Qt::dec << info.serviceData(id).count() << Qt::hex + // << "service data" << Qt::dec << info.serviceData(id).size() << Qt::hex // << "bytes:" << info.serviceData(id).toHex(); ArduinoJson::DynamicJsonDocument doc(2048); @@ -294,6 +297,12 @@ void DeviceManager::updateBleDevice(const QBluetoothDeviceInfo &info, status = true; } + else + { + //std::string input; + //serializeJson(doc, input); + //qDebug() << "decodeBLEJson(svd2) error:" << input.c_str(); + } } } diff --git a/src/DeviceManager_theengs.cpp b/src/DeviceManager_theengs.cpp index a9fe46b..4c1fd3d 100644 --- a/src/DeviceManager_theengs.cpp +++ b/src/DeviceManager_theengs.cpp @@ -24,7 +24,6 @@ #include "device_theengs.h" #include "devices/device_theengs_generic.h" -#include "devices/device_theengs_beacons.h" #include "devices/device_theengs_probes.h" #include "devices/device_theengs_scales.h" #include "devices/device_theengs_motionsensors.h" @@ -41,13 +40,14 @@ #include #include +/* ************************************************************************** */ /* ************************************************************************** */ Device * DeviceManager::createTheengsDevice_fromDb(const QString &deviceName, const QString &deviceModel_theengs, const QString &deviceAddr) { - //qDebug() << "createTheengsDevice_fromDb(" << deviceName << "/" << deviceModel_theengs << "/" << deviceAddr << ")"; + qDebug() << "createTheengsDevice_fromDb(" << deviceName << "/" << deviceModel_theengs << "/" << deviceAddr << ")"; DeviceTheengs *device = nullptr; @@ -144,9 +144,11 @@ Device * DeviceManager::createTheengsDevice_fromDb(const QString &deviceName, return device; } +/* ************************************************************************** */ + Device * DeviceManager::createTheengsDevice_fromAdv(const QBluetoothDeviceInfo &deviceInfo) { - //qDebug() << "createTheengsDevice_fromAdv(" << deviceInfo.name() << ")"; + qDebug() << "createTheengsDevice_fromAdv(" << deviceInfo.name() << ")"; DeviceTheengs *device = nullptr; @@ -173,13 +175,19 @@ Device * DeviceManager::createTheengsDevice_fromAdv(const QBluetoothDeviceInfo & device_modelid_theengs = QString::fromStdString(doc["model_id"]); device_props = QString::fromUtf8(dec.getTheengProperties(device_modelid_theengs.toLocal8Bit())); - if (device_model_theengs == "IBEACON" && device_modelid_theengs == "IBEACON") continue; - if (device_model_theengs == "MS-CDP" && device_modelid_theengs == "MS-CDP") continue; - if (device_model_theengs == "GAEN" && device_modelid_theengs == "GAEN") continue; + if (device_modelid_theengs == "IBEACON") continue; + if (device_modelid_theengs == "MS-CDP") continue; + if (device_modelid_theengs == "GAEN") continue; qDebug() << "addDevice() FOUND [mfd] :" << device_model_theengs << device_modelid_theengs << device_props; break; } + else + { + std::string input; + serializeJson(doc, input); + qDebug() << "decodeBLEJson(mfd_add) error:" << input.c_str(); + } } const QList &serviceIds = deviceInfo.serviceIds(); @@ -191,7 +199,7 @@ Device * DeviceManager::createTheengsDevice_fromAdv(const QBluetoothDeviceInfo & doc["id"] = deviceInfo.address().toString().toStdString(); doc["name"] = deviceInfo.name().toStdString(); doc["servicedata"] = deviceInfo.serviceData(id).toHex().toStdString(); - doc["servicedatauuid"] = id.toString(QUuid::Id128).toStdString(); + doc["servicedatauuid"] = QByteArray::number(id.toUInt16(), 16).rightJustified(4, '0').toStdString(); TheengsDecoder dec; ArduinoJson::JsonObject obj = doc.as(); @@ -202,13 +210,19 @@ Device * DeviceManager::createTheengsDevice_fromAdv(const QBluetoothDeviceInfo & device_modelid_theengs = QString::fromStdString(doc["model_id"]); device_props = QString::fromUtf8(dec.getTheengProperties(device_modelid_theengs.toLocal8Bit())); - if (device_model_theengs == "IBEACON" && device_modelid_theengs == "IBEACON") continue; - if (device_model_theengs == "MS-CDP" && device_modelid_theengs == "MS-CDP") continue; - if (device_model_theengs == "GAEN" && device_modelid_theengs == "GAEN") continue; + if (device_modelid_theengs == "IBEACON") continue; + if (device_modelid_theengs == "MS-CDP") continue; + if (device_modelid_theengs == "GAEN") continue; qDebug() << "addDevice() FOUND [svd] :" << device_model_theengs << device_modelid_theengs << device_props; break; } + else + { + std::string input; + serializeJson(doc, input); + qDebug() << "decodeBLEJson(svd_add) error:" << input.c_str(); + } } if ((!device_modelid_theengs.isEmpty() && !device_props.isEmpty())) @@ -307,6 +321,8 @@ Device * DeviceManager::createTheengsDevice_fromAdv(const QBluetoothDeviceInfo & return device; } +/* ************************************************************************** */ + QString DeviceManager::getDeviceModelIdTheengs_fromAdv(const QBluetoothDeviceInfo &deviceInfo) { //qDebug() << "getDeviceModelIdTheengs_fromAdv(" << deviceInfo.name() << ")";