diff options
author | Timur Pocheptsov <Timur.Pocheptsov@digia.com> | 2015-01-22 17:53:20 +0100 |
---|---|---|
committer | Timur Pocheptsov <Timur.Pocheptsov@digia.com> | 2015-01-23 09:58:13 +0100 |
commit | 769a597083a60dc530b9a28fe606dae6d1b02369 (patch) | |
tree | a85eb95e1b4b3d85e60ef52b77a44a5ec46c3c9c /examples | |
parent | 21cb8297c16cb8f700cabce68508665ca25066b0 (diff) |
Bluetooth LE - hearlistener example (OS X, iOS)
Workaround for CoreBluetooth's limitation (no addresses, only 'uuids').
Change-Id: I9ab83a403d4643df11320185eb473818ef798d70
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/bluetooth/heartlistener/deviceinfo.cpp | 12 | ||||
-rw-r--r-- | examples/bluetooth/heartlistener/deviceinfo.h | 2 | ||||
-rw-r--r-- | examples/bluetooth/heartlistener/heartrate.cpp | 7 |
3 files changed, 20 insertions, 1 deletions
diff --git a/examples/bluetooth/heartlistener/deviceinfo.cpp b/examples/bluetooth/heartlistener/deviceinfo.cpp index 5be9fcfe..0e832dff 100644 --- a/examples/bluetooth/heartlistener/deviceinfo.cpp +++ b/examples/bluetooth/heartlistener/deviceinfo.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ +#include <qbluetoothuuid.h> + #include "deviceinfo.h" DeviceInfo::DeviceInfo(const QBluetoothDeviceInfo &info): @@ -51,6 +53,16 @@ QBluetoothDeviceInfo DeviceInfo::getDevice() const return m_device; } +QString DeviceInfo::getAddress() const +{ +#ifdef Q_OS_MAC + // workaround for Core Bluetooth: + return m_device.deviceUuid().toString(); +#else + return m_device.address().toString(); +#endif +} + void DeviceInfo::setDevice(const QBluetoothDeviceInfo &device) { m_device = device; diff --git a/examples/bluetooth/heartlistener/deviceinfo.h b/examples/bluetooth/heartlistener/deviceinfo.h index a80f723b..af14547d 100644 --- a/examples/bluetooth/heartlistener/deviceinfo.h +++ b/examples/bluetooth/heartlistener/deviceinfo.h @@ -56,7 +56,7 @@ public: DeviceInfo(const QBluetoothDeviceInfo &device); void setDevice(const QBluetoothDeviceInfo &device); QString getName() const { return m_device.name(); } - QString getAddress() const { return m_device.address().toString(); } + QString getAddress() const; QBluetoothDeviceInfo getDevice() const; signals: diff --git a/examples/bluetooth/heartlistener/heartrate.cpp b/examples/bluetooth/heartlistener/heartrate.cpp index 91fe41c1..dd7371af 100644 --- a/examples/bluetooth/heartlistener/heartrate.cpp +++ b/examples/bluetooth/heartlistener/heartrate.cpp @@ -152,8 +152,15 @@ void HeartRate::connectToService(const QString &address) } //! [Connect signals] +#ifdef Q_OS_MAC + // with CoreBluetooth controller requires QBluetoothDeviceInfo to connect: + m_control = new QLowEnergyController(m_currentDevice.getDevice(), + this); + +#else m_control = new QLowEnergyController(m_currentDevice.getDevice().address(), this); +#endif connect(m_control, SIGNAL(serviceDiscovered(QBluetoothUuid)), this, SLOT(serviceDiscovered(QBluetoothUuid))); connect(m_control, SIGNAL(discoveryFinished()), |