summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergycharacteristicdata.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@theqtcompany.com>2015-12-02 15:02:47 +0100
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-12-04 14:17:33 +0000
commit38b765206c352cc88123a03025024b3e5e368a4a (patch)
tree189a37106251c87d499b1122bafa1b06ca3a4753 /src/bluetooth/qlowenergycharacteristicdata.cpp
parentb0a0b2572a5060c268f96a77716e7ea4e3065da4 (diff)
Bluetooth LE: Implement ATT access permissions.
Change-Id: I456d083d45569ea8d61f0a659f72646d653143d1 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/bluetooth/qlowenergycharacteristicdata.cpp')
-rw-r--r--src/bluetooth/qlowenergycharacteristicdata.cpp49
1 files changed, 47 insertions, 2 deletions
diff --git a/src/bluetooth/qlowenergycharacteristicdata.cpp b/src/bluetooth/qlowenergycharacteristicdata.cpp
index a64af7a3..f11779a5 100644
--- a/src/bluetooth/qlowenergycharacteristicdata.cpp
+++ b/src/bluetooth/qlowenergycharacteristicdata.cpp
@@ -51,6 +51,8 @@ struct QLowEnergyCharacteristicDataPrivate : public QSharedData
QLowEnergyCharacteristic::PropertyTypes properties;
QList<QLowEnergyDescriptorData> descriptors;
QByteArray value;
+ QBluetooth::AttAccessConstraints readConstraints;
+ QBluetooth::AttAccessConstraints writeConstraints;
};
/*!
@@ -157,6 +159,44 @@ void QLowEnergyCharacteristicData::addDescriptor(const QLowEnergyDescriptorData
}
/*!
+ Specifies that clients need to fulfill \a constraints to read the value of this characteristic.
+ */
+void QLowEnergyCharacteristicData::setReadConstraints(QBluetooth::AttAccessConstraints constraints)
+{
+ d->readConstraints = constraints;
+}
+
+/*!
+ Returns the constraints needed for a client to read the value of this characteristic.
+ If \l properties() does not include \l QLowEnergyCharacteristic::Read, this value is irrelevant.
+ By default, there are no read constraints.
+ */
+QBluetooth::AttAccessConstraints QLowEnergyCharacteristicData::readConstraints() const
+{
+ return d->readConstraints;
+}
+
+/*!
+ Specifies that clients need to fulfill \a constraints to write the value of this characteristic.
+ */
+void QLowEnergyCharacteristicData::setWriteConstraints(QBluetooth::AttAccessConstraints constraints)
+{
+ d->writeConstraints = constraints;
+}
+
+/*!
+ Returns the constraints needed for a client to write the value of this characteristic.
+ If \l properties() does not include either of \l QLowEnergyCharacteristic::Write,
+ \l QLowEnergyCharacteristic::WriteNoResponse and \l QLowEnergyCharacteristic::WriteSigned,
+ this value is irrelevant.
+ By default, there are no write constraints.
+ */
+QBluetooth::AttAccessConstraints QLowEnergyCharacteristicData::writeConstraints() const
+{
+ return d->writeConstraints;
+}
+
+/*!
Returns true if and only if this characteristic is valid, that is, it has a non-null UUID.
*/
bool QLowEnergyCharacteristicData::isValid() const
@@ -175,8 +215,13 @@ bool QLowEnergyCharacteristicData::isValid() const
*/
bool operator==(const QLowEnergyCharacteristicData &cd1, const QLowEnergyCharacteristicData &cd2)
{
- return cd1.d == cd2.d || (cd1.uuid() == cd2.uuid() && cd1.properties() == cd2.properties()
- && cd1.descriptors() == cd2.descriptors() && cd1.value() == cd2.value());
+ return cd1.d == cd2.d || (
+ cd1.uuid() == cd2.uuid()
+ && cd1.properties() == cd2.properties()
+ && cd1.descriptors() == cd2.descriptors()
+ && cd1.value() == cd2.value()
+ && cd1.readConstraints() == cd2.readConstraints()
+ && cd1.writeConstraints() == cd2.writeConstraints());
}
/*!