aboutsummaryrefslogtreecommitdiffstats
path: root/lhist_scr.c
diff options
context:
space:
mode:
Diffstat (limited to 'lhist_scr.c')
-rw-r--r--lhist_scr.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/lhist_scr.c b/lhist_scr.c
index 84b6925..2595b45 100644
--- a/lhist_scr.c
+++ b/lhist_scr.c
@@ -18,6 +18,7 @@
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "iw_if.h"
+#include "iw_nl80211.h"
/* Number of lines in the key window at the bottom */
#define KEY_WIN_HEIGHT 3
@@ -117,22 +118,34 @@ static struct iw_levelstat iw_cache_get(const uint32_t index)
return iw_stats_cache[(count - index) % IW_STACKSIZE];
}
-void iw_cache_update(struct iw_stat *iw)
+void iw_cache_update(struct iw_nl80211_linkstat *ls)
{
static struct iw_levelstat prev, avg = IW_LSTAT_INIT;
static int slot;
+ int sig_level = ls->signal_avg ?: ls->signal;
- if (! (iw->stat.qual.updated & IW_QUAL_LEVEL_INVALID)) {
+ /*
+ * If hardware does not support dBm signal level, it will not
+ * be filled in, and show up as 0. Try to fall back to the BSS
+ * probe where again a 0 dBm value reflects 'not initialized'.
+ */
+ if (sig_level == 0)
+ sig_level = ls->bss_signal;
+
+ if (sig_level == 0) {
+ avg.flags |= IW_QUAL_LEVEL_INVALID;
+ } else {
avg.flags &= ~IW_QUAL_LEVEL_INVALID;
- avg.signal += iw->dbm.signal / conf.slotsize;
- track_extrema(iw->dbm.signal, &e_signal);
+ avg.signal += (float)sig_level / conf.slotsize;
+ track_extrema(sig_level, &e_signal);
}
- if (! (iw->stat.qual.updated & IW_QUAL_NOISE_INVALID)) {
- avg.flags &= ~IW_QUAL_NOISE_INVALID;
- avg.noise += iw->dbm.noise / conf.slotsize;
- track_extrema(iw->dbm.noise, &e_noise);
- track_extrema(iw->dbm.signal - iw->dbm.noise, &e_snr);
+ if (iw_nl80211_have_survey_data(ls)) {
+ avg.flags &= ~IW_QUAL_NOISE_INVALID;
+ avg.noise += (float)ls->survey.noise / conf.slotsize;
+ track_extrema(ls->survey.noise, &e_noise);
+ if (! (avg.flags & IW_QUAL_LEVEL_INVALID))
+ track_extrema(sig_level - ls->survey.noise, &e_snr);
}
if (++slot >= conf.slotsize) {