From a7e67ace12d71162583b00b306060d21ad0a5580 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 4 Dec 2014 14:37:37 +0100 Subject: Client characteristic configuration (OS X and iOS) If client characteristic configuration descriptor has an indication/notification bit set - enable ("automatically" == no explicit user's request) notifications. Change-Id: I839aabd6f5513141f66c8e4467618b3edd523350 Reviewed-by: Alex Blasche --- src/bluetooth/osx/osxbtcentralmanager.mm | 5 +++++ src/bluetooth/qlowenergycontroller_osx.mm | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/bluetooth/osx/osxbtcentralmanager.mm b/src/bluetooth/osx/osxbtcentralmanager.mm index 73d9d5bc..733d73a6 100644 --- a/src/bluetooth/osx/osxbtcentralmanager.mm +++ b/src/bluetooth/osx/osxbtcentralmanager.mm @@ -530,6 +530,11 @@ using namespace QT_NAMESPACE; newDesc.uuid = qt_uuid(d.UUID); newDesc.value = qt_bytearray(static_cast(d.value)); descList[lastValidHandle] = newDesc; + // Check, if it's client characteristic configuration descriptor: + if (newDesc.uuid == QBluetoothUuid::ClientCharacteristicConfiguration) { + if (newDesc.value.size() && (newDesc.value[0] & 3)) + [peripheral setNotifyValue:YES forCharacteristic:c]; + } } newChar.descriptorList = descList; diff --git a/src/bluetooth/qlowenergycontroller_osx.mm b/src/bluetooth/qlowenergycontroller_osx.mm index ea22ac36..cde11f67 100644 --- a/src/bluetooth/qlowenergycontroller_osx.mm +++ b/src/bluetooth/qlowenergycontroller_osx.mm @@ -344,8 +344,11 @@ void QLowEnergyControllerPrivateOSX::characteristicUpdateNotification(QLowEnergy ServicePrivate service(serviceForHandle(charHandle)); if (service.isNull()) { - qCWarning(QT_BT_OSX) << "QLowEnergyControllerPrivateOSX::characteristicUpdateNotification(), " - "can not find service for characteristic handle " << charHandle; + // This can be an error (no characteristic found for this handle), + // it can also be that we set notify value before the service + // was reported (serviceDetailsDiscoveryFinished) - this happens, + // if we read a descriptor (characteristic client configuration), + // and it's (pre)set. return; } -- cgit v1.2.3