summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/bluetooth/heartrate-game/devicefinder.cpp3
-rw-r--r--examples/bluetooth/heartrate-game/devicehandler.cpp5
2 files changed, 5 insertions, 3 deletions
diff --git a/examples/bluetooth/heartrate-game/devicefinder.cpp b/examples/bluetooth/heartrate-game/devicefinder.cpp
index 6d952351..4ff967eb 100644
--- a/examples/bluetooth/heartrate-game/devicefinder.cpp
+++ b/examples/bluetooth/heartrate-game/devicefinder.cpp
@@ -47,6 +47,7 @@ DeviceFinder::DeviceFinder(DeviceHandler *handler, QObject *parent):
m_deviceHandler(handler)
{
m_deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
+ m_deviceDiscoveryAgent->setLowEnergyDiscoveryTimeout(5000);
connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &DeviceFinder::addDevice);
connect(m_deviceDiscoveryAgent, static_cast<void (QBluetoothDeviceDiscoveryAgent::*)(QBluetoothDeviceDiscoveryAgent::Error)>(&QBluetoothDeviceDiscoveryAgent::error),
@@ -81,7 +82,7 @@ void DeviceFinder::startSearch()
#ifdef SIMULATOR
m_demoTimer.start();
#else
- m_deviceDiscoveryAgent->start();
+ m_deviceDiscoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod);
#endif
emit scanningChanged();
setInfo(tr("Scanning for devices..."));
diff --git a/examples/bluetooth/heartrate-game/devicehandler.cpp b/examples/bluetooth/heartrate-game/devicehandler.cpp
index 96c78313..153a99fb 100644
--- a/examples/bluetooth/heartrate-game/devicehandler.cpp
+++ b/examples/bluetooth/heartrate-game/devicehandler.cpp
@@ -249,7 +249,7 @@ void DeviceHandler::updateDemoHR()
void DeviceHandler::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;
@@ -262,7 +262,8 @@ void DeviceHandler::disconnectService()
m_foundHeartRateService = false;
//disable notifications
- if (m_notificationDesc.isValid() && m_service) {
+ if (m_notificationDesc.isValid() && m_service
+ && m_notificationDesc.value() == QByteArray::fromHex("0100")) {
m_service->writeDescriptor(m_notificationDesc, QByteArray::fromHex("0000"));
} else {
if (m_control)