summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergyservice.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-07-10 15:47:41 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-07-16 08:28:46 +0200
commitf399837b3a723af9add6d9ea2d2e988f64f76ae0 (patch)
tree2c2a17ff5c4cfd007af98c98c70a2bf8c5fe8984 /src/bluetooth/qlowenergyservice.cpp
parent8bf7e9986e359df46bb351dfb76e4140d9b04da7 (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 'src/bluetooth/qlowenergyservice.cpp')
-rw-r--r--src/bluetooth/qlowenergyservice.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/bluetooth/qlowenergyservice.cpp b/src/bluetooth/qlowenergyservice.cpp
index 30fe5733..401468f4 100644
--- a/src/bluetooth/qlowenergyservice.cpp
+++ b/src/bluetooth/qlowenergyservice.cpp
@@ -93,12 +93,35 @@ QLowEnergyService::ServiceState QLowEnergyService::state() const
return d_ptr->state;
}
-
QLowEnergyService::ServiceType QLowEnergyService::type() const
{
return d_ptr->type;
}
+/*!
+ Returns the matching characteristic for \a uuid; otherwise an invalid
+ characteristic.
+
+ \sa characteristics()
+*/
+QLowEnergyCharacteristic QLowEnergyService::characteristic(const QBluetoothUuid &uuid) const
+{
+ foreach (const QLowEnergyHandle handle, d_ptr->characteristicList.keys()) {
+ if (d_ptr->characteristicList[handle].uuid == uuid)
+ return QLowEnergyCharacteristic(d_ptr, handle);
+ }
+
+ return QLowEnergyCharacteristic();
+}
+
+/*!
+ Returns all characteristics associated with this \c QLowEnergyService instance.
+
+ The returned list will be empty if this service instance is invalid,
+ \l discoverDetails() was not yet called or there are no known characteristics.
+
+ \sa characteristic(), state(), discoverDetails
+*/
QList<QLowEnergyCharacteristic> QLowEnergyService::characteristics() const
{