diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-06-13 16:10:08 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-06-16 14:17:38 +0200 |
commit | 680537e519c859c79251da94fa15740d87b5ca35 (patch) | |
tree | b000920fc26f4a230361bd770c42c5477602e2d2 | |
parent | 856fa57a431077febf11fea27d8c63091623126d (diff) |
Don't construct QBluetoothUuid via string parsing
This improves conversion performance.
Change-Id: Ib78b2a6e24d0f44723be0bfb63b6aafc965188a6
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
-rw-r--r-- | src/bluetooth/qbluetoothuuid.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontrollernew_bluez.cpp | 20 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/bluetooth/qbluetoothuuid.cpp b/src/bluetooth/qbluetoothuuid.cpp index b68e6e1f..3f8487b4 100644 --- a/src/bluetooth/qbluetoothuuid.cpp +++ b/src/bluetooth/qbluetoothuuid.cpp @@ -470,6 +470,8 @@ QBluetoothUuid::QBluetoothUuid(quint32 uuid) /*! Constructs a new Bluetooth UUID from the 128 bit \a uuid. + + Note that \a uuid must be in big endian order. */ QBluetoothUuid::QBluetoothUuid(quint128 uuid) { diff --git a/src/bluetooth/qlowenergycontrollernew_bluez.cpp b/src/bluetooth/qlowenergycontrollernew_bluez.cpp index ad0ee3eb..2ab97170 100644 --- a/src/bluetooth/qlowenergycontrollernew_bluez.cpp +++ b/src/bluetooth/qlowenergycontrollernew_bluez.cpp @@ -61,20 +61,18 @@ Q_DECLARE_LOGGING_CATEGORY(QT_BT_BLUEZ) static inline QBluetoothUuid convert_uuid128(const uint128_t *p) { - uint128_t dst; - bt_uuid_t uuid; - btoh128(p, &dst); - bt_uuid128_create(&uuid, dst); -// //TODO don't use string conversion but raw ints once QBluetoothUuid ctor is fixed -// quint128 qtdst; -// memcpy(&qtdst, &dst, sizeof(uint128_t)); + uint128_t dst_hostOrder, dst_bigEndian; - char buffer[48]; - bt_uuid_to_string(&uuid, buffer, 48); + // Bluetooth LE data comes as little endian + // uuids are constructed using high endian + btoh128(p, &dst_hostOrder); + hton128(&dst_hostOrder, &dst_bigEndian); -// qDebug() << buffer << QBluetoothUuid(qtdst); + // convert to Qt's own data type + quint128 qtdst; + memcpy(&qtdst, &dst_bigEndian, sizeof(uint128_t)); - return QBluetoothUuid(QString::fromLocal8Bit(buffer)); + return QBluetoothUuid(qtdst); } void QLowEnergyControllerNewPrivate::connectToDevice() |