delay discovery restarts a bit so that we don't end up in a busy loop if the adapter is busy

pull/38/head
Michael Zanetti 2018-08-05 19:25:53 +02:00
parent 82c10cb03f
commit fa9ef3ef25
1 changed files with 7 additions and 1 deletions

View File

@ -2,6 +2,8 @@
#include "discoverymodel.h"
#include <QTimer>
BluetoothServiceDiscovery::BluetoothServiceDiscovery(DiscoveryModel *discoveryModel, QObject *parent) :
QObject(parent),
m_discoveryModel(discoveryModel)
@ -45,7 +47,11 @@ void BluetoothServiceDiscovery::discover()
qDebug() << "BluetoothServiceDiscovery: Start scanning for service" << m_nymeaServiceUuid.toString();
setDiscovering(true);
m_serviceDiscovery->setUuidFilter(m_nymeaServiceUuid);
m_serviceDiscovery->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
// Delay restarting as Bluez might not be ready just yet
QTimer::singleShot(500, this, [this]() {
m_serviceDiscovery->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
});
}
void BluetoothServiceDiscovery::stopDiscovery()