refactor(network): proper signal strength type

This commit is contained in:
Alexis 2018-12-27 11:41:43 +01:00
parent 1647e31b48
commit 800d2f388e
2 changed files with 3 additions and 4 deletions

View File

@ -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_;
};
}

View File

@ -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<int>(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;