summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergyservice_osx.mm
diff options
context:
space:
mode:
authorTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-12-05 18:48:55 +0100
committerTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-12-08 10:42:18 +0100
commitdfc0a00c4fdde773e4e8154a8b51488fd10831d0 (patch)
treed5ff3697c3f006e5c17d613c5e5ee4bd2986f44b /src/bluetooth/qlowenergyservice_osx.mm
parent776f23147a90f8d9c394a00574d365fec57ff904 (diff)
QLowEnergyController - bug fixes (OS X, iOS)
Several problems found by qlowenergycontroller auto test: - Core Bluetooth in its didWriteCharacteristicValue callback does not have this new updated value, but the old one, to avoid additional characteristic read I have to cache this value in writeCharacteristic and report it later from the callback as it's already done for client characteristic configuration. - writeDescriptor with state != ServiceDiscovered (can happen after disconnectFromDevice) should set an error. - setNotifyValue did not check that value has the wrong length ( > 2 bytes) - this also should be an error. - Fix a key mismatch - in setNotifyValue remember descrptor's handle, not the characteristic's handle. - Remove annoying qCWarnings from didUpdateNotifyValue - it happens very often that we set this value in 'automatic' mode, without 'writeDescriptor' request. Change-Id: If3955f0e1364587b96403d23f2f8da28e6723e87 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/bluetooth/qlowenergyservice_osx.mm')
-rw-r--r--src/bluetooth/qlowenergyservice_osx.mm13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/bluetooth/qlowenergyservice_osx.mm b/src/bluetooth/qlowenergyservice_osx.mm
index cb1c1f30..2e961c0c 100644
--- a/src/bluetooth/qlowenergyservice_osx.mm
+++ b/src/bluetooth/qlowenergyservice_osx.mm
@@ -184,15 +184,13 @@ void QLowEnergyService::writeCharacteristic(const QLowEnergyCharacteristic &ch,
if (!contains(ch))
return;
- if (state() != ServiceDiscovered) {
+ QLowEnergyControllerPrivateOSX *const controller = qt_mac_le_controller(d_ptr);
+
+ if (state() != ServiceDiscovered || !controller) {
d_ptr->setError(QLowEnergyService::OperationError);
return;
}
- QLowEnergyControllerPrivateOSX *const controller = qt_mac_le_controller(d_ptr);
- if (!controller)
- return;
-
// Don't write if properties don't permit it
if (mode == WriteWithResponse && (ch.properties() & QLowEnergyCharacteristic::Write))
controller->writeCharacteristic(ch.d_ptr, ch.attributeHandle(), newValue, true);
@@ -227,10 +225,7 @@ void QLowEnergyService::writeDescriptor(const QLowEnergyDescriptor &descriptor,
return;
QLowEnergyControllerPrivateOSX *const controller = qt_mac_le_controller(d_ptr);
- if (!controller)
- return;
-
- if (state() != ServiceDiscovered) {
+ if (state() != ServiceDiscovered || !controller) {
d_ptr->setError(OperationError);
return;
}