summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergyservice_osx.mm
diff options
context:
space:
mode:
authorTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-11-25 16:11:48 +0100
committerTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-12-01 12:10:36 +0100
commit63a158b2d53a4f18f118a95796c0386911e1e5fa (patch)
tree0c39dafd71c760fd4fdc6a1fbfc4063aeb000553 /src/bluetooth/qlowenergyservice_osx.mm
parentae3d26661aeaa2917ed35e5892648dea4caced04 (diff)
QLowEnergyController - writeDescriptor (OS X/iOS)
Core Bluetooth - based implementation. Change-Id: Ie642a13ae9a4d75401dd10648fac6eeee4123a3b Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/bluetooth/qlowenergyservice_osx.mm')
-rw-r--r--src/bluetooth/qlowenergyservice_osx.mm26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/bluetooth/qlowenergyservice_osx.mm b/src/bluetooth/qlowenergyservice_osx.mm
index f9c124e4..996de64b 100644
--- a/src/bluetooth/qlowenergyservice_osx.mm
+++ b/src/bluetooth/qlowenergyservice_osx.mm
@@ -221,8 +221,30 @@ bool QLowEnergyService::contains(const QLowEnergyDescriptor &descriptor) const
void QLowEnergyService::writeDescriptor(const QLowEnergyDescriptor &descriptor,
const QByteArray &newValue)
{
- Q_UNUSED(descriptor)
- Q_UNUSED(newValue)
+ if (!contains(descriptor))
+ return;
+
+ QLowEnergyControllerPrivateOSX *const controller = qt_mac_le_controller(d_ptr);
+ if (!controller)
+ return;
+
+ if (state() != ServiceDiscovered) {
+ d_ptr->setError(OperationError);
+ return;
+ }
+
+ if (descriptor.uuid() == QBluetoothUuid::ClientCharacteristicConfiguration) {
+ // Core Bluetooth:
+ //
+ // "You cannot use this method to write the value of a client configuration descriptor
+ // (represented by the CBUUIDClientCharacteristicConfigurationString constant),
+ // which describes how notification or indications are configured for a
+ // characteristic’s value with respect to a client. If you want to manage
+ // notifications or indications for a characteristic’s value, you must
+ // use the setNotifyValue:forCharacteristic: method instead."
+ } else {
+ controller->writeDescriptor(descriptor.d_ptr, descriptor.handle(), newValue);
+ }
}
QT_END_NAMESPACE