Index: sources/bluetooth/BluetoothInterface.cpp =================================================================== diff -u -r3e64d98e243484505a44d99b13826097cb6b01eb -r1d6adeff8df4dc9395d6a2aee3c7f33d903c4711 --- sources/bluetooth/BluetoothInterface.cpp (.../BluetoothInterface.cpp) (revision 3e64d98e243484505a44d99b13826097cb6b01eb) +++ sources/bluetooth/BluetoothInterface.cpp (.../BluetoothInterface.cpp) (revision 1d6adeff8df4dc9395d6a2aee3c7f33d903c4711) @@ -20,6 +20,7 @@ #include // Project +#include "ApplicationController.h" #include "Logger.h" // namespace @@ -295,6 +296,10 @@ connect(this , SIGNAL(didDeviceSelect (BluetoothDeviceData )), this , SLOT( onDeviceSelect (BluetoothDeviceData ))); + + connect(&_ApplicationController, SIGNAL(didAttributeResponse(const DeviceBluetoothPairedQueryResponseData &)), + this , SLOT( onAttributeResponse(const DeviceBluetoothPairedQueryResponseData &))); + } /*! @@ -511,10 +516,38 @@ * \param vDevice */ void BluetoothInterface::onDeviceSelect(const BluetoothDeviceData &vDevice) { + stopScan(); _temp = QBluetoothDeviceInfo(QBluetoothAddress(vDevice.addr), vDevice.name, QBluetoothDeviceInfo::HealthBloodPressureMonitor); connectToDevice(); } +void BluetoothInterface::onAttributeResponse(const DeviceBluetoothPairedQueryResponseData &vData) +{ + if ( ! vData.mAccepted ) { + LOG_DEBUG(vData.mMessage); + return; + } + + _tryingrepairActive = true; + // Notify the View that it is a new scan so clean up the list, and update screen status. + NOTIFY_SCAN_START + + // create a device info with the given paired device information + // to simulate the device discovered slot call + QBluetoothDeviceInfo info(QBluetoothAddress(vData.mAddr), vData.mName, 0); + info.setCoreConfigurations(QBluetoothDeviceInfo::LowEnergyCoreConfiguration); + onAgentDiscoverDevice(info); + + // since it is only one paired device, the device discovery finish is called to process the device. + onAgentDiscoverFinish(); + + // try to call to the device for the first time to make the device and initialize it. + BluetoothDeviceData data; + data.addr = vData.mAddr; + data.name = vData.mName; + onDeviceSelect(data); +} + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~ Remote Device Slots // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -539,6 +572,9 @@ */ void BluetoothInterface::onDeviceError(QLowEnergyController::Error vError) { + // if the device is trying to connect to the previously paired device and the device was not on at this moment it should go to the reconnection state. + if ( _tryingrepairActive ) _reconnectionActive = true; + // if reconnect is active it should display "Device Connecting ..." and shouldn't display the "Connection Error", // because we know we will always get the error since we are trying to connected to a device which is probably off. if ( ! _reconnectionActive )