Index: sources/device/DeviceController.cpp =================================================================== diff -u -r719bd896dd47db720ee00ca476a3a27a8ddf6ea4 -rb38e1590d137f607b982d336e60b614c2ae685c2 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 719bd896dd47db720ee00ca476a3a27a8ddf6ea4) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision b38e1590d137f607b982d336e60b614c2ae685c2) @@ -21,6 +21,7 @@ // Qt #include #include +#include #include // Project @@ -252,30 +253,24 @@ */ void DeviceController::checkWiFi() { - struct WiFiData { - QString mSSID ; - QString mIP ; - QString mSTRENGTH ; - QString mSECURITY ; + QString mIP = tr("No WiFi"); - QString toString() { - QStringList fields = QStringList() - << mSSID - << mIP - << mSTRENGTH - << mSECURITY; - return fields.join(','); - } - } ; + const QNetworkInterface dev = QNetworkInterface::interfaceFromName("wlan0"); + if ( dev.isValid() ) { + auto addresses = dev.addressEntries(); - WiFiData mWifiData; - mWifiData.mSSID = "TEST"; - mWifiData.mIP = "1925.3168.0.31"; - mWifiData.mSECURITY = "max"; - mWifiData.mSTRENGTH = "150"; + if ( addresses.count() ) { + if ( dev.flags().testFlag(QNetworkInterface::IsUp) && dev.flags().testFlag(QNetworkInterface::IsRunning) ) { + mIP = addresses.first().ip().toString(); + } + else { + mIP = tr("WiFi Not Connected"); + } + } + } - emit didWiFiData(mWifiData.toString()); + emit didWiFiData(mIP); } /*! @@ -622,6 +617,7 @@ } _hasThread = true; checkConfugurationMountReady(); + checkWifiConnectionReady(); } /*! @@ -834,7 +830,6 @@ return; } - ////////////////////////////////////////////////////////////////////////////////////////////////// DeviceUSBMounting void DeviceController::onAttributeRequest(const DeviceUSBMountRequestData &vData) { @@ -1110,6 +1105,15 @@ } } +/*! + * \brief DeviceController::checkWifiConnectionReady + * \details This function will run the wifi_info.sh at start up when the + * device controller thread is ready + */ +void DeviceController::checkWifiConnectionReady() +{ + wifiInfoRequest(); +} ////////////////////////////////////////////////////////////////////////////////////////////////// DeviceWifiConnect void DeviceController::onAttributeRequest(const DeviceWifiConnectRequestData &vData) Index: sources/device/DeviceController.h =================================================================== diff -u -r3bee9f20350882eca47f3d18b0accf5bec3933d4 -rb38e1590d137f607b982d336e60b614c2ae685c2 --- sources/device/DeviceController.h (.../DeviceController.h) (revision 3bee9f20350882eca47f3d18b0accf5bec3933d4) +++ sources/device/DeviceController.h (.../DeviceController.h) (revision b38e1590d137f607b982d336e60b614c2ae685c2) @@ -284,6 +284,7 @@ void findPendingLogs(); void checkWiFi(); + void checkWifiConnectionReady(); bool logBackup(const QString &vFileName); bool logUpload(const QString &vFileName); Index: sources/device/DeviceView.cpp =================================================================== diff -u -r719bd896dd47db720ee00ca476a3a27a8ddf6ea4 -rb38e1590d137f607b982d336e60b614c2ae685c2 --- sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 719bd896dd47db720ee00ca476a3a27a8ddf6ea4) +++ sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision b38e1590d137f607b982d336e60b614c2ae685c2) @@ -45,17 +45,6 @@ osVersion(vOSVersion); } -void VDevice::onWiFiData (const QString &vData) -{ - QStringList wifiData = vData.split(','); - - if (wifiData.count() == 2) { - ssid(wifiData[0]); - ipAddress(wifiData[1]); - } - -} - // ================================================= Brightness void VDevice::doInitBrightness() { // DEBUG : qDebug() << "HERE Request" << vValue; @@ -637,3 +626,9 @@ response(true); } +// ================================================= WiFi Indicator +void VDevice::onWiFiData (const QString &vData) +{ + ipAddress(vData); +} + Index: sources/gui/qml/dialogs/WiFiDialog.qml =================================================================== diff -u -r3bee9f20350882eca47f3d18b0accf5bec3933d4 -rb38e1590d137f607b982d336e60b614c2ae685c2 --- sources/gui/qml/dialogs/WiFiDialog.qml (.../WiFiDialog.qml) (revision 3bee9f20350882eca47f3d18b0accf5bec3933d4) +++ sources/gui/qml/dialogs/WiFiDialog.qml (.../WiFiDialog.qml) (revision b38e1590d137f607b982d336e60b614c2ae685c2) @@ -4,58 +4,34 @@ import "qrc:/globals" HeaderBarPopup { id: _root - readonly property int pixelSize : 24 + readonly property int pixelSize : 22 + readonly property bool isConnected : vDevice.ssid !== "" - -// width : Math.max( _wifiDataTable.contentWidth) + Variables.defaultMargin * 2 - - width : Math.max( test1.contentWidth, - _ssid.contentWidth, + width : Math.max( _ssid.contentWidth, _ipAddress.contentWidth) + Variables.defaultMargin * 2 - height : 100 + height : isConnected ? _ssid.contentHeight + _ipAddress.contentHeight + Variables.defaultMargin : + _ipAddress.contentHeight + Variables.defaultMargin -// ListModel { id: _wiFiData -//// ListElement { name: qsTr("x"); text: ("%1").arg(_root.x) } -// ListElement { name: qsTr("SSID"); text: vDevice.ssid } -// ListElement { name: qsTr("IP"); text: vDevice.ipAddress } -//// ListElement { name: qsTr("Security"); text: 2.45 } -//// ListElement { name: qsTr("Strength"); text: 2.45 } -// } + // TODO: Later add Securty type and signal strength if needed - Column { id : _dialogRow + Column { id : _dialogColumn anchors.fill : parent anchors.leftMargin : Variables.defaultMargin anchors.topMargin : 10 - -// Repeater { id: _wifiDataTable -// model: _wiFiData -// Text { -// text: ("%1: %2").arg(model.name).arg(model.text) -// color: Colors.dialogText -// font.pixelSize: _root.pixelSize -// } -// } - - Text { id: test1 - text: "x: " + _root.x - color: Colors.dialogText - font.pixelSize: _root.pixelSize - } - Text { id: _ssid - text: ("%1: %2").arg(qsTr("SSID")).arg(vDevice.ssid) - color: Colors.dialogText - font.pixelSize: _root.pixelSize + text : ("%1: %2").arg(qsTr("SSID")).arg(vDevice.ssid) + color : Colors.dialogText + font.pixelSize : _root.pixelSize + visible : _root.isConnected } Text { id: _ipAddress - text : ("%1: %2").arg(qsTr("IP")).arg(vDevice.ipAddress) + text : _root.isConnected ? ("%1: %2").arg(qsTr("IP")).arg(vDevice.ipAddress) : + qsTr(vDevice.ipAddress) color : Colors.dialogText font.pixelSize : _root.pixelSize } } - - }