From 6ad924f42634aa71df54b53f7de98394ad2ce298 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Sun, 18 Oct 2020 01:37:09 +0200 Subject: [PATCH] - removed some debug messages - fixed rowCountChanged not being emited on model clear --- qbluetoothleuartclient.cpp | 20 +++++++++++--------- qbluetoothleuartdevicemodel.cpp | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/qbluetoothleuartclient.cpp b/qbluetoothleuartclient.cpp index cd0f4f8..c803641 100644 --- a/qbluetoothleuartclient.cpp +++ b/qbluetoothleuartclient.cpp @@ -177,7 +177,7 @@ void QBluetoothLeUartClient::handleDeviceDiscovered(const QBluetoothDeviceInfo & { // Is it a BLE device? if (device.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) { - qWarning() << "Discovered BLE Device: name: " << device.name() << " Address: " << device.address().toString() << " UUIDs: " << device.serviceUuids(); + //qWarning() << "Discovered BLE Device: name: " << device.name() << " Address: " << device.address().toString() << " UUIDs: " << device.serviceUuids(); // ignore all devices that to not support our service if(!device.serviceUuids().contains(QBluetoothUuid(this->uartServiceUUID))) return; @@ -210,6 +210,8 @@ void QBluetoothLeUartClient::handleDeviceScanError(QBluetoothDeviceDiscoveryAgen emit this->scanningErrorOccured(InputOutputError); else emit this->scanningErrorOccured(UnknownError); + + this->stopScanningForDevices(); } // ---------------------------------- @@ -218,11 +220,11 @@ void QBluetoothLeUartClient::handleDeviceScanError(QBluetoothDeviceDiscoveryAgen void QBluetoothLeUartClient::handleServiceDiscovered(const QBluetoothUuid &uuid){ - qDebug() << "Found service with ID: " << uuid; + //qDebug() << "Found service with ID: " << uuid; if(uuid == QBluetoothUuid(QUuid(this->uartServiceUUID))){ foundValidUARTService =true; - qDebug() << "UART service found!"; + //qDebug() << "UART service found!"; } } @@ -232,12 +234,12 @@ void QBluetoothLeUartClient::handleServiceScanDone(){ bluetoothService=0; if(foundValidUARTService){ - qDebug() << "Connecting to UART service..."; + //qDebug() << "Connecting to UART service..."; bluetoothService = bluetoothController->createServiceObject(QBluetoothUuid(QUuid(this->uartServiceUUID)),this); } if(!bluetoothService){ - qDebug() <<"UART service not found"; + //qDebug() <<"UART service not found"; this->disconnectFromDevice(); return; } @@ -260,7 +262,7 @@ void QBluetoothLeUartClient::handleControllerError(QLowEnergyController::Error e void QBluetoothLeUartClient::handleDeviceConnected() { - qDebug() << "Device connected"; + //qDebug() << "Device connected"; bluetoothController->discoverServices(); setState(ScanningForService); } @@ -268,7 +270,7 @@ void QBluetoothLeUartClient::handleDeviceConnected() void QBluetoothLeUartClient::handleDeviceDisconnected() { this->setState(Idle); - qDebug() << "UART service disconnected"; + //qDebug() << "UART service disconnected"; qWarning() << "Remote device disconnected"; } @@ -287,7 +289,7 @@ void QBluetoothLeUartClient::handleServiceStateChange(QLowEnergyService::Service //looking for the RX characteristic const QLowEnergyCharacteristic TxChar = bluetoothService->characteristic(QBluetoothUuid(QUuid(this->rxUUID))); if (!TxChar.isValid()){ - qDebug() << "Rx characteristic not found"; + //qDebug() << "Rx characteristic not found"; this->disconnectFromDevice(); return; } @@ -295,7 +297,7 @@ void QBluetoothLeUartClient::handleServiceStateChange(QLowEnergyService::Service //looking for the TX characteristic const QLowEnergyCharacteristic RxChar = bluetoothService->characteristic(QBluetoothUuid(QUuid(this->txUUID))); if (!RxChar.isValid()) { - qDebug() << "Tx characteristic not found"; + //qDebug() << "Tx characteristic not found"; this->disconnectFromDevice(); return; } diff --git a/qbluetoothleuartdevicemodel.cpp b/qbluetoothleuartdevicemodel.cpp index 012944a..232f007 100644 --- a/qbluetoothleuartdevicemodel.cpp +++ b/qbluetoothleuartdevicemodel.cpp @@ -68,4 +68,6 @@ void QBluetoothLeUartDeviceModel::clear() { this->availableDevices.clear(); this->endResetModel(); + + emit this->rowCountChanged(); }