summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2015-10-28 13:50:38 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2015-10-28 11:33:33 +0000
commitc7c4fa2823de1fc6795e95efd49a0c7ed6248b42 (patch)
tree987e3949102863229fb9447ed705ced3714431e1 /src
parent9cbd63e8155779f866da1154ed6016423bbe5265 (diff)
Windows: Detect the end handle of a service
Change-Id: I03f02c376f2cd9e83b7e2559c2becb80ff307435 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/bluetooth/qlowenergycontroller_win.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/bluetooth/qlowenergycontroller_win.cpp b/src/bluetooth/qlowenergycontroller_win.cpp
index 0518177c..b126a954 100644
--- a/src/bluetooth/qlowenergycontroller_win.cpp
+++ b/src/bluetooth/qlowenergycontroller_win.cpp
@@ -38,6 +38,8 @@
#include <QtCore/QLoggingCategory>
#include <QtCore/QIODevice> // for open modes
+#include <algorithm> // for std::max
+
#include <windows/qwinlowenergybluetooth_p.h>
#include <setupapi.h>
@@ -564,6 +566,9 @@ void QLowEnergyControllerPrivate::discoverServiceDetails(
return;
}
+ // We assume that the service does not have any characteristics with descriptors.
+ servicePrivate->endHandle = servicePrivate->startHandle;
+
const QVector<BTH_LE_GATT_CHARACTERISTIC> foundCharacteristics =
enumerateGattCharacteristics(hService, NULL, &systemErrorCode);
@@ -616,6 +621,12 @@ void QLowEnergyControllerPrivate::discoverServiceDetails(
<< ":" << qt_error_string(systemErrorCode);
}
+ // We assume that the characteristic has no any descriptors. So, the
+ // biggest characteristic + 1 will indicate an end handle of service.
+ servicePrivate->endHandle = std::max(
+ servicePrivate->endHandle,
+ QLowEnergyHandle(gattCharacteristic.AttributeHandle + 1));
+
const QVector<BTH_LE_GATT_DESCRIPTOR> foundDescriptors = enumerateGattDescriptors(
hService, const_cast<PBTH_LE_GATT_CHARACTERISTIC>(
&gattCharacteristic), &systemErrorCode);
@@ -656,6 +667,11 @@ void QLowEnergyControllerPrivate::discoverServiceDetails(
return;
}
+ // Biggest descriptor will contain an end handle of service.
+ servicePrivate->endHandle = std::max(
+ servicePrivate->endHandle,
+ QLowEnergyHandle(gattDescriptor.AttributeHandle));
+
detailsData.descriptorList.insert(descriptorHandle, data);
}