Index: denali.pro.user =================================================================== diff -u -r60db0ce19666f04ea58992a7670497d83f9bf7c4 -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- denali.pro.user (.../denali.pro.user) (revision 60db0ce19666f04ea58992a7670497d83f9bf7c4) +++ denali.pro.user (.../denali.pro.user) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -1,6 +1,6 @@ - + EnvironmentId @@ -86,311 +86,6 @@ ProjectExplorer.Project.Target.0 - Qt 5.12.5 (iMX8) - Qt 5.12.5 (iMX8) - {5d6458ef-f917-4aef-a092-c77bbe106149} - 1 - 0 - 0 - - /home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Debug - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - true - - - /home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Release - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - - /home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Profile - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 3 - - - - true - Check for free disk space - - RemoteLinux.CheckForFreeDiskSpaceStep - - - - - / - 5242880 - - - - - true - Kill current application instance - - RemoteLinux.KillAppStep - - - - - - - - - true - Deploy files via rsync - - RemoteLinux.RsyncDeployStep - - - - - - - -av - false - - 3 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy to Remote Linux Host - - DeployToGenericLinux - - 1 - - - dwarf - - cpu-cycles - - - 250 - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 1 - - - denali (on UI Test Board) - RemoteLinuxRunConfiguration:/home/denali/Projects/application/denali.pro - 1 - - false - - 3768 - false - true - false - false - true - false - - - :0 - - 1 - - - - ProjectExplorer.Project.Target.1 - Desktop Qt 5.12.5 GCC 64bit Desktop Qt 5.12.5 GCC 64bit qt.qt5.5125.gcc_64_kit @@ -1496,6 +1191,311 @@ + ProjectExplorer.Project.Target.1 + + Qt 5.12.5 (iMX8) + Qt 5.12.5 (iMX8) + {5d6458ef-f917-4aef-a092-c77bbe106149} + 1 + 0 + 0 + + /home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + /home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + + true + Check for free disk space + + RemoteLinux.CheckForFreeDiskSpaceStep + + + + + / + 5242880 + + + + + true + Kill current application instance + + RemoteLinux.KillAppStep + + + + + + + + + true + Deploy files via rsync + + RemoteLinux.RsyncDeployStep + + + + + + + -av + false + + 3 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy to Remote Linux Host + + DeployToGenericLinux + + 1 + + + dwarf + + cpu-cycles + + + 250 + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 1 + + + denali (on UI Test Board) + RemoteLinuxRunConfiguration:/home/denali/Projects/application/denali.pro + 1 + + false + + 3768 + false + true + false + false + true + false + + + :0 + + 1 + + + ProjectExplorer.Project.TargetCount 2 Index: scripts/wifi_generate_wpa_supplicant.sh =================================================================== diff -u -r2085962f7bd0a2239ee5c857928a11d5e38fe0a2 -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- scripts/wifi_generate_wpa_supplicant.sh (.../wifi_generate_wpa_supplicant.sh) (revision 2085962f7bd0a2239ee5c857928a11d5e38fe0a2) +++ scripts/wifi_generate_wpa_supplicant.sh (.../wifi_generate_wpa_supplicant.sh) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -2,13 +2,30 @@ ssid=$1 password=$2 dest=$3 -echo "ctrl_interface=/var/run/wpa_supplicant +securityType=$4 +case $securityType in + wpa2|wpa) + echo "Security: wpa2/wpa"; + psk=$(wpa_passphrase "$ssid" "$password" | grep "psk=" | grep -v "#psk" | sed -nr 's/.*psk=(.*)/\1/p') + echo "ctrl_interface=/var/run/wpa_supplicant ctrl_interface_group=0 update_config=1 network={ ssid=\"$ssid\" - psk=\"$password\" -}" > $dest + #psk=\"\" + psk=$psk +}" > $dest;; + wep) + echo "Security: wep"; + echo "ctrl_interface=/var/run/wpa_supplicant +ctrl_interface_group=0 +update_config=1 - +network={ + ssid=\"$ssid\" + key_mgmt=NONE + wep_key0=$password + wep_tx_keyidx=0 +}" > $dest;; +esac Index: scripts/wifi_request_auto_assigned_ip.sh =================================================================== diff -u -r2085962f7bd0a2239ee5c857928a11d5e38fe0a2 -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- scripts/wifi_request_auto_assigned_ip.sh (.../wifi_request_auto_assigned_ip.sh) (revision 2085962f7bd0a2239ee5c857928a11d5e38fe0a2) +++ scripts/wifi_request_auto_assigned_ip.sh (.../wifi_request_auto_assigned_ip.sh) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -3,4 +3,4 @@ if [ $# -eq 1 ]; then iface=$1 fi -killall udhcpc; udhcpc -i $iface +killall udhcpc; udhcpc --timeout=3 --retries=2 --tryagain=5 -n -i $iface Index: scripts/wifi_reset_adapter.sh =================================================================== diff -u -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- scripts/wifi_reset_adapter.sh (.../wifi_reset_adapter.sh) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) +++ scripts/wifi_reset_adapter.sh (.../wifi_reset_adapter.sh) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -1,4 +1,4 @@ #!/bin/sh rfkill block wifi rfkill unblock wifi -ifconfig wlan0 up +ip link set wlan0 up Index: scripts/wifi_reset_interface.sh =================================================================== diff -u -r2085962f7bd0a2239ee5c857928a11d5e38fe0a2 -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- scripts/wifi_reset_interface.sh (.../wifi_reset_interface.sh) (revision 2085962f7bd0a2239ee5c857928a11d5e38fe0a2) +++ scripts/wifi_reset_interface.sh (.../wifi_reset_interface.sh) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -1,4 +1,4 @@ #!/bin/sh iface=$1 -ifconfig $iface down -ifconfig $iface up +ifdown $iface +ifup $iface Index: scripts/wifi_save_static_interface_assignments.sh =================================================================== diff -u --- scripts/wifi_save_static_interface_assignments.sh (revision 0) +++ scripts/wifi_save_static_interface_assignments.sh (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -0,0 +1,12 @@ +#!/bin/sh + +iface=$1 +ip=$2 +gateway=$3 +subnet_mask=$4 + +echo "auto $iface +iface $iface inet static + address $ip + netmask $subnet_mask + gateway $3" > /etc/network/interfaces Fisheye: Tag 13ac42cf8bdc5038dedd3302ba79dc387e5704b4 refers to a dead (removed) revision in file `scripts/wifi_set_static_ip.sh'. Fisheye: No comparison available. Pass `N' to diff? Index: scripts/wifi_test_internet.sh =================================================================== diff -u --- scripts/wifi_test_internet.sh (revision 0) +++ scripts/wifi_test_internet.sh (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -0,0 +1,3 @@ +#!/bin/sh +iface=$1 +ping -I $iface www.google.com Index: sources/canbus/MessageGlobals.h =================================================================== diff -u -r5215e145a0f26a20c99e3f10af6ac8a9c3b67383 -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- sources/canbus/MessageGlobals.h (.../MessageGlobals.h) (revision 5215e145a0f26a20c99e3f10af6ac8a9c3b67383) +++ sources/canbus/MessageGlobals.h (.../MessageGlobals.h) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -225,7 +225,7 @@ // UI listens occasionally eChlid_DG_UI = 0x070, ///< DG => UI - eChlid_UI_DG = eChlid_UI_Sync , ///< No direct channel has been defined between DG&UI, May be required for logging + eChlid_UI_DG = 0x110, ///< UI => DG }; /*! Index: sources/gui/qml/globals/Variables.qml =================================================================== diff -u -rea52cee2614f319804690a9b1d5091bed9676753 -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- sources/gui/qml/globals/Variables.qml (.../Variables.qml) (revision ea52cee2614f319804690a9b1d5091bed9676753) +++ sources/gui/qml/globals/Variables.qml (.../Variables.qml) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -133,6 +133,7 @@ readonly property int settingsWIFINetworkHeight : 85 readonly property int settingsWIFINetworkWidth : 375 readonly property int settingsWIFINetworksWidth : settingsWIFINetworkWidth + 50 + readonly property int settingsWIFIBottomMargin : 15 readonly property int rinsebackIconDiameterDefault : 85 readonly property int rinsebackIconDiameterResumePause : 110 Index: sources/gui/qml/pages/SettingsWifi.qml =================================================================== diff -u -rf35b360054e1e2fa81bf107427fe2d50d78e9e8a -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- sources/gui/qml/pages/SettingsWifi.qml (.../SettingsWifi.qml) (revision f35b360054e1e2fa81bf107427fe2d50d78e9e8a) +++ sources/gui/qml/pages/SettingsWifi.qml (.../SettingsWifi.qml) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -136,6 +136,7 @@ TouchRect { id: _scan anchors { bottom: _rect.bottom + bottomMargin: Variables.settingsWIFIBottomMargin left: _rect.left } @@ -160,6 +161,7 @@ textfontSize: Fonts.fontPixelTextRectExtra anchors { bottom: parent.bottom + bottomMargin: Variables.settingsWIFIBottomMargin } } @@ -168,6 +170,7 @@ anchors { top: parent.top bottom: parent.bottom + bottomMargin: _notification.height + Variables.settingsWIFIBottomMargin right: parent.right } width: Variables.settingsWIFINetworksWidth @@ -193,7 +196,7 @@ width: Variables.settingsWIFINetworkWidth color: Colors.backgroundMain border.color: Colors.borderButton - border.width: 4 + border.width: 2 radius: 20 animated: true @@ -207,6 +210,18 @@ color: Colors.textMain } + Text { + id: _securityLevel + anchors { + left: parent.left + leftMargin: 10 + bottom: parent.bottom + } + font.pixelSize: Fonts.fontPixelDialogText + text: securityTypes + color: Colors.textMain + } + onClicked: { console.debug("Clicked " + ssid + " with macAddress: " + macAddress); if (vNetworkModel.doCheckIfConnected(macAddress)) { Index: sources/view/VNetworkModel.cpp =================================================================== diff -u -r60db0ce19666f04ea58992a7670497d83f9bf7c4 -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- sources/view/VNetworkModel.cpp (.../VNetworkModel.cpp) (revision 60db0ce19666f04ea58992a7670497d83f9bf7c4) +++ sources/view/VNetworkModel.cpp (.../VNetworkModel.cpp) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -29,8 +29,11 @@ this, SLOT(onDisconnectedNetwork(const Network))); connect(&_WifiInterface, SIGNAL(didError(const QString)), - this, SLOT(onError(const QString))); + this, SLOT(onStatusChanged(const QString))); + connect(&_WifiInterface, SIGNAL(didStatusChanged(const QString)), + this, SLOT(onStatusChanged(const QString))); + // outgoing connect(this, SIGNAL(didScan()), &_WifiInterface, SLOT(doScan())); @@ -43,6 +46,21 @@ connect(this, SIGNAL(didRequestIPSettings()), &_WifiInterface, SLOT(doRequestIPSettings())); + + // static IP address assignment + connect(this, SIGNAL(didRequestSetIPAddress(const QString)), + &_WifiInterface, SLOT(doRequestSetIPAddress(const QString))); + + connect(this, SIGNAL(didRequestSetGateway(const QString)), + &_WifiInterface, SLOT(doRequestSetGateway(const QString))); + + connect(this, SIGNAL(didRequestSetSubnetMask(const QString)), + &_WifiInterface, SLOT(doRequestSetSubnetMask(const QString))); + + connect(this, SIGNAL(didRequestSetDNS(const QString)), + &_WifiInterface, SLOT(doRequestSetDNS(const QString))); + + } /*! @@ -61,6 +79,17 @@ } /*! + * \brief VNetworkModel::removeRows + * Removes all rows from the model + */ +void VNetworkModel::removeAllRows() +{ + beginRemoveRows(QModelIndex(), 0, rowCount()); + _networks.clear(); + endRemoveRows(); +} + +/*! * \brief VNetworkModel::rowCount * Gets the number of networks * \param parent - (QModelIndex) the parent QModelIndex @@ -92,8 +121,8 @@ return network.macAddress(); case SSIDRole: return network.ssid(); - case SecurityLevelRole: - return network.security(); + case SecurityTypesRole: + return network.securityTypesToStringList(network.securityTypes()).join("/"); case StatusRole: return network.status(); case SignalLevelRole: @@ -112,7 +141,7 @@ QHash roles; roles[MacAddressRole] = "macAddress"; roles[SSIDRole] = "ssid"; - roles[SecurityLevelRole] = "securityLevel"; + roles[SecurityTypesRole] = "securityTypes"; roles[StatusRole] = "status"; roles[SignalLevelRole] = "signalLevel"; return roles; @@ -123,7 +152,9 @@ * Handles when a user clicks the Scan button */ void VNetworkModel::doScan() { - qDebug() << __FUNCTION__ << QThread::currentThread()->objectName(); + LOG_DEBUG(QString("VNetworkModel::%1 %2").arg(__FUNCTION__).arg(QThread::currentThread()->objectName())); + LOG_DEBUG("Clearing networks before re-scanning."); + removeAllRows(); status(tr("Scanning...")); emit didScan(); } @@ -251,12 +282,48 @@ } /*! - * \brief VNetworkModel::onError - * Called when the wifi interface emits an error + * \brief VNetworkModel::onStatusChanged + * Called when the wifi interface status changes * \param vMessage - (QString) the error message */ -void VNetworkModel::onError(const QString &vMessage) +void VNetworkModel::onStatusChanged(const QString &vMessage) { LOG_DEBUG(QString("VNetworkModel::%1 %2").arg(__FUNCTION__).arg(QThread::currentThread()->objectName())); status(vMessage); } + +/*! + * \brief VNetworkModel::doSetIPAddress + * \param vIPAddress + */ +void VNetworkModel::doSetIPAddress(const QString &vIPAddress) +{ + emit didRequestSetIPAddress(vIPAddress); +} + +/*! + * \brief VNetworkModel::doSetGateway + * \param vGateway + */ +void VNetworkModel::doSetGateway(const QString &vGateway) +{ + emit didRequestSetGateway(vGateway); +} + +/*! + * \brief VNetworkModel::doSetSubnetMask + * \param vSubnetMask + */ +void VNetworkModel::doSetSubnetMask(const QString &vSubnetMask) +{ + emit didRequestSetSubnetMask(vSubnetMask); +} + +/*! + * \brief VNetworkModel::doSetDNS + * \param vDNS + */ +void VNetworkModel::doSetDNS(const QString &vDNS) +{ + emit didRequestSetDNS(vDNS); +} Index: sources/view/VNetworkModel.h =================================================================== diff -u -rf35b360054e1e2fa81bf107427fe2d50d78e9e8a -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- sources/view/VNetworkModel.h (.../VNetworkModel.h) (revision f35b360054e1e2fa81bf107427fe2d50d78e9e8a) +++ sources/view/VNetworkModel.h (.../VNetworkModel.h) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -41,20 +41,27 @@ enum NetworkDataRole { MacAddressRole = Qt::UserRole + 1, SSIDRole, - SecurityLevelRole, + SecurityTypesRole, StatusRole, SignalLevelRole, }; void addNetwork (const Network &network); int rowCount (const QModelIndex &parent = QModelIndex()) const; QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const; + void removeAllRows(); signals: void didScan(); void didJoinNetwork(const Network, const QString); void didDisconnectNetwork(const Network); void didRequestIPSettings(); + // set IP addresses + void didRequestSetIPAddress(const QString); + void didRequestSetGateway(const QString); + void didRequestSetSubnetMask(const QString); + void didRequestSetDNS(const QString); + public slots: void doScan(); void doAddNetwork(const Network &vNetwork); @@ -63,6 +70,12 @@ void doDisconnectNetwork(const QString &vMacAddress); void doRequestIPSettings(); + // static IP address assignment + void doSetIPAddress(const QString &vIPAddress); + void doSetGateway(const QString &vGateway); + void doSetSubnetMask(const QString &vSubnetMask); + void doSetDNS(const QString &vDNS); + protected: QHash roleNames() const; private: @@ -72,9 +85,9 @@ private slots: void onScanStatusChanged(const bool &vScanning); + void onStatusChanged(const QString &vNewStatus); void onConnectedToNetwork(const Network &vNetwork); void onDisconnectedNetwork(const Network &vNetwork); - void onError(const QString &vMessage); }; } Index: sources/wifi/Network.h =================================================================== diff -u -r3403122944ec8f31dfd33b387e21204783579f60 -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- sources/wifi/Network.h (.../Network.h) (revision 3403122944ec8f31dfd33b387e21204783579f60) +++ sources/wifi/Network.h (.../Network.h) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -16,14 +16,13 @@ { public: - enum SECURITY_LEVEL { + enum SECURITY_TYPE { UNSUPPORTED, WEP, WPA_TKIP, WPA_TKIP_AES, WPA_AES, - WPA2_AES_PERSONAL, - WPA2_AES_ENTERPRISE + WPA2_AES }; enum SIGNAL_LEVEL @@ -77,12 +76,59 @@ void ssid(const QString &vSSID) { _ssid = vSSID; } - SECURITY_LEVEL security() const { - return _security; + + static QStringList securityTypesToStringList(QList vSecurityTypes) + { + QStringList result; + for (const SECURITY_TYPE &type : vSecurityTypes) + { + switch (type) { + case WEP: + { + result.append("WEP"); + break; + } + case WPA_TKIP: + { + result.append("WPA_TKIP"); + break; + } + case WPA_TKIP_AES: + { + result.append("WPA_TKIP_AES"); + break; + } + case WPA_AES: + { + result.append("WPA_AES"); + break; + } + case WPA2_AES: + { + result.append("WPA2_AES"); + break; + } + case UNSUPPORTED: + { + result.append("UNSUPPORTED"); + break; + } + default: + { + result.append("UNKNOWN"); + break; + } + } + } + return result; } - void security(const SECURITY_LEVEL &vSecurity) { - _security = vSecurity; + + QList securityTypes() const { + return _securityTypes; } + void securityTypes(const QList &vSecurityTypes) { + _securityTypes = vSecurityTypes; + } SIGNAL_LEVEL signalLevel() const { return _signalLevel; } @@ -121,10 +167,10 @@ explicit Network() {} explicit Network(const QString &vMacAddress) {_macAddress = vMacAddress; } - explicit Network(const QString &vMacAddress, const QString &vSSID, const SECURITY_LEVEL &vSecurityLevel, const STATUS &vStatus, const int &vSignalLevel) { + explicit Network(const QString &vMacAddress, const QString &vSSID, const QList &vSecurityTypes, const STATUS &vStatus, const int &vSignalLevel) { _macAddress = vMacAddress; _ssid = vSSID; - _security = vSecurityLevel; + _securityTypes = vSecurityTypes; _status = vStatus; _signalLevel = convertSignalLevel(vSignalLevel); } @@ -137,15 +183,15 @@ _macAddress = ""; _ssid = ""; - _security = UNSUPPORTED; + _securityTypes.clear(); _status = NOT_CONNECTED; _signalLevel = NO_SIGNAL; } private: QString _macAddress; QString _ssid; - SECURITY_LEVEL _security = UNSUPPORTED; + QList _securityTypes; SIGNAL_LEVEL _signalLevel = NO_SIGNAL; STATUS _status = NOT_CONNECTED; }; Index: sources/wifi/WifiInterface.cpp =================================================================== diff -u -r60db0ce19666f04ea58992a7670497d83f9bf7c4 -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- sources/wifi/WifiInterface.cpp (.../WifiInterface.cpp) (revision 60db0ce19666f04ea58992a7670497d83f9bf7c4) +++ sources/wifi/WifiInterface.cpp (.../WifiInterface.cpp) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -4,6 +4,7 @@ #include #include #include +#include // Project #include "main.h" @@ -15,18 +16,26 @@ WifiInterface::WifiInterface(QObject *parent) : QObject(parent) { _processScan.setParent(this); + _processDisconnectNetwork.setParent(this); _processReadIPSettings.setParent(this); _processReadGateway.setParent(this); _processReadDNS.setParent(this); _processGenerateWPASupplicant.setParent(this); _processStartWPASupplicant.setParent(this); - _processRequestAutoAssignedIP.setParent(this); + _processRequestAutoAssignedIP.setParent(this); + _processSetStaticIPAddress.setParent(this); + _processSetStaticGateway.setParent(this); + _processSetStaticSubnetMask.setParent(this); + _processSetStaticDNS.setParent(this); } void WifiInterface::initConnections() { + connect(this, SIGNAL(didStatusChanged(const QString)), + this, SLOT(onStatusChanged(const QString))); + connect(this, SIGNAL(didError(const QString)), - this, SLOT(onLogFailure(const QString))); + this, SLOT(onStatusChanged(const QString))); connect(&_processScan, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onProcessFinishedScan(int,QProcess::ExitStatus))); @@ -48,6 +57,25 @@ connect(&_processRequestAutoAssignedIP, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onProcessFinishedRequestAutoAssignedIP(int,QProcess::ExitStatus))); + + connect(&_processDisconnectNetwork, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(onProcessFinishedDisconnectNetwork(int,QProcess::ExitStatus))); + + connect(this, SIGNAL(didRequestAutoAssignedIP()), + this, SLOT(onRequestAutoAssignedIP())); + + // static ip address connections + connect(&_processSetStaticIPAddress, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(onProcessFinishedSetIPAddress(int,QProcess::ExitStatus))); + + connect(&_processSetStaticGateway, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(onProcessFinishedSetGateway(int,QProcess::ExitStatus))); + + connect(&_processSetStaticSubnetMask, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(onProcessFinishedSetSubnetMask(int,QProcess::ExitStatus))); + + connect(&_processSetStaticDNS, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(onProcessFinishedSetDNS(int,QProcess::ExitStatus))); } /*! @@ -93,8 +121,9 @@ { // coco begin validated: Application termination is not correctly done in coco!!! // it has been tested and works perfectly fine in normal run. - quitThread(); // validated + quitThread(); } +// coco end /*! * \brief MessageAcknowModel::quitThread @@ -109,7 +138,7 @@ if (!_thread) return; // runs in thread - moveToThread(qApp->thread()); // validated + moveToThread(qApp->thread()); } // coco end @@ -206,7 +235,7 @@ * \param vRightDelim - (QString) the right delimiter * \return (QString) the text between the delimiters if found, "" otherwise */ -QString getTextBetweenDelimiters(const QString &vText, const QString &vLeftDelim, const QString &vRightDelim) +QString WifiInterface::getTextBetweenDelimiters(const QString &vText, const QString &vLeftDelim, const QString &vRightDelim) { QString result = ""; QString rightHalf = ""; @@ -226,50 +255,71 @@ * * \param vOutput - (QString) output collected from QProcess execution */ -void WifiInterface::parseWifiScan(const QString &vOutput) +QList WifiInterface::parseWifiScan(const QString &vOutput) { LOG_DEBUG(QString("WifiInterface::%1 %2").arg(__FUNCTION__).arg(QThread::currentThread()->objectName())); QList networks; - QStringList temp = vOutput.split("Cell"); - const QString signalLevelSearchTerm = "Signal level="; - const QString macAddressSearchTerm = "Address:"; - const QString ssidSearchTerm = "ESSID:"; - const QString groupCipherSearchTerm = "Group Cipher"; - const QString authSuitesSearchTerm = "Authentication Suites"; + QString outputNoReturns = vOutput; + outputNoReturns = outputNoReturns.replace("\r", ""); + QStringList temp = outputNoReturns.split("Cell"); + const QString searchTermSignalLevel = "Signal level="; + const QString searchTermMacAddress = "Address:"; + const QString searchTermSSID = "ESSID:"; - for (const QString &line : temp) + for (const QString &cell : temp) { - if (line.contains(ssidSearchTerm) && line.contains(macAddressSearchTerm) && line.contains(signalLevelSearchTerm)) + if (cell.contains(searchTermSSID) && cell.contains(searchTermMacAddress) && cell.contains(searchTermSignalLevel)) { - QString ssid = getTextBetweenDelimiters(line, ssidSearchTerm, "\n").replace("\"", "").trimmed(); - QString macAddress = getTextBetweenDelimiters(line, macAddressSearchTerm, "\n").trimmed(); - int signalLevel = getTextBetweenDelimiters(line, signalLevelSearchTerm, "dBm").trimmed().toInt(); + QString ssid = getTextBetweenDelimiters(cell, searchTermSSID, "\n").replace("\"", "").trimmed(); + if (ssid == "") + continue; + QString macAddress = getTextBetweenDelimiters(cell, searchTermMacAddress, "\n").trimmed(); + int signalLevel = getTextBetweenDelimiters(cell, searchTermSignalLevel, "dBm").trimmed().toInt(); + QList securityTypes; + bool requiresKey = QRegularExpression("Encryption key:on").match(cell).hasMatch(); - bool isCCMP = getTextBetweenDelimiters(line, groupCipherSearchTerm, "\n").contains("CCMP"); - bool isEnterprise = getTextBetweenDelimiters(line, authSuitesSearchTerm, "\n").contains("802.1x"); - bool isPersonal = getTextBetweenDelimiters(line, authSuitesSearchTerm, "\n").contains("PSK"); + QStringList infoElement = cell.split("IE: "); + if (infoElement.length() > 1) + { + QString element = infoElement[1]; + bool isWPA2 = QRegularExpression(".*WPA2 ").match(element).hasMatch(); + bool isWPA = QRegularExpression(".*WPA ").match(element).hasMatch(); + bool supportsAES = QRegularExpression("Pairwise Ciphers.*CCMP").match(element).hasMatch(); + bool requiresPSK = QRegularExpression("Authentication Suites.*PSK").match(element).hasMatch(); + bool supportsTKIP = QRegularExpression("Pairwise Ciphers.*TKIP").match(element).hasMatch(); - Network::SECURITY_LEVEL securityLevel = Network::SECURITY_LEVEL::UNSUPPORTED; + Network::SECURITY_TYPE securityType = Network::SECURITY_TYPE::UNSUPPORTED; - if (isPersonal && isCCMP) - securityLevel = Network::SECURITY_LEVEL::WPA2_AES_PERSONAL; - else if (isEnterprise && isCCMP) - securityLevel = Network::SECURITY_LEVEL::WPA2_AES_ENTERPRISE; - // TODO: Add support for the other security levels + if (isWPA2 && requiresPSK && supportsAES && !supportsTKIP) + securityType = Network::SECURITY_TYPE::WPA2_AES; + else if (isWPA && requiresPSK && supportsAES && supportsTKIP) + securityType = Network::SECURITY_TYPE::WPA_TKIP_AES; + else if (isWPA && requiresPSK && supportsTKIP) + securityType = Network::SECURITY_TYPE::WPA_TKIP; + else if (isWPA && requiresPSK && supportsAES) + securityType = Network::SECURITY_TYPE::WPA_AES; + else if (!isWPA && !isWPA2 && !requiresPSK && !supportsAES && !supportsTKIP && requiresKey) + securityType = Network::SECURITY_TYPE::WEP; - Network network(macAddress,ssid, securityLevel, Network::STATUS::NOT_CONNECTED, signalLevel); + if (securityType != Network::SECURITY_TYPE::UNSUPPORTED) + securityTypes.append(securityType); + } + + Network network(macAddress, ssid, securityTypes, Network::STATUS::NOT_CONNECTED, signalLevel); + networks.append(network); emit didAddNetwork(network); } } LOG_DEBUG(QString("WifiInterface::%1 Finished").arg(__FUNCTION__)); + return networks; } /*! - * \brief WifiInterface::onLogFailure - * Ensures any failures reported are logged - * \param vMessage (QString) the message detail of the failure + * \brief WifiInterface::onStatusChanged + * Ensures any status changes are logged + * \param vMessage (QString) the message detail */ -void WifiInterface::onError(const QString &vMessage) +void WifiInterface::onStatusChanged(const QString &vMessage) { LOG_DEBUG(vMessage); } @@ -292,10 +342,26 @@ .arg(_processGenerateWPASupplicant.objectName())); return; } + QString securityType; + if (vNetwork.securityTypes().contains(Network::SECURITY_TYPE::WPA2_AES)) + securityType = "wpa2"; + else if (vNetwork.securityTypes().contains(Network::SECURITY_TYPE::WPA_TKIP_AES) + || vNetwork.securityTypes().contains(Network::SECURITY_TYPE::WPA_AES) + || vNetwork.securityTypes().contains(Network::SECURITY_TYPE::WPA_TKIP)) + securityType = "wpa"; + else if (vNetwork.securityTypes().contains(Network::SECURITY_TYPE::WEP)) + securityType = "wep"; + else + { + LOG_DEBUG(QString("Network %1 has an unsupported security type.").arg(vNetwork.ssid())); + emit didError(QString("Network %1 has an unsupported security type.").arg(vNetwork.ssid())); + } + _processGenerateWPASupplicant.start(Wifi_Generate_WPA_Supplicant, QStringList() << vNetwork.ssid() << vPassword - << _wpaSupplicantConfPath); + << _wpaSupplicantConfPath + << securityType); } /*! @@ -306,6 +372,7 @@ */ void WifiInterface::onProcessFinishedGenerateWPASupplicant(int vExitCode, QProcess::ExitStatus vExitStatus) { + LOG_DEBUG(QString("WifiInterface::%1 %2").arg(__FUNCTION__).arg(QThread::currentThread()->objectName())); Q_UNUSED(vExitStatus) if (vExitCode != 0) { @@ -333,19 +400,31 @@ */ void WifiInterface::onProcessFinishedStartWPASupplicant(int vExitCode, QProcess::ExitStatus vExitStatus) { + LOG_DEBUG(QString("WifiInterface::%1 %2").arg(__FUNCTION__).arg(QThread::currentThread()->objectName())); Q_UNUSED(vExitStatus) if (vExitCode != 0) { emit didError("Could not configure network."); return; } + emit didRequestAutoAssignedIP(); +} + +/*! + * \brief WifiInterface::onRequestAutoAssignedIP + * Handles the request for an auto assigned IP address + */ +void WifiInterface::onRequestAutoAssignedIP() +{ + LOG_DEBUG(QString("WifiInterface::%1 %2").arg(__FUNCTION__).arg(QThread::currentThread()->objectName())); if (_processRequestAutoAssignedIP.state() != QProcess::NotRunning) { LOG_DEBUG(QString("Rejecting request for %1. %2 is already running.") .arg(__FUNCTION__) .arg(_processRequestAutoAssignedIP.objectName())); return; } + emit didStatusChanged(tr("Obtaining IP Address...")); _processRequestAutoAssignedIP.start(Wifi_Get_Auto_Assigned_IP, QStringList() << _iface); } @@ -358,12 +437,22 @@ */ void WifiInterface::onProcessFinishedRequestAutoAssignedIP(int vExitCode, QProcess::ExitStatus vExitStatus) { + LOG_DEBUG(QString("WifiInterface::%1 %2").arg(__FUNCTION__).arg(QThread::currentThread()->objectName())); Q_UNUSED(vExitStatus) if (vExitCode != 0) { - emit didError(QString("Could not connect to %1").arg(_network.ssid())); + if (_dhcpAttemptsLeft > 0) + { + _dhcpAttemptsLeft--; + emit didRequestAutoAssignedIP(); + } else + { + emit didError(QString("Could not connect to %1").arg(_network.ssid())); + _dhcpAttemptsLeft = 5; + } return; } + _dhcpAttemptsLeft = 5; doRequestIPSettings(); } @@ -394,6 +483,7 @@ */ void WifiInterface::onProcessFinishedReadIP(int vExitCode, QProcess::ExitStatus vExitStatus) { + LOG_DEBUG(QString("WifiInterface::%1 %2").arg(__FUNCTION__).arg(QThread::currentThread()->objectName())); Q_UNUSED(vExitCode); Q_UNUSED(vExitStatus); QString output = _processReadIPSettings.readAllStandardOutput(); @@ -419,6 +509,7 @@ */ void WifiInterface::onProcessFinishedReadGateway(int vExitCode, QProcess::ExitStatus vExitStatus) { + LOG_DEBUG(QString("WifiInterface::%1 %2").arg(__FUNCTION__).arg(QThread::currentThread()->objectName())); Q_UNUSED(vExitCode); Q_UNUSED(vExitStatus); _network.mIPSettings.mGateway = parseGateway(_processReadGateway.readAllStandardOutput()); @@ -456,13 +547,15 @@ { LOG_DEBUG(QString("WifiInterface::%1 %2").arg(__FUNCTION__).arg(QThread::currentThread()->objectName())); LOG_DEBUG(QString("Disconnecting from Network %1").arg(vNetwork.ssid())); - QProcess process; - process.start(Wifi_Disconnect_Network, + if (_processDisconnectNetwork.state() != QProcess::NotRunning) + { + LOG_DEBUG(QString("Rejecting request for %1. %2 is already running.") + .arg(__FUNCTION__) + .arg(_processDisconnectNetwork.objectName())); + return; + } + _processDisconnectNetwork.start(Wifi_Disconnect_Network, QStringList() << _iface); - if (process.waitForFinished(_defaultTimeout)) - emit didDisconnectNetwork(vNetwork); - process.kill(); - emit didError(tr("Failed to disconnect from %1").arg(vNetwork.ssid())); } /*! @@ -491,9 +584,9 @@ */ QString WifiInterface::parseIP(const QString &vOutput) { - if (vOutput.contains("inet addr:") && vOutput.contains("Bcast:")) - return vOutput.split("inet addr:")[1].split("Bcast:")[0].trimmed(); - return ""; + const QString leftDelim = "inet addr:"; + const QString rightDelim = "Bcast:"; + return getTextBetweenDelimiters(vOutput, leftDelim, rightDelim); } /*! @@ -504,9 +597,9 @@ */ QString WifiInterface::parseBroadcast(const QString &vOutput) { - if (vOutput.contains("Bcast:") && vOutput.contains("Mask:")) - return vOutput.split("Bcast:")[1].split("Mask:")[0].trimmed(); - return ""; + const QString leftDelim = "Bcast:"; + const QString rightDelim = "Mask:"; + return getTextBetweenDelimiters(vOutput, leftDelim, rightDelim); } /*! @@ -517,9 +610,9 @@ */ QString WifiInterface::parseSubnetMask(const QString &vOutput) { - if (vOutput.contains("Mask:")) - return vOutput.split("Mask:")[1].trimmed(); - return ""; + const QString leftDelim = "Mask:"; + const QString rightDelim = "\n"; + return getTextBetweenDelimiters(vOutput, leftDelim, rightDelim); } /*! @@ -530,9 +623,9 @@ */ QString WifiInterface::parseGateway(const QString &vOutput) { - if (vOutput.contains("default via")) - return vOutput.split("default via")[1].split("dev")[0].trimmed(); - return ""; + const QString leftDelim = "default via"; + const QString rightDelim = "dev"; + return getTextBetweenDelimiters(vOutput, leftDelim, rightDelim); } /*! @@ -543,7 +636,103 @@ */ QString WifiInterface::parseDNS(const QString &vOutput) { - if (vOutput.contains("nameserver")) - return vOutput.split("nameserver")[1].split("\n")[0].trimmed(); - return ""; + const QString leftDelim = "nameserver"; + const QString rightDelim = "\n"; + return getTextBetweenDelimiters(vOutput, leftDelim, rightDelim); } + +/*! + * \brief WifiInterface::doRequestSetIPAddress + * Issues command to set a static IP address + * \param vIPAddress - (QString) the IP address + */ +void WifiInterface::doRequestSetIPAddress(const QString &vIPAddress) +{ + Q_UNUSED(vIPAddress) + // TODO +} + +/*! + * \brief WifiInterface::onProcessFinishedSetIPAddress + * Called when settings a static IP address finishes + * \param vExitCode - (int) the exit code + * \param vExitStatus - (QProcess::ExitStatus) the exit status + */ +void WifiInterface::onProcessFinishedSetIPAddress(int vExitCode, QProcess::ExitStatus vExitStatus) +{ + Q_UNUSED(vExitCode) + Q_UNUSED(vExitStatus) + // TODO +} + +/*! + * \brief WifiInterface::doRequestSetGateway + * Issues command to set a static gateway + * \param vGateway - (QString) the gateway + */ +void WifiInterface::doRequestSetGateway(const QString &vGateway) +{ + Q_UNUSED(vGateway) + // TODO +} + +/*! + * \brief WifiInterface::onProcessFinishedSetGateway + * Called when the the process to set the gateway has finished + * \param vExitCode - (int) the exit code + * \param vExitStatus - (QProcess::ExitStatus) the exit status + */ +void WifiInterface::onProcessFinishedSetGateway(int vExitCode, QProcess::ExitStatus vExitStatus) +{ + Q_UNUSED(vExitCode) + Q_UNUSED(vExitStatus) + // TODO +} + +/*! + * \brief WifiInterface::doRequestSetSubnetMask + * Issues command to set the subnet mask + * \param vSubnetMask - (QString) the subnet mask + */ +void WifiInterface::doRequestSetSubnetMask(const QString &vSubnetMask) +{ + Q_UNUSED(vSubnetMask) + // TODO +} + +/*! + * \brief WifiInterface::onProcessFinishedSetSubnetMask + * Called when the process to set the subnet mask finishes + * \param vExitCode - (int) the exit code + * \param vExitStatus - (QProcess::ExitStatus) the exit status + */ +void WifiInterface::onProcessFinishedSetSubnetMask(int vExitCode, QProcess::ExitStatus vExitStatus) +{ + Q_UNUSED(vExitCode) + Q_UNUSED(vExitStatus) + // TODO +} + +/*! + * \brief WifiInterface::doRequestSetDNS + * Issues a command to set the DNS + * \param vDNS - (QString) the DNS + */ +void WifiInterface::doRequestSetDNS(const QString &vDNS) +{ + Q_UNUSED(vDNS) + // TODO +} + +/*! + * \brief WifiInterface::onProcessFinishedSetDNS + * Called when the process that finishes setting the DNS completes + * \param vExitCode - (int) the exit code + * \param vExitStatus - (QProcess::ExitStatus) the exit status + */ +void WifiInterface::onProcessFinishedSetDNS(int vExitCode, QProcess::ExitStatus vExitStatus) +{ + Q_UNUSED(vExitCode) + Q_UNUSED(vExitStatus) + // TODO +} Index: sources/wifi/WifiInterface.h =================================================================== diff -u -r60db0ce19666f04ea58992a7670497d83f9bf7c4 -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- sources/wifi/WifiInterface.h (.../WifiInterface.h) (revision 60db0ce19666f04ea58992a7670497d83f9bf7c4) +++ sources/wifi/WifiInterface.h (.../WifiInterface.h) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -12,6 +12,8 @@ // define #define _WifiInterface WifiInterface::I() +class tst_utilities; + /*! * \brief The WifiInterface class * Communicates with Access Points @@ -24,20 +26,28 @@ { Q_OBJECT + friend class ::tst_utilities; + QThread *_thread = nullptr; bool _init = false; bool _scanRunning = false; int _defaultTimeout = 5000; int _dhcpTimeout = 10000; int _scanTimeout = 30000; int _processCounter = 0; + int _dhcpAttemptsLeft = 5; QProcess _processScan; + QProcess _processDisconnectNetwork; QProcess _processReadIPSettings; QProcess _processReadGateway; QProcess _processReadDNS; QProcess _processGenerateWPASupplicant; QProcess _processStartWPASupplicant; QProcess _processRequestAutoAssignedIP; + QProcess _processSetStaticIPAddress; + QProcess _processSetStaticGateway; + QProcess _processSetStaticSubnetMask; + QProcess _processSetStaticDNS; Network _network; const QString _iface = "wlan0"; @@ -48,10 +58,8 @@ SINGLETON(WifiInterface) private: - bool generateWPASupplicant(const Network &vNetwork, const QString &vPassword); - bool startWPASupplicant(); - bool requestAutoAssignedIP(int vTries = 4); - void parseWifiScan(const QString &vOutput); + QString getTextBetweenDelimiters(const QString &vText, const QString &vLeftDelim, const QString &vRightDelim); + QList parseWifiScan(const QString &vOutput); QString parseIP(const QString &vOutput); QString parseBroadcast(const QString &vOutput); QString parseSubnetMask(const QString &vOutput); @@ -70,11 +78,19 @@ void doDisconnectNetwork(const Network &vNetwork); void doRequestIPSettings(); + // static IP address assignment + void doRequestSetIPAddress(const QString &vIPAddress); + void doRequestSetGateway(const QString &vGateway); + void doRequestSetSubnetMask(const QString &vSubnetMask); + void doRequestSetDNS(const QString &vDNS); + signals: void didAddNetwork(const Network); void didDisconnectNetwork(const Network); void didRejectRequest(const QString &vFunction, const QString &vReason); void didBusyChanged(const bool &vBusy); + void didStatusChanged(const QString &vNewStatus); + void didRequestAutoAssignedIP(); // emitted from separate threads void didScanStatusChanged(const bool); @@ -84,7 +100,8 @@ private slots: void quit(); void onQuit(); - void onError(const QString &vMessage); + void onStatusChanged(const QString &vMessage); + void onRequestAutoAssignedIP(); void onProcessFinishedScan(int vExitCode, QProcess::ExitStatus vExitStatus); void onProcessFinishedReadIP(int vExitCode, QProcess::ExitStatus vExitStatus); void onProcessFinishedReadGateway(int vExitCode, QProcess::ExitStatus vExitStatus); @@ -93,4 +110,8 @@ void onProcessFinishedStartWPASupplicant(int vExitCode, QProcess::ExitStatus vExitStatus); void onProcessFinishedRequestAutoAssignedIP(int vExitCode, QProcess::ExitStatus vExitStatus); void onProcessFinishedDisconnectNetwork(int vExitCode, QProcess::ExitStatus vExitStatus); + void onProcessFinishedSetIPAddress(int vExitCode, QProcess::ExitStatus vExitStatus); + void onProcessFinishedSetGateway(int vExitCode, QProcess::ExitStatus vExitStatus); + void onProcessFinishedSetSubnetMask(int vExitCode, QProcess::ExitStatus vExitStatus); + void onProcessFinishedSetDNS(int vExitCode, QProcess::ExitStatus vExitStatus); }; Index: unittests/tst_utilities.cpp =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- unittests/tst_utilities.cpp (.../tst_utilities.cpp) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ unittests/tst_utilities.cpp (.../tst_utilities.cpp) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -13,6 +13,7 @@ * */ #include "tst_utilities.h" +#include "WifiInterface.h" // Qt @@ -264,3 +265,195 @@ Types::safeIncrement(c); QCOMPARE(c, 0); } + +void tst_utilities::tst_wifi_interface_parse_scan() +{ + _WifiInterface.init(); + const QString output = "wlan0 Scan completed : \n" +" Cell 01 - Address: 7C:57:3C:FE:4C:D5 \n" +" Protocol:IEEE 802.11a \n" +" Channel:100 \n" +" Mode:Master \n" +" ESSID:\"DialityWAPB\" \n" +" IE: IEEE 802.11i/WPA2 Version 1 \n" +" Group Cipher : TKIP \n" +" Pairwise Ciphers (1) : CCMP \n" +" Authentication Suites (1) : PSK \n" +" IE: WPA Version 1 \n" +" Group Cipher : TKIP \n" +" Pairwise Ciphers (1) : TKIP \n" +" Authentication Suites (1) : PSK \n" +" IE: Unknown: DD180050F2020101890003A4000027A4000042435E0062322F00 \n" +" Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s \n" +" 36 Mb/s; 48 Mb/s; 54 Mb/s \n" +" Encryption key:on \n" +" Quality=176/0 Signal level=-80 dBm Noise level=0 dBm \n" +" Extra: Age: 3813 \n" +" Cell 02 - Address: 7C:57:3C:FE:4C:D0 \n" +" Protocol:IEEE 802.11a \n" +" Channel:100 \n" +" Mode:Master \n" +" ESSID:\"Diality Guest\" \n" +" IE: IEEE 802.11i/WPA2 Version 1 \n" +" Group Cipher : CCMP \n" +" Pairwise Ciphers (1) : CCMP \n" +" Authentication Suites (1) : PSK \n" +" IE: Unknown: DD180050F2020101890003A4000027A4000042435E0062322F00 \n" +" Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s \n" +" 36 Mb/s; 48 Mb/s; 54 Mb/s \n" +" Encryption key:on \n" +" Quality=176/0 Signal level=-80 dBm Noise level=0 dBm \n" +" Extra: Age: 3815 \n" +" Cell 03 - Address: 7C:57:3C:FE:4C:D4 \n" +" Protocol:IEEE 802.11a \n" +" Channel:100 \n" +" Mode:Master \n" +" ESSID:\"DialityWAPA\" \n" +" IE: WPA Version 1 \n" +" Group Cipher : TKIP \n" +" Pairwise Ciphers (2) : TKIP CCMP \n" +" Authentication Suites (1) : PSK \n" +" IE: Unknown: DD180050F2020101890003A4000027A4000042435E0062322F00 \n" +" Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s \n" +" 36 Mb/s; 48 Mb/s; 54 Mb/s \n" +" Encryption key:on \n" +" Quality=175/0 Signal level=-81 dBm Noise level=0 dBm \n" +" Extra: Age: 3814 \n" +" Cell 04 - Address: 7C:57:3C:FE:4C:D3 \n" +" Protocol:IEEE 802.11a \n" +" Channel:100 \n" +" Mode:Master \n" +" ESSID:\"DialityWEP\" \n" +" IE: Unknown: DD180050F2020101890003A4000027A4000042435E0062322F00 \n" +" Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s \n" +" 36 Mb/s; 48 Mb/s; 54 Mb/s \n" +" Encryption key:on \n" +" Quality=175/0 Signal level=-81 dBm Noise level=0 dBm \n" +" Extra: Age: 3814 \n" +" Cell 05 - Address: 7C:57:3C:FE:4C:D2 \n" +" Protocol:IEEE 802.11a \n" +" Channel:100 \n" +" Mode:Master \n" +" ESSID:\"DilaityIoT\" \n" +" IE: IEEE 802.11i/WPA2 Version 1 \n" +" Group Cipher : CCMP \n" +" Pairwise Ciphers (1) : CCMP \n" +" Authentication Suites (1) : PSK \n" +" IE: Unknown: DD180050F2020101890003A4000027A4000042435E0062322F00 \n" +" Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s \n" +" 36 Mb/s; 48 Mb/s; 54 Mb/s \n" +" Encryption key:on \n" +" Quality=175/0 Signal level=-81 dBm Noise level=0 dBm \n" +" Extra: Age: 3814 \n" +" Cell 06 - Address: 7C:57:3C:FE:4C:D1 \n" +" Protocol:IEEE 802.11a \n" +" Channel:100 \n" +" Mode:Master \n" +" ESSID:\"DialityHQ\" \n" +" IE: IEEE 802.11i/WPA2 Version 1 \n" +" Group Cipher : CCMP \n" +" Pairwise Ciphers (1) : CCMP \n" +" Authentication Suites (1) : PSK \n" +" IE: Unknown: DD180050F2020101890003A4000027A4000042435E0062322F00 \n" +" Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s \n" +" 36 Mb/s; 48 Mb/s; 54 Mb/s \n" +" Encryption key:on \n" +" Quality=175/0 Signal level=-81 dBm Noise level=0 dBm \n" +" Extra: Age: 3815 \n" +" Cell 07 - Address: 7C:57:3C:FE:4C:C2 \n" +" Protocol:IEEE 802.11g \n" +" Channel:11 \n" +" Mode:Master \n" +" ESSID:\"DilaityIoT\" \n" +" IE: IEEE 802.11i/WPA2 Version 1 \n" +" Group Cipher : CCMP \n" +" Pairwise Ciphers (1) : CCMP \n" +" Authentication Suites (1) : PSK \n" +" IE: Unknown: DD180050F20201018D0003A4000027A4000042435E0062322F00 \n" +" IE: Unknown: DD07000B8601040809 \n" +" Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s \n" +" 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s \n" +" 48 Mb/s; 54 Mb/s \n" +" Encryption key:on \n" +" Quality=169/0 Signal level=-87 dBm Noise level=0 dBm \n" +" Extra: Age: 1305742 \n" +" Cell 08 - Address: 7C:57:3C:FE:4C:C4 \n" +" Protocol:IEEE 802.11g \n" +" Channel:11 \n" +" Mode:Master \n" +" ESSID:\"DialityWAPA\" \n" +" IE: WPA Version 1 \n" +" Group Cipher : TKIP \n" +" Pairwise Ciphers (2) : TKIP CCMP \n" +" Authentication Suites (1) : PSK \n" +" IE: Unknown: DD180050F2020101850003A4000027A4000042435E0062322F00 \n" +" IE: Unknown: DD07000B8601040809 \n" +" Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s \n" +" 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s \n" +" 48 Mb/s; 54 Mb/s \n" +" Encryption key:on \n" +" Quality=167/0 Signal level=-89 dBm Noise level=0 dBm \n" +" Extra: Age: 1305739 \n" +" Cell 09 - Address: 7C:57:3C:FE:4C:C0 \n" +" Protocol:IEEE 802.11g \n" +" Channel:11 \n" +" Mode:Master \n" +" ESSID:\"Diality Guest\" \n" +" IE: IEEE 802.11i/WPA2 Version 1 \n" +" Group Cipher : CCMP \n" +" Pairwise Ciphers (1) : CCMP \n" +" Authentication Suites (1) : PSK \n" +" IE: Unknown: DD180050F20201018D0003A4000027A4000042435E0062322F00 \n" +" IE: Unknown: DD07000B8601040809 \n" +" Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s \n" +" 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s \n" +" 48 Mb/s; 54 Mb/s \n" +" Encryption key:on \n" +" Quality=167/0 Signal level=-89 dBm Noise level=0 dBm \n" +" Extra: Age: 5651"; + QList networks; + networks.append(Network("7C:57:3C:FE:4C:D5", "DialityWAPB", {Network::SECURITY_TYPE::WPA2_AES }, Network::STATUS::NOT_CONNECTED, -80)); + networks.append(Network("7C:57:3C:FE:4C:D0", "Diality Guest", {Network::SECURITY_TYPE::WPA2_AES }, Network::STATUS::NOT_CONNECTED, -80)); + networks.append(Network("7C:57:3C:FE:4C:D4", "DialityWAPA", {Network::SECURITY_TYPE::WPA_TKIP_AES}, Network::STATUS::NOT_CONNECTED, -81)); + networks.append(Network("7C:57:3C:FE:4C:D3", "DialityWEP", {Network::SECURITY_TYPE::WEP }, Network::STATUS::NOT_CONNECTED, -81)); + networks.append(Network("7C:57:3C:FE:4C:D2", "DilaityIoT", {Network::SECURITY_TYPE::WPA2_AES }, Network::STATUS::NOT_CONNECTED, -81)); + networks.append(Network("7C:57:3C:FE:4C:D1", "DialityHQ", {Network::SECURITY_TYPE::WPA2_AES }, Network::STATUS::NOT_CONNECTED, -81)); + networks.append(Network("7C:57:3C:FE:4C:C2", "DilaityIoT", {Network::SECURITY_TYPE::WPA2_AES }, Network::STATUS::NOT_CONNECTED, -87)); + networks.append(Network("7C:57:3C:FE:4C:C4", "DialityWAPA", {Network::SECURITY_TYPE::WPA_TKIP_AES}, Network::STATUS::NOT_CONNECTED, -89)); + networks.append(Network("7C:57:3C:FE:4C:C0", "Diality Guest", {Network::SECURITY_TYPE::WPA2_AES }, Network::STATUS::NOT_CONNECTED, -89)); + QList parsedNetworks = _WifiInterface.parseWifiScan(output); + QCOMPARE(parsedNetworks.length(), networks.length()); + for (int i = 0; i < networks.length(); ++i) + { + QCOMPARE(parsedNetworks[i].macAddress(), networks[i].macAddress()); + QCOMPARE(parsedNetworks[i].ssid(), networks[i].ssid()); + QCOMPARE(parsedNetworks[i].securityTypes(), networks[i].securityTypes()); + QCOMPARE(parsedNetworks[i].status(), networks[i].status()); + QCOMPARE(parsedNetworks[i].signalLevel(), networks[i].signalLevel()); + } +} + +void tst_utilities::tst_wifi_interface_parse_ip() +{ + +} + +void tst_utilities::tst_wifi_interface_parse_broadcast() +{ + +} + +void tst_utilities::tst_wifi_interface_parse_subnet_mask() +{ + +} + +void tst_utilities::tst_wifi_interface_parse_gateway() +{ + +} + +void tst_utilities::tst_wifi_interface_parse_dns() +{ + +} Index: unittests/tst_utilities.h =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r13ac42cf8bdc5038dedd3302ba79dc387e5704b4 --- unittests/tst_utilities.h (.../tst_utilities.h) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ unittests/tst_utilities.h (.../tst_utilities.h) (revision 13ac42cf8bdc5038dedd3302ba79dc387e5704b4) @@ -17,6 +17,8 @@ #include #include +#include "Network.h" + class tst_utilities : public QObject { Q_OBJECT @@ -48,4 +50,12 @@ void tst_safeIncrement_StepZero(); void tst_safeIncrement_GtMaxValue_Step1 (); void tst_safeIncrement_GtMaxValue_Step10(); + + // wifi + void tst_wifi_interface_parse_scan(); + void tst_wifi_interface_parse_ip(); + void tst_wifi_interface_parse_broadcast(); + void tst_wifi_interface_parse_subnet_mask(); + void tst_wifi_interface_parse_gateway(); + void tst_wifi_interface_parse_dns(); };