summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergycharacteristic.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-06-24 15:08:44 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-06-26 16:36:32 +0200
commit004491a61de53d128aade26d497dcf7a557e09c4 (patch)
tree6ec3a63f748c4e75bd856f458fc508dcab4e8c0b /src/bluetooth/qlowenergycharacteristic.cpp
parentb9909f15e8760e1587f67d9ff028bf730a92d044 (diff)
Introduce QLowEnergyDescriptor
The class is based in QLowEnergyDescriptorInfo and exposes the found descriptor information. The only missing piece of information is the descriptor value. Extends the QLowEnergyController unit test in such a way that descriptor information is tested too (except for values). Change-Id: I6ba6a862fff48fbdd27cd8219d2eb8f6d0058aea Reviewed-by: Fabian Bumberger <fbumberger@rim.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/bluetooth/qlowenergycharacteristic.cpp')
-rw-r--r--src/bluetooth/qlowenergycharacteristic.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/bluetooth/qlowenergycharacteristic.cpp b/src/bluetooth/qlowenergycharacteristic.cpp
index 10136c10..f74aa808 100644
--- a/src/bluetooth/qlowenergycharacteristic.cpp
+++ b/src/bluetooth/qlowenergycharacteristic.cpp
@@ -219,9 +219,16 @@ QLowEnergyCharacteristic &QLowEnergyCharacteristic::operator=(const QLowEnergyCh
}
/*!
- Returns true if the QLowEnergyCharacteristic object is valid, otherwise returns false.
- If it returns \c false, it means that this instance is not associated to any service
- or the associated service is no longer valid.
+ Returns \c true if the QLowEnergyCharacteristic object is valid, otherwise returns \c false.
+
+ An invalid characteristic object is not associated to any service
+ or the associated service is no longer valid due to for example a disconnect from
+ the underlying Bluetooth Low Energy device. Once the object is invalid
+ it cannot become valid anymore.
+
+ \note If a QLowEnergyCharacteristic instance turns invalid due to a disconnect
+ from the underlying device, the information encapsulated by the current
+ instance remains as it was at the time of the disconnect.
*/
bool QLowEnergyCharacteristic::isValid() const
{
@@ -239,12 +246,25 @@ bool QLowEnergyCharacteristic::isValid() const
/*!
Returns the list of characteristic descriptors.
*/
-QList<QLowEnergyDescriptorInfo> QLowEnergyCharacteristic::descriptors() const
+QList<QLowEnergyDescriptor> QLowEnergyCharacteristic::descriptors() const
{
- // TODO QLowEnergyCharacteristic::descriptors()
- QList<QLowEnergyDescriptorInfo> result;
- return result;
+ QList<QLowEnergyDescriptor> result;
+
+ if (d_ptr.isNull() || !data
+ || !d_ptr->characteristicList.contains(data->handle))
+ return result;
+ QList<QLowEnergyHandle> descriptorKeys = d_ptr->characteristicList[data->handle].
+ descriptorList.keys();
+
+ std::sort(descriptorKeys.begin(), descriptorKeys.end());
+
+ foreach (QLowEnergyHandle descHandle, descriptorKeys) {
+ QLowEnergyDescriptor descriptor(d_ptr, data->handle, descHandle);
+ result.append(descriptor);
+ }
+
+ return result;
}
QT_END_NAMESPACE