Diffstat (limited to 'noncore/settings/networksettings/wlan/wextensions.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp index 6335ebc..16654bb 100644 --- a/noncore/settings/networksettings/wlan/wextensions.cpp +++ b/noncore/settings/networksettings/wlan/wextensions.cpp | |||
@@ -92,6 +92,29 @@ double WExtensions::frequency(){ | |||
92 | } | 92 | } |
93 | 93 | ||
94 | /** | ||
95 | * Get the channel that the interface is running at. | ||
96 | * @return int the channel that the interfacae is running at. | ||
97 | */ | ||
98 | int WExtensions::channel(){ | ||
99 | if(!hasWirelessExtensions) | ||
100 | return 0; | ||
101 | if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr )) | ||
102 | return 0; | ||
103 | double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | ||
104 | double left = 2.401; | ||
105 | double right = 2.416; | ||
106 | for(int channel = 1; channel<= 15; channel++){ | ||
107 | if( num >= left && num <= right ) | ||
108 | return channel; | ||
109 | left += 0.005; | ||
110 | right += 0.005; | ||
111 | } | ||
112 | qDebug(QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1()); | ||
113 | return -1; | ||
114 | } | ||
115 | |||
94 | /*** | 116 | /*** |
95 | * Get the current rate that the card is transmiting at. | 117 | * Get the current rate that the card is transmiting at. |
118 | * @return double the rate, 0 if error. | ||
96 | */ | 119 | */ |
97 | double WExtensions::rate(){ | 120 | double WExtensions::rate(){ |