From b299a75a1d90dfd44c0f11ad75665c087c9ea120 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Mon, 10 Nov 2014 10:46:57 +0100 Subject: More lowenergyscanner example fixes. This fixes a UI display bug and a hanging UI when the service discovery aborts with an error. Change-Id: Ic84d7b885d777360c8f1396e3973623c1d2c550a Reviewed-by: Timur Pocheptsov Reviewed-by: Alex Blasche --- examples/bluetooth/lowenergyscanner/device.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'examples/bluetooth/lowenergyscanner/device.cpp') diff --git a/examples/bluetooth/lowenergyscanner/device.cpp b/examples/bluetooth/lowenergyscanner/device.cpp index 1f1e11c4..b9c8b532 100644 --- a/examples/bluetooth/lowenergyscanner/device.cpp +++ b/examples/bluetooth/lowenergyscanner/device.cpp @@ -290,13 +290,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(sender()); if (!service) return; + + //! [les-chars] const QList chars = service->characteristics(); foreach (const QLowEnergyCharacteristic &ch, chars) { -- cgit v1.2.3