From f9212cc64c0e081e700cde915c17eb8c81cc94a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Tue, 17 Jul 2018 15:34:00 +0200 Subject: [PATCH] Update bluetooth low energy discovery behaviour --- .../wifisetup/bluetoothdiscovery.cpp | 7 +++++-- .../ui/connection/BluetoothDiscoveryPage.qml | 15 --------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/libnymea-app-core/wifisetup/bluetoothdiscovery.cpp b/libnymea-app-core/wifisetup/bluetoothdiscovery.cpp index 63728d4d..aacbeab7 100644 --- a/libnymea-app-core/wifisetup/bluetoothdiscovery.cpp +++ b/libnymea-app-core/wifisetup/bluetoothdiscovery.cpp @@ -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); diff --git a/nymea-app/ui/connection/BluetoothDiscoveryPage.qml b/nymea-app/ui/connection/BluetoothDiscoveryPage.qml index e0b36f9d..27b635d2 100644 --- a/nymea-app/ui/connection/BluetoothDiscoveryPage.qml +++ b/nymea-app/ui/connection/BluetoothDiscoveryPage.qml @@ -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