summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/wifi/pluginmain.cpp14
-rw-r--r--src/wifi/qwifimanager.cpp10
-rw-r--r--src/wifi/qwifinetworklistmodel.cpp13
3 files changed, 22 insertions, 15 deletions
diff --git a/src/imports/wifi/pluginmain.cpp b/src/imports/wifi/pluginmain.cpp
index 7d129d2..b498b66 100644
--- a/src/imports/wifi/pluginmain.cpp
+++ b/src/imports/wifi/pluginmain.cpp
@@ -93,13 +93,13 @@ QT_BEGIN_NAMESPACE
interface, accessed with the following roles:
\list
- \li \e ssid - informal (human) name of a Wifi network
- \li \e bssid - basic service set identification of a network, used to uniquely identify BSS
- \li \e signalStrength - strength of a Wifi signal, measured in dBm
- \li \e supportsWPA - holds whether network access point supports WPA security protocol
- \li \e supportsWPA2 - holds whether network access point supports WPA2 security protocol
- \li \e supportsWEP - holds whether network access point supports WEP security protocol
- \li \e supportsWPS - holds whether network access point supports WPS security protocol
+ \li \e ssid - informal (human) name of a Wifi network (string)
+ \li \e bssid - basic service set identification of a network, used to uniquely identify BSS (string)
+ \li \e signalStrength - strength of a Wifi signal represented as percentage (0-100) (int)
+ \li \e supportsWPA - holds whether network access point supports WPA security protocol (bool)
+ \li \e supportsWPA2 - holds whether network access point supports WPA2 security protocol (bool)
+ \li \e supportsWEP - holds whether network access point supports WEP security protocol (bool)
+ \li \e supportsWPS - holds whether network access point supports WPS security protocol (bool)
\endlist
*/
diff --git a/src/wifi/qwifimanager.cpp b/src/wifi/qwifimanager.cpp
index 7585cf2..2a5cfff 100644
--- a/src/wifi/qwifimanager.cpp
+++ b/src/wifi/qwifimanager.cpp
@@ -212,11 +212,11 @@ void QWifiManagerPrivate::updateLastError(const QString &error)
\value SSID informal (human) name of a Wifi network (QString)
\value BSSID basic service set identification of a network, used to uniquely identify BSS (QString)
- \value SignalStrength strength of a Wifi signal, measured in dBm (int)
- \value WPASupported holds whether network access point supports WPA security protocol (QString)
- \value WPA2Supported holds whether network access point supports WPA2 security protocol (QString)
- \value WEPSupported holds whether network access point supports WEP security protocol (QString)
- \value WPSSupported holds whether network access point supports WPS security protocol (QString)
+ \value SignalStrength strength of a Wifi signal represented as percentage (0-100) (int)
+ \value WPASupported holds whether network access point supports WPA security protocol (bool)
+ \value WPA2Supported holds whether network access point supports WPA2 security protocol (bool)
+ \value WEPSupported holds whether network access point supports WEP security protocol (bool)
+ \value WPSSupported holds whether network access point supports WPS security protocol (bool)
*/
QWifiManager* QWifiManager::m_instance = 0;
diff --git a/src/wifi/qwifinetworklistmodel.cpp b/src/wifi/qwifinetworklistmodel.cpp
index 7ed4be4..9d6202f 100644
--- a/src/wifi/qwifinetworklistmodel.cpp
+++ b/src/wifi/qwifinetworklistmodel.cpp
@@ -132,9 +132,16 @@ void QWifiNetworkListModel::parseScanResults(const QString &results)
QWifiNetwork *knownNetwork = networkForSSID(ssid, &pos);
if (!knownNetwork)
knownNetwork = outOfRangeListContains(ssid);
- // signal strength is in dBm. Deprecated, but still widely used "wext"
- // wifi driver reports positive values for signal strength, we workaround that.
- int signalStrength = qAbs(info.at(2).trimmed().toInt()) * -1;
+
+ int signalStrength = info.at(2).trimmed().toInt();
+ if (signalStrength < 0) {
+ // signal is reported in dBm, rough conversion: best = -40, worst = -100
+ int val = qAbs(qMax(-100, qMin(signalStrength, -40)) + 40); // clamp and normalize to 0
+ signalStrength = 100 - (int) ((100.0 * (double) val) / 60.0);
+ } else if (signalStrength > 100) {
+ qCWarning(B2QT_WIFI) << "unexpected value for a signal level: " << signalStrength;
+ }
+
if (!knownNetwork) {
QWifiNetwork *network = new QWifiNetwork();
network->setOutOfRange(false);