Index: sources/canbus/MessageDispatcher.cpp =================================================================== diff -u -rcbb246d6efa242f927f88ac5da518dedb2d63320 -rb7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9 --- sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision cbb246d6efa242f927f88ac5da518dedb2d63320) +++ sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision b7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9) @@ -874,6 +874,10 @@ bool ok = false; GuiActionType mActionId = vMessage.actionId; Sequence mSequence = vMessage.sequence; + + // UI shall acknowledge the messages is intended for UI. + if ( ! needsAcknow(vMessage.can_id)) return ok; // false + if (mSequence < 0) { ok = true; #ifndef DISABLE_ACKNOW_CHECKIN_MESSAGE_LOG @@ -969,3 +973,27 @@ { return _needsAcknow.contains(vActionId); } + +/*! + * \brief MessageDispatcher::needsAcknow + * \details List of the CAN channels which need Acknow + * \param vCan_Id - The message CANBus id + * \return true if needs an Acknow + */ +bool MessageDispatcher::needsAcknow(Can_Id vCan_Id) +{ + bool ok = true; + switch(vCan_Id) { // list if the channels UI shall not Ack + case eChlid_HD_DG : // 0x008, ///< HD => DG + case eChlid_DG_HD : // 0x010, ///< DG => HD + case eDialin_HD : // 0x400, ///< dialin => HD + case eHD_Dialin : // 0x401, ///< HD => dialin + case eDialin_DG : // 0x402, ///< dialin => DG + case eDG_Dialin : // 0x403, ///< DG => dialin + ok = false; break; + + default: break; + } + + return ok; +} Index: sources/canbus/MessageDispatcher.h =================================================================== diff -u -rcbb246d6efa242f927f88ac5da518dedb2d63320 -rb7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9 --- sources/canbus/MessageDispatcher.h (.../MessageDispatcher.h) (revision cbb246d6efa242f927f88ac5da518dedb2d63320) +++ sources/canbus/MessageDispatcher.h (.../MessageDispatcher.h) (revision b7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9) @@ -178,6 +178,7 @@ void framesTransmit (Can_Id vCan_Id, const FrameList &vFrameList); bool needsAcknow (GuiActionType vActionId); + bool needsAcknow (Can_Id vCan_Id); bool buildMessage (Can_Id vCan_Id, const QByteArray &vPayload); bool interpretMessage(const Message &vMessage); Index: sources/device/DeviceController.cpp =================================================================== diff -u -re60d099fd4fbada632a974b9fc95d4d2c9652b1a -rb7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision e60d099fd4fbada632a974b9fc95d4d2c9652b1a) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision b7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9) @@ -497,7 +497,7 @@ * 3 - get no error when in onProcessBrightnessExitCode : MDeviceResponse.toString() * - in case 3 the specific model _data has to be filled prior to the toString to have it in the log. */ -void DeviceController::onProcessBrightnessExitCode(int vExitCode) +void DeviceController::onProcessBrightnessExitCode(int vExitCode, QProcess::ExitStatus) { _deviceBrightnessResponse._data.mBrightnessPercent = _deviceBrightnessRequest._data.mBrightness_old * 10; // set to old value in case of error if ( ! checkError(static_cast(vExitCode), _deviceBrightnessResponse, _deviceBrightnessResponse.toString()) ) { // has no error @@ -521,6 +521,37 @@ } } +void DeviceController::onAttributeRequest(const DeviceBluetoothPairedResetRequestData &) +{ + // ----- check that script exists. + QString script; + if ( checkError( DeviceError::checkScript(script, Bluetooth_Paired_Reset), _deviceBluetoothPairedResetResponse, script) ) + return; + + // ----- check if the process is not running + if ( _processBluetoothPairedReset.state() != QProcess::NotRunning ) { + checkError(DeviceError::eDevice_Scripts_Error_IsRunning, _deviceBluetoothPairedResetResponse); + return; + } + + // ----- run the process + TimedProcess *timedProcess = new TimedProcess(&_processBluetoothPairedReset, script, 2000); + timedProcess->start(); +} + +void DeviceController::onProcessBluetoothPairedResetExitCode(int vExitCode, QProcess::ExitStatus vStatus) +{ + DeviceBluetoothPairedResetResponseData data; + data.mAccepted = vStatus == QProcess::NormalExit; + data.mReason = vExitCode; + QString msg; + if (data.mAccepted) msg = tr("Removed previously paired devices."); + else msg = tr("Unsuccessful removal of previously paired devices."); + data.mMessage = msg; + didAttributeResponse(data); + LOG_DEBUG(msg); +} + /*! * \brief DeviceController::doScreenshot * \details emit the screenshot signal to run that in Device controller thread Index: sources/device/DeviceController.h =================================================================== diff -u -re60d099fd4fbada632a974b9fc95d4d2c9652b1a -rb7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9 --- sources/device/DeviceController.h (.../DeviceController.h) (revision e60d099fd4fbada632a974b9fc95d4d2c9652b1a) +++ sources/device/DeviceController.h (.../DeviceController.h) (revision b7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9) @@ -18,6 +18,7 @@ #include #include #include +#include // Project #include "main.h" // Doxygen : do not remove @@ -33,6 +34,39 @@ namespace Device { +class TimedProcess : public QObject { + Q_OBJECT + + explicit TimedProcess(QObject *parent = nullptr) : QObject(parent) { } + int _id = 0; + int _interval = 0; + QProcess *_process = nullptr; + QString _command = ""; + +private slots: + void onFinish(int) { + killTimer(_id); + _process->kill(); + _process = nullptr; + deleteLater(); + } +public: + TimedProcess(QProcess *vProcess, const QString &vCommand, int vInterval) + : QObject(), _interval(vInterval), _process(vProcess), _command(vCommand) { + connect(_process, SIGNAL( finished(int)), + this , SLOT(onFinish (int))); + } + void start() { + _id = startTimer(_interval); + _process->start(_command); + } + +protected: + void timerEvent(QTimerEvent *) { + onFinish(-1); + } +}; + /*! * \brief The DeviceController class * \details This class is the device controller meaning all the device interactions and settings like Volume(Device), Brightness, WiFi, Date, Time, etc Index: sources/device/DeviceGlobals.h =================================================================== diff -u -rf38edd22f7b63694c21b83d6f4b69ea618390126 -rb7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9 --- sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision f38edd22f7b63694c21b83d6f4b69ea618390126) +++ sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision b7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9) @@ -72,20 +72,20 @@ _process##vATTRIBUTEFLC .setParent(this); #define DEVICE_DEV_DEFINITION( vATTRIBUTEFLC ) \ - QProcess _process##vATTRIBUTEFLC; \ + QProcess _process##vATTRIBUTEFLC; \ Model::MDevice##vATTRIBUTEFLC##Response _device##vATTRIBUTEFLC##Response; \ Model::MDevice##vATTRIBUTEFLC##Request _device##vATTRIBUTEFLC##Request ; \ Q_SIGNALS : void didAttributeResponse (const Device##vATTRIBUTEFLC##ResponseData &); \ private Q_SLOTS : void onAttributeRequest (const Device##vATTRIBUTEFLC##RequestData &vData); \ - private Q_SLOTS : void onProcess##vATTRIBUTEFLC##ExitCode(int vExitCode); \ + private Q_SLOTS : void onProcess##vATTRIBUTEFLC##ExitCode(int vExitCode, QProcess::ExitStatus vStatus); \ private : #define DEVICE_DEV_INIT_CONNECTIONS( vATTRIBUTEFLC ) \ - /* App -> Dev */ \ + /* App -> Dev //TODO: Add the error LOG connection */ \ connect(&_ApplicationController , SIGNAL(didAttributeRequest(const Device##vATTRIBUTEFLC##RequestData &)), \ this , SLOT( onAttributeRequest(const Device##vATTRIBUTEFLC##RequestData &))); \ - connect(&_process##vATTRIBUTEFLC, SIGNAL( finished(int)), \ - this, SLOT(onProcess##vATTRIBUTEFLC##ExitCode(int))); + connect(&_process##vATTRIBUTEFLC, SIGNAL( finished(int, QProcess::ExitStatus)), \ + this, SLOT(onProcess##vATTRIBUTEFLC##ExitCode(int, QProcess::ExitStatus))); /* ---------------------------- APP */ #define DEVICE_APP_BRIDGE_DEFINITION( vATTRIBUTEFLC ) \ @@ -142,29 +142,37 @@ /* ---------------------------- DEV */ #define DEVICE_DEV_PARENT_LIST \ DEVICE_DEV_PARENT ( Brightness ) \ + DEVICE_DEV_PARENT ( BluetoothPairedReset ) \ #define DEVICE_DEV_INIT_CONNECTIONS_LIST \ DEVICE_DEV_INIT_CONNECTIONS ( Brightness ) \ + DEVICE_DEV_INIT_CONNECTIONS ( BluetoothPairedReset ) \ #define DEVICE_DEV_DEFINITION_LIST \ DEVICE_DEV_DEFINITION ( Brightness ) \ + DEVICE_DEV_DEFINITION ( BluetoothPairedReset ) \ /* ---------------------------- APP */ #define DEVICE_APP_INIT_CONNECTIONS_LIST \ DEVICE_APP_INIT_CONNECTIONS ( Brightness ) \ + DEVICE_APP_INIT_CONNECTIONS ( BluetoothPairedReset ) \ #define DEVICE_APP_BRIDGE_DEFINITION_LIST \ DEVICE_APP_BRIDGE_DEFINITION( Brightness ) \ + DEVICE_APP_BRIDGE_DEFINITION( BluetoothPairedReset ) \ /* ---------------------------- GUI */ #define DEVICE_GUI_BRIDGE_DEFINITION_LIST \ DEVICE_GUI_BRIDGE_DEFINITION( Brightness ) \ + DEVICE_GUI_BRIDGE_DEFINITION( BluetoothPairedReset ) \ #define DEVICE_GUI_INIT_CONNECTIONS_LIST \ DEVICE_GUI_INIT_CONNECTIONS ( Brightness ) \ + DEVICE_GUI_INIT_CONNECTIONS ( BluetoothPairedReset ) \ /* ---------------------------- VIEW */ #define DEVICE_VIEW_INIT_CONNECTIONS_LIST \ DEVICE_VIEW_INIT_CONNECTIONS( Brightness ) \ + DEVICE_VIEW_INIT_CONNECTIONS( BluetoothPairedReset ) \ Index: sources/device/DeviceModels.h =================================================================== diff -u -r3c27d9d2f482df4a16352bb7cb2cceccac325556 -rb7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9 --- sources/device/DeviceModels.h (.../DeviceModels.h) (revision 3c27d9d2f482df4a16352bb7cb2cceccac325556) +++ sources/device/DeviceModels.h (.../DeviceModels.h) (revision b7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9) @@ -117,8 +117,32 @@ Data data () const; }; + +class MDeviceBluetoothPairedResetRequest : public MDeviceRequestBase { +public: + struct Data { + } _data; + + QString toString() { + return MDeviceRequestBase::toString("DeviceBluetoothPairedReset", { }); + } +}; + +class MDeviceBluetoothPairedResetResponse : public MDeviceResponseBase { +public: + struct Data : MDeviceResponseBase::Data { + } _data; + QVariantList parameters () const override { return { }; } + QString infoText () const override { return QString("DeviceBluetoothPairedReset") ; } + Data data () const; +}; + } + typedef Model::MDeviceResponseBase ::Data DeviceResponseBaseData ; typedef Model::MDeviceBrightnessRequest ::Data DeviceBrightnessRequestData ; typedef Model::MDeviceBrightnessResponse::Data DeviceBrightnessResponseData ; + +typedef Model::MDeviceBluetoothPairedResetRequest ::Data DeviceBluetoothPairedResetRequestData ; +typedef Model::MDeviceBluetoothPairedResetResponse::Data DeviceBluetoothPairedResetResponseData; Index: sources/device/DeviceView.cpp =================================================================== diff -u -rf38edd22f7b63694c21b83d6f4b69ea618390126 -rb7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9 --- sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision f38edd22f7b63694c21b83d6f4b69ea618390126) +++ sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision b7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9) @@ -75,3 +75,35 @@ response(true); } + +// developer implementation section +void VDevice::doInitBluetoothPairedReset() { + // DEBUG : + qDebug() << "HERE Init"; + DeviceBluetoothPairedResetRequestData data; + emit didAttributeRequest(data); +} + +void VDevice::bluetoothPairedResetRequest(const quint8 &) { + // DEBUG : + qDebug() << "HERE Request"; + // DeviceBluetoothPairedResetRequestData data; + // emit didAttributeRequest(data); +} + +void VDevice::onAttributeResponse(const DeviceBluetoothPairedResetResponseData &vData) { + // DEBUG : + qDebug() << "HERE Response" << vData.mAccepted << vData.mReason << vData.mMessage; + // this has to be called to let Gui to set to old value that device controller provided. + status(vData.mMessage); + if ( vData.mAccepted ) { + emit bluetoothPairedResetChanged(0); + } + + accepted(vData.mAccepted); + reason (vData.mReason ); + + // has to be the last one + response(true); +} + Index: sources/device/DeviceView.h =================================================================== diff -u -rfc329c788fe9453983072bee937ccbc95b4ed6e4 -rb7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9 --- sources/device/DeviceView.h (.../DeviceView.h) (revision fc329c788fe9453983072bee937ccbc95b4ed6e4) +++ sources/device/DeviceView.h (.../DeviceView.h) (revision b7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9) @@ -44,6 +44,8 @@ ATTRIBUTE ( quint8 , brightness , 0, Brightness ) + ATTRIBUTE ( quint8 , bluetoothPairedReset, 0, BluetoothPairedReset ) + VIEW_DEC_CLASS(VDevice) }; } Index: sources/gui/qml/pages/settings/SettingsBluetoothCuff.qml =================================================================== diff -u -r59fc5195a10eeb83ac60cf32a9123fb9c9f8ec8e -rb7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9 --- sources/gui/qml/pages/settings/SettingsBluetoothCuff.qml (.../SettingsBluetoothCuff.qml) (revision 59fc5195a10eeb83ac60cf32a9123fb9c9f8ec8e) +++ sources/gui/qml/pages/settings/SettingsBluetoothCuff.qml (.../SettingsBluetoothCuff.qml) (revision b7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9) @@ -113,15 +113,22 @@ width : 300 isDefault : false enabled : vBluetooth.scanEnabled && vBluetooth.isInvalid - onClicked : vBluetooth.doScan() + onClicked : { + vDevice.doInitBluetoothPairedReset() + } } + Connections { target: vDevice + onBluetoothPairedResetChanged : { + vBluetooth.doScan() + } + } + WaitDone { id : _scanIndication anchors.horizontalCenter : parent.horizontalCenter anchors.verticalCenter : _scanButton.verticalCenter diameter : _scanButton.height visible : ! vBluetooth.scanEnabled && ! vBluetooth.isInvalid // done : _delegate.stepDone } - - notificationText : vBluetooth.notification + notificationText : vBluetooth.notification || vDevice.status } Index: sources/model/MModel.h =================================================================== diff -u -r161d1431cc3507cd430f54af6aa47dab5145d472 -rb7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9 --- sources/model/MModel.h (.../MModel.h) (revision 161d1431cc3507cd430f54af6aa47dab5145d472) +++ sources/model/MModel.h (.../MModel.h) (revision b7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9) @@ -264,6 +264,8 @@ REGISTER_METATYPE( DeviceBrightnessRequestData ) \ REGISTER_METATYPE( DeviceBrightnessResponseData ) \ REGISTER_METATYPE( UIBloodPressureData ) \ + REGISTER_METATYPE( DeviceBluetoothPairedResetRequestData ) \ + REGISTER_METATYPE( DeviceBluetoothPairedResetResponseData ) \ /* Settings */ \ REGISTER_METATYPE( SettingsData ) \ REGISTER_METATYPE( WifiNetworkData ) \ Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -r9ae3b0d6624904693329309aaf8ff02784c17184 -rb7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9 --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 9ae3b0d6624904693329309aaf8ff02784c17184) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision b7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9) @@ -114,7 +114,6 @@ const char *Brightness_Set = "brightness_set.sh"; const char *Brightness_Get = "brightness_get.sh"; - // Cloud Sync - const char *CloudSync_Out_File = "cloudsync_out.log"; - const char *CloudSync_Inp_File = "cloudsync_inp.log"; + // Bluetooth + const char *Bluetooth_Paired_Reset = "bluetooth_remove_paired.sh"; } Index: sources/storage/StorageGlobals.h =================================================================== diff -u -r9ae3b0d6624904693329309aaf8ff02784c17184 -rb7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9 --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 9ae3b0d6624904693329309aaf8ff02784c17184) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision b7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9) @@ -82,7 +82,6 @@ extern const char *Brightness_Set; extern const char *Brightness_Get; - // Cloud Sync - extern const char *CloudSync_Out_File; - extern const char *CloudSync_Inp_File; + // Bluetooth + extern const char *Bluetooth_Paired_Reset; } Index: sources/view/settings/VBluetooth.cpp =================================================================== diff -u -raeb915075b9e13e5c1aaf2800ba6db03b6c24a0b -rb7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9 --- sources/view/settings/VBluetooth.cpp (.../VBluetooth.cpp) (revision aeb915075b9e13e5c1aaf2800ba6db03b6c24a0b) +++ sources/view/settings/VBluetooth.cpp (.../VBluetooth.cpp) (revision b7c9de054c6b7a1ca4bac9fbb0ec5d4ac06620a9) @@ -308,4 +308,5 @@ * \details calls the Bluetooth Interface scan to start discovering the Bluetooth devices. */ void View::VBluetooth::doScan() { - _BluetoothInterface.doScan(); } + _BluetoothInterface.doScan(); +}