diff options
Diffstat (limited to 'examples/bluetooth/lowenergyscanner')
-rw-r--r-- | examples/bluetooth/lowenergyscanner/device.cpp | 6 | ||||
-rw-r--r-- | examples/bluetooth/lowenergyscanner/device.h | 1 | ||||
-rw-r--r-- | examples/bluetooth/lowenergyscanner/deviceinfo.cpp | 8 |
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 |