delay discovery restarts a bit so that we don't end up in a busy loop if the adapter is busy
This commit is contained in:
parent
82c10cb03f
commit
fa9ef3ef25
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "discoverymodel.h"
|
#include "discoverymodel.h"
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
BluetoothServiceDiscovery::BluetoothServiceDiscovery(DiscoveryModel *discoveryModel, QObject *parent) :
|
BluetoothServiceDiscovery::BluetoothServiceDiscovery(DiscoveryModel *discoveryModel, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_discoveryModel(discoveryModel)
|
m_discoveryModel(discoveryModel)
|
||||||
@ -45,7 +47,11 @@ void BluetoothServiceDiscovery::discover()
|
|||||||
qDebug() << "BluetoothServiceDiscovery: Start scanning for service" << m_nymeaServiceUuid.toString();
|
qDebug() << "BluetoothServiceDiscovery: Start scanning for service" << m_nymeaServiceUuid.toString();
|
||||||
setDiscovering(true);
|
setDiscovering(true);
|
||||||
m_serviceDiscovery->setUuidFilter(m_nymeaServiceUuid);
|
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()
|
void BluetoothServiceDiscovery::stopDiscovery()
|
||||||
|
|||||||
Reference in New Issue
Block a user