summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2017-04-03 16:24:25 +0200
committerAlex Blasche <alexander.blasche@qt.io>2017-04-06 08:27:29 +0000
commit26293d827f8c15dcc787acc5aa8f2e0277f9ce5f (patch)
treed96a37c6504720e305eb03903e18b8096bd0c8a4 /examples
parentba56814fa4f0ca4a20d8448dcee95e5bf7c9d3a5 (diff)
Update heartrate-game against latest heartlistener example
This patch incorporates the following two heartlistener patch: 1750983d3f053316c735d602c7f9a1b56dc4462b b01389be13b40833fa3f50a862b164c5d8389d1a The above two patches were applied to the heartlistener example after the fork for the new heartrate-game example was done. This patch applies the missing two patches. The first patch restricts the communication to Low Energy devices The second patch ensures that the device properly disables the heartrate notifications on disconnect events. Change-Id: Ia2904f2ae3d5cef22abcc9815c5e0c342370e83c Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'examples')
-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)