Index: scripts/wifi_test_network.sh =================================================================== diff -u --- scripts/wifi_test_network.sh (revision 0) +++ scripts/wifi_test_network.sh (revision bba484de53409dec9c7d3cf331621d9733154872) @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ "$1" == "-h" ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +ping -I $1 -c 4 $2 Index: sources/gui/qml/pages/settings/SettingsWiFi.qml =================================================================== diff -u -r87ca1f6fca153e2ac05425d2dc5937d5a46ba206 -rbba484de53409dec9c7d3cf331621d9733154872 --- sources/gui/qml/pages/settings/SettingsWiFi.qml (.../SettingsWiFi.qml) (revision 87ca1f6fca153e2ac05425d2dc5937d5a46ba206) +++ sources/gui/qml/pages/settings/SettingsWiFi.qml (.../SettingsWiFi.qml) (revision bba484de53409dec9c7d3cf331621d9733154872) @@ -150,14 +150,20 @@ color : Colors.textMain horizontalAlignment : TextInput.Alignleft width : labelWidth - text : qsTr("Internet") + text : qsTr("Connection") } Text { id : _internetConnectionStatus font.pixelSize : Fonts.fontPixelTextRectExtra color : Colors.textMain horizontalAlignment : TextInput.Alignleft - text : vNetwork.connectedToInternet ? "Connected" : "Not Connected" + text : { + let result = "Network: "; + result += vNetwork.connectedToNetwork ? "Connected\n" : "Not Connected\n" + result += "Internet: " + result += vNetwork.connectedToInternet ? "Connected" : "Not Connected" + return result; + } width : entryWidth } } @@ -189,7 +195,7 @@ anchors.rightMargin : _root.rightMargin delegate : TouchRect { id : _delegate - property bool isCurrrentNetwork: vNetwork.macAddress === macAddress + property bool isCurrrentNetwork: vNetwork.macAddress === macAddress && vNetwork.connectedToNetwork clip : true text.text : ssid Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -r87ca1f6fca153e2ac05425d2dc5937d5a46ba206 -rbba484de53409dec9c7d3cf331621d9733154872 --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 87ca1f6fca153e2ac05425d2dc5937d5a46ba206) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision bba484de53409dec9c7d3cf331621d9733154872) @@ -96,6 +96,7 @@ const char *Wifi_Set_Gateway = "wifi_set_gateway.sh"; const char *Wifi_Set_SubnetMask = "wifi_set_subnetmask.sh"; const char *Wifi_Start_WPA_Supplicant = "wifi_start_wpa_supplicant.sh"; + const char *Wifi_Test_Network = "wifi_test_network.sh"; const char *Wifi_Test_Internet = "wifi_test_internet.sh"; const char *WifiSettings_SSID = "wifi/ssid"; const char *WifiSettings_MacAddress = "wifi/macAddress"; Index: sources/storage/StorageGlobals.h =================================================================== diff -u -r87ca1f6fca153e2ac05425d2dc5937d5a46ba206 -rbba484de53409dec9c7d3cf331621d9733154872 --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 87ca1f6fca153e2ac05425d2dc5937d5a46ba206) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision bba484de53409dec9c7d3cf331621d9733154872) @@ -53,6 +53,7 @@ extern const char *Wifi_Reset_Adapter; extern const char *Wifi_Reset_Interface; extern const char *Wifi_Scan_For_Networks; + extern const char *Wifi_Test_Network; extern const char *Wifi_Test_Internet; extern const char *Wifi_Set_Auto_Assigned_IP; extern const char *Wifi_Set_DNS; Index: sources/view/settings/VNetworkModel.cpp =================================================================== diff -u -r87ca1f6fca153e2ac05425d2dc5937d5a46ba206 -rbba484de53409dec9c7d3cf331621d9733154872 --- sources/view/settings/VNetworkModel.cpp (.../VNetworkModel.cpp) (revision 87ca1f6fca153e2ac05425d2dc5937d5a46ba206) +++ sources/view/settings/VNetworkModel.cpp (.../VNetworkModel.cpp) (revision bba484de53409dec9c7d3cf331621d9733154872) @@ -26,8 +26,8 @@ connect(&_WifiInterface, SIGNAL(didScanStatusChanged(bool)), this, SLOT( onScanStatusChanged(bool))); - connect(&_WifiInterface, SIGNAL( didConnectToNetwork(const WifiNetworkData &)), - this, SLOT( onConnectToNetwork(const WifiNetworkData &))); + connect(&_WifiInterface, SIGNAL( didSetupNetworkConnection(const WifiNetworkData &)), + this, SLOT( onSetupNetworkConnection(const WifiNetworkData &))); connect(&_WifiInterface, SIGNAL(didDisconnectNetwork(const WifiNetworkData &)), this, SLOT( onDisconnectNetwork(const WifiNetworkData &))); @@ -41,6 +41,9 @@ connect(&_WifiInterface, SIGNAL(didInternetConnectionChange (const bool &)), this, SLOT( onInternetConnectionChanged(const bool &))); + connect(&_WifiInterface, SIGNAL(didLocalNetworkConnectionChange (const bool &)), + this, SLOT( onLocalNetworkConnectionChanged(const bool &))); + // incoming - static IP address assignment connect(&_WifiInterface, SIGNAL(didSetStaticIPAddress (const QString &)), this, SLOT( onSetStaticIPAddressSuccess(const QString &))); @@ -269,20 +272,20 @@ } /*! - * \brief VNetworkModel::onConnectedToNetwork - * Called when we have connected to a network. - * \param vNetwork - (Network) the network we have connected to + * \brief VNetworkModel::onSetupNetworkConnection + * Called when we have finished setting up the connection to a network + * \param vNetwork - (Network) the network we have finished setting up */ -void VNetworkModel::onConnectToNetwork(const WifiNetworkData &vNetwork) +void VNetworkModel::onSetupNetworkConnection(const WifiNetworkData &vNetwork) { - LOG_DEBUG(QString("Connected to %1.").arg(vNetwork.ssid())); + LOG_DEBUG(QString("Setup connection to %1.").arg(vNetwork.ssid())); ipAddress(vNetwork.mIPSettings.mIPAddress.trimmed()); gateway(vNetwork.mIPSettings.mGateway.trimmed()); subnetMask(vNetwork.mIPSettings.mSubnetMask.trimmed()); dns(vNetwork.mIPSettings.mDNS.trimmed()); ssid(vNetwork.ssid().trimmed()); macAddress(vNetwork.macAddress().trimmed()); - status(tr("Connected to %1.").arg(vNetwork.ssid()).trimmed()); + status(tr("Setup connection to %1.").arg(vNetwork.ssid()).trimmed()); } /*! @@ -407,6 +410,16 @@ } /*! + * \brief VNetworkModel::onLocalNetworkConnectionChanged + * Called when the internet connection changes + * \param vConnected - if true, we're connected to the internet, false otherwise + */ +void VNetworkModel::onLocalNetworkConnectionChanged(const bool &vConnected) +{ + connectedToNetwork(vConnected); +} + +/*! * \brief VNetworkModel::onInternetConnectionChanged * Called when the internet connection changes * \param vConnected - if true, we're connected to the internet, false otherwise Index: sources/view/settings/VNetworkModel.h =================================================================== diff -u -r87ca1f6fca153e2ac05425d2dc5937d5a46ba206 -rbba484de53409dec9c7d3cf331621d9733154872 --- sources/view/settings/VNetworkModel.h (.../VNetworkModel.h) (revision 87ca1f6fca153e2ac05425d2dc5937d5a46ba206) +++ sources/view/settings/VNetworkModel.h (.../VNetworkModel.h) (revision bba484de53409dec9c7d3cf331621d9733154872) @@ -28,6 +28,7 @@ PROPERTY(bool , isIdle , true ) PROPERTY(bool , scanInProgress , false) + PROPERTY(bool , connectedToNetwork , false) PROPERTY(bool , connectedToInternet, false) PROPERTY(QString , status , "") PROPERTY(QString , ipAddress , "") @@ -92,8 +93,9 @@ void onAddNetwork(const WifiNetworkData &vNetwork); void onScanStatusChanged(const bool &vScanning); void onStatusChanged(const QString &vNewStatus); - void onConnectToNetwork(const WifiNetworkData &vNetwork); + void onSetupNetworkConnection(const WifiNetworkData &vNetwork); void onDisconnectNetwork(const WifiNetworkData &vNetwork); + void onLocalNetworkConnectionChanged(const bool &vConnected); void onInternetConnectionChanged(const bool &vConnected); // static IP address assignment confirmation Index: sources/wifi/WifiInterface.cpp =================================================================== diff -u -r87ca1f6fca153e2ac05425d2dc5937d5a46ba206 -rbba484de53409dec9c7d3cf331621d9733154872 --- sources/wifi/WifiInterface.cpp (.../WifiInterface.cpp) (revision 87ca1f6fca153e2ac05425d2dc5937d5a46ba206) +++ sources/wifi/WifiInterface.cpp (.../WifiInterface.cpp) (revision bba484de53409dec9c7d3cf331621d9733154872) @@ -40,6 +40,7 @@ _processSetStaticGateway .setParent(this); _processSetStaticSubnetMask .setParent(this); _processSetDNS .setParent(this); + _processTestNetwork .setParent(this); _processTestInternet .setParent(this); } @@ -149,6 +150,9 @@ connect(&_processTestInternet , SIGNAL( finished(int, QProcess::ExitStatus)), this , SLOT( onProcessFinishedTestInternet(int, QProcess::ExitStatus))); + connect(&_processTestNetwork , SIGNAL( finished(int, QProcess::ExitStatus)), + this , SLOT( onProcessFinishedTestLocalNetwork(int, QProcess::ExitStatus))); + connect(this, SIGNAL(didRequestAutoAssignedIP()), this, SLOT( onRequestAutoAssignedIP())); @@ -262,6 +266,14 @@ */ void WifiInterface::timerEvent(QTimerEvent *) { + if (_processTestNetwork.state() != QProcess::NotRunning) { + LOG_DEBUG("The network test is already running."); + return; + } + + QString script_network; if ( ! checkScript(script_network, Wifi_Test_Network) ) return; + _processTestNetwork.start(script_network, QStringList() << _iface << _network.mIPSettings.mGateway); + if (_processTestInternet.state() != QProcess::NotRunning) { LOG_DEBUG("The internet test is already running."); return; @@ -280,19 +292,42 @@ void WifiInterface::onProcessFinishedTestInternet(int vExitCode, QProcess::ExitStatus) { QString out = _processTestInternet.readAllStandardOutput(); - QString err = _processTestInternet.readAllStandardError(); if (vExitCode != 0) { - didInternetConnectionChange(false); + emit didInternetConnectionChange(false); return; } bool hasInternet = QRegularExpression("4 packets transmitted, 4 packets received, 0% packet loss").match(out).hasMatch(); LOG_DEBUG(QString("Connected to internet? %1").arg(hasInternet)); + if (hasInternet) + emit didLocalNetworkConnectionChange(true); emit didInternetConnectionChange(hasInternet); } /*! + * \brief WifiInterface::onProcessFinishedTestLocalNetwork + * Called when the local network connectivity test has finished + * \param vExitCode - (int) the exit code + * \param vExitStatus - (QProcess::ExitStatus) the exit status + */ +void WifiInterface::onProcessFinishedTestLocalNetwork(int vExitCode, QProcess::ExitStatus) +{ + QString out = _processTestNetwork.readAllStandardOutput(); + if (vExitCode != 0) + { + emit didLocalNetworkConnectionChange(false); + return; + } + + bool hasNetwork = QRegularExpression("4 packets transmitted, 4 packets received, 0% packet loss").match(out).hasMatch(); + LOG_DEBUG(QString("Connected to Wi-Fi network? %1").arg(hasNetwork)); + if (!hasNetwork) + emit didInternetConnectionChange(false); + emit didLocalNetworkConnectionChange(hasNetwork); +} + +/*! * \brief WifiInterface::doScan * Scans for WiFi Access Points */ @@ -652,7 +687,7 @@ if (_useStaticDNS && !dns.isEmpty()) doRequestSetDNS(dns); - emit didConnectToNetwork(_network); + emit didSetupNetworkConnection(_network); } /*! Index: sources/wifi/WifiInterface.h =================================================================== diff -u -r87ca1f6fca153e2ac05425d2dc5937d5a46ba206 -rbba484de53409dec9c7d3cf331621d9733154872 --- sources/wifi/WifiInterface.h (.../WifiInterface.h) (revision 87ca1f6fca153e2ac05425d2dc5937d5a46ba206) +++ sources/wifi/WifiInterface.h (.../WifiInterface.h) (revision bba484de53409dec9c7d3cf331621d9733154872) @@ -71,6 +71,7 @@ QProcess _processSetStaticGateway; QProcess _processSetStaticSubnetMask; QProcess _processSetDNS; + QProcess _processTestNetwork; QProcess _processTestInternet; WifiNetworkData _network; @@ -126,6 +127,7 @@ void didBusyChanged ( bool vBusy); void didStatusChanged (const QString &vNewStatus ); void didRequestAutoAssignedIP (); + void didLocalNetworkConnectionChange(const bool &vConnected); void didInternetConnectionChange(const bool &vConnected); // static IP address settings void didSetStaticIPAddress (const QString &); @@ -135,7 +137,7 @@ // emitted from separate threads void didScanStatusChanged ( bool ); - void didConnectToNetwork (const WifiNetworkData &); + void didSetupNetworkConnection (const WifiNetworkData &); void didError (const QString &); private slots: @@ -153,6 +155,7 @@ void onProcessFinishedRequestAutoAssignedIP (int vExitCode, QProcess::ExitStatus); void onProcessFinishedDisconnectNetwork (int vExitCode, QProcess::ExitStatus); void onProcessFinishedTestInternet (int vExitCode, QProcess::ExitStatus); + void onProcessFinishedTestLocalNetwork (int vExitCode, QProcess::ExitStatus); void onProcessFinishedSetIPAddress (int vExitCode, QProcess::ExitStatus); void onProcessFinishedSetGateway (int vExitCode, QProcess::ExitStatus); void onProcessFinishedSetSubnetMask (int vExitCode, QProcess::ExitStatus);