summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-01 09:14:36 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-01 09:14:42 +0200
commit60d1ebac9e81619a24e66fc6defc3e0299491a9d (patch)
tree39cc5bfb0f6f5b22b0d0a2e71d92ac7e9e69d0e7 /examples/bluetooth
parent22bffc8c5927d2a6e6b50b05bb6c9db2bc0c7e15 (diff)
parent71a0d199a29001cc31bfde15aabcc53cf88aae1e (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Diffstat (limited to 'examples/bluetooth')
-rw-r--r--examples/bluetooth/heartlistener/heartrate.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/bluetooth/heartlistener/heartrate.cpp b/examples/bluetooth/heartlistener/heartrate.cpp
index 08433195..7077bf1c 100644
--- a/examples/bluetooth/heartlistener/heartrate.cpp
+++ b/examples/bluetooth/heartlistener/heartrate.cpp
@@ -234,8 +234,10 @@ void HeartRate::disconnectService()
return;
}
- //disable notifications
- if (m_notificationDesc.isValid() && m_service) {
+ //disable notifications before disconnecting
+ if (m_notificationDesc.isValid() && m_service
+ && m_notificationDesc.value() == QByteArray::fromHex("0100"))
+ {
m_service->writeDescriptor(m_notificationDesc, QByteArray::fromHex("0000"));
} else {
m_control->disconnectFromDevice();
@@ -266,7 +268,7 @@ void HeartRate::serviceStateChanged(QLowEnergyService::ServiceState s)
break;
}
- const QLowEnergyDescriptor m_notificationDesc = hrChar.descriptor(
+ m_notificationDesc = hrChar.descriptor(
QBluetoothUuid::ClientCharacteristicConfiguration);
if (m_notificationDesc.isValid()) {
m_service->writeDescriptor(m_notificationDesc, QByteArray::fromHex("0100"));
@@ -333,7 +335,7 @@ void HeartRate::updateHeartRateValue(const QLowEnergyCharacteristic &c,
void HeartRate::confirmedDescriptorWrite(const QLowEnergyDescriptor &d,
const QByteArray &value)
{
- if (d.isValid() && d == m_notificationDesc && value == QByteArray("0000")) {
+ if (d.isValid() && d == m_notificationDesc && value == QByteArray::fromHex("0000")) {
//disabled notifications -> assume disconnect intent
m_control->disconnectFromDevice();
delete m_service;