diff options
Diffstat (limited to 'examples/bluetooth/lowenergyscanner/device.cpp')
-rw-r--r-- | examples/bluetooth/lowenergyscanner/device.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/examples/bluetooth/lowenergyscanner/device.cpp b/examples/bluetooth/lowenergyscanner/device.cpp index 9175095c..0891f040 100644 --- a/examples/bluetooth/lowenergyscanner/device.cpp +++ b/examples/bluetooth/lowenergyscanner/device.cpp @@ -166,7 +166,11 @@ void Device::scanServices(const QString &address) //! [les-controller-1] if (!controller) { // Connecting signals and slots for connecting to LE services. +#ifdef Q_OS_MAC + controller = new QLowEnergyController(currentDevice.getDevice()); +#else controller = new QLowEnergyController(currentDevice.getDevice().address()); +#endif connect(controller, SIGNAL(connected()), this, SLOT(deviceConnected())); connect(controller, SIGNAL(error(QLowEnergyController::Error)), @@ -291,13 +295,24 @@ void Device::deviceDisconnected() void Device::serviceDetailsDiscovered(QLowEnergyService::ServiceState newState) { - if (newState != QLowEnergyService::ServiceDiscovered) + if (newState != QLowEnergyService::ServiceDiscovered) { + // do not hang in "Scanning for characteristics" mode forever + // in case the service discovery failed + // We have to queue the signal up to give UI time to even enter + // the above mode + if (newState != QLowEnergyService::DiscoveringServices) { + QMetaObject::invokeMethod(this, "characteristicsUpdated", + Qt::QueuedConnection); + } return; + } QLowEnergyService *service = qobject_cast<QLowEnergyService *>(sender()); if (!service) return; + + //! [les-chars] const QList<QLowEnergyCharacteristic> chars = service->characteristics(); foreach (const QLowEnergyCharacteristic &ch, chars) { |