Update bluetooth low energy discovery behaviour
This commit is contained in:
parent
2b994b608d
commit
f9212cc64c
@ -135,6 +135,9 @@ void BluetoothDiscovery::onBluetoothHostModeChanged(const QBluetoothLocalDevice:
|
||||
|
||||
void BluetoothDiscovery::deviceDiscovered(const QBluetoothDeviceInfo &deviceInfo)
|
||||
{
|
||||
if (!deviceInfo.isValid())
|
||||
return;
|
||||
|
||||
BluetoothDeviceInfo *deviceInformation = new BluetoothDeviceInfo(deviceInfo);
|
||||
bool isLowEnergy = deviceInfo.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
|
||||
|
||||
@ -163,8 +166,6 @@ void BluetoothDiscovery::discoveryFinished()
|
||||
{
|
||||
qDebug() << "BluetoothDiscovery: Discovery finished";
|
||||
setDiscovering(false);
|
||||
if (m_enabled)
|
||||
start();
|
||||
}
|
||||
|
||||
void BluetoothDiscovery::onError(const QBluetoothDeviceDiscoveryAgent::Error &error)
|
||||
@ -183,6 +184,8 @@ void BluetoothDiscovery::start()
|
||||
if (m_discoveryAgent->isActive())
|
||||
m_discoveryAgent->stop();
|
||||
|
||||
m_deviceInfos->clearModel();
|
||||
|
||||
qDebug() << "BluetoothDiscovery: Start discovering.";
|
||||
m_discoveryAgent->start();
|
||||
setDiscovering(true);
|
||||
|
||||
@ -15,7 +15,6 @@ Page {
|
||||
imageSource: Qt.resolvedUrl("../images/refresh.svg")
|
||||
onClicked: {
|
||||
if (Engine.bluetoothDiscovery.bluetoothAvailable) {
|
||||
Engine.bluetoothDiscovery.deviceInfos.clearModel()
|
||||
Engine.bluetoothDiscovery.start()
|
||||
}
|
||||
}
|
||||
@ -24,27 +23,13 @@ Page {
|
||||
}
|
||||
|
||||
|
||||
property bool shouldDiscover: true
|
||||
|
||||
Component.onCompleted: Engine.bluetoothDiscovery.start()
|
||||
Connections {
|
||||
target: Engine.bluetoothDiscovery
|
||||
onDiscoveringChanged: {
|
||||
print("BT discovery changed:", Engine.bluetoothDiscovery.discovering, shouldDiscover)
|
||||
if (!Engine.bluetoothDiscovery.discovering && shouldDiscover) {
|
||||
Engine.bluetoothDiscovery.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setupDevice(name, btAddress) {
|
||||
shouldDiscover = false;
|
||||
Engine.bluetoothDiscovery.stop()
|
||||
pageStack.push(connectingPageComponent, { name: name, address: btAddress } )
|
||||
}
|
||||
|
||||
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
spacing: app.margins
|
||||
|
||||
Reference in New Issue
Block a user