From 3b2ec1e3ba172771365ff7822f623c3c6cb4d378 Mon Sep 17 00:00:00 2001 From: benmeyer Date: Wed, 11 Dec 2002 20:16:34 +0000 Subject: Now will display the channel and not the freqency --- (limited to 'noncore/settings/networksettings/wlan') diff --git a/noncore/settings/networksettings/wlan/info.ui b/noncore/settings/networksettings/wlan/info.ui index 1e3e8b5..7a5bf0b 100644 --- a/noncore/settings/networksettings/wlan/info.ui +++ b/noncore/settings/networksettings/wlan/info.ui @@ -11,7 +11,7 @@ 0 0 - 242 + 238 316 @@ -61,7 +61,7 @@ text - Frequency + Channel @@ -172,7 +172,7 @@ QLabel name - freqLabel + channelLabel frameShape diff --git a/noncore/settings/networksettings/wlan/infoimp.cpp b/noncore/settings/networksettings/wlan/infoimp.cpp index 6d3e167..bd56678 100644 --- a/noncore/settings/networksettings/wlan/infoimp.cpp +++ b/noncore/settings/networksettings/wlan/infoimp.cpp @@ -37,7 +37,7 @@ void WlanInfoImp::update(){ apLabel->setText(wExtensions->ap()); stationLabel->setText(wExtensions->station()); modeLabel->setText(wExtensions->mode()); - freqLabel->setText(QString("%1 GHz").arg(wExtensions->frequency())); + channelLabel->setText(QString("%1").arg(wExtensions->channel())); int signal = 0; int noise = 0; int quality = 0; 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 @@ -91,8 +91,31 @@ 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; + 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) diff --git a/noncore/settings/networksettings/wlan/wextensions.h b/noncore/settings/networksettings/wlan/wextensions.h index 1565eb5..a89e33a 100644 --- a/noncore/settings/networksettings/wlan/wextensions.h +++ b/noncore/settings/networksettings/wlan/wextensions.h @@ -16,6 +16,7 @@ public: QString essid(); QString mode(); double frequency(); + int channel(); double rate(); QString ap(); bool stats( int &signal, int &noise, int &quality); -- cgit v0.9.0.2