aboutsummaryrefslogtreecommitdiffstats
path: root/core/qt-ble.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-08-21 15:47:10 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-08-22 19:35:58 -0700
commitf74328df0b550936c2d7f271461a368ef3078d30 (patch)
tree1d6ef842af38f8b40562371881e449c50628f38e /core/qt-ble.cpp
parentc87e0286022a7fbfcef4de183cdcdb15af15010c (diff)
downloadsubsurface-f74328df0b550936c2d7f271461a368ef3078d30.tar.gz
core/BLE: provide state and error updates during BLE discovery
This simply helps us see some possible errors while trying to talk to a device. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/qt-ble.cpp')
-rw-r--r--core/qt-ble.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp
index 4c8f08a2d..4e1410160 100644
--- a/core/qt-ble.cpp
+++ b/core/qt-ble.cpp
@@ -215,8 +215,16 @@ void BLEObject::addService(const QBluetoothUuid &newService)
auto service = controller->createServiceObject(newService, this);
if (service) {
- qDebug() << " .. starting discovery";
+ // provide some visibility into what's happening in the log
+ service->connect(service, &QLowEnergyService::stateChanged,[=](QLowEnergyService::ServiceState newState) {
+ qDebug() << " .. service state changed to" << newState;
+ });
+ service->connect(service, QOverload<QLowEnergyService::ServiceError>::of(&QLowEnergyService::error),
+ [=](QLowEnergyService::ServiceError newError) {
+ qDebug() << "error discovering service details" << newError;
+ });
services.append(service);
+ qDebug() << "starting service characteristics discovery";
service->discoverDetails();
}
}
@@ -360,6 +368,8 @@ dc_status_t BLEObject::select_preferred_service(void)
// Wait for each service to finish discovering
foreach (const QLowEnergyService *s, services) {
WAITFOR(s->state() != QLowEnergyService::DiscoveringServices, BLE_TIMEOUT);
+ if (s->state() == QLowEnergyService::DiscoveringServices)
+ qDebug() << " .. service " << s->serviceUuid() << "still hasn't completed discovery - trouble ahead";
}
// Print out the services for debugging