summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2016-05-17 15:01:39 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2016-05-18 13:10:04 +0000
commit0690d4801ca5ee92d5e7511d48d95786212d5fb3 (patch)
treebb6eb9eb9d1a659ca6d2a1a1b3dcbe7f33326981 /src
parent014df77d92fb0070b2d95b9747a1a988e654355f (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')
-rw-r--r--src/bluetooth/qleadvertiser_bluez.cpp8
-rw-r--r--src/bluetooth/qlowenergycontroller_bluez.cpp15
2 files changed, 18 insertions, 5 deletions
diff --git a/src/bluetooth/qleadvertiser_bluez.cpp b/src/bluetooth/qleadvertiser_bluez.cpp
index c1b38acb..ff00b2b1 100644
--- a/src/bluetooth/qleadvertiser_bluez.cpp
+++ b/src/bluetooth/qleadvertiser_bluez.cpp
@@ -285,7 +285,13 @@ void QLeAdvertiserBluez::setServicesData(const QLowEnergyAdvertisingData &src, A
services32 << service32;
continue;
}
- services128 << service.toUInt128();
+
+ // QBluetoothUuid::toUInt128() is always Big-Endian
+ // convert it to host order
+ quint128 hostOrder;
+ quint128 qtUuidOrder = service.toUInt128();
+ ntoh128(&qtUuidOrder, &hostOrder);
+ services128 << hostOrder;
}
addServicesData(dest, services16);
addServicesData(dest, services32);
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;
}