summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergyservice.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-07-07 15:45:40 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-07-15 20:39:48 +0200
commit4d2fb32117cd37e0cd4ed3de9c43941b11ad708d (patch)
treef24be0904f537f6aa274be47e98af9ca6ea87327 /src/bluetooth/qlowenergyservice.cpp
parent74a4d1b1ab44274d208d4a52d666d39010f2227a (diff)
Add QLowEnergyService::contains(QLowEnergyDescriptor)
The patch adds extensive test code for the two contains() functions in QLowEnergyService. Change-Id: I640767b55ccad63e390478ccf14f2b47eb24de7f Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'src/bluetooth/qlowenergyservice.cpp')
-rw-r--r--src/bluetooth/qlowenergyservice.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/bluetooth/qlowenergyservice.cpp b/src/bluetooth/qlowenergyservice.cpp
index 564898ce..89d9adc2 100644
--- a/src/bluetooth/qlowenergyservice.cpp
+++ b/src/bluetooth/qlowenergyservice.cpp
@@ -157,7 +157,14 @@ QLowEnergyService::ServiceError QLowEnergyService::error() const
return d_ptr->lastError;
}
-bool QLowEnergyService::contains(const QLowEnergyCharacteristic &characteristic)
+
+/*!
+ Returns \c true if \a characteristic belongs to this service; otherwise \c false.
+
+ A characteristic belongs to a service if \l {QLowEnergyService::characteristics()}
+ contains the \a characteristic.
+ */
+bool QLowEnergyService::contains(const QLowEnergyCharacteristic &characteristic) const
{
if (characteristic.d_ptr.isNull() || !characteristic.data)
return false;
@@ -209,5 +216,26 @@ void QLowEnergyService::writeCharacteristic(
newValue);
}
+/*!
+ Returns \c true if \a descriptor belongs to this service; otherwise \c false.
+ */
+bool QLowEnergyService::contains(const QLowEnergyDescriptor &descriptor) const
+{
+ if (descriptor.d_ptr.isNull() || !descriptor.data)
+ return false;
+
+ const QLowEnergyHandle charHandle = descriptor.characteristicHandle();
+ if (!charHandle)
+ return false;
+
+ if (d_ptr == descriptor.d_ptr
+ && d_ptr->characteristicList.contains(charHandle)
+ && d_ptr->characteristicList[charHandle].descriptorList.contains(descriptor.handle()))
+ {
+ return true;
+ }
+
+ return false;
+}
QT_END_NAMESPACE