if (sinfo[NL80211_STA_INFO_SIGNAL])
{
dbm = nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]);
- rr->rssi = rr->rssi ? (int8_t)((rr->rssi + dbm) / 2) : dbm;
+ rr->rssi = (rr->rssi * rr->rssi_samples + dbm) / (rr->rssi_samples + 1);
+ rr->rssi_samples++;
}
if (sinfo[NL80211_STA_INFO_TX_BITRATE])
if (rinfo[NL80211_RATE_INFO_BITRATE])
{
mbit = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
- rr->rate = rr->rate
- ? (int16_t)((rr->rate + mbit) / 2) : mbit;
+ rr->rate = (rr->rate * rr->rate_samples + mbit) / (rr->rate_samples + 1);
+ rr->rate_samples++;
}
}
}
DIR *d;
struct dirent *de;
- r->rssi = 0;
- r->rate = 0;
+ memset(r, 0, sizeof(*r));
if ((d = opendir("/sys/class/net")) != NULL)
{
nl80211_fill_signal(ifname, &rr);
- if (rr.rate)
+ if (rr.rate_samples)
{
*buf = (rr.rate * 100);
return 0;
nl80211_fill_signal(ifname, &rr);
- if (rr.rssi)
+ if (rr.rssi_samples)
{
*buf = rr.rssi;
return 0;