diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-05-28 16:22:19 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-06-04 13:41:18 +0200 |
commit | 622288ecb7d194b8c3ca08effc3315e1734c251e (patch) | |
tree | 54d278ec6c788bf7617008ceb9db3f43798dcd5a /src/bluetooth/qlowenergycontroller_bluez.cpp | |
parent | 96f46e71d0d76f4d5063c95bbe50165391a20a4f (diff) |
Streamline some of the QLowEnergyDescriptorInfo related code
1. QLowEnergyDescriptorInfo::type() added
2. QLowEnergyDescriptorInfo ctor signature modified
3. QBluetoothUuid::DescriptorId enum renamed
4. QLowEnergyDescriptorInfo::uuid() changed its meaning
5. QBluetoothUuid(CharacteristicDescriptor) ctor added
Starting from this change QNX is going to be broken. In particular
point 2 cause breaks or bug. The focus is on santizing the API at
this point in time.
Change-Id: I7838f550410b6a0f94026b68ecf0751533eba3cb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_bluez.cpp')
-rw-r--r-- | src/bluetooth/qlowenergycontroller_bluez.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp index 42ae9101..bebce1cf 100644 --- a/src/bluetooth/qlowenergycontroller_bluez.cpp +++ b/src/bluetooth/qlowenergycontroller_bluez.cpp @@ -1,5 +1,6 @@ /*************************************************************************** ** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2013 BlackBerry Limited all rights reserved ** Contact: http://www.qt-project.org/legal ** @@ -257,9 +258,10 @@ void QLowEnergyControllerPrivate::_q_replyReceived(const QString &reply) } } if (index1 != -1) { - for (int j = 0; j < (m_leServices.at(index1).d_ptr->characteristicList.size()-1); j++) { - QLowEnergyCharacteristicInfo chars = m_leServices.at(index1).d_ptr->characteristicList.at(j); - QLowEnergyCharacteristicInfo charsNext = m_leServices.at(index1).d_ptr->characteristicList.at(j+1); + QLowEnergyServiceInfo service = m_leServices.at(index1); + for (int j = 0; j < service.d_ptr->characteristicList.size()-1; j++) { + QLowEnergyCharacteristicInfo chars = service.d_ptr->characteristicList.at(j); + QLowEnergyCharacteristicInfo charsNext = service.d_ptr->characteristicList.at(j+1); const QString handleId = handleDetails.at(1); ushort h = handleId.toUShort(0, 0); qCDebug(QT_BT_BLUEZ) << handleId << h << chars.handle() << chars.handle().toUShort(0,0); @@ -267,25 +269,25 @@ void QLowEnergyControllerPrivate::_q_replyReceived(const QString &reply) if (h > chars.handle().toUShort(0,0) && h < charsNext.handle().toUShort(0,0)) { chars.d_ptr->notificationHandle = handleId; chars.d_ptr->notification = true; - QBluetoothUuid descUuid((ushort)0x2902); - QLowEnergyDescriptorInfo descriptor(descUuid, handleId); + QLowEnergyDescriptorInfo descriptor( + service.d_ptr->characteristicList[j].uuid(), + QBluetoothUuid::ClientCharacteristicConfiguration, + handleId); QString val; //TODO why do we start parsing value from k = 0? Shouldn't it be k = 2 for (int k = 3; k < handleDetails.size(); k++) val = val + handleDetails.at(k); descriptor.d_ptr->m_value = val.toUtf8(); - QVariantMap map; - map[QStringLiteral("uuid")] = descUuid.toString(); - map[QStringLiteral("handle")] = handleId; - map[QStringLiteral("value")] = val.toUtf8(); - m_leServices.at(index1).d_ptr->characteristicList[j].d_ptr->descriptorsList.append(descriptor); - qCDebug(QT_BT_BLUEZ) << "Notification characteristic set." << chars.d_ptr->handle << chars.d_ptr->notificationHandle; + service.d_ptr->characteristicList[j].d_ptr->descriptorsList.append(descriptor); + qCDebug(QT_BT_BLUEZ) << "Notification characteristic set." + << chars.d_ptr->handle + << chars.d_ptr->notificationHandle; } } if (!lastStep) { - m_leServices.at(index1).d_ptr->m_step++; - m_leServices.at(index1).d_ptr->connected = true; - emit q_ptr->connected(m_leServices.at(index1)); + service.d_ptr->m_step++; + service.d_ptr->connected = true; + emit q_ptr->connected(service); } lastStep = true; } @@ -362,6 +364,8 @@ void QLowEnergyControllerPrivate::setCharacteristics(int a) void QLowEnergyControllerPrivate::setNotifications() { + // TODO at the moment we only search for 2902 descriptors + // it doesn't show all 2902's and we leave a lot of other descriptors out process->executeCommand(QStringLiteral("char-read-uuid 2902")); } |