diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-05-17 15:01:39 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-05-18 13:10:04 +0000 |
commit | 0690d4801ca5ee92d5e7511d48d95786212d5fb3 (patch) | |
tree | bb6eb9eb9d1a659ca6d2a1a1b3dcbe7f33326981 /src/bluetooth/qlowenergycontroller_bluez.cpp | |
parent | 014df77d92fb0070b2d95b9747a1a988e654355f (diff) |
Fix endianness conversion order bug when handling 128bit Qt Uuid
QBluetoothUuid.toUInt128() always returns big endian notation.
We have to convert it to host order before we convert to Bluetooth
order.
Task-number: QTBUG-53421
Change-Id: Ibab4f06fa70739adb163523c803a203608454427
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_bluez.cpp')
-rw-r--r-- | src/bluetooth/qlowenergycontroller_bluez.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp index adac55fc..d4fe0232 100644 --- a/src/bluetooth/qlowenergycontroller_bluez.cpp +++ b/src/bluetooth/qlowenergycontroller_bluez.cpp @@ -235,10 +235,14 @@ template<typename T> static void putDataAndIncrement(const T &src, char *&dst) template<> void putDataAndIncrement(const QBluetoothUuid &uuid, char *&dst) { const int uuidSize = getUuidSize(uuid); - if (uuidSize == 2) + if (uuidSize == 2) { putBtData(uuid.toUInt16(), dst); - else - putBtData(uuid.toUInt128(), dst); + } else { + quint128 hostOrder; + quint128 qtUuidOrder = uuid.toUInt128(); + ntoh128(&qtUuidOrder, &hostOrder); + putBtData(hostOrder, dst); + } dst += uuidSize; } template<> void putDataAndIncrement(const QByteArray &value, char *&dst) @@ -2925,7 +2929,10 @@ static QByteArray uuidToByteArray(const QBluetoothUuid &uuid) putBtData(uuid.toUInt16(), ba.data()); } else { ba.resize(16); - putBtData(uuid.toUInt128(), ba.data()); + quint128 hostOrder; + quint128 qtUuidOrder = uuid.toUInt128(); + ntoh128(&qtUuidOrder, &hostOrder); + putBtData(hostOrder, ba.data()); } return ba; } |