Skip to content

Commit

Permalink
properly print the wireless signal strength on OpenBSD (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
rnagy authored Dec 15, 2021
1 parent 0843d0c commit 61a2c42
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/print_wireless_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,21 @@ static int get_wireless_info(const char *interface, wireless_info_t *info) {

if (ioctl(s, SIOCG80211NODE, &nr) == 0 && nr.nr_rssi) {
info->signal_level = nr.nr_rssi;
if (nr.nr_max_rssi)
if (nr.nr_max_rssi) {
info->signal_level_max = nr.nr_max_rssi;

info->quality = IEEE80211_NODEREQ_RSSI(&nr);
} else {
if (info->signal_level <= -100)
info->quality = 0;
else if (info->signal_level > -50)
info->quality = 100;
else
info->quality = abs(2 * (info->signal_level + 100));
}
info->quality_max = 100;
info->quality_average = 50;

info->flags |= WIRELESS_INFO_FLAG_HAS_QUALITY;
info->flags |= WIRELESS_INFO_FLAG_HAS_SIGNAL;
}
}
Expand Down

0 comments on commit 61a2c42

Please sign in to comment.