diff options
Diffstat (limited to 'src/bluetooth/osx/osxbtledeviceinquiry.mm')
-rw-r--r-- | src/bluetooth/osx/osxbtledeviceinquiry.mm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/bluetooth/osx/osxbtledeviceinquiry.mm b/src/bluetooth/osx/osxbtledeviceinquiry.mm index 2cece15b..e61968ed 100644 --- a/src/bluetooth/osx/osxbtledeviceinquiry.mm +++ b/src/bluetooth/osx/osxbtledeviceinquiry.mm @@ -45,6 +45,7 @@ #include <QtCore/qloggingcategory.h> #include <QtCore/qdebug.h> +#include <QtCore/qendian.h> #include <algorithm> @@ -81,6 +82,7 @@ struct AdvertisementData { // For now, we "parse": QString localName; QList<QBluetoothUuid> serviceUuids; + QHash<quint16, QByteArray> manufacturerData; // TODO: other keys probably? AdvertisementData(NSDictionary *AdvertisementData); }; @@ -105,6 +107,12 @@ AdvertisementData::AdvertisementData(NSDictionary *advertisementData) for (CBUUID *cbUuid in uuids) serviceUuids << qt_uuid(cbUuid); } + + value = [advertisementData objectForKey:CBAdvertisementDataManufacturerDataKey]; + if (value && [value isKindOfClass:[NSData class]]) { + QByteArray data = QByteArray::fromNSData(static_cast<NSData *>(value)); + manufacturerData.insert(qFromLittleEndian<quint16>(data.constData()), data.mid(2)); + } } } @@ -321,6 +329,10 @@ QT_USE_NAMESPACE QBluetoothDeviceInfo::DataIncomplete); } + const QList<quint16> keys = qtAdvData.manufacturerData.keys(); + for (quint16 key : keys) + newDeviceInfo.setManufacturerData(key, qtAdvData.manufacturerData.value(key)); + // CoreBluetooth scans only for LE devices. newDeviceInfo.setCoreConfigurations(QBluetoothDeviceInfo::LowEnergyCoreConfiguration); emit notifier->deviceDiscovered(newDeviceInfo); |