Diffstat (limited to 'noncore/net/networksetup/wlan/wextensions.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.cpp | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/noncore/net/networksetup/wlan/wextensions.cpp b/noncore/net/networksetup/wlan/wextensions.cpp index f45ebf2..ef4ba8f 100644 --- a/noncore/net/networksetup/wlan/wextensions.cpp +++ b/noncore/net/networksetup/wlan/wextensions.cpp | |||
@@ -12,4 +12,4 @@ | |||
12 | #define PROCNETWIRELESS "/proc/net/wireless" | 12 | #define PROCNETWIRELESS "/proc/net/wireless" |
13 | #define IW_LOWER 140 | 13 | #define IW_LOWER 0 |
14 | #define IW_UPPER 200 | 14 | #define IW_UPPER 256 |
15 | 15 | ||
@@ -91,5 +91,18 @@ double WExtensions::frequency(){ | |||
91 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | 91 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); |
92 | return 0;; | 92 | return 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | /*** | ||
96 | * Get the current rate that the card is transmiting at. | ||
97 | */ | ||
98 | double WExtensions::rate(){ | ||
99 | if(!hasWirelessExtensions) | ||
100 | return 0; | ||
101 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ | ||
102 | return ((double)iwr.u.bitrate.value)/1000000; | ||
103 | } | ||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | |||
95 | /** | 108 | /** |
@@ -112,5 +125,11 @@ QString WExtensions::ap(){ | |||
112 | else return QString(); | 125 | else return QString(); |
113 | |||
114 | } | 126 | } |
115 | 127 | ||
128 | /** | ||
129 | * Get the stats for interfaces | ||
130 | * @param signal the signal strength of interface | ||
131 | * @param noise the noise level of the interface | ||
132 | * @param quality the quality level of the interface | ||
133 | * @return bool true if successfull | ||
134 | */ | ||
116 | bool WExtensions::stats(int &signal, int &noise, int &quality){ | 135 | bool WExtensions::stats(int &signal, int &noise, int &quality){ |
@@ -133,15 +152,13 @@ bool WExtensions::stats(int &signal, int &noise, int &quality){ | |||
133 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | 152 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; |
134 | if(name == interface){ | 153 | if(name == QString("%1:").arg(interface)){ |
135 | if ( quality > 92 ) | 154 | if ( quality > 92 ) |
136 | #ifdef MDEBUG | ||
137 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | 155 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); |
138 | #endif | ||
139 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | 156 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) |
140 | #ifdef MDEBUG | ||
141 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | 157 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); |
142 | #endif | ||
143 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | 158 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) |
144 | #ifdef MDEBUG | ||
145 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); | 159 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); |
146 | #endif | 160 | qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); |
161 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; | ||
162 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; | ||
163 | quality = ( quality*100 ) / 92; | ||
147 | return true; | 164 | return true; |
@@ -150,3 +167,3 @@ bool WExtensions::stats(int &signal, int &noise, int &quality){ | |||
150 | 167 | ||
151 | qDebug("Card no longer present"); | 168 | qDebug("WExtensions::statsCard no longer present."); |
152 | quality = -1; | 169 | quality = -1; |