mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
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>
This commit is contained in:
parent
c87e028602
commit
f74328df0b
1 changed files with 11 additions and 1 deletions
|
@ -215,8 +215,16 @@ void BLEObject::addService(const QBluetoothUuid &newService)
|
||||||
|
|
||||||
auto service = controller->createServiceObject(newService, this);
|
auto service = controller->createServiceObject(newService, this);
|
||||||
if (service) {
|
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);
|
services.append(service);
|
||||||
|
qDebug() << "starting service characteristics discovery";
|
||||||
service->discoverDetails();
|
service->discoverDetails();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,6 +368,8 @@ dc_status_t BLEObject::select_preferred_service(void)
|
||||||
// Wait for each service to finish discovering
|
// Wait for each service to finish discovering
|
||||||
foreach (const QLowEnergyService *s, services) {
|
foreach (const QLowEnergyService *s, services) {
|
||||||
WAITFOR(s->state() != QLowEnergyService::DiscoveringServices, BLE_TIMEOUT);
|
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
|
// Print out the services for debugging
|
||||||
|
|
Loading…
Reference in a new issue