diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-07-10 15:47:41 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-07-16 08:28:46 +0200 |
commit | f399837b3a723af9add6d9ea2d2e988f64f76ae0 (patch) | |
tree | 2c2a17ff5c4cfd007af98c98c70a2bf8c5fe8984 /tests/auto/qlowenergycontroller | |
parent | 8bf7e9986e359df46bb351dfb76e4140d9b04da7 (diff) |
Add simpler API to retrieve descriptor/characteristic for certain uuid
This new API is mostly syntactic sugar and reduces the amount of code
to be written by API users.
Change-Id: I51ff1ea706ac97199646d211e39e79c8140ee74b
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'tests/auto/qlowenergycontroller')
-rw-r--r-- | tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp index 1fa8b9bf..bb7bd720 100644 --- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp +++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp @@ -1648,17 +1648,10 @@ void tst_QLowEnergyController::tst_writeDescriptor() // http://processors.wiki.ti.com/index.php/SensorTag_User_Guide // 1. Find temperature data characteristic - const QList<QLowEnergyCharacteristic> chars = service->characteristics(); - QLowEnergyCharacteristic tempData, tempConfig; - foreach (const QLowEnergyCharacteristic &c, chars) { - if (c.uuid() == - QBluetoothUuid(QStringLiteral("f000aa01-0451-4000-b000-000000000000"))) { - tempData = c; - } else if (c.uuid() == - QBluetoothUuid(QStringLiteral("f000aa02-0451-4000-b000-000000000000"))) { - tempConfig = c; - } - } + const QLowEnergyCharacteristic tempData = service->characteristic( + QBluetoothUuid(QStringLiteral("f000aa01-0451-4000-b000-000000000000"))); + const QLowEnergyCharacteristic tempConfig = service->characteristic( + QBluetoothUuid(QStringLiteral("f000aa02-0451-4000-b000-000000000000"))); if (!tempData.isValid()) { delete service; @@ -1667,14 +1660,8 @@ void tst_QLowEnergyController::tst_writeDescriptor() } // 2. Find temperature data notification descriptor - const QList<QLowEnergyDescriptor> descs = tempData.descriptors(); - QLowEnergyDescriptor notification; - foreach (const QLowEnergyDescriptor &d, descs) { - if (d.type() == QBluetoothUuid::ClientCharacteristicConfiguration) { - notification = d; - break; - } - } + const QLowEnergyDescriptor notification = tempData.descriptor( + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); if (!notification.isValid()) { delete service; |