diff options
-rw-r--r-- | examples/bluetooth/lowenergyscanner/characteristicinfo.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycharacteristicinfo.cpp | 11 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycharacteristicinfo.h | 11 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycharacteristicinfo_bluez.cpp | 3 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycharacteristicinfo_p.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycharacteristicinfo_p.h | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycharacteristicinfo_qnx.cpp | 5 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_bluez.cpp | 10 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_qnx.cpp | 10 | ||||
-rw-r--r-- | src/bluetooth/qlowenergydescriptorinfo.h | 1 |
10 files changed, 36 insertions, 21 deletions
diff --git a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp index 18b9e282..10b8fad6 100644 --- a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp +++ b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp @@ -88,7 +88,7 @@ QString CharacteristicInfo::getHandle() const QString CharacteristicInfo::getPermission() const { QString properties = "Properties:"; - int permission = m_characteristic.permissions(); + int permission = m_characteristic.properties(); if (permission & QLowEnergyCharacteristicInfo::Read) properties = properties + QStringLiteral(" Read"); if (permission & QLowEnergyCharacteristicInfo::Write) diff --git a/src/bluetooth/qlowenergycharacteristicinfo.cpp b/src/bluetooth/qlowenergycharacteristicinfo.cpp index efd2ec38..aea4be5e 100644 --- a/src/bluetooth/qlowenergycharacteristicinfo.cpp +++ b/src/bluetooth/qlowenergycharacteristicinfo.cpp @@ -61,10 +61,11 @@ QT_BEGIN_NAMESPACE */ /*! - \enum QLowEnergyCharacteristicInfo::Property + \enum QLowEnergyCharacteristicInfo::PropertyType This enum describes the properties of a characteristic. + \value Unknown The type is not known. \value Broadcasting Allow for the broadcasting of Generic Attributes (GATT) characteristic values. \value Read Allow the characteristic values to be read. \value WriteNoResponse Allow characteristic values without responses to be written. @@ -74,6 +75,8 @@ QT_BEGIN_NAMESPACE \value WriteSigned Permits signed writes of the GATT characteristic values. \value ExtendedProperty Additional characteristic properties are defined in the characteristic extended properties descriptor. + + \sa properties() */ /*! @@ -132,11 +135,11 @@ QBluetoothUuid QLowEnergyCharacteristicInfo::uuid() const } /*! - Returns permissions of the gatt characteristic. + Returns the properties of the gatt characteristic. */ -int QLowEnergyCharacteristicInfo::permissions() const +QLowEnergyCharacteristicInfo::PropertyTypes QLowEnergyCharacteristicInfo::properties() const { - return d_ptr->permission; + return d_ptr->properties; } /*! diff --git a/src/bluetooth/qlowenergycharacteristicinfo.h b/src/bluetooth/qlowenergycharacteristicinfo.h index dd1820ae..21dd48d7 100644 --- a/src/bluetooth/qlowenergycharacteristicinfo.h +++ b/src/bluetooth/qlowenergycharacteristicinfo.h @@ -52,14 +52,15 @@ QT_BEGIN_NAMESPACE class QBluetoothUuid; class QLowEnergyCharacteristicInfoPrivate; +//TODO rename class to QLowEnergyCharacteristic class Q_BLUETOOTH_EXPORT QLowEnergyCharacteristicInfo { friend class QLowEnergyController; friend class QLowEnergyControllerPrivate; public: - //TODO rename enum name - enum Property { + enum PropertyType { + Unknown = 0x00, Broadcasting = 0x01, Read = 0x02, WriteNoResponse = 0x04, @@ -69,6 +70,7 @@ public: WriteSigned = 0x40, ExtendedProperty = 0x80 }; + Q_DECLARE_FLAGS(PropertyTypes, PropertyType) QLowEnergyCharacteristicInfo(); QLowEnergyCharacteristicInfo(const QBluetoothUuid &uuid); @@ -84,7 +86,7 @@ public: void setValue(const QByteArray &value); QByteArray value() const; - int permissions() const; //TODO should be of Type QLowEnergyCharacteristicInfo::Property + QLowEnergyCharacteristicInfo::PropertyTypes properties() const; QString handle() const; //TODO should be int bool isNotificationCharacteristic() const; @@ -95,9 +97,10 @@ public: protected: QSharedPointer<QLowEnergyCharacteristicInfoPrivate> d_ptr; - }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QLowEnergyCharacteristicInfo::PropertyTypes) + QT_END_NAMESPACE #endif // QLOWENERGYCHARACTERISTICINFO_H diff --git a/src/bluetooth/qlowenergycharacteristicinfo_bluez.cpp b/src/bluetooth/qlowenergycharacteristicinfo_bluez.cpp index 5010ffa3..d7c92337 100644 --- a/src/bluetooth/qlowenergycharacteristicinfo_bluez.cpp +++ b/src/bluetooth/qlowenergycharacteristicinfo_bluez.cpp @@ -54,7 +54,8 @@ QT_BEGIN_NAMESPACE QLowEnergyCharacteristicInfoPrivate::QLowEnergyCharacteristicInfoPrivate() - : permission(0), notification (false), handle(QStringLiteral("0x0000")) + : properties(QLowEnergyCharacteristicInfo::Unknown), + notification (false), handle(QStringLiteral("0x0000")) { } diff --git a/src/bluetooth/qlowenergycharacteristicinfo_p.cpp b/src/bluetooth/qlowenergycharacteristicinfo_p.cpp index 8ae4ef8b..e0fe41ad 100644 --- a/src/bluetooth/qlowenergycharacteristicinfo_p.cpp +++ b/src/bluetooth/qlowenergycharacteristicinfo_p.cpp @@ -44,6 +44,8 @@ QT_BEGIN_NAMESPACE QLowEnergyCharacteristicInfoPrivate::QLowEnergyCharacteristicInfoPrivate() + : properties(QLowEnergyCharacteristicInfo::Unknown), + notification(false) { } diff --git a/src/bluetooth/qlowenergycharacteristicinfo_p.h b/src/bluetooth/qlowenergycharacteristicinfo_p.h index 74085d36..d779a57f 100644 --- a/src/bluetooth/qlowenergycharacteristicinfo_p.h +++ b/src/bluetooth/qlowenergycharacteristicinfo_p.h @@ -72,7 +72,7 @@ public: QString name; QBluetoothUuid uuid; QByteArray value; - int permission; + QLowEnergyCharacteristicInfo::PropertyType properties; bool notification; QString handle; int instance; diff --git a/src/bluetooth/qlowenergycharacteristicinfo_qnx.cpp b/src/bluetooth/qlowenergycharacteristicinfo_qnx.cpp index c0051ea9..d3f48609 100644 --- a/src/bluetooth/qlowenergycharacteristicinfo_qnx.cpp +++ b/src/bluetooth/qlowenergycharacteristicinfo_qnx.cpp @@ -55,8 +55,9 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(QT_BT_QNX) -QLowEnergyCharacteristicInfoPrivate::QLowEnergyCharacteristicInfoPrivate(): - permission(0), notification(false), handle(QStringLiteral("0x0000")), instance(-1) +QLowEnergyCharacteristicInfoPrivate::QLowEnergyCharacteristicInfoPrivate() + : properties(QLowEnergyCharacteristicInfo::Unknown), + notification(false), handle(QStringLiteral("0x0000")), instance(-1) { } diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp index 48bb5d88..24aef175 100644 --- a/src/bluetooth/qlowenergycontroller_bluez.cpp +++ b/src/bluetooth/qlowenergycontroller_bluez.cpp @@ -196,8 +196,10 @@ void QLowEnergyControllerPrivate::_q_replyReceived(const QString &reply) QLowEnergyCharacteristicInfo charInfo(charUuid); charInfo.d_ptr->handle = charHandle; - charInfo.d_ptr->permission = handleDetails.at(4).toUShort(0,0); - if (!(charInfo.d_ptr->permission & QLowEnergyCharacteristicInfo::Read)) + charInfo.d_ptr->properties = + static_cast<QLowEnergyCharacteristicInfo::PropertyType>( + handleDetails.at(4).toUShort(0,0)); + if (!(charInfo.d_ptr->properties & QLowEnergyCharacteristicInfo::Read)) qCDebug(QT_BT_BLUEZ) << "GATT characteristic: Read not permitted: " << charInfo.d_ptr->uuid; else m_leServices.at(i).d_ptr->m_readCounter++; @@ -367,7 +369,7 @@ void QLowEnergyControllerPrivate::readCharacteristicValue(int index) QLowEnergyServiceInfo info = m_leServices.at(index); for (int i = 0; i < info.d_ptr->characteristicList.size(); i++) { - if ((info.d_ptr->characteristicList.at(i).d_ptr->permission & QLowEnergyCharacteristicInfo::Read)) { + if ((info.d_ptr->characteristicList.at(i).d_ptr->properties & QLowEnergyCharacteristicInfo::Read)) { const QString uuidHandle = info.d_ptr->characteristicList.at(i).uuid().toString().remove(QLatin1Char('{')).remove(QLatin1Char('}')); const QString command = QStringLiteral("char-read-uuid ") + uuidHandle; process->executeCommand(command); @@ -442,7 +444,7 @@ void QLowEnergyControllerPrivate::disableNotification(const QLowEnergyCharacteri bool QLowEnergyControllerPrivate::write(const QLowEnergyCharacteristicInfo &characteristic) { if (process->isConnected() && characteristic.isValid()) { - if (QLowEnergyCharacteristicInfo::Write & characteristic.permissions()) { + if (QLowEnergyCharacteristicInfo::Write & characteristic.properties()) { writeValue(characteristic.handle(), characteristic.value()); return true; } else { diff --git a/src/bluetooth/qlowenergycontroller_qnx.cpp b/src/bluetooth/qlowenergycontroller_qnx.cpp index 079f67be..8492bedb 100644 --- a/src/bluetooth/qlowenergycontroller_qnx.cpp +++ b/src/bluetooth/qlowenergycontroller_qnx.cpp @@ -190,7 +190,9 @@ void QLowEnergyControllerPrivate::serviceConnected(const char *bdaddr, const cha characteristicInfo.d_ptr->handle = handleUuid; characteristicInfo.d_ptr->instance = instance; characteristicInfo.d_ptr->characteristic = allCharacteristicList[i]; - characteristicInfo.d_ptr->permission = allCharacteristicList[i].properties; + characteristicInfo.d_ptr->properties = + static_cast<QLowEnergyCharacteristicInfo::PropertyType>( + allCharacteristicList[i].properties); p->readDescriptors(characteristicInfo); p->readValue(characteristicInfo); //Subscribe only once since it is static function @@ -475,7 +477,7 @@ bool QLowEnergyControllerPrivate::enableNotification(const QLowEnergyCharacteris Q_EMIT q->error(characteristic, error); return false; } - if (!(characteristic.d_ptr->permission & QLowEnergyCharacteristicInfo::Notify)) { + if (!(characteristic.d_ptr->properties & QLowEnergyCharacteristicInfo::Notify)) { qCDebug(QT_BT_QNX) << "Notification changes not allowed"; error = QLowEnergyController::PermissionError; errorString = QStringLiteral("This characteristic does not support notifications."); @@ -515,7 +517,7 @@ bool QLowEnergyControllerPrivate::write(const QLowEnergyCharacteristicInfo &char return false; } - if (characteristic.permissions() & QLowEnergyCharacteristicInfo::Write) { + if (characteristic.properties() & QLowEnergyCharacteristicInfo::Write) { writeValue(characteristic.d_ptr->instance, characteristic.d_ptr->handle, characteristic.d_ptr->value); if (errorString == QString()) { return true; @@ -619,7 +621,7 @@ void QLowEnergyControllerPrivate::readDescriptors(QLowEnergyCharacteristicInfo & void QLowEnergyControllerPrivate::readValue(QLowEnergyCharacteristicInfo &characteristic) { - if ((characteristic.d_ptr->permission & QLowEnergyCharacteristicInfo::Read) == 0) { + if (!(characteristic.d_ptr->properties & QLowEnergyCharacteristicInfo::Read)) { qCDebug(QT_BT_QNX) << "GATT characteristic: Read not permitted"; return; } diff --git a/src/bluetooth/qlowenergydescriptorinfo.h b/src/bluetooth/qlowenergydescriptorinfo.h index 2840e1aa..64233776 100644 --- a/src/bluetooth/qlowenergydescriptorinfo.h +++ b/src/bluetooth/qlowenergydescriptorinfo.h @@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE class QLowEnergyCharacteristicInfo; class QLowEnergyDescriptorInfoPrivate; +//TODO rename to QLowEnergyDescriptor class Q_BLUETOOTH_EXPORT QLowEnergyDescriptorInfo { friend class QLowEnergyControllerPrivate; |