Index: sources/ApplicationPost.cpp =================================================================== diff -u -r16bd55822fa77e5bea6fdfa7b54abf123c1da8bb -r6c6f1f5d466badd9b4fd67be7c907234c342b2a2 --- sources/ApplicationPost.cpp (.../ApplicationPost.cpp) (revision 16bd55822fa77e5bea6fdfa7b54abf123c1da8bb) +++ sources/ApplicationPost.cpp (.../ApplicationPost.cpp) (revision 6c6f1f5d466badd9b4fd67be7c907234c342b2a2) @@ -1,13 +1,13 @@ /*! * - * Copyright (c) 2020-2022 Diality Inc. - All Rights Reserved. + * Copyright (c) 2020-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 ApplicationPost.cpp * \author (last) Behrouz NematiPour - * \date (last) 28-Sep-2022 + * \date (last) 19-Apr-2023 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * @@ -36,7 +36,7 @@ */ void ApplicationPost::start() { - QString postLogFileName = qApp->applicationDirPath() + "/" + Storage::POST_LOG; + QString postLogFileName = QDir::tempPath() + "/" + Storage::POST_LOG; if (Storage::FileHandler::read(postLogFileName, _content)) { _isShaSum = checkShaSum (); _isCANBus = checkCANBus (); @@ -49,6 +49,7 @@ _isCloudSync = checkCloudSync (); // is not mandatory and the device can still be used without it. Alarm will be triggered to notify user in Active Alarm List. _isEthernet = checkEthernet (); // this is not a Fault and not required the application to stop. No Alarm will be triggered. _isSound = checkSound (); // this is not a Fault and not required the application to stop. No Alarm will be triggered. + _isYearCheck = checkYear (); // WARNING: // all of the checks have to be done, // although some are not failing the final result, @@ -62,7 +63,10 @@ isRtc () && isWiFi () && isBluetooth () && - isCloudSync () + isCloudSync () && + // isEthernet () && // it is being executed to get the information but is not part of the POST failure. + // isSound () && + isYearCheck () ; } else { @@ -81,7 +85,7 @@ bool ApplicationPost::checkShaSum() { bool ok = _content.contains(_postmsg_shasum + _postmsg_postfix_passed); - if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_SHASUM); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_SHASUM); emit didShaSum(ok); return ok; } @@ -94,7 +98,7 @@ bool ApplicationPost::checkCANBus() { bool ok = _content.contains(_postmsg_canbus + _postmsg_postfix_passed); - if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_CANBUS); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_CANBUS); emit didCANBus(ok); return ok; } @@ -108,7 +112,7 @@ { bool ok = true; //TODO: do the test : not a good test has been found yet. - if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_DISPLAY); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_DISPLAY); emit didDisplay(ok); return ok; } @@ -121,7 +125,7 @@ bool ApplicationPost::checkTouch() { bool ok = _content.contains(_postmsg_touch + _postmsg_postfix_passed); - if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_TOUCH); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_TOUCH); emit didTouch(ok); return ok; } @@ -134,7 +138,7 @@ bool ApplicationPost::checkSDCard() { bool ok = _content.contains(_postmsg_sdcard + _postmsg_postfix_passed); - if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_SDCARD); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_SDCARD); emit didSDCard(ok); return ok; } @@ -147,20 +151,53 @@ bool ApplicationPost::checkRtc() { bool ok = _content.contains(_postmsg_rtc + _postmsg_postfix_passed); - if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_RTC); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_RTC); emit didRtc(ok); return ok; } /*! + * \brief ApplicationPost::checkEthernet + * \details Checks the Ethernet driver is loaded and functional. + * \return false if there is an issue [Removed from the PRS (always true)]. + */ +bool ApplicationPost::checkEthernet() +{ + bool ok = false; + int posDev = -1; + int posMac = -1; + QString section = ""; + posDev = _content.indexOf( _devEthernet ); if ( posDev < 0 ) goto lOut; + section = _content.mid(posDev, _macAppearLen); + posMac = section.indexOf(_macEthernetLabel); if ( posMac < 0 ) goto lOut; + _macEthernet = section.mid(posMac + _macEthernetLabel.length(), _macAddrssLen).toUpper(); if ( _macEthernet.isEmpty() ) goto lOut; + ok = true; + +lOut: + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_ETHERNET); + emit didEthernet(ok); + return ok; +} + +/*! * \brief ApplicationPost::checkWiFi * \details Checks the WiFi driver is loaded and functional * \return false if there is an issue. */ bool ApplicationPost::checkWiFi() { - bool ok = _content.contains(_postmsg_wifi + _postmsg_postfix_passed); - if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_WIFI); + bool ok = false; + int posDev = -1; + int posMac = -1; + QString section = ""; + posDev = _content.indexOf( _devWireless ); if ( posDev < 0 ) goto lOut; + section = _content.mid(posDev, _macAppearLen); + posMac = section.indexOf(_macWirelessLabel); if ( posMac < 0 ) goto lOut; + _macWireless = section.mid(posMac + _macWirelessLabel.length(), _macAddrssLen).toUpper(); if ( _macWireless.isEmpty() ) goto lOut; + ok = _content.contains(_postmsg_wifi + _postmsg_postfix_passed); + +lOut: + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_WIFI); emit didWiFi(ok); return ok; } @@ -172,8 +209,18 @@ */ bool ApplicationPost::checkBluetooth() { - bool ok = _content.contains(_postmsg_bluetooth + _postmsg_postfix_passed); - if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_BLUETOOTH); + bool ok = false; + int posDev = -1; + int posMac = -1; + QString section = ""; + posDev = _content.indexOf( _devBluetooth ); if ( posDev < 0 ) goto lOut; + section = _content.mid(posDev, _macAppearLen); + posMac = section.indexOf(_macBluetoothLabel); if ( posMac < 0 ) goto lOut; + _macBluetooth = section.mid(posMac + _macBluetoothLabel.length(), _macAddrssLen).toUpper(); if ( _macBluetooth.isEmpty() ) goto lOut; + ok = _content.contains(_postmsg_bluetooth + _postmsg_postfix_passed); + +lOut: + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_BLUETOOTH); emit didBluetooth(ok); return ok; } @@ -189,26 +236,12 @@ if (! gDisableCloudSyncFailStop ) { ok = _content.contains(_postmsg_cloudsync + _postmsg_postfix_passed); } - if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_CLOUDSYNC); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_CLOUDSYNC); emit didCloudSync(ok); return ok; } /*! - * \brief ApplicationPost::checkEthernet - * \details Checks the Ethernet driver is loaded and functional. - * \return false if there is an issue [Removed from the PRS (always true)]. - */ -bool ApplicationPost::checkEthernet() -{ - bool ok = true; - // do the test : we are not using this for now since it has been removed from the PRS. - if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_ETHERNET); - emit didEthernet(ok); - return ok; -} - -/*! * \brief ApplicationPost::checkSound * \details Checks the sound driver is loaded. * \return false if there is an issue [No Implementation yet (always true)]. @@ -217,7 +250,21 @@ { bool ok = true; // do the test - if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_SOUND); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_SOUND); emit didSound(ok); return ok; } + +/*! + * \brief ApplicationPost::checkYear + * \details Checks if the year is greater than or equal to 2022. + * \return false if there is an issue. + */ +bool ApplicationPost::checkYear() +{ + QDate currentDate = QDate::currentDate(); + bool ok = currentDate.year() >= _yearMinimum; + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_INVALID_YEAR); + emit didYearCheck(ok); + return ok; +}