Index: sources/device/DeviceController.cpp =================================================================== diff -u -rcd589a3f0683918fc299652c4f265269ac83d945 -r0932b2beee9cc169291cbf69161f902f805237b1 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision cd589a3f0683918fc299652c4f265269ac83d945) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -39,6 +39,8 @@ using namespace Device; using namespace Storage; +DEVICE_DEV_DECLARATION_LIST + /*! * \brief DeviceController::DeviceController * \details Constructor @@ -586,8 +588,11 @@ * 3 - get no error when in onProcessBrightnessExitCode : MDeviceResponse.toString() * - in case 3 the specific model _data has to be filled prior to the toString to have it in the log. */ -void DeviceController::onProcessBrightnessExitCode(int vExitCode, QProcess::ExitStatus) +void DeviceController::onProcessBrightnessExitCode(int vExitCode, QProcess::ExitStatus vStatus) { + //DEBUG + qDebug() << __FUNCTION__ << vExitCode << vStatus; + if ( ! checkError(static_cast(vExitCode), _deviceBrightnessResponse, _deviceBrightnessResponse.toString()) ) { // has no error if (_deviceBrightnessRequest._data.mRead) { bool ok = false; @@ -1230,7 +1235,6 @@ ///////////////////////////////////////////// DeviceUSBMounting void DeviceController::onAttributeRequest(const DeviceUSBMountRequestData &vData) { - Q_UNUSED(vData) usbMountReq(vData.usbDevice, vData.isMountRequest); } @@ -1312,3 +1316,68 @@ // log error and exit return; } + +///////////////////////////////////////////// DeviceWifiList +void DeviceController::onAttributeRequest(const DeviceWifiListRequestData &) +{ + wifiListRequest(); +} + +/*! + * \brief DeviceController::wifiListRequest + * \details Calls the Wifi List script + * \note This function is created to be able to call independently if needed in this class. + */ +void DeviceController::wifiListRequest() +{ + // _deviceWifiListRequest._data + + // ----- check that script exists. + QString script; + if ( checkError( DeviceError::checkScript(script, Wifi_Scan_For_Networks), _deviceWifiListResponse, script) ) + return; + + // ----- check if the process is not running + if ( _processWifiList.state() != QProcess::NotRunning ) { + checkError(DeviceError::eDevice_Scripts_Error_IsRunning, _deviceWifiListResponse); + return; + } + + // ----- run the process + int timeout_ms = 10000; + TimedProcess *timedProcess = new TimedProcess(&_processWifiList, script, timeout_ms, {}); + timedProcess->start(); + + MDeviceWifiListResponse model; + model._data.mCompleted = false; + model._data.mAccepted = false; + model._data.mMessage = tr("WiFi list scan started."); + emit didAttributeResponse(model.data()); +} + +/*! + * \brief DeviceController::onProcessUSBMountExitCode + * \param vExitCode + * \param vStatus + */ +void DeviceController::onProcessWifiListExitCode(int vExitCode, QProcess::ExitStatus vStatus) +{ + //DEBUG + qDebug() << __FUNCTION__ << vExitCode << vStatus; + + MDeviceWifiListResponse model; + model._data.mCompleted = true; + QByteArray deviceInfo; + if ( vStatus ) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status; + else deviceInfo = _processWifiList.readAll(); + model.fromByteArray( deviceInfo, &vExitCode ); + emit didAttributeResponse(model.data()); + + bool ok = ! vStatus; + + // log error and exit + if ( ! ok ) { + LOG_DEBUG(QString("WiFi list scan filed [%1]").arg(vExitCode)); + } + return; +}