diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2018-01-29 19:06:59 +0100 |
---|---|---|
committer | Oliver Wolff <oliver.wolff@qt.io> | 2018-08-17 06:28:17 +0000 |
commit | 0f930cddefe386c6b6f65b8b11342c9e76876a9b (patch) | |
tree | 546340d74090e05865bc4a28d27895ae969e1919 /src/bluetooth/osx | |
parent | c0960600bad55c5df62ba26a78d08179658b0454 (diff) |
Add manufacturer data to QBluetoothDeviceInfo
The initial patch was contributed by Thiemo van Engelen.
Change-Id: I45fad793ba092ab2820e606d8bf8807afa3e911e
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/bluetooth/osx')
-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); |