Index: denali.pro.user =================================================================== diff -u -r93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7 -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae --- denali.pro.user (.../denali.pro.user) (revision 93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7) +++ denali.pro.user (.../denali.pro.user) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) @@ -1,6 +1,6 @@ - + EnvironmentId Index: sources/bluetooth/BluetoothInterface.cpp =================================================================== diff -u -r93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7 -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae --- sources/bluetooth/BluetoothInterface.cpp (.../BluetoothInterface.cpp) (revision 93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7) +++ sources/bluetooth/BluetoothInterface.cpp (.../BluetoothInterface.cpp) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) @@ -163,12 +163,6 @@ #define NOTIFY_LOCAL_ERROR_OFF notifyStateChange(MBluetooth(MBluetooth::eIS_Local_Error_Off )); #define NOTIFY_LOCAL_ERROR_INVALID notifyStateChange(MBluetooth(MBluetooth::eIS_Local_Error_Invalid )); #define NOTIFY_LOCAL_DISCONNECT notifyStateChange(MBluetooth(MBluetooth::eIS_Local_Disconnect , vAddress.toString()) ); -// ~~~~~~~~~~~ Pair -#define NOTIFY_PAIR_START notifyStateChange(MBluetooth(MBluetooth::eIS_Pair_Start , _device->remoteAddress().toString())); -#define NOTIFY_PAIR_DONE notifyStateChange(MBluetooth(MBluetooth::eIS_Pair_Done , vAddress.toString(), "", "", vPairing)); -#define NOTIFY_PAIR_CONFIRM notifyStateChange(MBluetooth(MBluetooth::eIS_Pair_Confirm , vAddress.toString(), "", vPin ) ); -#define NOTIFY_PAIR_PINCODE notifyStateChange(MBluetooth(MBluetooth::eIS_Pair_PinCode , vAddress.toString(), "", vPin ) ); -#define NOTIFY_PAIR_ERROR notifyStateChange(MBluetooth(MBluetooth::eIS_Pair_Error )); // ~~~~~~~~~~~ Scan #define NOTIFY_SCAN_DISCOVER notifyStateChange(MBluetooth(MBluetooth::eIS_Scan_Discover , \ vInfo.address().toString() , \ @@ -273,6 +267,7 @@ */ void BluetoothInterface::ondoScan() { + onstart(); // TODO: it may require in case the application needs to reset the Bluetooth Adapter. Or can be moved to Adapter Reset function(no implemented yet) if (_agent && _agent->isActive()) { NOTIFY_SCAN_REJECT return; @@ -350,7 +345,7 @@ case QBluetoothDeviceDiscoveryAgent::InputOutputError : NOTIFY_LOCAL_ERROR_IO break; default : NOTIFY_LOCAL_ERROR break; } - if ( _device ) _device->disconnectFromDevice(); + quitDevice(); } /*! @@ -396,6 +391,14 @@ return true; } +bool BluetoothInterface::reconnectToDevice() +{ + if ( ! isLocalValid() ) return false; + NOTIFY_DEVICE_START + _device->connectToDevice(); + return true; +} + /*! * \brief BluetoothInterface::discoverServices * \details The function to be called to start retrieving the remote Bluetooth device _device's services, and @@ -470,7 +473,11 @@ */ void BluetoothInterface::onDeviceError(QLowEnergyController::Error vError) { - NOTIFY_DEVICE_ERROR + // 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 ) + NOTIFY_DEVICE_ERROR + } void BluetoothInterface::onServiceCharacteristicChanged(const QLowEnergyCharacteristic &vCharacteristic, const QByteArray &vValue) { @@ -592,7 +599,7 @@ return; } service->readCharacteristic(detailBPFeat); - _connectionActive = true; + _reconnectionActive = true; } break; @@ -650,9 +657,8 @@ */ void BluetoothInterface::timerEvent(QTimerEvent *) { - if ( _connectionActive ) { - if ( _device ) - _device->connectToDevice(); + if ( _reconnectionActive ) { + reconnectToDevice(); } } @@ -677,6 +683,7 @@ bool BluetoothInterface::isLocalValid() { if (! _local->isValid() ) { NOTIFY_LOCAL_ERROR_INVALID + quitDevice(); return false; } return true; @@ -735,7 +742,7 @@ * \details quits and deletes the old remote device _device and the device info _temp. */ void BluetoothInterface::quitDevice() { - _connectionActive = false; + _reconnectionActive = false; if ( _device ) { NOTIFY_DEVICE_DONE quitServices(); // it seems safe to delete all the services when the device is deleted because the current discovered service may not apply to the next device. Index: sources/bluetooth/BluetoothInterface.h =================================================================== diff -u -r93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7 -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae --- sources/bluetooth/BluetoothInterface.h (.../BluetoothInterface.h) (revision 93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7) +++ sources/bluetooth/BluetoothInterface.h (.../BluetoothInterface.h) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) @@ -67,7 +67,7 @@ QBluetoothDeviceInfo _temp ; - bool _connectionActive = false ; + bool _reconnectionActive = false ; const quint16 _interval = 1000 ; // the interface timer base interval in mSec public: // 19 total bytes @@ -147,7 +147,8 @@ bool isDetailValid (const QLowEnergyCharacteristic &vDetail); bool isDeviceSupported ( const QString &vName ); - bool connectToDevice (); + bool connectToDevice (); + bool reconnectToDevice (); void discoverServices (); void discoverServicesDetails(); Index: sources/gui/qml/pages/settings/SettingsStack.qml =================================================================== diff -u -r028cb1403e8fcb2d2e9ab2aa1562f660124015b1 -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae --- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 028cb1403e8fcb2d2e9ab2aa1562f660124015b1) +++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) @@ -229,15 +229,15 @@ text.text : qsTr("SCAN") width : 300 isDefault : false - enabled : ! vBluetooth.scanInProgress - onClicked : vBluetooth.doScan() + enabled : vBluetooth.scanEnabled + onClicked : vBluetooth.doScan() } WaitDone { id : _scanIndication anchors.horizontalCenter : parent.horizontalCenter anchors.verticalCenter : _scanButton.verticalCenter diameter : _scanButton.height - visible : vBluetooth.scanInProgress + visible : ! vBluetooth.scanEnabled // done : _delegate.stepDone } Index: sources/model/settings/MBluetooth.h =================================================================== diff -u -r93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7 -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae --- sources/model/settings/MBluetooth.h (.../MBluetooth.h) (revision 93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7) +++ sources/model/settings/MBluetooth.h (.../MBluetooth.h) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) @@ -48,12 +48,6 @@ eIS_Scan_Stop , eIS_Scan_Done , - eIS_Pair_Start , - eIS_Pair_Error , - eIS_Pair_PinCode , - eIS_Pair_Confirm , - eIS_Pair_Done , - eIS_Device_Init , eIS_Device_Start , eIS_Device_Connect , Index: sources/view/settings/VBluetooth.cpp =================================================================== diff -u -r93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7 -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae --- sources/view/settings/VBluetooth.cpp (.../VBluetooth.cpp) (revision 93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7) +++ sources/view/settings/VBluetooth.cpp (.../VBluetooth.cpp) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) @@ -44,12 +44,15 @@ void View::VBluetooth::onStateChange(const Model::MBluetooth &vData) { - scanInProgress( ! ( vData.state == MBluetooth::eIS_Idle || - vData.state == MBluetooth::eIS_Device_Disconnect || - vData.state == MBluetooth::eIS_Device_Error || - vData.state == MBluetooth::eIS_Device_Error_Init || - vData.state == MBluetooth::eIS_Scan_NotFound || - vData.state == MBluetooth::eIS_Local_Disconnect )); + scanEnabled( ! (vData.state == MBluetooth::eIS_Close || + // local + vData.state == MBluetooth::eIS_Local_Init || + // device + vData.state == MBluetooth::eIS_Device_Connect || + // service + vData.state == MBluetooth::eIS_Service_Start || + vData.state == MBluetooth::eIS_Service_Discover || + vData.state == MBluetooth::eIS_Service_Detail )); switch (vData.state) { // The device name is not always available and the interface may be in investigation. @@ -78,7 +81,6 @@ case MBluetooth::eIS_Idle : message = "" ; break; case MBluetooth::eIS_Close : message = tr("BluetoothInterface Closed" ); break; // Used BluetoothInterface to be consistent with the - case MBluetooth::eIS_Local_Init : message = tr("The Bluetooth Adapter Is Ready %1" ).arg(_localAddr ); break; case MBluetooth::eIS_Local_Connect : message = tr("The Bluetooth Adapter Connected" ); break; case MBluetooth::eIS_Local_Disconnect : message = tr("The Bluetooth Adapter Disconnected" ); break; @@ -112,12 +114,6 @@ case MBluetooth::eIS_Service_Detail_Done : message = tr("Service Detail Done" ); break; case MBluetooth::eIS_Service_Done : message = tr("Service Scanning Finished" ); break; - case MBluetooth::eIS_Pair_Start : message = tr("Pairing ..." ); break; - case MBluetooth::eIS_Pair_Error : message = tr("Pairing Error" ); break; - case MBluetooth::eIS_Pair_PinCode : message = tr("Pairing PinCode" ); break; - case MBluetooth::eIS_Pair_Confirm : message = tr("Pairing Confirm" ); break; - case MBluetooth::eIS_Pair_Done : message = tr("Pairing Done" ); break; - // IMPORTANT: Do not use the "default:" to let compiler check for all the enumeration which are not handled. } Index: sources/view/settings/VBluetooth.h =================================================================== diff -u -r028cb1403e8fcb2d2e9ab2aa1562f660124015b1 -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae --- sources/view/settings/VBluetooth.h (.../VBluetooth.h) (revision 028cb1403e8fcb2d2e9ab2aa1562f660124015b1) +++ sources/view/settings/VBluetooth.h (.../VBluetooth.h) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) @@ -43,7 +43,7 @@ PROPERTY(QString , localName , "" ) PROPERTY(QString , localAddr , "" ) - PROPERTY(bool , scanInProgress , false ) + PROPERTY(bool , scanEnabled , true ) PROPERTY(QString , deviceName , "" ) PROPERTY(QString , deviceAddr , "" ) PROPERTY(QString , devicePin , "" )