From 800d2f388e596389059655cb426ab6ccd89a3def Mon Sep 17 00:00:00 2001 From: Alexis Date: Thu, 27 Dec 2018 11:41:43 +0100 Subject: [PATCH] refactor(network): proper signal strength type --- include/modules/network.hpp | 4 ++-- src/modules/network.cpp | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/modules/network.hpp b/include/modules/network.hpp index 41bc04d..81fde0a 100644 --- a/include/modules/network.hpp +++ b/include/modules/network.hpp @@ -52,8 +52,8 @@ class Network : public ALabel { std::string ipaddr_; std::string netmask_; int cidr_; - int signal_strength_dbm_; - uint16_t signal_strength_; + int32_t signal_strength_dbm_; + uint8_t signal_strength_; }; } diff --git a/src/modules/network.cpp b/src/modules/network.cpp index f3f4141..e3c8a08 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -455,8 +455,7 @@ void waybar::modules::Network::parseEssid(struct nlattr **bss) void waybar::modules::Network::parseSignal(struct nlattr **bss) { if (bss[NL80211_BSS_SIGNAL_MBM] != nullptr) { // signalstrength in dBm from mBm - signal_strength_dbm_ = - static_cast(nla_get_u32(bss[NL80211_BSS_SIGNAL_MBM])) / 100; + signal_strength_dbm_ = nla_get_s32(bss[NL80211_BSS_SIGNAL_MBM]) / 100; // WiFi-hardware usually operates in the range -90 to -20dBm. const int hardwareMax = -20;