diff options
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()), |