From 0cf802e9dd963e5eb881a3e849beb4143d7c304c Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 10 Apr 2015 15:13:25 +0200 Subject: Android: Fix read/write error reports when failure during initial call The BluetoothGatt.[read|write][Characteristic|Descriptor]() functions may immediately return under certain circumstances such as writing a read-only characteristic. So far, this "synchronous" form of error reporting was not handled. Any read error during the initial service dioscovery and its related cache population continues to surpress any read errors. Change-Id: I4987f67f4a0d2afe58cd144a577a19e0f0d43b33 Reviewed-by: Timur Pocheptsov --- src/bluetooth/qlowenergycontroller_android.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/bluetooth/qlowenergycontroller_android.cpp') diff --git a/src/bluetooth/qlowenergycontroller_android.cpp b/src/bluetooth/qlowenergycontroller_android.cpp index 992427ff..f48c0e85 100644 --- a/src/bluetooth/qlowenergycontroller_android.cpp +++ b/src/bluetooth/qlowenergycontroller_android.cpp @@ -80,6 +80,8 @@ void QLowEnergyControllerPrivate::connectToDevice() this, &QLowEnergyControllerPrivate::descriptorWritten); connect(hub, &LowEnergyNotificationHub::characteristicChanged, this, &QLowEnergyControllerPrivate::characteristicChanged); + connect(hub, &LowEnergyNotificationHub::serviceError, + this, &QLowEnergyControllerPrivate::serviceError); } if (!hub->javaObject().isValid()) { @@ -563,6 +565,10 @@ void QLowEnergyControllerPrivate::characteristicChanged( void QLowEnergyControllerPrivate::serviceError( int attributeHandle, QLowEnergyService::ServiceError errorCode) { + // ignore call if it isn't really an error + if (errorCode == QLowEnergyService::NoError) + return; + QSharedPointer service = serviceForHandle(attributeHandle); Q_ASSERT(!service.isNull()); -- cgit v1.2.3