author | benmeyer <benmeyer> | 2002-12-11 20:26:40 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-12-11 20:26:40 (UTC) |
commit | b433feb7b048d5155e085c12f88ac5531d045140 (patch) (side-by-side diff) | |
tree | 9acc6fa0b1722bdbf04fe4730562972b31896303 | |
parent | 3b2ec1e3ba172771365ff7822f623c3c6cb4d378 (diff) | |
download | opie-b433feb7b048d5155e085c12f88ac5531d045140.zip opie-b433feb7b048d5155e085c12f88ac5531d045140.tar.gz opie-b433feb7b048d5155e085c12f88ac5531d045140.tar.bz2 |
Added PDF url
-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.cpp | 3 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.cpp | 3 |
2 files changed, 6 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 @@ -71,64 +71,67 @@ QString WExtensions::essid(){ /** * @return QString the mode of interface */ QString WExtensions::mode(){ if(!hasWirelessExtensions) return QString(); if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); return QString(); } /** * Get the frequency that the interface is running at. * @return int the frequency that the interfacae is running at. */ double WExtensions::frequency(){ if(!hasWirelessExtensions) return 0; if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); 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; } /*** * Get the current rate that the card is transmiting at. * @return double the rate, 0 if error. */ double WExtensions::rate(){ if(!hasWirelessExtensions) return 0; if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ return ((double)iwr.u.bitrate.value)/1000000; } return 0; } /** * @return QString the AccessPoint that the interface is connected to. */ QString WExtensions::ap(){ if(!hasWirelessExtensions) diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp index 16654bb..827d075 100644 --- a/noncore/settings/networksettings/wlan/wextensions.cpp +++ b/noncore/settings/networksettings/wlan/wextensions.cpp @@ -71,64 +71,67 @@ QString WExtensions::essid(){ /** * @return QString the mode of interface */ QString WExtensions::mode(){ if(!hasWirelessExtensions) return QString(); if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); return QString(); } /** * Get the frequency that the interface is running at. * @return int the frequency that the interfacae is running at. */ double WExtensions::frequency(){ if(!hasWirelessExtensions) return 0; if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); 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; } /*** * Get the current rate that the card is transmiting at. * @return double the rate, 0 if error. */ double WExtensions::rate(){ if(!hasWirelessExtensions) return 0; if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ return ((double)iwr.u.bitrate.value)/1000000; } return 0; } /** * @return QString the AccessPoint that the interface is connected to. */ QString WExtensions::ap(){ if(!hasWirelessExtensions) |