From 97a76a6615f3a4451b3f3d71fd4861ceb0a66f9e Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 1 Sep 2023 20:24:30 +0200 Subject: [PATCH] Report an error if enabling notifications fails If enabling the notification fails, receiving data packets is not possible. Instead of silently ignoring this fatal problem and trying to continue, report the error back to the caller. Signed-off-by: Jef Driesen --- core/qt-ble.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp index a4f6f0b42..49dd52d1d 100644 --- a/core/qt-ble.cpp +++ b/core/qt-ble.cpp @@ -673,6 +673,12 @@ dc_status_t qt_ble_open(void **io, dc_context_t *, const char *devaddr, device_d ble->preferredService()->writeDescriptor(d, QByteArray::fromHex("0100")); WAITFOR(ble->descriptorWritten(), 1000); + if (!ble->descriptorWritten()) { + qDebug() << "Bluetooth: Failed to enable notifications for characteristic" << c.uuid(); + report_error("Bluetooth: Failed to enable notifications."); + delete ble; + return DC_STATUS_TIMEOUT; + } break; } }