Index: sources/bluetooth/BluetoothInterface.cpp =================================================================== diff -u -rfb6d2ffcfd44a933380b21784bfaf5c827ec811d -r9dd6d10ac1164c651e8d536673641d1e90981207 --- sources/bluetooth/BluetoothInterface.cpp (.../BluetoothInterface.cpp) (revision fb6d2ffcfd44a933380b21784bfaf5c827ec811d) +++ sources/bluetooth/BluetoothInterface.cpp (.../BluetoothInterface.cpp) (revision 9dd6d10ac1164c651e8d536673641d1e90981207) @@ -1,4 +1,4 @@ -/*! +/*! * * Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. * \copyright @@ -541,6 +541,18 @@ */ void BluetoothInterface::onDeviceSelect(const BluetoothDeviceData &vDevice) { stopScan(); + + if ( isLocalValid() && isDeviceValid() ){ + // Check pair status, if connected to a bt device already, disconnect before connecting to selected + // bt device to avoid "device connection error" + bool isPaired = _local->pairingStatus(_device->remoteAddress()) == QBluetoothLocalDevice::Paired; + bool isAuthPaired = _local->pairingStatus(_device->remoteAddress()) == QBluetoothLocalDevice::AuthorizedPaired; + if ( isPaired || isAuthPaired ) { + quitDevice(); + } + } + + // Proceed to connect to selected device _temp = QBluetoothDeviceInfo(QBluetoothAddress(vDevice.addr), vDevice.name, QBluetoothDeviceInfo::HealthBloodPressureMonitor); connectToDevice(); } @@ -596,6 +608,7 @@ */ void BluetoothInterface::onDeviceError(QLowEnergyController::Error vError) { + //DEBUG: qDebug()<< "Device Error " << vError; bool isErrorUnknown = (vError == QLowEnergyController::UnknownError); if ( isErrorUnknown ) { // When polling to reconnect to the remote device, the application encounters an unknown @@ -606,6 +619,7 @@ // Code is opting to set _reconnectionActive to true to allow polling to continue since the device // is still paired and the error encountered is due to not being able to connect to the remote device. _reconnectionActive = true; + //DEBUG: qDebug()<< "unknown error : reconnection set to true"; } } Index: sources/gui/qml/pages/settings/SettingsBluetoothCuff.qml =================================================================== diff -u -r45e753bb6f0ffde4ebdb60f6658cbccdd440957f -r9dd6d10ac1164c651e8d536673641d1e90981207 --- sources/gui/qml/pages/settings/SettingsBluetoothCuff.qml (.../SettingsBluetoothCuff.qml) (revision 45e753bb6f0ffde4ebdb60f6658cbccdd440957f) +++ sources/gui/qml/pages/settings/SettingsBluetoothCuff.qml (.../SettingsBluetoothCuff.qml) (revision 9dd6d10ac1164c651e8d536673641d1e90981207) @@ -65,7 +65,7 @@ readonly property color selectedColor: Colors.borderButtonSelected readonly property color pairedColor: Colors.borderButton readonly property color normalColor: Colors.borderButtonUnselected - property bool selectedDevice: pair || addr === vBluetooth.pairedAddr + property bool selectedDevice: addr === vBluetooth.pairedAddr clip : true radius : 10 width : 500 - 10 // give room to scrollbar