wpa_supplicant: Add AVG_RSSI report in signal_poll

Submitted by Ilan Peer on June 6, 2013, 6:12 a.m.

Details

Message ID 1370499138-21257-1-git-send-email-ilan.peer@intel.com
State Superseded
Headers show

Commit Message

Ilan Peer June 6, 2013, 6:12 a.m.
From: Andrei Otcheretianski <andrei.otcheretianski@intel.com>

Add AVG_RSSI report to the signal_poll command. This will work if
kernel supports NL80211_STA_INFO_SIGNAL_AVG, otherwise a default value
(0) will be returned.

Change-Id: I02a9e28bb22c54646e8ed76c6032a7a877ce842a
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-hostap: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
---
 src/drivers/driver.h         |    1 +
 src/drivers/driver_nl80211.c |    8 ++++++++
 wpa_supplicant/ctrl_iface.c  |    6 ++++--
 3 files changed, 13 insertions(+), 2 deletions(-)

Comments

Holger Schurig June 6, 2013, 9:53 a.m.
> otherwise a default value (0) will be returned

I'm not in love with such a behavior. Back in WEXT days various
drivers returned "interesting" things if they didn't knew the true
value. In the end you couldn't rely on anything.

I'd suggest that you create the returned string dynamically. And if
you have an average RSSI, then you append/prepend AVG_RSSI=%d to it.
If you don't know the value, then don't append it.

Patch hide | download patch | download mbox

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 07cc1d2..e18ee65 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -1108,6 +1108,7 @@  struct wpa_signal_info {
 	u32 frequency;
 	int above_threshold;
 	int current_signal;
+	int avg_signal;
 	int current_noise;
 	int current_txrate;
 	enum chan_width chanwidth;
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 5484d87..ac3c6bc 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -1765,6 +1765,7 @@  static int get_link_signal(struct nl_msg *msg, void *arg)
 	struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1];
 	static struct nla_policy policy[NL80211_STA_INFO_MAX + 1] = {
 		[NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
+		[NL80211_STA_INFO_SIGNAL_AVG] = { .type = NLA_U8 },
 	};
 	struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
 	static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
@@ -1787,6 +1788,13 @@  static int get_link_signal(struct nl_msg *msg, void *arg)
 	sig_change->current_signal =
 		(s8) nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]);
 
+
+	if (sinfo[NL80211_STA_INFO_SIGNAL_AVG])
+		sig_change->avg_signal =
+			(s8) nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL_AVG]);
+	else
+		sig_change->avg_signal = 0;
+
 	if (sinfo[NL80211_STA_INFO_TX_BITRATE]) {
 		if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
 				     sinfo[NL80211_STA_INFO_TX_BITRATE],
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 7b26493..cd7843e 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -5029,10 +5029,12 @@  static int wpa_supplicant_signal_poll(struct wpa_supplicant *wpa_s, char *buf,
 	if (ret)
 		return -1;
 
-	ret = os_snprintf(buf, buflen, "RSSI=%d\nLINKSPEED=%d\n"
+	ret = os_snprintf(buf, buflen, "RSSI=%d\n"
+			  "AVG_RSSI=%d\nLINKSPEED=%d\n"
 			  "NOISE=%d\nFREQUENCY=%u\nWIDTH=%s\n"
 			  "CENTER_FRQ1=%d\nCENTER_FRQ2=%d\n",
-			  si.current_signal, si.current_txrate / 1000,
+			  si.current_signal, si.avg_signal,
+			  si.current_txrate / 1000,
 			  si.current_noise, si.frequency,
 			  channel_width_name(si.chanwidth),
 			  si.center_frq1, si.center_frq2);