diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-08-27 13:36:13 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-09-02 20:18:26 +0200 |
commit | 2da622742aaf2566edea43b541180a7fb23cb899 (patch) | |
tree | 7f632bc65937326f7dd2d81e3efe6a5fdefda1ec | |
parent | 4ab9c732a466dc793e5ec162a928d4350a29281c (diff) |
Rename descriptorChanged() to descriptorWritten()
This is the part of a change to be able to distinguish
characteristic write confirmations from characteristic
change notifications. Since descriptors
cannot receive notifications they won't have a
changed() signal and all existing
descriptorChanged() signals become descriptorWritten()
signals.
The changed() signal is emitted when a value notification
is received from the device. The written() signal is emitted
when a write request from the API user was successful.
Change-Id: Ief2491ead4723eaa1bca65a09a09c34458f33630
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r-- | examples/bluetooth/heartlistener/heartrate.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_bluez.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergydescriptor.cpp | 6 | ||||
-rw-r--r-- | src/bluetooth/qlowenergyservice.cpp | 12 | ||||
-rw-r--r-- | src/bluetooth/qlowenergyservice.h | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergyserviceprivate_p.h | 2 | ||||
-rw-r--r-- | tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp | 4 |
7 files changed, 16 insertions, 14 deletions
diff --git a/examples/bluetooth/heartlistener/heartrate.cpp b/examples/bluetooth/heartlistener/heartrate.cpp index 6567fb90..91fe41c1 100644 --- a/examples/bluetooth/heartlistener/heartrate.cpp +++ b/examples/bluetooth/heartlistener/heartrate.cpp @@ -215,7 +215,7 @@ void HeartRate::serviceScanDone() this, SLOT(serviceStateChanged(QLowEnergyService::ServiceState))); connect(m_service, SIGNAL(characteristicChanged(QLowEnergyCharacteristic,QByteArray)), this, SLOT(updateHeartRateValue(QLowEnergyCharacteristic,QByteArray))); - connect(m_service, SIGNAL(descriptorChanged(QLowEnergyDescriptor,QByteArray)), + connect(m_service, SIGNAL(descriptorWritten(QLowEnergyDescriptor,QByteArray)), this, SLOT(confirmedDescriptorWrite(QLowEnergyDescriptor,QByteArray))); m_service->discoverDetails(); diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp index 97eb429b..2fd0e325 100644 --- a/src/bluetooth/qlowenergycontroller_bluez.cpp +++ b/src/bluetooth/qlowenergycontroller_bluez.cpp @@ -799,7 +799,7 @@ void QLowEnergyControllerPrivate::processReply( } else { service->characteristicList[charHandle].descriptorList[descriptorHandle].value = newValue; QLowEnergyDescriptor descriptor(service, charHandle, descriptorHandle); - emit service->descriptorChanged(descriptor, newValue); + emit service->descriptorWritten(descriptor, newValue); } } break; diff --git a/src/bluetooth/qlowenergydescriptor.cpp b/src/bluetooth/qlowenergydescriptor.cpp index 976ee73f..270a8a68 100644 --- a/src/bluetooth/qlowenergydescriptor.cpp +++ b/src/bluetooth/qlowenergydescriptor.cpp @@ -52,10 +52,10 @@ QT_BEGIN_NAMESPACE and so on). The descriptor value may be written via the \l QLowEnergyService instance - that manages the service to which this descriptor belongs. the + that manages the service to which this descriptor belongs. The \l {QLowEnergyService::writeDescriptor()} function writes the new value. - The \l {QLowEnergyService::descriptorChanged()} signal - is emitted upon success. The \l value() of this object is automatically updated accordingly. + The \l {QLowEnergyService::descriptorWritten()} signal + is emitted upon success. The cahced \l value() of this object is updated accordingly. \sa QLowEnergyService, QLowEnergyCharacteristic */ diff --git a/src/bluetooth/qlowenergyservice.cpp b/src/bluetooth/qlowenergyservice.cpp index d60b4e81..ab0e0a43 100644 --- a/src/bluetooth/qlowenergyservice.cpp +++ b/src/bluetooth/qlowenergyservice.cpp @@ -224,7 +224,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QLowEnergyService::descriptorChanged(const QLowEnergyDescriptor &descriptor, const QByteArray &newValue) + \fn void QLowEnergyService::descriptorWritten(const QLowEnergyDescriptor &descriptor, const QByteArray &newValue) This signal is emitted when the value of \a descriptor is successfully changed to \a newValue. The change may have been caused @@ -255,8 +255,8 @@ QLowEnergyService::QLowEnergyService(QSharedPointer<QLowEnergyServicePrivate> p, this, SIGNAL(stateChanged(QLowEnergyService::ServiceState))); connect(p.data(), SIGNAL(characteristicChanged(QLowEnergyCharacteristic,QByteArray)), this, SIGNAL(characteristicChanged(QLowEnergyCharacteristic,QByteArray))); - connect(p.data(), SIGNAL(descriptorChanged(QLowEnergyDescriptor,QByteArray)), - this, SIGNAL(descriptorChanged(QLowEnergyDescriptor,QByteArray))); + connect(p.data(), SIGNAL(descriptorWritten(QLowEnergyDescriptor,QByteArray)), + this, SIGNAL(descriptorWritten(QLowEnergyDescriptor,QByteArray))); } /*! @@ -448,7 +448,8 @@ bool QLowEnergyService::contains(const QLowEnergyCharacteristic &characteristic) /*! Writes \a newValue as value for the \a characteristic. If the operation is successful, - the \l characteristicChanged() signal is emitted. + the \l characteristicChanged() signal is emitted; otherwise the \l CharacteristicWriteError + is emitted. The \a mode parameter determines whether the remote device should send a write confirmation. The to-be-written \a characteristic must support the relevant @@ -522,7 +523,8 @@ bool QLowEnergyService::contains(const QLowEnergyDescriptor &descriptor) const /*! Writes \a newValue as value for \a descriptor. If the operation is successful, - the \l descriptorChanged() signal is emitted. + the \l descriptorWritten() signal is emitted; otherwise the \l DescriptorWriteError + is emitted. A descriptor can only be written if this service is in the \l ServiceDiscovered state, belongs to the service and is writable. diff --git a/src/bluetooth/qlowenergyservice.h b/src/bluetooth/qlowenergyservice.h index 7bb2c0d3..e4612c8a 100644 --- a/src/bluetooth/qlowenergyservice.h +++ b/src/bluetooth/qlowenergyservice.h @@ -101,7 +101,7 @@ Q_SIGNALS: void stateChanged(QLowEnergyService::ServiceState newState); void characteristicChanged(const QLowEnergyCharacteristic &info, const QByteArray &value); - void descriptorChanged(const QLowEnergyDescriptor &info, + void descriptorWritten(const QLowEnergyDescriptor &info, const QByteArray &value); void error(QLowEnergyService::ServiceError error); diff --git a/src/bluetooth/qlowenergyserviceprivate_p.h b/src/bluetooth/qlowenergyserviceprivate_p.h index ec87da1f..9d41f21d 100644 --- a/src/bluetooth/qlowenergyserviceprivate_p.h +++ b/src/bluetooth/qlowenergyserviceprivate_p.h @@ -80,7 +80,7 @@ signals: void error(QLowEnergyService::ServiceError error); void characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue); - void descriptorChanged(const QLowEnergyDescriptor &descriptor, + void descriptorWritten(const QLowEnergyDescriptor &descriptor, const QByteArray &newValue); public: diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp index b282e943..a6d216aa 100644 --- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp +++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp @@ -1754,7 +1754,7 @@ void tst_QLowEnergyController::tst_writeDescriptor() // 3. Test writing to descriptor -> activate notifications QSignalSpy descChangedSpy(service, - SIGNAL(descriptorChanged(QLowEnergyDescriptor,QByteArray))); + SIGNAL(descriptorWritten(QLowEnergyDescriptor,QByteArray))); QSignalSpy charChangedSpy(service, SIGNAL(characteristicChanged(QLowEnergyCharacteristic,QByteArray))); @@ -1962,7 +1962,7 @@ void tst_QLowEnergyController::tst_writeDescriptorNoResponse() // 3. Enable notifications QSignalSpy descChangedSpy(service, - SIGNAL(descriptorChanged(QLowEnergyDescriptor,QByteArray))); + SIGNAL(descriptorWritten(QLowEnergyDescriptor,QByteArray))); QSignalSpy charChangedSpy(service, SIGNAL(characteristicChanged(QLowEnergyCharacteristic,QByteArray))); if (notification.value() != QByteArray::fromHex("0100")) { |