Index: scripts/crypt_setup.sh =================================================================== diff -u --- scripts/crypt_setup.sh (revision 0) +++ scripts/crypt_setup.sh (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -0,0 +1,110 @@ +#!/bin/bash +########################################################################### +# +# Copyright (c) 2022-2023 Diality Inc. - All Rights Reserved. +# +# 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 crypt_setup.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 15-May-2023 +# @author (original) Behrouz NematiPour +# @date (original) 15-May-2023 +# +############################################################################ + + +ERR_CRYPTSETUP_UNKNOWN=100 + +ERR_CRYPTSETUP_USAGE=101 +ERR_CRYPTSETUP_PASSWORD=102 + +ERR_CRYPTSETUP_UMOUNT=111 +ERR_CRYPTSETUP_CLOSE=112 + +ERR_CRYPTSETUP_CREATE_MKDIR=121 +ERR_CRYPTSETUP_CREATE_FORMAT=122 +ERR_CRYPTSETUP_CREATE_OPEN=123 +ERR_CRYPTSETUP_CREATE_MKFS=124 +ERR_CRYPTSETUP_CREATE_MOUNT=125 + +ERR_CRYPTSETUP_MOUNT_OPEN=131 +ERR_CRYPTSETUP_MOUNT_MOUNT=132 + +LOC_DEV="/dev/mmcblk0p7" +LOC_DIR="configurations" +LOC_MAP="/dev/mapper/"$LOC_DIR +LOC_VAR="/var/"$LOC_DIR + +function checkPassword() { + if [ "$PASSWORD" == "" ]; then + echo "setup command missing password argument" + exit $ERR_CRYPTSETUP_PASSWORD + fi +} + +function checkOutput() { + if [ "$3" == "" ]; then + out=` eval "$1" 2>&1` + else + out=`echo $3 | eval "$1" 2>&1` + fi + if [ "$?" -ne 0 ]; then + echo $out + exit $2 + fi +} + +function unmount_luks_partition() +{ + checkOutput "umount $LOC_VAR " $ERR_CRYPTSETUP_UNMOUNT_UNMOUNT + checkOutput "cryptsetup luksClose $LOC_DIR " $ERR_CRYPTSETUP_UNMOUNT_CLOSE +} + +function create_luks_partition() +{ + umount_luks_partition + + checkOutput "mkdir -p $LOC_VAR " $ERR_CRYPTSETUP_CREATE_MKDIR + checkOutput "cryptsetup luksFormat $LOC_DEV " $ERR_CRYPTSETUP_CREATE_FORMAT $PASSWORD + checkOutput "cryptsetup luksOpen $LOC_DEV $LOC_DIR" $ERR_CRYPTSETUP_CREATE_OPEN $PASSWORD + checkOutput "mkfs.ext4 $LOC_MAP " $ERR_CRYPTSETUP_CREATE_MKFS + checkOutput "mount -t ext4 $LOC_MAP $LOC_VAR" $ERR_CRYPTSETUP_CREATE_MOUNT +} + +function mount_luks_partition() +{ + checkOutput "cryptsetup luksOpen $LOC_DEV $LOC_DIR" $ERR_CRYPTSETUP_MOUNT_OPEN $PASSWORD + checkOutput "mount -t ext4 $LOC_MAP $LOC_VAR" $ERR_CRYPTSETUP_MOUNT_MOUNT +} + +function handleCommand() { + # Handle the first argument to script, one of start, stop, erase, restart, force-reload or status + case $1 in + setup) + checkPassword + create_luks_partition + ;; + + mount) + checkPassword + mount_luks_partition + ;; + + umount) + unmount_luks_partition + ;; + + *) + echo "unknown command" + exit $ERR_CRYPTSETUP_UNKNOWN + ;; + + esac +} + +handleCommand $1 $2 + +exit 0 Index: scripts/run.sh =================================================================== diff -u -r9c7a790376d07de7ddaa67e39d47102d68693c87 -r0e122c98700951af539d9f47c5578e26d640fcc7 --- scripts/run.sh (.../run.sh) (revision 9c7a790376d07de7ddaa67e39d47102d68693c87) +++ scripts/run.sh (.../run.sh) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -15,6 +15,15 @@ # ############################################################################ + +time_start=$(date +%s) + +echo nameserver 8.8.8.8 > /etc/resolv.conf +echo nameserver 192.168.10.20 >> /etc/resolv.conf +echo nameserver 192.168.10.21 > /etc/resolv.conf +systemctl start systemd-resolved.service + + echo "HOME : $HOME " > /home/root/post.debug HOME="$1" source ./globals.sh @@ -24,6 +33,7 @@ echo "COUT : $COUT " >> /home/root/post.debug echo "POSTLOG : $POSTLOG " >> /home/root/post.debug + # cleanup the POST log file post_log_clear post_err_clear @@ -43,9 +53,12 @@ #setting up ethernet----------------------- Ethernet post_log_dash " Ethernet " -udhcpc eth0 & +ieth=eth0 +udhcpc --timeout=5 --retries=1 -n -i $ieth +post_log "$(ip addr show $ieth)" # -details -statistics + #setting up can interface ----------------- CANBus post_log_dash " CANBus " #current settings can be retrieved by the command below @@ -93,6 +106,45 @@ fi +# ----------------------------------------- WiFi +post_log_dash " WiFi " + +# create the wpa supplicant folder for conf storing +iwlan=wlan0 +WPA_SUPPLICANT_DIR="/etc/wpa_supplicant/" +WPA_SUPPLICANT_CNF="wpa_supplicant-$iwlan.conf" +mkdir -p $WPA_SUPPLICANT_DIR + +# remove any software blocks +rfkill unblock wlan + +if [[ ! -z $(dmesg | grep "wlan: driver loaded") ]]; then + post_log_pass "$POSTMSG_WIFI$POSTMSG_POSTFIX_PASSED [driver]" + post_log "$(dmesg | grep -i wlan:)" + + # start the wpa_supplicant service + systemctl start wpa_supplicant@$iwlan.service + post_log "start wpa_supplicant service" + if [ $? -eq 0 ]; then + post_log_pass "$POSTMSG_WIFI$POSTMSG_POSTFIX_PASSED [service]" + # try to connect to WiFi + if [ -f $WPA_SUPPLICANT_DIR$WPA_SUPPLICANT_CNF ]; then + post_log_dash " WiFi Connection " + killall udhcpc + post_log "connecting to WiFi" + # run this manually in terminal if didn't work on bootup + udhcpc --timeout=5 --retries=2 -n -i $iwlan + fi + post_log "$(ip link show $iwlan)" # -details -statistics + else + post_log_fail "$POSTMSG_WIFI$POSTMSG_POSTFIX_FAILED" + post_log "$(systemctl --failed | grep wpa)" + fi +else + post_log_fail "$POSTMSG_WIFI$POSTMSG_POSTFIX_FAILED" +fi + + # ----------------------------------------- Bluetooth post_log_dash " Bluetooth " /usr/share/silex-uart/silex-uart.sh start 1>> $POSTOUT 2>> $POSTERR @@ -124,34 +176,6 @@ fi -# ----------------------------------------- WiFi -post_log_dash " WiFi " - -# create the wpa supplicant folder for conf storing -WPA_SUPPLICANT_DIR="/etc/wpa_supplicant/" -mkdir -p $WPA_SUPPLICANT_DIR - -# remove any software blocks -rfkill unblock wlan - -if [[ ! -z $(dmesg | grep "wlan: driver loaded") ]]; then - post_log_pass "$POSTMSG_WIFI$POSTMSG_POSTFIX_PASSED" - post_log "$(dmesg | grep -i wlan:)" - post_log "$(ip link show wlan0)" # -details -statistics -else - post_log_fail "$POSTMSG_WIFI$POSTMSG_POSTFIX_FAILED" -fi - -# start the wpa_supplicant service -systemctl start wpa_supplicant@wlan0.service -if [ $? -eq 0 ]; then -    post_log_pass "$POSTMSG_WIFI$POSTMSG_POSTFIX_PASSED" -else -    post_log_fail "$POSTMSG_WIFI$POSTMSG_POSTFIX_FAILED" -    post_log      "$(systemctl --failed | grep wpa)" -fi - - # ----------------------------------------- Sha256Sum post_log_dash " Sha256Sum " #check the denali applicatoin checksum @@ -164,7 +188,11 @@ fi -# ----------------------------------------- CloudSync +# ----------------------------------------- Cloud +post_log_dash " CloudSystem " +post_log "$(ip addr show $iwlan)" # -details -statistics +post_log "$(ping device-api.diality.qa.kebormed.com -I $iwlan -c 3 -4)" + post_log_dash " CloudSync " if [ -d $HOME/$CLOUDSYNC_FOLDER ]; then # moving/ backing up the previous treatment logs so the new buff starts with fresh sequence @@ -195,8 +223,14 @@ #launching denali application DENALI_VERSION="$($HOME/$DENALI_BIN -v)" if [ -n "$DENALI_VERSION" ]; then - post_log_pass "$DENALI_VERSION" # log UI Software version - $HOME/$DENALI_BIN -u -C & # -C to disable cloudsync for now sync it blocks the system and no cloudsync has been installed. + post_log_pass "$($HOME/$DENALI_BIN -v)" # log UI Software version + # Note: + # The denali application needs to run with -E for the first time during manufacturing. + # Ther need to be an indication in the application itself to go to the manufacturing mode (-E). + # otherwise on each update it want to set to -E mode + # a good indication would be the Service Password, and it will be implemented soon. + # The -E has been removed for now from run.sh to prevent the setuation mentioned above. + $HOME/$DENALI_BIN -Kauk & else post_log_fail "Unknown Applicaion Version" fi @@ -205,6 +239,8 @@ # ----------------------------------------- END # tag the end time in the POST log file post_log "End: $(timestamp)" +time_end=$(date +%s) +post_log "time spent: "$(( $time_end - $time_start ))" seconds" post_log_star " ***** " exit 0 Index: sources/device/DeviceController.cpp =================================================================== diff -u -r7c86f3854db9ad02d95681203198d75a0d65c9fa -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 7c86f3854db9ad02d95681203198d75a0d65c9fa) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -256,7 +256,7 @@ static bool mOIsReady = false; bool mCIsReady = false; static bool mOIsReadOnly = false; bool mCIsReadOnly = false; static qint64 mOAvailable = 0; qint64 mCAvailable = 0; - static quint8 mOPercent = 0; quint8 mCPercent = 0; + static quint8 mOPercent = 0; quint8 mCPercent = 0; qint64 mCTotal = 0; @@ -477,15 +477,16 @@ vModel._data.mAccepted = false ; vModel._data.mReason = vError ; vModel._data.mMessage = DeviceError::deviceErrorText(vError, vError); - LOG_APPED(src + vModel._data.mMessage + " " + vExtraLogInfo); + LOG_APPED(" ," + src + vModel._data.mMessage + " " + vExtraLogInfo); emit didAttributeResponse(vModel._data); return true; } return false; } +///////////////////////////////////////////// DeviceBrightness /*! - * \brief DeviceController::doBrightness + * \brief DeviceController::onAttributeRequest * \details Sets the brightness level * \param vBrightness */ @@ -548,6 +549,61 @@ } } +///////////////////////////////////////////// DeviceCryptSetup +/*! + * \brief DeviceController::onAttributeRequest + * \details Calls the CryptSetup script with the model data DeviceCryptSetupRequestData + * \param vData - the model data + */ +void DeviceController::onAttributeRequest(const DeviceCryptSetupRequestData &vData) +{ + _deviceCryptSetupRequest._data = vData; + + // ----- check that script exists. + QString script; + if ( checkError( DeviceError::checkScript(script, Crypt_Setup), _deviceCryptSetupResponse, script) ) + return; + + // ----- check if the process is not running + if ( _processCryptSetup.state() != QProcess::NotRunning ) { + checkError(DeviceError::eDevice_Scripts_Error_IsRunning, _deviceCryptSetupResponse); + return; + } + + + // ----- run the process + int timeout = 10000; + TimedProcess *timedProcess = new TimedProcess(&_processCryptSetup, script, timeout, { _deviceCryptSetupRequest._data.mCommand }); + _processCryptSetup.setEnvironment(QProcess::systemEnvironment() << QString("PASSWORD=%1").arg(_deviceCryptSetupRequest._data.mPassword)); + timedProcess->start(); + + MDeviceCryptSetupResponse model; + model._data.mAccepted = false; + model._data.mMessage = tr("Encrypted Partition %1 started.").arg(_deviceCryptSetupRequest._data.mCommand); + didAttributeResponse(model.data()); +} + +/*! + * \brief DeviceController::onProcessCryptSetupExitCode + * \param vExitCode + * \param vStatus + */ +void DeviceController::onProcessCryptSetupExitCode(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 pared device info in text and it will be empty string if error happens. + MDeviceCryptSetupResponse model; + QByteArray deviceInfo = _processCryptSetup.readAll(); + if ( vStatus ) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status; + else deviceInfo = _processCryptSetup.readAll(); + model.fromByteArray( deviceInfo, &vExitCode ); + // DEBUG: qDebug() << model._data.mEchoInfo; + didAttributeResponse(model.data()); + LOG_APPED_UI(model.data().mMessage); +} + +///////////////////////////////////////////// DeviceBluetoothPaired void DeviceController::onAttributeRequest(const DeviceBluetoothPairedResetRequestData &) { // ----- check that script exists. @@ -578,6 +634,7 @@ didAttributeResponse(model.data()); } +///////////////////////////////////////////// DeviceBluetoothPairedQuery void DeviceController::onAttributeRequest(const DeviceBluetoothPairedQueryRequestData &) { // ----- check that script exists. @@ -598,7 +655,7 @@ void DeviceController::onProcessBluetoothPairedQueryExitCode(int vExitCode, QProcess::ExitStatus vStatus) { - // The Exit code in this script is not used and is not used. + // 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 pared device info in text and it will be empty string if error happens. MDeviceBluetoothPairedQueryResponse model; Index: sources/device/DeviceController.h =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/device/DeviceController.h (.../DeviceController.h) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/device/DeviceController.h (.../DeviceController.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -46,6 +46,7 @@ int _timeout = 0; QProcess *_process = nullptr; QString _command = ""; + QStringList _arguments = {}; private slots: void onFinish(int) { @@ -55,14 +56,14 @@ deleteLater(); } public: - TimedProcess(QProcess *vProcess, const QString &vCommand, int vTimeout) - : QObject(), _timeout(vTimeout), _process(vProcess), _command(vCommand) { + TimedProcess(QProcess *vProcess, const QString &vCommand, int vTimeout, QStringList vArguments = {}) + : QObject(), _timeout(vTimeout), _process(vProcess), _command(vCommand), _arguments(vArguments) { connect(_process, SIGNAL( finished(int)), this , SLOT(onFinish (int))); } void start() { _pid = startTimer(_timeout); - _process->start(_command, QStringList()); + _process->start(_command, _arguments); } protected: Index: sources/device/DeviceError.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/device/DeviceError.cpp (.../DeviceError.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/device/DeviceError.cpp (.../DeviceError.cpp) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -43,6 +43,8 @@ QT_TR_NOOP("The Bluetooth cuff pair query error." ), // eDevice_BCuff_Error_Query QT_TR_NOOP("No paired Bluetooth cuff found." ), // eDevice_BCuff_Error_Query_Empty QT_TR_NOOP("The Bluetooth cuff pair invalid address." ), // eDevice_BCuff_Error_Query_Addr + + QT_TR_NOOP("The Encrypted Partition error." ), // eDevice_CryptSetup_Error }; /*! Index: sources/device/DeviceError.h =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/device/DeviceError.h (.../DeviceError.h) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/device/DeviceError.h (.../DeviceError.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -62,6 +62,8 @@ eDevice_BCuff_Error_Query_Empty , eDevice_BCuff_Error_Query_Addr , + eDevice_CryptSetup_Error , + eDevice_Error_End }; Index: sources/device/DeviceGlobals.h =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -174,42 +174,50 @@ DEVICE_DEV_PARENT ( Brightness ) \ DEVICE_DEV_PARENT ( BluetoothPairedReset ) \ DEVICE_DEV_PARENT ( BluetoothPairedQuery ) \ + DEVICE_DEV_PARENT ( CryptSetup ) \ #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 ) \ #define DEVICE_DEV_DEFINITION_LIST \ DEVICE_DEV_DEFINITION ( Brightness ) \ DEVICE_DEV_DEFINITION ( BluetoothPairedReset ) \ DEVICE_DEV_DEFINITION ( BluetoothPairedQuery ) \ + DEVICE_DEV_DEFINITION ( CryptSetup ) \ /* ---------------------------- 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 ) \ #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 ) \ /* ---------------------------- 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 ) \ #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 ) \ /* ---------------------------- 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 ) \ Index: sources/device/DeviceModels.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/device/DeviceModels.cpp (.../DeviceModels.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/device/DeviceModels.cpp (.../DeviceModels.cpp) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -52,6 +52,36 @@ } /*! + * \brief MDeviceCryptSetupResponse::fromByteArray + * \details Checks the response and sets up the mode data. + * \param vExitCode - Passed script exit code + * \return true if passed. + */ +bool MDeviceCryptSetupResponse::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_CryptSetup_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 Encrypt Partition Command Complete."); goto lOut ; // normal return + +lError: + _data.mMessage = Device::DeviceError::deviceErrorText(static_cast(_data.mReason), error) + "\n" + vByteArray; + +lOut: + return _data.mAccepted; +} + +/*! * \brief MDeviceBluetoothPairedQueryResponse::fromByteArray * \details Checks the script returned value and * converts the returning paired device information from the process into the response model. Index: sources/device/DeviceModels.h =================================================================== diff -u -r7c86f3854db9ad02d95681203198d75a0d65c9fa -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/device/DeviceModels.h (.../DeviceModels.h) (revision 7c86f3854db9ad02d95681203198d75a0d65c9fa) +++ sources/device/DeviceModels.h (.../DeviceModels.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -79,6 +79,7 @@ }; +// ---------- MDeviceBrightness ---------- // /*! * \brief The MDeviceBrightnessRequest class * \details The model for the device brightness value modification request. @@ -212,6 +213,37 @@ bool fromByteArray(const QByteArray &vByteArray, int *vExitCode = nullptr) override; }; +// ---------- MDeviceCryptSetup ---------- // +/*! + * \brief The MDeviceCryptSetupRequest class + * \details The model for the CryptSetup script call. + */ +class MDeviceCryptSetupRequest : public MDeviceRequestBase { +public: + struct Data { + QString mCommand = ""; + QString mPassword = ""; + } _data; + + QString toString() { + return MDeviceRequestBase::toString("DeviceCryptSetup", { }); + } +}; + +/*! + * \brief The MDeviceCryptSetupResponse class + * \details The model for the CryptSetup script call returned value / response. + */ +class MDeviceCryptSetupResponse : public MDeviceResponseBase { +public: + struct Data : MDeviceResponseBase::Data { + } _data; + QVariantList parameters ( ) const override { return { }; } + QString infoText ( ) const override { return QString("DeviceCryptSetup"); } + Data data ( ) const { return _data; } + bool fromByteArray(const QByteArray &vByteArray, int *vExitCode = nullptr) override; +}; + } @@ -224,3 +256,6 @@ typedef Model::MDeviceBluetoothPairedQueryRequest ::Data DeviceBluetoothPairedQueryRequestData ; typedef Model::MDeviceBluetoothPairedQueryResponse::Data DeviceBluetoothPairedQueryResponseData; + +typedef Model::MDeviceCryptSetupRequest ::Data DeviceCryptSetupRequestData ; +typedef Model::MDeviceCryptSetupResponse::Data DeviceCryptSetupResponseData; Index: sources/device/DeviceView.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -62,6 +62,37 @@ response(true); } +void VDevice::doInitCryptSetup() { + // Nothing for now. +} + +void VDevice::cryptSetupRequest(const QString &vCommand) { + // DEBUG : qDebug() << "HERE Request" << vValue; + DeviceCryptSetupRequestData data; + data.mCommand = vCommand; + //FIXME:Change this to get it from the encryptString + // Currently located in the QString VSettings::encryptString(const QString &vString) + // Which has to be moved to a better global class. + data.mPassword = "_0.aBc.0_"; + emit didAttributeRequest(data); +} + +void VDevice::onAttributeResponse(const DeviceCryptSetupResponseData &vData) { + // DEBUG : qDebug() << "HERE Response" << vData.mBrightnessPercent; + // this has to be called to let Gui to set to old value that device controller provided. + // this response is not updating the cryptsetup attribute. + // cryptsetup attribute will containe the command to be sent to the cryptsetup script + // and the retrurned message can be the model message in vData.mMessage + status(vData.mMessage); + cryptSetupEnabled(vData.mAccepted); + + accepted(vData.mAccepted); + reason (vData.mReason ); + + // has to be the last one + response(true); +} + void VDevice::doInitBluetoothPairedReset() { // DEBUG : qDebug() << "HERE Init"; DeviceBluetoothPairedResetRequestData data; Index: sources/device/DeviceView.h =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/device/DeviceView.h (.../DeviceView.h) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/device/DeviceView.h (.../DeviceView.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -47,6 +47,9 @@ ATTRIBUTE ( quint8 , bluetoothPairedReset, 0, BluetoothPairedReset ) ATTRIBUTE ( QStringList , bluetoothPairedQuery, {}, BluetoothPairedQuery ) + ATTRIBUTE ( QString , cryptSetup , "", CryptSetup ) + PROPERTY ( bool , cryptSetupEnabled , true ) + VIEW_DEC_CLASS(VDevice) }; } Index: sources/gui/qml/pages/settings/SettingsManufacturingSetup.qml =================================================================== diff -u -r9c7a790376d07de7ddaa67e39d47102d68693c87 -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/gui/qml/pages/settings/SettingsManufacturingSetup.qml (.../SettingsManufacturingSetup.qml) (revision 9c7a790376d07de7ddaa67e39d47102d68693c87) +++ sources/gui/qml/pages/settings/SettingsManufacturingSetup.qml (.../SettingsManufacturingSetup.qml) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -27,5 +27,8 @@ */ SettingsBase { id: _root itemIndex : SettingsStack.DeviceConfiguration - confirmVisible : false + confirmVisible : true + confirmEnabled : vDevice.cryptSetupEnabled + onConfirmClicked: vDevice.cryptSetup = "setup"; + notificationText: vDevice.status } Index: sources/gui/qml/pages/settings/SettingsStack.qml =================================================================== diff -u -r9c7a790376d07de7ddaa67e39d47102d68693c87 -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 9c7a790376d07de7ddaa67e39d47102d68693c87) +++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -51,8 +51,8 @@ RoInput , Language , Calibration , - DeviceRegistration , DeviceConfiguration , + DeviceRegistration , SWUpdate , FactoryReset } @@ -68,8 +68,8 @@ qsTr("Water Input Mode" ), // RoInput qsTr("Set Language" ), // Language qsTr("Calibration " ), // Calibration - qsTr("Device Registration" ), // DeviceRegistration qsTr("Device Configuration" ), // Manufacturing Setup + qsTr("Device Registration" ), // DeviceRegistration qsTr("Software Update" ), // SWUpdate qsTr("Factory Reset" ), // FactoryReset ] @@ -85,8 +85,8 @@ true , // RoInput false , // Language false , // Calibration - true , // DeviceRegistration _GuiView.manufactSetup , // Manufacturing Setup + true , // DeviceRegistration false , // SWUpdate serviceMode , // FactoryReset ] @@ -102,10 +102,10 @@ ! _GuiView.manufactSetup , // RoInput false /* serviceMode phase 1 */ , // Language false /* serviceMode phase 1 */ , // Calibration - _GuiView.manufactSetup , // DeviceRegistration - serviceMode && _GuiView.manufactSetup, // Manufacturing Setup + _GuiView.manufactSetup && serviceMode, // Manufacturing Setup // && serviceMode added to make sure the service mode is confirmed by HD + _GuiView.manufactSetup && serviceMode, // DeviceRegistration // && serviceMode added to make sure the service mode is confirmed by HD false /* serviceMode phase 1 */ , // SWUpdate - serviceMode /* serviceMode phase 1 */ , // FactoryReset + serviceMode , // FactoryReset ] SettingsHome { id : _settingsHome @@ -176,7 +176,6 @@ } } - SettingsManufacturingSetup { id: _settingsDeviceConfiguration } SettingsInformation { id: _settingsInformation } SettingsVolumeBrightness { id: _settingsVolumeBrightness } SettingsDateTime { id: _settingsDateTime } @@ -185,6 +184,7 @@ SettingsDG { id: _settingsDGSettings } SettingsExportLogs { id: _settingsExportLogs } SettingsROInput { id: _settingsRoInput } + SettingsManufacturingSetup { id: _settingsDeviceConfiguration } SettingsDeviceRegistration { id: _settingsDeviceRegistration } SettingsServicePassword { id: _servicePassword } Index: sources/model/MModel.h =================================================================== diff -u -rd949be21f2a9badd0978dddaaf436f6805de28dc -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/model/MModel.h (.../MModel.h) (revision d949be21f2a9badd0978dddaaf436f6805de28dc) +++ sources/model/MModel.h (.../MModel.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -284,6 +284,8 @@ REGISTER_METATYPE( DeviceBluetoothPairedResetResponseData ) \ REGISTER_METATYPE( DeviceBluetoothPairedQueryRequestData ) \ REGISTER_METATYPE( DeviceBluetoothPairedQueryResponseData ) \ + REGISTER_METATYPE( DeviceCryptSetupRequestData ) \ + REGISTER_METATYPE( DeviceCryptSetupResponseData ) \ /* Settings */ \ REGISTER_METATYPE( SettingsData ) \ REGISTER_METATYPE( WifiNetworkData ) \ Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -raf8d98b36b427e2b5f4d6659fcf3b58ee79eab6a -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision af8d98b36b427e2b5f4d6659fcf3b58ee79eab6a) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -159,4 +159,8 @@ // Bluetooth const char *Bluetooth_Paired_Reset = "bluetooth_paired_clear.sh"; const char *Bluetooth_Paired_Query = "bluetooth_paired_query.sh"; + + // Encrypted Partision - cryptsetup + const char *Crypt_Setup = "crypt_setup.sh"; + } Index: sources/storage/StorageGlobals.h =================================================================== diff -u -raf8d98b36b427e2b5f4d6659fcf3b58ee79eab6a -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision af8d98b36b427e2b5f4d6659fcf3b58ee79eab6a) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -113,4 +113,7 @@ // Bluetooth extern const char *Bluetooth_Paired_Reset; extern const char *Bluetooth_Paired_Query; + + // Encrypted Partision - cryptsetup + extern const char *Crypt_Setup; }