Index: denali.pro.user =================================================================== diff -u -rf11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- denali.pro.user (.../denali.pro.user) (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) +++ denali.pro.user (.../denali.pro.user) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -1,6 +1,6 @@ - + EnvironmentId @@ -1481,7 +1481,7 @@ denali Qt4ProjectManager.Qt4RunConfiguration:/home/denali/Projects/application/denali.pro - --disable-timeout + --disable-timeout -l 3768 false true Index: denali.qrc =================================================================== diff -u -r9b34a391e7401e9a045270744902a20d0e66d650 -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- denali.qrc (.../denali.qrc) (revision 9b34a391e7401e9a045270744902a20d0e66d650) +++ denali.qrc (.../denali.qrc) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -14,6 +14,7 @@ sources/gui/qml/pages/settings/SettingsWiFi.qml sources/gui/qml/pages/settings/SettingsDG.qml sources/gui/qml/pages/settings/SettingsVolumeBrightness.qml + sources/gui/qml/pages/settings/SettingsBluetoothCuff.qml sources/gui/qml/dialogs/PowerOff.qml Index: main.cpp =================================================================== diff -u -r2dd767833cf0cf706c457951c2d78e7e20aff768 -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- main.cpp (.../main.cpp) (revision 2dd767833cf0cf706c457951c2d78e7e20aff768) +++ main.cpp (.../main.cpp) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -359,6 +359,7 @@ //! - Initializing WiFi Interface _WifiInterface.init(Threads::_Wifi_Thread); + //! - Initializing Bluetooth Interface _BluetoothInterface.init(Threads::_Bluetooth_Thread); //! - Initialize the QML Viewer and starts GUI @@ -367,11 +368,6 @@ if ( startGui() ) { LOG_DEBUG("UI Initialized"); _ApplicationController .startPOST(); - - // TODO: check if the POST for the interfaces below are passed do the start. - _WifiInterface .start(); - _BluetoothInterface .start(); - app_exec = app.exec(); } Index: scripts/run.sh =================================================================== diff -u -r93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7 -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- scripts/run.sh (.../run.sh) (revision 93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7) +++ scripts/run.sh (.../run.sh) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -33,7 +33,7 @@ POSTMSG_SDCARD="SD-CARD passed" POSTMSG_TOUCH="Touch passed" POSTMSG_RTC="RTC passed" -POSTMSG_BLUETOOTH="WiFi passed" +POSTMSG_WIFI="WiFi passed" POSTMSG_BLUETOOTH="Bluetooth passed" @@ -79,7 +79,7 @@ echo $POSTMSG_CANBUS >> $POSTLOG fi - + #mounting sdcard -------------------------- SD-CARD mount $SDCARD_DEV $SDCARD_MNT if [ $? -eq 0 ]; then @@ -122,6 +122,7 @@ # setup bluetooth /usr/share/silex-uart/silex-uart.sh start > $HOME/filesystem.out 2> $HOME/filesystem.err +sleep 5 hciconfig hci0 up if [ $? -eq 0 ]; then echo $POSTMSG_BLUETOOTH >> $POSTLOG @@ -130,6 +131,9 @@ # setup wifi killall wpa_supplicant >> $HOME/filesystem.out 2>> $HOME/filesystem.err +if [[ ! -z $(ip a | grep "wlan0:" | grep "state UP") ]]; then + echo $POSTMSG_WIFI >> $POSTLOG +fi #launching denali application, disable keep-alive Index: sources/ApplicationController.cpp =================================================================== diff -u -r20453ac382a122d1dde3c399ed9fcaf8a39b4ad6 -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision 20453ac382a122d1dde3c399ed9fcaf8a39b4ad6) +++ sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -18,7 +18,6 @@ #include // Project -#include "ApplicationPost.h" #include "MainTimer.h" #include "MessageDispatcher.h" #include "Logger.h" @@ -27,6 +26,8 @@ #include "GuiController.h" #include "Settings.h" #include "MSettings.h" +#include "WifiInterface.h" +#include "BluetoothInterface.h" /*! @@ -35,7 +36,9 @@ * \param parent - QObject parent owner object. * Qt handles the children destruction by their parent objects life-cycle. */ -ApplicationController::ApplicationController(QObject *parent) : QObject(parent) { } +ApplicationController::ApplicationController(QObject *parent) : QObject(parent) { + _post.setParent(this); +} /*! * \brief ApplicationController initializer @@ -86,6 +89,17 @@ */ void ApplicationController::initConnections() { + + connect(&_post , SIGNAL(didWiFi ()), + &_WifiInterface , SLOT( doStart ())); + connect(&_post , SIGNAL( didBluetooth()), + this , SLOT(onPOSTBluetooth())); + + connect(&_post , SIGNAL( didFail (Gui::GuiAlarmID )), + this , SLOT(onPOSTFail (Gui::GuiAlarmID ))); + connect(&_post , SIGNAL( didDone (bool )), + this , SLOT (onPOSTDone (bool ))); + connect(&_MainTimer , SIGNAL( didTimeout()), this , SLOT(onMainTimerTimeout())); @@ -490,6 +504,38 @@ } /*! + * \brief ApplicationController::onPOSTBluetooth + * \details Starts the Bluetooth Interface + */ +void ApplicationController::onPOSTBluetooth() { + _BluetoothInterface.valid(true); + _BluetoothInterface.doStart(); +} + + +/*! + * \brief ApplicationController::onPOSTFail + * \details sends the Alarm Trigger message, used when the POST Failed. + * \param vAlarmID + */ +void ApplicationController::onPOSTFail(GuiAlarmID vAlarmID) { + emit didActionTransmit(GuiActionType::ID_AlarmTriggered, { vAlarmID ,0,0,0,0}); +} + +/*! + * \brief ApplicationController::onPOSTDone + * \details Sends the POST Final message + */ +void ApplicationController::onPOSTDone(bool vPass) { + AdjustUIPostFinalResultRequestData data; + data.mResult = vPass; + emit didAdjustment(data); + QString message = "ApplicationPost Done :" + QTime::currentTime().toString("HH:mm:ss.zzz"); + qDebug() << message; + LOG_DEBUG(message); +} + +/*! * \brief ApplicationController::settingsInit * \details The Settings read function is called in this method. * This callback function for the QCuncurrnent run. @@ -510,15 +556,7 @@ * \return void */ void ApplicationController::onstartPOST() { + LOG_DEBUG("ApplicationPost Start:" + QTime::currentTime().toString("HH:mm:ss.zzz")); emit didActionTransmit(GuiActionType::ID_KeepAlive, {}); - ApplicationPost post; - connect(&post, &ApplicationPost::didPOSTFail, [=] (Gui::GuiAlarmID vAlarmID) { - emit didActionTransmit(GuiActionType::ID_AlarmTriggered, { vAlarmID ,0,0,0,0}); - }); - connect(&post, &ApplicationPost::didPOSTDone, [=] (bool vResult) { - AdjustUIPostFinalResultRequestData data; - data.mResult = vResult; - emit didAdjustment(data); - }); - post.start(); + _post.start(); } Index: sources/ApplicationController.h =================================================================== diff -u -rfc329c788fe9453983072bee937ccbc95b4ed6e4 -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/ApplicationController.h (.../ApplicationController.h) (revision fc329c788fe9453983072bee937ccbc95b4ed6e4) +++ sources/ApplicationController.h (.../ApplicationController.h) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -20,6 +20,7 @@ // Project #include "main.h" // Doxygen : do not remove #include "MModel.h" +#include "ApplicationPost.h" #include "GuiGlobals.h" #include "MessageGlobals.h" #include "DeviceGlobals.h" @@ -56,6 +57,8 @@ QFutureWatcher _settingsWatcher; + ApplicationPost _post; // I may need to be put in a concurrent. + public: void initSettings(); @@ -100,6 +103,10 @@ void onSettingsInit(); void onSettingsUpdate(); + void onPOSTBluetooth (); + void onPOSTFail (Gui::GuiAlarmID vAlarmID); + void onPOSTDone (bool vPass); + signals: void didActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG void didActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG Index: sources/ApplicationPost.cpp =================================================================== diff -u -r20453ac382a122d1dde3c399ed9fcaf8a39b4ad6 -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/ApplicationPost.cpp (.../ApplicationPost.cpp) (revision 20453ac382a122d1dde3c399ed9fcaf8a39b4ad6) +++ sources/ApplicationPost.cpp (.../ApplicationPost.cpp) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -18,8 +18,8 @@ #include // Project +#include "Logger.h" #include "FileHandler.h" -#include "StorageGlobals.h" /*! * \brief ApplicationPost::ApplicationPost @@ -36,21 +36,35 @@ */ void ApplicationPost::start() { - bool ok = false; - if (Storage::FileHandler::read(qApp->applicationDirPath() + "/" + Storage::POST_LOG, _content) ) { - ok = checkFileSystem () - && checkCANBus () - && checkDisplay () - && checkTouch () - && checkSDCard () - && RTC () - && checkWiFi () - && checkBluetooth () - && checkEthernet () - && checkSound () - ; + QString postLogFileName = qApp->applicationDirPath() + "/" + Storage::POST_LOG; + if (Storage::FileHandler::read(postLogFileName, _content) ) { + _isFileSystem = checkFileSystem (); + _isCANBus = checkCANBus (); + _isDisplay = checkDisplay (); + _isTouch = checkTouch (); + _isSDCard = checkSDCard (); + _isRtc = checkRtc (); + _isWiFi = checkWiFi (); + _isBluetooth = checkBluetooth (); + _isEthernet = checkEthernet (); + _isSound = checkSound (); + // Please take care that, all of the checks have to be done so they need to be assigned to a variable and then, and them, + // otherwise on the first fail rest will not run by compiler optimization. + _isDone = _isFileSystem && + _isCANBus && + _isDisplay && + _isTouch && + _isSDCard && + _isRtc && + // _isWiFi && // is not mandatory and the device can still be used without it. Alarm will be triggered to notify user in Active Alarm List., + // _isBluetooth && // is not mandatory and the device can still be used without it. Alarm will be triggered to notify user in Active Alarm List., + _isEthernet && + _isSound ; } - emit didPOSTDone(ok); + else { + LOG_EVENT(tr("The POST log file could not be read.")); + } + emit didDone(_isDone); } /*! @@ -61,8 +75,9 @@ bool ApplicationPost::checkFileSystem() { bool ok = true; - // it will be done after consulting as part of CyberSecurity - if (! ok) emit didPOSTFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_FILESYSTEM); + //TODO: it will be done after consulting as part of CyberSecurity + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_FILESYSTEM); + else emit didFileSystem(); return ok; } @@ -74,7 +89,8 @@ bool ApplicationPost::checkCANBus() { bool ok = _content.contains(_postmsg_canbus); - if (! ok) emit didPOSTFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_CANBUS); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_CANBUS); + else emit didCANBus(); return ok; } @@ -86,8 +102,9 @@ bool ApplicationPost::checkDisplay() { bool ok = true; - // do the test : not a good test has been found yet. - if (! ok) emit didPOSTFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_DISPLAY); + //TODO: do the test : not a good test has been found yet. + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_DISPLAY); + else emit didDisplay(); return ok; } @@ -99,7 +116,8 @@ bool ApplicationPost::checkTouch() { bool ok = _content.contains(_postmsg_touch); - if (! ok) emit didPOSTFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_TOUCH); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_TOUCH); + else emit didTouch(); return ok; } @@ -111,7 +129,8 @@ bool ApplicationPost::checkSDCard() { bool ok = _content.contains(_postmsg_sdcard); - if (! ok) emit didPOSTFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_SDCARD); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_SDCARD); + else emit didSDCard(); return ok; } @@ -120,10 +139,11 @@ * \details Checks the RTC driver is loaded and functional * \return false if there is an issue */ -bool ApplicationPost::RTC() +bool ApplicationPost::checkRtc() { bool ok = _content.contains(_postmsg_rtc); - if (! ok) emit didPOSTFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_RTC); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_RTC); + else emit didRtc(); return ok; } @@ -134,9 +154,9 @@ */ bool ApplicationPost::checkWiFi() { - bool ok = true; - // do the test - if (! ok) emit didPOSTFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_WIFI); + bool ok = true; //TODO: _content.contains(_postmsg_wifi); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_WIFI); + else emit didWiFi(); return ok; } @@ -147,10 +167,9 @@ */ bool ApplicationPost::checkBluetooth() { - bool ok = true; // This should not stop the FW POST and is only a warning that will show up in the alarm list. - // do the test - // Test : if (! ok) - emit didPOSTFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_BLUETOOTH); + bool ok = _content.contains(_postmsg_bluetooth); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_BLUETOOTH); + else emit didBluetooth(); return ok; } @@ -163,7 +182,8 @@ { bool ok = true; // do the test : we are not using this for now since it has been removed from the PRS. - if (! ok) emit didPOSTFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_ETHERNET); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_ETHERNET); + else emit didEthernet(); return ok; } @@ -176,7 +196,8 @@ { bool ok = true; // do the test - if (! ok) emit didPOSTFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_SOUND); + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_SOUND); + else emit didSound(); return ok; } Index: sources/ApplicationPost.h =================================================================== diff -u -r3f555c49ddd2c983f469709e3c001d0e76159248 -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/ApplicationPost.h (.../ApplicationPost.h) (revision 3f555c49ddd2c983f469709e3c001d0e76159248) +++ sources/ApplicationPost.h (.../ApplicationPost.h) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -25,28 +25,68 @@ Q_OBJECT QString _content; - const char *_postmsg_canbus ="CANBus passed" ; - const char *_postmsg_sdcard ="SD-CARD passed" ; - const char *_postmsg_touch ="Touch passed" ; - const char *_postmsg_rtc ="RTC passed" ; + const char *_postmsg_canbus = "CANBus passed" ; + const char *_postmsg_sdcard = "SD-CARD passed" ; + const char *_postmsg_touch = "Touch passed" ; + const char *_postmsg_rtc = "RTC passed" ; + const char *_postmsg_wifi = "WiFi passed" ; + const char *_postmsg_bluetooth = "Bluetooth passed"; + bool _isFileSystem = false ; // HIGH : ALARM_ID_UI_POST_FAILURE_FILESYSTEM + bool _isCANBus = false ; // HIGH : ALARM_ID_UI_POST_FAILURE_CANBUS + bool _isDisplay = false ; // HIGH : ALARM_ID_UI_POST_FAILURE_DISPLAY + bool _isTouch = false ; // HIGH : ALARM_ID_UI_POST_FAILURE_TOUCH + bool _isSDCard = false ; // HIGH : ALARM_ID_UI_POST_FAILURE_SDCARD + bool _isRtc = false ; // MEDIUM : ALARM_ID_UI_POST_FAILURE_RTC + bool _isWiFi = false ; // LOW : ALARM_ID_UI_POST_FAILURE_WIFI + bool _isBluetooth = false ; // LOW : ALARM_ID_UI_POST_FAILURE_BLUETOOTH + bool _isEthernet = false ; // NONE : ALARM_ID_UI_POST_FAILURE_ETHERNET : this is not a Fault and not required the application to stop. + bool _isSound = false ; // NONE : ALARM_ID_UI_POST_FAILURE_SOUND : this is not a Fault and not required the application to stop. + + bool _isDone = false ; + // tests // Severity - bool checkFileSystem (); // HIGH : ALARM_ID_UI_POST_FAILURE_FILESYSTEM - bool checkCANBus (); // HIGH : ALARM_ID_UI_POST_FAILURE_CANBUS - bool checkDisplay (); // HIGH : ALARM_ID_UI_POST_FAILURE_DISPLAY - bool checkTouch (); // HIGH : ALARM_ID_UI_POST_FAILURE_TOUCH - bool checkSDCard (); // HIGH : ALARM_ID_UI_POST_FAILURE_SDCARD - bool RTC (); // MEDIUM : ALARM_ID_UI_POST_FAILURE_RTC - bool checkWiFi (); // LOW : ALARM_ID_UI_POST_FAILURE_WIFI - bool checkBluetooth (); // LOW : ALARM_ID_UI_POST_FAILURE_BLUETOOTH - bool checkEthernet (); // NONE : ALARM_ID_UI_POST_FAILURE_ETHERNET : this is not a Fault and not required the application to stop. - bool checkSound (); // NONE : ALARM_ID_UI_POST_FAILURE_SOUND : this is not a Fault and not required the application to stop. + bool checkFileSystem (); // HIGH : ALARM_ID_UI_POST_FAILURE_FILESYSTEM + bool checkCANBus (); // HIGH : ALARM_ID_UI_POST_FAILURE_CANBUS + bool checkDisplay (); // HIGH : ALARM_ID_UI_POST_FAILURE_DISPLAY + bool checkTouch (); // HIGH : ALARM_ID_UI_POST_FAILURE_TOUCH + bool checkSDCard (); // HIGH : ALARM_ID_UI_POST_FAILURE_SDCARD + bool checkRtc (); // MEDIUM : ALARM_ID_UI_POST_FAILURE_RTC + bool checkWiFi (); // LOW : ALARM_ID_UI_POST_FAILURE_WIFI + bool checkBluetooth (); // LOW : ALARM_ID_UI_POST_FAILURE_BLUETOOTH + bool checkEthernet (); // NONE : ALARM_ID_UI_POST_FAILURE_ETHERNET : this is not a Fault and not required the application to stop. + bool checkSound (); // NONE : ALARM_ID_UI_POST_FAILURE_SOUND : this is not a Fault and not required the application to stop. public: + bool isFileSystem () { return _isFileSystem ; } + bool isCANBus () { return _isCANBus ; } + bool isDisplay () { return _isDisplay ; } + bool isTouch () { return _isTouch ; } + bool isSDCard () { return _isSDCard ; } + bool isRtc () { return _isRtc ; } + bool isWiFi () { return _isWiFi ; } + bool isBluetooth () { return _isBluetooth ; } + bool isEthernet () { return _isEthernet ; } + bool isSound () { return _isSound ; } + + bool isDone () { return _isDone ; } + +public: explicit ApplicationPost(QObject *parent = nullptr); void start(); signals: - void didPOSTFail(Gui::GuiAlarmID vAlarmID); - void didPOSTDone(bool vResult ); + void didFileSystem (); + void didCANBus (); + void didDisplay (); + void didTouch (); + void didSDCard (); + void didRtc (); + void didWiFi (); + void didBluetooth (); + void didEthernet (); + void didSound (); + + void didFail(Gui::GuiAlarmID vAlarmID); + void didDone(bool vPass); }; Index: sources/bluetooth/BluetoothInterface.cpp =================================================================== diff -u -rf11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/bluetooth/BluetoothInterface.cpp (.../BluetoothInterface.cpp) (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) +++ sources/bluetooth/BluetoothInterface.cpp (.../BluetoothInterface.cpp) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -21,7 +21,6 @@ // Project #include "Logger.h" -#include "types.h" // namespace using namespace Bluetooth; @@ -34,8 +33,6 @@ * Qt handles the children destruction by their parent objects life-cycle. */ BluetoothInterface::BluetoothInterface(QObject *parent) : QObject(parent) { - _local = new QBluetoothLocalDevice (this); - _agent = new QBluetoothDeviceDiscoveryAgent (this); startTimer(_interval); } @@ -46,7 +43,8 @@ */ bool BluetoothInterface::init() { - if ( _init ) return false; + if ( ! _isValid ) return false; + if ( _init ) return false; _init = true; // runs in BluetoothInterface thread @@ -78,13 +76,14 @@ */ void BluetoothInterface::quit() { + if ( ! _isValid ) return; // coco begin validated: Application termination is not correctly done in coco!!! // it has been tested and works perfectly fine in normal run. quitThread(); // validated if ( _local ) _local ->deleteLater(); if ( _agent ) _agent ->deleteLater(); - if ( _device ) _device ->deleteLater(); + quitDevice(); } // coco end @@ -95,6 +94,7 @@ */ void BluetoothInterface::initConnections() { + if ( ! isLocalValid() ) return; // Local connections connect(_local , &QBluetoothLocalDevice :: deviceConnected , this , &BluetoothInterface ::onLocalDeviceConnect ); @@ -103,6 +103,7 @@ connect(_local , &QBluetoothLocalDevice :: error , this , &BluetoothInterface ::onLocalError ); + if ( ! isAgentValid() ) return; // Agent connections connect(_agent , &QBluetoothDeviceDiscoveryAgent ::deviceDiscovered , this , &BluetoothInterface ::onAgentDiscoverDevice ); @@ -159,6 +160,7 @@ #define NOTIFY_LOCAL_CONNECT notifyStateChange(MBluetooth(MBluetooth::eIS_Local_Connect , vAddress.toString()) ); #define NOTIFY_LOCAL_ERROR notifyStateChange(MBluetooth(MBluetooth::eIS_Local_Error )); +#define NOTIFY_LOCAL_ERROR_POST notifyStateChange(MBluetooth(MBluetooth::eIS_Local_Error_POST )); #define NOTIFY_LOCAL_ERROR_IO notifyStateChange(MBluetooth(MBluetooth::eIS_Local_Error_IO )); #define NOTIFY_LOCAL_ERROR_OFF notifyStateChange(MBluetooth(MBluetooth::eIS_Local_Error_Off )); #define NOTIFY_LOCAL_ERROR_INVALID notifyStateChange(MBluetooth(MBluetooth::eIS_Local_Error_Invalid )); @@ -291,13 +293,28 @@ // ~~~~~ Public interface to initialize and start the scan // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /*! - * \brief BluetoothInterface::onstart + * \brief BluetoothInterface::ondoStart * \details the thread safe slot to be called when the public function start is called. * initializes the local Bluetooth device _local and setups up the interface. */ -void BluetoothInterface::onstart() +void BluetoothInterface::ondoStart() { - if ( ! isLocalValid() ) return; + // check the POST was successful and Bluetooth adapter is up. + if ( ! isValid() ) { // POST failed. + NOTIFY_LOCAL_ERROR_POST + return; + } + + _local = new QBluetoothLocalDevice (this); + if ( _local->address().toString() == _invalidLocalAddress ) { + _isValid = false; + NOTIFY_LOCAL_ERROR_POST + quit(); + return; + } + + _agent = new QBluetoothDeviceDiscoveryAgent (this); + _local->powerOn(); quitDevice(); _agent->setLowEnergyDiscoveryTimeout(5000); NOTIFY_LOCAL_INIT @@ -311,6 +328,8 @@ */ void BluetoothInterface::ondoScan() { + if ( ! isValid() ) return; // POST failed. + if (_agent && _agent->isActive()) { NOTIFY_SCAN_REJECT return; @@ -388,9 +407,12 @@ case QBluetoothDeviceDiscoveryAgent::InputOutputError : NOTIFY_LOCAL_ERROR_IO break; default : NOTIFY_LOCAL_ERROR break; } - quitDevice(); } +void BluetoothInterface::ondoConnectToDevice() { + connectToDevice(); +} + /*! * \brief BluetoothInterface::onAgentDiscoverFinish * \details Notifies the observers (view: VBluetooth) that the discovery agent has done discovery, and @@ -425,6 +447,7 @@ bool BluetoothInterface::connectToDevice() { if ( ! isLocalValid() ) return false; + if ( ! isAgentValid() ) return false; if ( ! isInfoValid () ) return false; if ( ! initDevice () ) return false; @@ -437,18 +460,25 @@ bool BluetoothInterface::reconnectToDevice() { if ( ! isLocalValid() ) return false; + if ( ! isAgentValid() ) return false; + NOTIFY_DEVICE_START _device->connectToDevice(); return true; } +void BluetoothInterface::ondoDiscoverServices() { + discoverServices(); +} + /*! * \brief BluetoothInterface::discoverServices * \details The function to be called to start retrieving the remote Bluetooth device _device's services, and * notifies the observers (view: VBluetooth) that the state is MBluetooth::eIS_Service_Start. */ void BluetoothInterface::discoverServices() { + if ( ! isDeviceValid() ) return; NOTIFY_SERVICE_START _device->discoverServices(); } @@ -487,6 +517,7 @@ void BluetoothInterface::discoverServicesDetails() { + if ( ! isValid() ) return; if ( _serviceDeviceInformation ) { NOTIFY_SERVICE_DETAILS (_serviceDeviceInformation ) _serviceDeviceInformation ->discoverDetails(); @@ -588,6 +619,7 @@ * \details sets up the remote Bluetooth device _device connections. */ void BluetoothInterface::initConnectionsDevice() { + if ( ! isDeviceValid() ) return; // Device controller connect( _device, SIGNAL( connected ( )), this , SLOT(onDeviceConnect ( ))); @@ -632,7 +664,70 @@ NOTIFY_SERVICE_ERROR } +void BluetoothInterface::ondoReadMeasurements() { + readMeasurements(); +} + +void BluetoothInterface::readMeasurements() +{ + if ( ! _serviceBloodPressure ) { + NOTIFY_DETAILS_INVALID + return; + } + // blood pressure feature + const QLowEnergyCharacteristic detailBPFeat = _serviceBloodPressure->characteristic(QBluetoothUuid(QBluetoothUuid::BloodPressureFeature)); + if (!detailBPFeat.isValid()) { + qDebug() << "Blood pressure feature not found."; + return; + } + _serviceBloodPressure->readCharacteristic(detailBPFeat); +} + +void BluetoothInterface::ondoReadInformation() { + readInformation(); +} + +void BluetoothInterface::readInformation() +{ + if ( ! _serviceDeviceInformation ) { + NOTIFY_DETAILS_INVALID + return; + } + + // device information + const QLowEnergyCharacteristic detailInfo = _serviceDeviceInformation->characteristic(QBluetoothUuid(QBluetoothUuid::DeviceInformation)); + if (!detailInfo.isValid()) { + qDebug() << "Device Information feature not found."; + return; + } + _serviceDeviceInformation->readCharacteristic(detailInfo); +} + +void BluetoothInterface::printCharacteristics(QLowEnergyService *vService) +{ + for ( auto const &detail: vService->characteristics()) { + qDebug() << " ~~~~~ " << detail.name() << detail.uuid() << detail.value(); + } +} + +void BluetoothInterface::ondoEnableNotify() { + enableNotify(); +} + +void BluetoothInterface::enableNotify() { + if ( ! _serviceBloodPressure ) { + NOTIFY_DETAILS_INVALID + return; + } + + // blood pressure measurements + const QLowEnergyCharacteristic detailBPMeas = _serviceBloodPressure->characteristic(QBluetoothUuid(QBluetoothUuid::BloodPressureMeasurement)); + QLowEnergyDescriptor configBPMeas = detailBPMeas.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration); + if (configBPMeas.isValid()) _serviceBloodPressure->writeDescriptor(configBPMeas, QByteArray::fromHex("0100")); +} + void BluetoothInterface::onServiceStateChanged(QLowEnergyService::ServiceState vState) { + if ( ! sender() ) return; QLowEnergyService *service = reinterpret_cast(sender()); qDebug() << "Service State:" << service->serviceUuid() << service->serviceName() << vState; switch (vState) { @@ -642,24 +737,15 @@ case QLowEnergyService::ServiceDiscovered : NOTIFY_SERVICE_DETAILS_DONE - for ( auto const &detail: service->characteristics()) { - qDebug() << " ~~~~~ " << detail.name() << detail.uuid() << detail.value(); - } - if ( service->serviceUuid() == QBluetoothUuid (QBluetoothUuid::BloodPressure)) { - // blood pressure measurements - const QLowEnergyCharacteristic detailBPMeas = service->characteristic(QBluetoothUuid(QBluetoothUuid::BloodPressureMeasurement)); - QLowEnergyDescriptor configBPMeas = detailBPMeas.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration); - if (configBPMeas.isValid()) service->writeDescriptor(configBPMeas, QByteArray::fromHex("0100")); - - // blood pressure feature - const QLowEnergyCharacteristic detailBPFeat = service->characteristic(QBluetoothUuid(QBluetoothUuid::BloodPressureFeature)); - if (!detailBPFeat.isValid()) { - qDebug() << "Blood pressure feature not found."; - return; - } - service->readCharacteristic(detailBPFeat); + printCharacteristics(service); + if ( service->serviceUuid() == QBluetoothUuid (QBluetoothUuid::BloodPressure )) { + enableNotify(); + readMeasurements(); _reconnectionActive = true; } + if (service->serviceUuid() == QBluetoothUuid (QBluetoothUuid::DeviceInformation )) { + readInformation(); + } break; default: @@ -740,21 +826,30 @@ * \return false if the local Bluetooth device _local is not valid */ bool BluetoothInterface::isLocalValid() { - if (! _local->isValid() ) { + if ( ! _isValid ) return false; + if ( ! _local ) return false; + if ( ! _local->isValid() ) { NOTIFY_LOCAL_ERROR_INVALID quitDevice(); return false; } return true; } +bool BluetoothInterface::isAgentValid() { + if (! _agent ) { + return false; + } + return true; +} + /*! * \brief BluetoothInterface::isInfoValid * \details checks if the device info _temp is valid. * notifies the observers (view: VBluetooth) that the device info is not valid. * \return false if the device info _local is not valid * \note the device info _temp is set to a default QBluetoothDeviceInfo which is invalid by default, - * when the interface initialized (onStart), and + * when the interface initialized (doStart), and * when a scan started (ondoScan) */ bool BluetoothInterface::isInfoValid() { Index: sources/bluetooth/BluetoothInterface.h =================================================================== diff -u -rf11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/bluetooth/BluetoothInterface.h (.../BluetoothInterface.h) (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) +++ sources/bluetooth/BluetoothInterface.h (.../BluetoothInterface.h) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -34,8 +34,10 @@ using namespace Model; /*! - * \brief The MessageAcknowModel class - * \details The wrapper class of the AcknowModel which does the thread handling. + * \brief The Bluetooth Controller class + * \details The wrapper class of the Bluetooth which does the thread handling. + * \warning In the Bluetooth interface it checks about the Bluetooth POST to avoid creating threads, objects. + * The validity of the Bluetooth interface has to be always checked before use. */ class BluetoothInterface : public QObject { @@ -50,25 +52,26 @@ typedef QMap< QBluetoothUuid::ServiceClassUuid, QLowEnergyService *> ServiceMap; QThread *_thread = nullptr; - bool _init = false; + bool _init = false ; + bool _isValid = false ; + const char *_invalidLocalAddress = "00:00:00:00:00:00"; QStringList _supportedDeviceKeywords { "BP7000", "BLEsmart", "BLESmart" }; // Regarding to Omron Documents. QBluetoothLocalDevice *_local = nullptr ; QBluetoothDeviceDiscoveryAgent *_agent = nullptr ; QLowEnergyController *_device = nullptr ; - // QList _services ; - QLowEnergyService *_serviceDeviceInformation = nullptr ; QLowEnergyService *_serviceCurrentTime = nullptr ; QLowEnergyService *_serviceBloodPressure = nullptr ; QLowEnergyService *_serviceBattery = nullptr ; QBluetoothDeviceInfo _temp ; - bool _reconnectionActive = false ; + bool _reconnectionActive = false ; const quint16 _interval = 1000 ; // the interface timer base interval in mSec + public: // 19 total bytes struct MeasurementData { @@ -87,6 +90,9 @@ uint16_t measurement_status; // 2 bytes }; + bool isValid( ) const { return _isValid ; } + void valid(bool vValid) { _isValid = vValid; } + protected: void timerEvent(QTimerEvent *event) override; @@ -141,6 +147,7 @@ void quitServices (); bool isLocalValid (); + bool isAgentValid (); bool isInfoValid (); bool isDeviceValid (); // bool isServiceValid (QLowEnergyService *vService); @@ -151,14 +158,23 @@ bool reconnectToDevice (); void discoverServices (); void discoverServicesDetails(); + void enableNotify (); + void readMeasurements (); + void readInformation (); + void printCharacteristics (QLowEnergyService *vService); void notifyStateChange(const BluetoothData &vData); void parseMeasurement (const QByteArray &byteArray); signals: void didStateChange(const BluetoothData &vData); - SAFE_CALL(start ) - SAFE_CALL(doScan) + SAFE_CALL(doStart ) + SAFE_CALL(doScan ) + SAFE_CALL(doConnectToDevice ) + SAFE_CALL(doDiscoverServices ) + SAFE_CALL(doEnableNotify ) + SAFE_CALL(doReadMeasurements ) + SAFE_CALL(doReadInformation ) }; } Index: sources/canbus/MessageGlobals.h =================================================================== diff -u -r54221e0e6482d4124661190fab14551cba0ec535 -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/canbus/MessageGlobals.h (.../MessageGlobals.h) (revision 54221e0e6482d4124661190fab14551cba0ec535) +++ sources/canbus/MessageGlobals.h (.../MessageGlobals.h) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -64,7 +64,7 @@ {Gui::GuiActionType::ID_PressureOcclusion , 5 * 4 }, // 5 parameters each 4bytes {Gui::GuiActionType::ID_Saline , 3 * 4 }, // 3 parameters each 4bytes {Gui::GuiActionType::ID_Heparin , 1 * 4 }, // 1 parameters each 4bytes - {Gui::GuiActionType::ID_Rinseback , 5 * 4 }, // 5 parameters each 4bytes + {Gui::GuiActionType::ID_Rinseback , 6 * 4 }, // 6 parameters each 4bytes {Gui::GuiActionType::ID_Recirculate , 2 * 4 }, // 2 parameters each 4bytes {Gui::GuiActionType::ID_BloodPrime , 2 * 4 }, // 2 parameters each 4bytes Index: sources/gui/qml/pages/settings/SettingsBluetoothCuff.qml =================================================================== diff -u --- sources/gui/qml/pages/settings/SettingsBluetoothCuff.qml (revision 0) +++ sources/gui/qml/pages/settings/SettingsBluetoothCuff.qml (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -0,0 +1,129 @@ +/*! + * + * Copyright (c) 2019-2020 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 SettingsDateTimeSet.qml + * \author (last) Behrouz NematiPour + * \date (last) 03-Jun-2021 + * \author (original) Behrouz NematiPour + * \date (original) 03-Jun-2021 + * + */ + +// Qt +import QtQuick 2.12 + +// Project +import Gui.Actions 0.1 + +// Qml imports +import "qrc:/globals" +import "qrc:/components" + +/*! + * \brief SettingsVolumeBrightness is used to adjust the + * volume (alarm/system), brightness on the device + */ +SettingsBase { id: _root + itemIndex : SettingsStack.Bluetooth + confirmVisible : false + Image { id: _image + width : 640 + height : 480 + source: "qrc:/images/iCuff-Omron-BP7000" + anchors { + top : parent.top + topMargin : _root.topMarginContent + right : parent.right + rightMargin : 0 // the image itself has some margins // kept to make sure it was intentional. + } + } + Column { id : _deviceColumn + property int labelHeight: 25 + + anchors.top : _image.top + anchors.topMargin : 100 + anchors.left : parent.left + anchors.leftMargin : 50 + spacing : 10 + Label { id : _deviceTitle + text : vBluetooth.devicePair ? qsTr("Found Paired Device") : qsTr("Found Device") + } + Row { id : _deviceNameRow + leftPadding : 25 + Label { id : _deviceNameLabel + height : _deviceColumn.labelHeight + text : qsTr("Name") + labelWidth : 125 + verticalAlignment : Text.AlignVCenter + } + Label { id : _deviceName + height : _deviceColumn.labelHeight + text : ": " + vBluetooth.deviceName + font.pixelSize : Fonts.fontPixelNotification + verticalAlignment : Text.AlignVCenter + } + } + Row { + leftPadding : 25 + Label { id : _deviceAddressLabel + height : _deviceColumn.labelHeight + text : qsTr("Address") + labelWidth : 125 + verticalAlignment : Text.AlignVCenter + + } + Label { id : _deviceAddress + height : _deviceColumn.labelHeight + text : ": " + vBluetooth.deviceAddr + font.pixelSize : Fonts.fontPixelNotification + verticalAlignment : Text.AlignVCenter + } + } + } + + // Column { id : _debugColumn + // anchors.bottom : _scanButton.top + // anchors.left : parent.left + // anchors.leftMargin : 100 + // + // TouchRect { id : _connectButton + // text.text : qsTr("CONNECT") + // width : 300 + // isDefault : false + // enabled : vBluetooth.scanEnabled + // onClicked : vBluetooth.doConnectToDevice() + // } + // + // TouchRect { id : _notifyButton + // text.text : qsTr("NOTIFY") + // width : 300 + // isDefault : false + // enabled : vBluetooth.scanEnabled + // onClicked : vBluetooth.doEnableNotify() + // } + // } + TouchRect { id : _scanButton + anchors.bottom : parent.bottom + anchors.bottomMargin: Variables.mainMenuHeight * 2 + Variables.minVGap + anchors.left : parent.left + anchors.leftMargin : 100 + text.text : qsTr("SCAN") + width : 300 + isDefault : false + enabled : vBluetooth.scanEnabled && vBluetooth.isInvalid + onClicked : 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 +} Index: sources/gui/qml/pages/settings/SettingsStack.qml =================================================================== diff -u -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) +++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -164,84 +164,7 @@ itemIndex : SettingsStack.WiFi } - SettingsBase { id: _settingsBluetooth - itemIndex : SettingsStack.Bluetooth - confirmVisible : false - Image { id: _image - width : 640 - height : 480 - source: "qrc:/images/iCuff-Omron-BP7000" - anchors { - top : parent.top - topMargin : _settingsBluetooth.topMarginContent - right : parent.right - rightMargin : 0 // the image itself has some margins // kept to make sure it was intentional. - } - } - Column { id : _deviceColumn - property int labelHeight: 25 - - anchors.top : _image.top - anchors.topMargin : 100 - anchors.left : parent.left - anchors.leftMargin : 50 - spacing : 10 - Label { id : _deviceTitle - text : vBluetooth.devicePair ? qsTr("Found Paired Device") : qsTr("Found Device") - } - Row { id : _deviceNameRow - leftPadding : 25 - Label { id : _deviceNameLabel - height : _deviceColumn.labelHeight - text : qsTr("Name") - labelWidth : 125 - verticalAlignment : Text.AlignVCenter - } - Label { id : _deviceName - height : _deviceColumn.labelHeight - text : ": " + vBluetooth.deviceName - font.pixelSize : Fonts.fontPixelNotification - verticalAlignment : Text.AlignVCenter - } - } - Row { - leftPadding : 25 - Label { id : _deviceAddressLabel - height : _deviceColumn.labelHeight - text : qsTr("Address") - labelWidth : 125 - verticalAlignment : Text.AlignVCenter - - } - Label { id : _deviceAddress - height : _deviceColumn.labelHeight - text : ": " + vBluetooth.deviceAddr - font.pixelSize : Fonts.fontPixelNotification - verticalAlignment : Text.AlignVCenter - } - } - } - TouchRect { id : _scanButton - anchors.bottom : parent.bottom - anchors.bottomMargin: Variables.mainMenuHeight * 2 + Variables.minVGap - anchors.left : parent.left - anchors.leftMargin : 100 - text.text : qsTr("SCAN") - width : 300 - isDefault : false - enabled : vBluetooth.scanEnabled - onClicked : vBluetooth.doScan() - } - - WaitDone { id : _scanIndication - anchors.horizontalCenter : parent.horizontalCenter - anchors.verticalCenter : _scanButton.verticalCenter - diameter : _scanButton.height - visible : ! vBluetooth.scanEnabled - // done : _delegate.stepDone - } - - notificationText : vBluetooth.notification + SettingsBluetoothCuff { id: _settingsBluetooth } SettingsDG { id: _settingsDGSettings Index: sources/main.h =================================================================== diff -u -r028cb1403e8fcb2d2e9ab2aa1562f660124015b1 -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/main.h (.../main.h) (revision 028cb1403e8fcb2d2e9ab2aa1562f660124015b1) +++ sources/main.h (.../main.h) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -315,7 +315,7 @@ ADJUST_TRANSMT_SIGNAL (vTYPE) \ //--------------------------------------------------------------------------------// #define SAFE_CALL( vMETHOD) \ -public : void vMETHOD() { \ +public Q_SLOTS : void vMETHOD() { \ static bool init = false; \ if ( ! init ) { \ connect(this, SIGNAL(did##vMETHOD()), \ Index: sources/model/hd/data/treatment/MTreatmentRinsebackData.cpp =================================================================== diff -u -r88563177f10f20ced98750b2e40036201728131d -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/model/hd/data/treatment/MTreatmentRinsebackData.cpp (.../MTreatmentRinsebackData.cpp) (revision 88563177f10f20ced98750b2e40036201728131d) +++ sources/model/hd/data/treatment/MTreatmentRinsebackData.cpp (.../MTreatmentRinsebackData.cpp) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -23,6 +23,7 @@ _data.mRate .value, _data.mTimeoutTotal .value, _data.mTimeoutCountDown.value, + _data.mSafetyVolume .value, }; } @@ -33,12 +34,14 @@ if (GetValue(vByteArray, index, _data.mRate )) if (GetValue(vByteArray, index, _data.mTimeoutTotal )) if (GetValue(vByteArray, index, _data.mTimeoutCountDown)) + if (GetValue(vByteArray, index, _data.mSafetyVolume )) return true ; else { if(vIndex) *vIndex = index; return false; } else { if(vIndex) *vIndex = index; return false; } else { if(vIndex) *vIndex = index; return false; } else { if(vIndex) *vIndex = index; return false; } else { if(vIndex) *vIndex = index; return false; } + else { if(vIndex) *vIndex = index; return false; } } /*! @@ -53,5 +56,6 @@ data.mRate = _data.mRate .value; data.mTimeoutTotal = _data.mTimeoutTotal .value; data.mTimeoutCountDown = _data.mTimeoutCountDown.value; + data.mTimeoutCountDown = _data.mSafetyVolume .value; return data; } Index: sources/model/hd/data/treatment/MTreatmentRinsebackData.h =================================================================== diff -u -r88563177f10f20ced98750b2e40036201728131d -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/model/hd/data/treatment/MTreatmentRinsebackData.h (.../MTreatmentRinsebackData.h) (revision 88563177f10f20ced98750b2e40036201728131d) +++ sources/model/hd/data/treatment/MTreatmentRinsebackData.h (.../MTreatmentRinsebackData.h) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -41,6 +41,7 @@ * | #3:(U32) | \ref Data::mRate | * | #4:(U32) | \ref Data::mTimeoutTotal | * | #5:(U32) | \ref Data::mTimeoutCountDown| + * | #6:(F32) | \ref Data::mSafetyVolume | * * \sa Data * \sa MAdjustRinsebackReq : Rinseback Request @@ -67,6 +68,7 @@ Types::U32 mRate ; Types::U32 mTimeoutTotal ; Types::U32 mTimeoutCountDown; + Types::F32 mSafetyVolume ; } _data; public: @@ -81,6 +83,7 @@ quint32 mRate = 0; ///< Current flow rate of rinseback delivery quint32 mTimeoutTotal = 0; ///< Total Timeout of rinseback delivery quint32 mTimeoutCountDown = 0; ///< Current Timeout count down of rinseback delivery + float mSafetyVolume = 0; ///< Safety Volume of rinseback delivery }; public: Index: sources/model/settings/MBluetooth.h =================================================================== diff -u -rf11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/model/settings/MBluetooth.h (.../MBluetooth.h) (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) +++ sources/model/settings/MBluetooth.h (.../MBluetooth.h) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -35,6 +35,7 @@ eIS_Local_Init , eIS_Local_Connect , eIS_Local_Error_Invalid , + eIS_Local_Error_POST , eIS_Local_Error_Off , eIS_Local_Error_IO , eIS_Local_Error , Index: sources/view/settings/VBluetooth.cpp =================================================================== diff -u -rf11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/view/settings/VBluetooth.cpp (.../VBluetooth.cpp) (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) +++ sources/view/settings/VBluetooth.cpp (.../VBluetooth.cpp) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -17,8 +17,9 @@ // Qt // Project +#include "ApplicationController.h" #include "GuiController.h" -#include "MBluetooth.h" +#include "BluetoothInterface.h" VIEW_DEF_CLASS(VBluetooth) @@ -31,19 +32,18 @@ */ void View::VBluetooth::initConnections() { - ACTION_VIEW_CONNECTION(AdjustSerialNumberHDResponseData); connect(&_BluetoothInterface, &BluetoothInterface::didStateChange, this , &VBluetooth::onStateChange ); } -void View::VBluetooth::onActionReceive(const AdjustSerialNumberHDResponseData &vData) -{ - LOG_EVENT( QString() + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + vData.mSerialNumber); - _BluetoothInterface.doScan(); -} - void View::VBluetooth::onStateChange(const Model::MBluetooth &vData) { + if ( vData.state == MBluetooth::eIS_Local_Error_POST ) { + isInvalid( true ); + notify( vData.state ); + return; + } + scanEnabled( ! (vData.state == MBluetooth::eIS_Close || // local vData.state == MBluetooth::eIS_Local_Init || @@ -86,15 +86,21 @@ error (vData.error ); devicePin (vData.devicePin ); + notify( vData.state ); +} + +QString View::VBluetooth::toText(MBluetooth::InterfaceStates vState) const +{ QString message; - switch (vData.state) { + switch (vState) { 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; case MBluetooth::eIS_Local_Error_Invalid : message = tr("No Valid Bluetooth Adapter" ); break; + case MBluetooth::eIS_Local_Error_POST : message = tr("The Bluetooth Adapter POST Failed" ); break; case MBluetooth::eIS_Local_Error_Off : message = tr("The Bluetooth Adapter Is Off" ); break; case MBluetooth::eIS_Local_Error_IO : message = tr("The Bluetooth Adapter IO Error" ); break; case MBluetooth::eIS_Local_Error : message = tr("The Bluetooth Adapter Unknown Error" ); break; @@ -112,7 +118,7 @@ case MBluetooth::eIS_Device_Start : message = tr("Device Connecting ..." ); break; case MBluetooth::eIS_Device_Error : message = tr("Device Connection Error" ); break; case MBluetooth::eIS_Device_Connect : message = tr("Device Connected" ); break; - case MBluetooth::eIS_Device_Done : message = tr("Device Connection Done" ); break; + case MBluetooth::eIS_Device_Done : message = tr("Device Clean Up" ); break; case MBluetooth::eIS_Device_Disconnect : message = tr("Device Disconnected" ); break; case MBluetooth::eIS_Service_Start : message = tr("Service Scanning ..." ); break; @@ -122,7 +128,7 @@ case MBluetooth::eIS_Service_Detail_Error : message = tr("Service Detail Error" ); break; case MBluetooth::eIS_Service_Detail_Invalid : message = tr("Service Detail Invalid" ); break; 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_Service_Done : message = tr("Service Clean Up" ); break; case MBluetooth::eIS_Detail_Change : message = tr("Service Characteristic Changed" ); break; case MBluetooth::eIS_Detail_Read : message = tr("Service Characteristic Read" ); break; @@ -131,7 +137,12 @@ case MBluetooth::eIS_Config_Write : message = tr("Service Descriptor Write" ); break; // IMPORTANT: Do not use the "default:" to let compiler check for all the enumeration which are not handled. } + return message; +} +void View::VBluetooth::notify(MBluetooth::InterfaceStates vState) +{ + QString message = toText(vState); notification(message); // Console Log @@ -143,7 +154,9 @@ LOG_DEBUG(message); } -void View::VBluetooth::doScan() -{ - _BluetoothInterface.doScan(); -} +void View::VBluetooth::doScan () { _BluetoothInterface.doScan (); } +void View::VBluetooth::doConnectToDevice () { _BluetoothInterface.doConnectToDevice (); } +void View::VBluetooth::doDiscoverServices () { _BluetoothInterface.doDiscoverServices (); } +void View::VBluetooth::doEnableNotify () { _BluetoothInterface.doEnableNotify (); } +void View::VBluetooth::doReadMeasurements () { _BluetoothInterface.doReadMeasurements (); } +void View::VBluetooth::doReadInformation () { _BluetoothInterface.doReadInformation (); } Index: sources/view/settings/VBluetooth.h =================================================================== diff -u -rf11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/view/settings/VBluetooth.h (.../VBluetooth.h) (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) +++ sources/view/settings/VBluetooth.h (.../VBluetooth.h) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -21,7 +21,7 @@ #include "main.h" // Doxygen : do not remove #include "VView.h" #include "MAdjustHDSerialNumberResponse.h" -#include "BluetoothInterface.h" +#include "MBluetooth.h" // forward declarations class tst_views; @@ -38,12 +38,14 @@ // friends friend class ::tst_views; + PROPERTY(bool , isInvalid , true ) // chose isInvalid instead of isValid for performance reasons to avoid multi call when it is valid. + PROPERTY(QString , notification , "" ) PROPERTY(QString , localName , "" ) PROPERTY(QString , localAddr , "" ) - PROPERTY(bool , scanEnabled , true ) + PROPERTY(bool , scanEnabled , false ) PROPERTY(QString , deviceName , "" ) PROPERTY(QString , deviceAddr , "" ) PROPERTY(QString , devicePin , "" ) @@ -56,16 +58,20 @@ PROPERTY(QString , detailValue , "" ) VIEW_DEC_CLASS(VBluetooth) - VIEW_DEC_SLOT (AdjustSerialNumberHDResponseData) signals: private slots: - void onStateChange(const Model::MBluetooth &vData); + void onStateChange (const Model::MBluetooth &vData); + QString toText ( Model::MBluetooth::InterfaceStates vState) const; + void notify (Model::MBluetooth::InterfaceStates vState); public slots: - void doScan(); - - + void doScan (); + void doConnectToDevice (); + void doDiscoverServices (); + void doEnableNotify (); + void doReadMeasurements (); + void doReadInformation (); }; } Index: sources/wifi/WifiInterface.cpp =================================================================== diff -u -r66506a15ac0234c0a2fcf78d3262fdb91c51cbca -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/wifi/WifiInterface.cpp (.../WifiInterface.cpp) (revision 66506a15ac0234c0a2fcf78d3262fdb91c51cbca) +++ sources/wifi/WifiInterface.cpp (.../WifiInterface.cpp) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -97,9 +97,6 @@ void WifiInterface::initConnections() { - connect(this, SIGNAL(didStart()), - this, SLOT( onStart())); - connect(this, SIGNAL(didStatusChanged(const QString)), this, SLOT( onStatusChanged(const QString))); @@ -228,20 +225,11 @@ } /*! - * \brief WifiInterface::start + * \brief WifiInterface::ondoStart * Starts the WifiInterface */ -void WifiInterface::start() +void WifiInterface::ondoStart() { - emit didStart({}); -} - -/*! - * \brief WifiInterface::onStart - * Called when the WifiInterface has started - */ -void WifiInterface::onStart() -{ if (hasConnectedToWifi()) rejoinLastWifiNetwork(); } Index: sources/wifi/WifiInterface.h =================================================================== diff -u -r66506a15ac0234c0a2fcf78d3262fdb91c51cbca -re4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845 --- sources/wifi/WifiInterface.h (.../WifiInterface.h) (revision 66506a15ac0234c0a2fcf78d3262fdb91c51cbca) +++ sources/wifi/WifiInterface.h (.../WifiInterface.h) (revision e4a0e2fc4c7ae0cbce0d670772276bf7f5ff3845) @@ -93,9 +93,6 @@ QStringList securityTypesToStringList(const QList &securityTypes); QList variantListToSecurityTypes(const QList &securityTypesVar); -public: - void start(); - public slots: bool init(QThread &vThread); bool init(); @@ -132,7 +129,6 @@ private slots: void quit(); - void onStart(); void onStatusChanged(const QString &vMessage); void onRequestAutoAssignedIP(); void onProcessFinishedScan (int vExitCode, QProcess::ExitStatus vExitStatus); @@ -147,4 +143,6 @@ void onProcessFinishedSetGateway (int vExitCode, QProcess::ExitStatus vExitStatus); void onProcessFinishedSetSubnetMask (int vExitCode, QProcess::ExitStatus vExitStatus); void onProcessFinishedSetDNS (int vExitCode, QProcess::ExitStatus vExitStatus); + + SAFE_CALL(doStart) };