Index: denali.pro.user =================================================================== diff -u -rc73feffa73c7fe073a7a7581144f5806dfc91beb -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- denali.pro.user (.../denali.pro.user) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) +++ denali.pro.user (.../denali.pro.user) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -1,6 +1,6 @@ - + EnvironmentId @@ -89,17 +89,17 @@ ProjectExplorer.Project.Target.0 - Desktop - Desktop Qt 5.15.10 GCC 64bit - Desktop Qt 5.15.10 GCC 64bit - qt.qt5.51510.gcc_64_kit + QdbLinuxOsType + Qt 5.15.10 (iMX8) + Qt 5.15.10 (iMX8) + {ada4083c-13b6-4ac8-a486-71ff00b060da} 0 0 0 0 - /home/denali/Projects/tmp/build/build-denali-Desktop_Qt_5_15_10_GCC_64bit-Debug - /home/denali/Projects/tmp/build/build-denali-Desktop_Qt_5_15_10_GCC_64bit-Debug + /home/denali/Projects2/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug + /home/denali/Projects2/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug true @@ -119,8 +119,7 @@ true - -b --tag denali >> denali - + -b --tag denali >> denali sha256sum %{buildDir} ProjectExplorer.ProcessStep @@ -152,11 +151,12 @@ 0 - /home/denali/Projects/tmp/build/build-denali-Desktop_Qt_5_15_10_GCC_64bit-Release - /home/denali/Projects/tmp/build/build-denali-Desktop_Qt_5_15_10_GCC_64bit-Release + /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Release + /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Release true + 0 0 /home/denali/Projects/application/imake.sh %{sourceDir} ProjectExplorer.ProcessStep @@ -173,8 +173,7 @@ true - -b --tag denali >> denali - + -b --tag denali >> denali sha256sum %{buildDir} ProjectExplorer.ProcessStep @@ -207,8 +206,8 @@ 0 - /home/denali/Projects/application/../build-denali-Desktop_Qt_5_15_10_GCC_64bit-Profile - /home/denali/Projects/build-denali-Desktop_Qt_5_15_10_GCC_64bit-Profile + /home/denali/Projects/application/../build-denali-Qt_5_15_10_iMX8-Profile + /home/denali/Projects/build-denali-Qt_5_15_10_iMX8-Profile true @@ -250,51 +249,74 @@ 3 - 0 + + true + Qdb.StopApplicationStep + + + + + + + + + true + RemoteLinux.RsyncDeployStep + + + + + + + -av + + 2 Deploy Deploy ProjectExplorer.BuildSteps.Deploy 1 false - ProjectExplorer.DefaultDeployConfiguration + Qt4ProjectManager.Qdb.QdbDeployConfiguration 1 true true true - 2 + 1 - Qt4ProjectManager.Qt4RunConfiguration:/home/denali/Projects/application/denali.pro - /home/denali/Projects/application/denali.pro - -K + denali + QdbLinuxRunConfiguration:/home/denali/Projects2/application/denali.pro + /home/denali/Projects2/application/denali.pro + /home/denali/Projects2/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali + /home/root/denali + 1 + --disable-alarm-no-minimize -acu -E false true - true false true - /home/denali/Projects/tmp/build/build-denali-Desktop_Qt_5_15_10_GCC_64bit-Debug 1 ProjectExplorer.Project.Target.1 - GenericLinuxOsType - Qt 5.15.10 (iMX8) - Qt 5.15.10 (iMX8) - {ada4083c-13b6-4ac8-a486-71ff00b060da} + Desktop + Desktop Qt 5.15.10 GCC 64bit + Desktop Qt 5.15.10 GCC 64bit + qt.qt5.51510.gcc_64_kit 0 0 0 0 - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug + /home/denali/Projects2/tmp/build/build-denali-Desktop_Qt_5_15_10_GCC_64bit-Debug + /home/denali/Projects2/tmp/build/build-denali-Desktop_Qt_5_15_10_GCC_64bit-Debug true @@ -314,7 +336,8 @@ true - -b --tag denali >> denali + -b --tag denali >> denali + sha256sum %{buildDir} ProjectExplorer.ProcessStep @@ -346,12 +369,11 @@ 0 - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Release - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Release + /home/denali/Projects/tmp/build/build-denali-Desktop_Qt_5_15_10_GCC_64bit-Release + /home/denali/Projects/tmp/build/build-denali-Desktop_Qt_5_15_10_GCC_64bit-Release true - 0 0 /home/denali/Projects/application/imake.sh %{sourceDir} ProjectExplorer.ProcessStep @@ -368,7 +390,8 @@ true - -b --tag denali >> denali + -b --tag denali >> denali + sha256sum %{buildDir} ProjectExplorer.ProcessStep @@ -401,8 +424,8 @@ 0 - /home/denali/Projects/application/../build-denali-Qt_5_15_10_iMX8-Profile - /home/denali/Projects/build-denali-Qt_5_15_10_iMX8-Profile + /home/denali/Projects/application/../build-denali-Desktop_Qt_5_15_10_GCC_64bit-Profile + /home/denali/Projects/build-denali-Desktop_Qt_5_15_10_GCC_64bit-Profile true @@ -444,180 +467,32 @@ 3 - - true - RemoteLinux.KillAppStep - - - - - - - - - true - RemoteLinux.DirectUploadStep - - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Release/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Release/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Release/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Release/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - - - 192.168.10.228 - 192.168.10.228 - 192.168.10.138 - 192.168.137.210 - 192.168.10.159 - 192.168.10.186 - 192.168.10.167 - 192.168.137.170 - 192.168.137.30 - 192.168.137.25 - 192.168.10.186 - 192.168.137.3 - 192.168.137.26 - 192.168.137.170 - 192.168.40.23 - 192.168.137.24 - 192.168.137.202 - 192.168.137.36 - 192.168.137.125 - 192.168.137.247 - - - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - /home/root - - - /opt/b2qt/3.1.18/sysroots/x86_64-pokysdk-linux - /opt/b2qt/3.1.18/sysroots/x86_64-pokysdk-linux - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots/x86_64-pokysdk-linux - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - /opt/b2qt/3.1.18/sysroots - - - 2023-01-17T18:18:03.749 - 2023-01-17T18:06:25.579 - 2023-02-02T09:06:00.862 - 2023-02-02T01:52:20.307 - 2023-01-24T18:19:13.179 - 2023-01-18T17:47:08.797 - 2023-02-02T19:40:15.813 - 2023-01-27T10:15:15.423 - 2023-02-02T02:30:48.337 - 2023-02-02T02:13:54.596 - 2023-01-18T20:13:36.296 - 2023-02-02T02:40:56.627 - 2023-02-01T05:00:56.449 - 2023-01-27T09:45:11.898 - 2023-01-24T17:29:54.849 - 2023-02-02T02:05:29.947 - 2023-02-02T01:46:50.167 - 2023-02-01T03:23:15.710 - 2023-02-02T02:07:25.922 - 2023-02-02T02:26:33.738 - - - 2023-01-17T18:17:25.000 - 2023-01-17T18:05:42.000 - 2023-02-02T09:05:22.000 - 2023-02-02T01:52:16.000 - 2023-01-24T18:18:58.000 - 2023-01-18T17:47:04.000 - 2023-02-02T19:39:36.000 - 2023-01-27T10:15:08.000 - 2023-02-02T02:31:01.000 - 2023-02-02T02:14:08.000 - 2023-01-18T20:13:33.000 - 2023-02-02T02:41:10.000 - 2023-02-01T05:00:51.000 - 2023-01-27T09:44:58.000 - 2023-01-24T17:30:03.000 - 2023-02-02T02:05:42.000 - 2023-02-02T01:47:02.000 - 2023-02-01T03:23:28.000 - 2023-02-02T02:07:21.000 - 2023-02-02T02:26:46.000 - - - 2 + 0 Deploy Deploy ProjectExplorer.BuildSteps.Deploy 1 false - DeployToGenericLinux + ProjectExplorer.DefaultDeployConfiguration 1 true true true - 1 + 2 - denali (on %{Device:Name}) - RemoteLinuxRunConfiguration:/home/denali/Projects/application/denali.pro - /home/denali/Projects/application/denali.pro - 1 - --disable-alarm-no-minimize + denali2 + Qt4ProjectManager.Qt4RunConfiguration:/home/denali/Projects2/application/denali.pro + /home/denali/Projects2/application/denali.pro false true + true false true - :0 1 Index: denali.qrc =================================================================== diff -u -r288fa90973888a57056998a7d645034b063ef893 -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- denali.qrc (.../denali.qrc) (revision 288fa90973888a57056998a7d645034b063ef893) +++ denali.qrc (.../denali.qrc) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -21,6 +21,7 @@ sources/gui/qml/pages/settings/SettingsROInput.qml sources/gui/qml/pages/settings/SettingsServicePassword.qml sources/gui/qml/pages/settings/SettingsManufacturingSetup.qml + sources/gui/qml/pages/settings/SettingsFactoryReset.qml sources/gui/qml/dialogs/PowerOff.qml Index: sources/cloudsync/CloudSyncController.cpp =================================================================== diff -u -r6d76149dca70e879f33bf6ed44203d0d06bc523a -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 6d76149dca70e879f33bf6ed44203d0d06bc523a) +++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -528,6 +528,10 @@ // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // writing the message into the buffer. LOG_APPED_UI( vInpBuff ); + // TODO TBD - Need to determine if need to add this code or change factory_reset.sh script +// if(!QFile::exists(_date_inp_File)){ +// Storage::FileHandler::makeFolder(_location); +// } if ( ! Storage::FileHandler::write(_date_inp_File, vInpBuff + "\n") ) { error = eError_LogFileInp; args = { _date_inp_File }; ok = false; goto lErr; } return ok; Index: sources/device/DeviceController.cpp =================================================================== diff -u -rc73feffa73c7fe073a7a7581144f5806dfc91beb -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -724,3 +724,56 @@ _macWireless = vMacWireless .trimmed(); _macBluetooth = vMacBluetooth .trimmed(); } + +///////////////////////////////////////////// DeviceFactoryReset +/*! + * \brief DeviceController::onAttributeRequest + * \details Calls the FactoryReset script with the model data DeviceFactoryResetRequestData + * \param vData - the model data + */ +void DeviceController::onAttributeRequest(const DeviceFactoryResetRequestData &vData) +{ + _deviceFactoryResetRequest._data = vData; + + // ----- check that script exists. + QString script; + if ( checkError( DeviceError::checkScript(script, Factory_Reset), _deviceFactoryResetResponse, script) ) + return; + + // ----- check if the process is not running + if ( _processFactoryReset.state() != QProcess::NotRunning ) { + checkError(DeviceError::eDevice_Scripts_Error_IsRunning, _deviceFactoryResetResponse); + return; + } + + + // ----- run the process + int timeout = 10000; + TimedProcess *timedProcess = new TimedProcess(&_processFactoryReset, script, timeout); + timedProcess->start(); + + MDeviceFactoryResetResponse model; + model._data.mAccepted = false; // will indirectly set the property factoryResetEnabled + model._data.mMessage = tr("Factory Reset started."); + didAttributeResponse(model.data()); +} + +/*! + * \brief DeviceController::onProcessFactoryResetExitCode + * \param vExitCode + * \param vStatus + */ +void DeviceController::onProcessFactoryResetExitCode(int vExitCode, QProcess::ExitStatus vStatus) +{ + // The Exit code in this script is not used. + // any other checking is done by UI Software at the moment this script is called. + // The only thing matters is the paired device info in text and it will be empty string if error happens. + MDeviceFactoryResetResponse model; + QByteArray deviceInfo = _processFactoryReset.readAll(); + if ( vStatus ) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status; + else deviceInfo = _processFactoryReset.readAll(); + model.fromByteArray( deviceInfo, &vExitCode ); + // DEBUG: qDebug() << model._data.mEchoInfo; + didAttributeResponse(model.data()); + LOG_APPED_UI(model.data().mMessage); +} Index: sources/device/DeviceError.h =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- sources/device/DeviceError.h (.../DeviceError.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/device/DeviceError.h (.../DeviceError.h) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -63,6 +63,7 @@ eDevice_BCuff_Error_Query_Addr , eDevice_CryptSetup_Error , + eDevice_FactoryReset_Error , eDevice_Error_End Index: sources/device/DeviceGlobals.h =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -175,49 +175,57 @@ DEVICE_DEV_PARENT ( BluetoothPairedReset ) \ DEVICE_DEV_PARENT ( BluetoothPairedQuery ) \ DEVICE_DEV_PARENT ( CryptSetup ) \ + DEVICE_DEV_PARENT ( FactoryReset ) \ #define DEVICE_DEV_INIT_CONNECTIONS_LIST \ DEVICE_DEV_INIT_CONNECTIONS ( Brightness ) \ DEVICE_DEV_INIT_CONNECTIONS ( BluetoothPairedReset ) \ DEVICE_DEV_INIT_CONNECTIONS ( BluetoothPairedQuery ) \ DEVICE_DEV_INIT_CONNECTIONS ( CryptSetup ) \ + DEVICE_DEV_INIT_CONNECTIONS ( FactoryReset ) \ #define DEVICE_DEV_DEFINITION_LIST \ DEVICE_DEV_DEFINITION ( Brightness ) \ DEVICE_DEV_DEFINITION ( BluetoothPairedReset ) \ DEVICE_DEV_DEFINITION ( BluetoothPairedQuery ) \ DEVICE_DEV_DEFINITION ( CryptSetup ) \ + DEVICE_DEV_DEFINITION ( FactoryReset ) \ /* ---------------------------- APP */ #define DEVICE_APP_INIT_CONNECTIONS_LIST \ DEVICE_APP_INIT_CONNECTIONS ( Brightness ) \ DEVICE_APP_INIT_CONNECTIONS ( BluetoothPairedReset ) \ DEVICE_APP_INIT_CONNECTIONS ( BluetoothPairedQuery ) \ DEVICE_APP_INIT_CONNECTIONS ( CryptSetup ) \ + DEVICE_APP_INIT_CONNECTIONS ( FactoryReset ) \ #define DEVICE_APP_BRIDGE_DEFINITION_LIST \ DEVICE_APP_BRIDGE_DEFINITION( Brightness ) \ DEVICE_APP_BRIDGE_DEFINITION( BluetoothPairedReset ) \ DEVICE_APP_BRIDGE_DEFINITION( BluetoothPairedQuery ) \ DEVICE_APP_BRIDGE_DEFINITION( CryptSetup ) \ + DEVICE_APP_BRIDGE_DEFINITION( FactoryReset ) \ /* ---------------------------- GUI */ #define DEVICE_GUI_BRIDGE_DEFINITION_LIST \ DEVICE_GUI_BRIDGE_DEFINITION( Brightness ) \ DEVICE_GUI_BRIDGE_DEFINITION( BluetoothPairedReset ) \ DEVICE_GUI_BRIDGE_DEFINITION( BluetoothPairedQuery ) \ DEVICE_GUI_BRIDGE_DEFINITION( CryptSetup ) \ + DEVICE_GUI_BRIDGE_DEFINITION( FactoryReset ) \ #define DEVICE_GUI_INIT_CONNECTIONS_LIST \ DEVICE_GUI_INIT_CONNECTIONS ( Brightness ) \ DEVICE_GUI_INIT_CONNECTIONS ( BluetoothPairedReset ) \ DEVICE_GUI_INIT_CONNECTIONS ( BluetoothPairedQuery ) \ DEVICE_GUI_INIT_CONNECTIONS ( CryptSetup ) \ + DEVICE_GUI_INIT_CONNECTIONS ( FactoryReset ) \ /* ---------------------------- VIEW */ #define DEVICE_VIEW_INIT_CONNECTIONS_LIST \ DEVICE_VIEW_INIT_CONNECTIONS( Brightness ) \ DEVICE_VIEW_INIT_CONNECTIONS( BluetoothPairedReset ) \ DEVICE_VIEW_INIT_CONNECTIONS( BluetoothPairedQuery ) \ DEVICE_VIEW_INIT_CONNECTIONS( CryptSetup ) \ + DEVICE_VIEW_INIT_CONNECTIONS( FactoryReset ) \ Index: sources/device/DeviceModels.cpp =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- sources/device/DeviceModels.cpp (.../DeviceModels.cpp) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/device/DeviceModels.cpp (.../DeviceModels.cpp) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -190,3 +190,34 @@ _data.mBrightnessPercent = HW2UI[ vSysVal ]; return Device::DeviceError::eDevice_OK; } + + +/*! + * \brief MDeviceFactoryResetResponse::fromByteArray + * \details Checks the response and sets up the mode data. + * \param vExitCode - Passed script exit code + * \return true if passed. + */ +bool MDeviceFactoryResetResponse::fromByteArray(const QByteArray &vByteArray, int *vExitCode) +{ + // initialize data + int error = 0; + _data.mAccepted = false; + + // check if the vExitCode passed and it has a value other than zero + if ( vExitCode && *vExitCode ){ _data.mReason = Device::DeviceError::eDevice_FactoryReset_Error; error = *vExitCode; } + else _data.mReason = Device::DeviceError::eDevice_OK; + + // if vExitCode is not zero go to error since the data is no longer valid + if ( _data.mReason ) goto lError; // non-zero Exit code + + // Now everything is good to extract the data + _data.mAccepted = true; + _data.mMessage = QObject::tr("The Factory Reset Command Complete."); goto lOut ; // normal return + +lError: + _data.mMessage = Device::DeviceError::deviceErrorText(static_cast(_data.mReason), error) + "\n" + vByteArray; + +lOut: + return _data.mAccepted; +} Index: sources/device/DeviceModels.h =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- sources/device/DeviceModels.h (.../DeviceModels.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/device/DeviceModels.h (.../DeviceModels.h) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -244,9 +244,42 @@ bool fromByteArray(const QByteArray &vByteArray, int *vExitCode = nullptr) override; }; + + +// ---------- MDeviceFactoryReset ---------- // +/*! + * \brief The MDeviceFactoryResetRequest class + * \details The model for the factory reset script call. + */ +class MDeviceFactoryResetRequest : public MDeviceRequestBase { +public: + struct Data { + QString mCommand = ""; + } _data; + + QString toString() { + return MDeviceRequestBase::toString("DeviceFactoryReset", { }); + } +}; + +/*! + * \brief The MDeviceFactoryResetResponse class + * \details The model for the CryptSetup script call returned value / response. + */ +class MDeviceFactoryResetResponse : public MDeviceResponseBase { +public: + struct Data : MDeviceResponseBase::Data { + } _data; + QVariantList parameters ( ) const override { return { }; } + QString infoText ( ) const override { return QString("DeviceFactoryReset"); } + Data data ( ) const { return _data; } + bool fromByteArray(const QByteArray &vByteArray, int *vExitCode = nullptr) override; +}; } + + typedef Model::MDeviceResponseBase ::Data DeviceResponseBaseData ; typedef Model::MDeviceBrightnessRequest ::Data DeviceBrightnessRequestData ; typedef Model::MDeviceBrightnessResponse::Data DeviceBrightnessResponseData ; @@ -259,3 +292,6 @@ typedef Model::MDeviceCryptSetupRequest ::Data DeviceCryptSetupRequestData ; typedef Model::MDeviceCryptSetupResponse::Data DeviceCryptSetupResponseData; + +typedef Model::MDeviceFactoryResetRequest ::Data DeviceFactoryResetRequestData ; +typedef Model::MDeviceFactoryResetResponse::Data DeviceFactoryResetResponseData; Index: sources/device/DeviceView.cpp =================================================================== diff -u -r99e5b87f73c3b849ba33a212ec84cf4bf6ef38f1 -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 99e5b87f73c3b849ba33a212ec84cf4bf6ef38f1) +++ sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -144,3 +144,28 @@ emit bluetoothPairedQueryChanged(vData.mInfo); response(true); } + +// ================================================= Factory Reset +void VDevice::doInitFactoryReset() { + // Nothing for now. +} + +void VDevice::onAttributeResponse(const DeviceFactoryResetResponseData &vData) { + // DEBUG : qDebug() << "HERE Response " << Q_FUNCT_INFO ; + // this has to be called to let Gui to set to old value that device controller provided. + status(vData.mMessage); + factoryResetEnabled(vData.mAccepted); + + accepted(vData.mAccepted); + reason (vData.mReason ); + + // has to be the last one + response(true); +} + +void VDevice::factoryResetRequest(const QString &vCommand) { + Q_UNUSED(vCommand) + // DEBUG : qDebug() << "HERE Request" << vCommand; + DeviceFactoryResetRequestData data; + emit didAttributeRequest(data); +} Index: sources/device/DeviceView.h =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- sources/device/DeviceView.h (.../DeviceView.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/device/DeviceView.h (.../DeviceView.h) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -50,6 +50,9 @@ ATTRIBUTE ( QString , cryptSetup , "", CryptSetup ) PROPERTY ( bool , cryptSetupEnabled , true ) + ATTRIBUTE ( QString , factoryReset , "", FactoryReset ) + PROPERTY ( bool , factoryResetEnabled , true ) + VIEW_DEC_CLASS(VDevice) }; } Index: sources/gui/qml/pages/settings/SettingsFactoryReset.qml =================================================================== diff -u --- sources/gui/qml/pages/settings/SettingsFactoryReset.qml (revision 0) +++ sources/gui/qml/pages/settings/SettingsFactoryReset.qml (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -0,0 +1,37 @@ +/*! + * + * Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file SettingsFactoryReset.qml + * \author (last) Behrouz NematiPour + * \date (last) 11-May-2023 + * \author (original) Behrouz NematiPour + * \date (original) 11-May-2023 + * + */ + +// Qt +import QtQuick 2.12 + +// Qml imports +import "qrc:/globals" +import "qrc:/pages" +import "qrc:/components" + +/*! + * \brief SettingsFactoryReset is the screen + * which asks for confirmation of performing a factory reset and doing it if confirmed + */ +UserConfirmation{ id: _root + confirmVisible : true + confirmEnabled : vDevice.factoryResetEnabled + itemIndex : SettingsStack.FactoryReset + backVisible : true + backEnabled : vDevice.factoryResetEnabled + title : qsTr("Factory Reset") + onBackClicked : _settingsHome.notificationText = "" + onConfirmClicked : vDevice.factoryReset = "start" +} Index: sources/gui/qml/pages/settings/SettingsStack.qml =================================================================== diff -u -rc73feffa73c7fe073a7a7581144f5806dfc91beb -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) +++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -105,7 +105,7 @@ _GuiView.manufactMode && serviceMode , // Device Configuration // && serviceMode added to make sure the service mode is confirmed by HD _GuiView.manufactMode && serviceMode , // DeviceRegistration // && serviceMode added to make sure the service mode is confirmed by HD false /* serviceMode phase 1 */ , // SWUpdate - serviceMode , // FactoryReset + _GuiView.manufactMode && serviceMode , // FactoryReset ] SettingsHome { id : _settingsHome @@ -169,6 +169,10 @@ push( _settingsDeviceConfiguration ) break + case SettingsStack.FactoryReset: + push( _serviceFactoryReset ) + break + default: console.debug("Unknown Index", vIndex) break @@ -187,6 +191,7 @@ SettingsManufacturingSetup { id: _settingsDeviceConfiguration } SettingsDeviceRegistration { id: _settingsDeviceRegistration } SettingsServicePassword { id: _servicePassword } + SettingsFactoryReset { id: _serviceFactoryReset } function gotoServiceMode( vservice ) { if ( ! _servicePassword.isPassword_Accepted ) return Index: sources/model/MModel.h =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- sources/model/MModel.h (.../MModel.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/model/MModel.h (.../MModel.h) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -286,6 +286,8 @@ REGISTER_METATYPE( DeviceBluetoothPairedQueryResponseData ) \ REGISTER_METATYPE( DeviceCryptSetupRequestData ) \ REGISTER_METATYPE( DeviceCryptSetupResponseData ) \ + REGISTER_METATYPE( DeviceFactoryResetRequestData) \ + REGISTER_METATYPE( DeviceFactoryResetResponseData) \ /* Settings */ \ REGISTER_METATYPE( SettingsData ) \ REGISTER_METATYPE( WifiNetworkData ) \ Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -160,7 +160,10 @@ const char *Bluetooth_Paired_Reset = "bluetooth_paired_clear.sh"; const char *Bluetooth_Paired_Query = "bluetooth_paired_query.sh"; - // Encrypted Partision - cryptsetup + // Encrypted Partition - cryptsetup const char *Crypt_Setup = "crypt_setup.sh"; + // Factory Reset + const char *Factory_Reset = "factory_reset.sh"; + } Index: sources/storage/StorageGlobals.h =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rf0ffeb8c9ec7a838f039b904ce253b001561b5db --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db) @@ -114,6 +114,9 @@ extern const char *Bluetooth_Paired_Reset; extern const char *Bluetooth_Paired_Query; - // Encrypted Partision - cryptsetup + // Encrypted Partition - cryptsetup extern const char *Crypt_Setup; + + // Factory Reset + extern const char *Factory_Reset; }