diff options
author | Liang Qi <liang.qi@qt.io> | 2016-08-01 09:14:36 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-08-01 09:14:42 +0200 |
commit | 60d1ebac9e81619a24e66fc6defc3e0299491a9d (patch) | |
tree | 39cc5bfb0f6f5b22b0d0a2e71d92ac7e9e69d0e7 /examples | |
parent | 22bffc8c5927d2a6e6b50b05bb6c9db2bc0c7e15 (diff) | |
parent | 71a0d199a29001cc31bfde15aabcc53cf88aae1e (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I64352b6cc066255972874e2f9c28abff35f0d613
Diffstat (limited to 'examples')
-rw-r--r-- | examples/bluetooth/heartlistener/heartrate.cpp | 10 |
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; |