summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth
diff options
context:
space:
mode:
authorTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-12-05 10:58:47 +0100
committerTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-12-05 14:20:32 +0100
commit228b54c723a2f05e493eab6b67dece29ab7de687 (patch)
tree9a00eaedc9994a4e41b55a1a1b9f346efdb75624 /examples/bluetooth
parent3ff29159e8ca3deb2705aea92f673e0ea51c2aaa (diff)
Bluetooth example - lowenergyscanner (OS X and iOS)
Core Bluetooth hides addresses and uses unique UUIDs instead. This patch updates/adjusts lowenergyscanner example to work with UUIDs on iOS and OS X instead of (empty on these platforms) device addresses. Change-Id: Iad0b35250f434b736616fe60e356f2088e6dc279 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'examples/bluetooth')
-rw-r--r--examples/bluetooth/lowenergyscanner/device.cpp6
-rw-r--r--examples/bluetooth/lowenergyscanner/device.h1
-rw-r--r--examples/bluetooth/lowenergyscanner/deviceinfo.cpp8
3 files changed, 15 insertions, 0 deletions
diff --git a/examples/bluetooth/lowenergyscanner/device.cpp b/examples/bluetooth/lowenergyscanner/device.cpp
index 0891f040..7ba27ad1 100644
--- a/examples/bluetooth/lowenergyscanner/device.cpp
+++ b/examples/bluetooth/lowenergyscanner/device.cpp
@@ -138,6 +138,7 @@ QString Device::getUpdate()
void Device::scanServices(const QString &address)
{
// We need the current device for service discovery.
+
for (int i = 0; i < devices.size(); i++) {
if (((DeviceInfo*)devices.at(i))->getAddress() == address )
currentDevice.setDevice(((DeviceInfo*)devices.at(i))->getDevice());
@@ -157,7 +158,12 @@ void Device::scanServices(const QString &address)
setUpdate("Back\n(Connecting to device...)");
+#ifdef Q_OS_MAC
+ if (controller && m_previousAddress != currentDevice.getAddress()) {
+ m_previousAddress = currentDevice.getAddress();
+#else
if (controller && controller->remoteAddress() != currentDevice.getDevice().address()) {
+#endif
controller->disconnectFromDevice();
delete controller;
controller = 0;
diff --git a/examples/bluetooth/lowenergyscanner/device.h b/examples/bluetooth/lowenergyscanner/device.h
index a12f9e0e..756209da 100644
--- a/examples/bluetooth/lowenergyscanner/device.h
+++ b/examples/bluetooth/lowenergyscanner/device.h
@@ -119,6 +119,7 @@ private:
QList<QObject*> devices;
QList<QObject*> m_services;
QList<QObject*> m_characteristics;
+ QString m_previousAddress;
QString m_message;
bool connected;
QLowEnergyController *controller;
diff --git a/examples/bluetooth/lowenergyscanner/deviceinfo.cpp b/examples/bluetooth/lowenergyscanner/deviceinfo.cpp
index d6b7a734..d774cb22 100644
--- a/examples/bluetooth/lowenergyscanner/deviceinfo.cpp
+++ b/examples/bluetooth/lowenergyscanner/deviceinfo.cpp
@@ -39,6 +39,8 @@
**
****************************************************************************/
+#include <qbluetoothuuid.h>
+
#include "deviceinfo.h"
DeviceInfo::DeviceInfo()
@@ -52,7 +54,13 @@ DeviceInfo::DeviceInfo(const QBluetoothDeviceInfo &d)
QString DeviceInfo::getAddress() const
{
+#ifdef Q_OS_MAC
+ // On OS X and iOS we do not have addresses,
+ // only unique UUIDs generated by Core Bluetooth.
+ return device.deviceUuid().toString();
+#else
return device.address().toString();
+#endif
}
QString DeviceInfo::getName() const