diff --git a/nuki/bluez/bluetoothgattdescriptor.cpp b/nuki/bluez/bluetoothgattdescriptor.cpp index bb59f32c..35531c9a 100644 --- a/nuki/bluez/bluetoothgattdescriptor.cpp +++ b/nuki/bluez/bluetoothgattdescriptor.cpp @@ -76,6 +76,8 @@ BluetoothGattDescriptor::BluetoothGattDescriptor(const QDBusObjectPath &path, co processProperties(properties); + readValue(); + // QDBusPendingCall readingCall = m_descriptorInterface->asyncCall("GetAll", QVariantMap()); // QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(readingCall, this); // connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](){ @@ -158,11 +160,11 @@ void BluetoothGattDescriptor::onReadingFinished(QDBusPendingCallWatcher *call) void BluetoothGattDescriptor::onWritingFinished(QDBusPendingCallWatcher *call) { + QByteArray value = m_asyncWrites.take(call); QDBusPendingReply reply = *call; if (reply.isError()) { qCWarning(dcBluez()) << "Could not write descriptor" << m_uuid.toString() << reply.error().name() << reply.error().message(); } else { - QByteArray value = m_asyncWrites.take(call); qCDebug(dcBluez()) << "Async descriptor writing finished for" << m_uuid.toString() << value; emit writingFinished(value); } diff --git a/nuki/bluez/bluetoothmanager.cpp b/nuki/bluez/bluetoothmanager.cpp index 7facc9d8..01d21df3 100644 --- a/nuki/bluez/bluetoothmanager.cpp +++ b/nuki/bluez/bluetoothmanager.cpp @@ -181,6 +181,7 @@ void BluetoothManager::processInterfaceList(const QDBusObjectPath &objectPath, c QDBusObjectPath serviceObjectPath = qvariant_cast(properties.value("Service")); BluetoothGattService *service = findService(serviceObjectPath); if (service) + qCDebug(dcBluez()) << "Add characteristic" << serviceObjectPath.path() << properties << service; service->addCharacteristicInternally(objectPath, properties); } @@ -196,6 +197,7 @@ void BluetoothManager::processInterfaceList(const QDBusObjectPath &objectPath, c QDBusObjectPath characterisitcObjectPath = qvariant_cast(properties.value("Characteristic")); BluetoothGattCharacteristic *characteristic = findCharacteristic(characterisitcObjectPath); if (characteristic) + qCDebug(dcBluez()) << "Add descriptor" << characterisitcObjectPath.path() << properties << characteristic; characteristic->addDescriptorInternally(objectPath, properties); } diff --git a/nuki/nuki.cpp b/nuki/nuki.cpp index 30f3f946..2ee562dc 100644 --- a/nuki/nuki.cpp +++ b/nuki/nuki.cpp @@ -214,18 +214,18 @@ bool Nuki::enableNotificationsIndications(BluetoothGattCharacteristic *character return false; } - qCDebug(dcNuki()) << "Enable notifications on" << characteristic; - if (!characteristic->startNotifications()) { - qCDebug(dcNuki()) << "Failed to start notifications on" << characteristic; - return false; - } +// qCDebug(dcNuki()) << "Enable notifications on" << characteristic; +// if (!characteristic->startNotifications()) { +// qCDebug(dcNuki()) << "Failed to start notifications on" << characteristic; +// return false; +// } if (characteristic->properties().testFlag(BluetoothGattCharacteristic::Indicate)) { qCDebug(dcNuki()) << "Enable indications on" << characteristic; QByteArray configuration; QDataStream stream(&configuration, QIODevice::WriteOnly); stream.setByteOrder(QDataStream::LittleEndian); - stream << static_cast(0x02); + stream << static_cast(2); if (!clientConfiguration->writeValue(configuration)) { qCWarning(dcNuki()) << "Failed to write client configuration descriptor on" << characteristic; return false; @@ -590,6 +590,8 @@ void Nuki::setAvailable(bool available) if (m_available) { executeCurrentAction(); + + } else { // Finish any running actions finishCurrentAction(false);