Diffstat (limited to 'noncore/net/networksetup/wlan/wextensions.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/noncore/net/networksetup/wlan/wextensions.cpp b/noncore/net/networksetup/wlan/wextensions.cpp index 16654bb..827d075 100644 --- a/noncore/net/networksetup/wlan/wextensions.cpp +++ b/noncore/net/networksetup/wlan/wextensions.cpp @@ -91,24 +91,27 @@ double WExtensions::frequency(){ return 0; } /** * Get the channel that the interface is running at. * @return int the channel that the interfacae is running at. */ int WExtensions::channel(){ if(!hasWirelessExtensions) return 0; if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr )) return 0; + + // http://www.elanix.com/pdf/an137e.pdf + double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); double left = 2.401; double right = 2.416; for(int channel = 1; channel<= 15; channel++){ if( num >= left && num <= right ) return channel; left += 0.005; right += 0.005; } qDebug(QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1()); return -1; } |