diff options
author | Jonathan McCrohan <jmccrohan@gmail.com> | 2016-01-30 17:08:40 +0000 |
---|---|---|
committer | Jonathan McCrohan <jmccrohan@gmail.com> | 2016-01-30 17:08:40 +0000 |
commit | 947da597663e60b0a214d96bfcadc0cd042a49ff (patch) | |
tree | f4d3df7b9f3e41ee4beed2e049d9b52031404b8e /lhist_scr.c | |
parent | cec92f1a82b9f29ec16a4c03c37487c7cb019acf (diff) | |
parent | 0b0aac6ce21bcb38d7e03dc2b3ff419861476a24 (diff) | |
download | wavemon-947da597663e60b0a214d96bfcadc0cd042a49ff.tar.gz |
Merge tag 'upstream/0.8.0'
Upstream version 0.8.0
Diffstat (limited to '')
-rw-r--r-- | lhist_scr.c | 31 |
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) { |