From 3d6b1b576b3c1acd6d2932da454171cfd8e22821 Mon Sep 17 00:00:00 2001 From: Sascha Wessel Date: Mon, 21 Oct 2019 08:48:50 +0200 Subject: wireless: update %signal and %quality based on station info on Linux (#368) Use station info instead of bss info to update %signal and %quality. Bss info is based on scan info and doesn't get updated often. Station info get's updated with every beacon. Bss info still used as fallback. --- src/print_wireless_info.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/print_wireless_info.c b/src/print_wireless_info.c index 6215704..c6df4cb 100644 --- a/src/print_wireless_info.c +++ b/src/print_wireless_info.c @@ -189,6 +189,16 @@ static int gwi_sta_cb(struct nl_msg *msg, void *data) { // used to specify bit/s, so we convert to use the same code path. info->bitrate = (int)nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]) * 100 * 1000; + if (sinfo[NL80211_STA_INFO_SIGNAL] != NULL) { + info->flags |= WIRELESS_INFO_FLAG_HAS_SIGNAL; + info->signal_level = (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]); + + info->flags |= WIRELESS_INFO_FLAG_HAS_QUALITY; + info->quality = nl80211_xbm_to_percent(info->signal_level, 1); + info->quality_max = 100; + info->quality_average = 50; + } + return NL_SKIP; } -- cgit v1.2.3