Patchwork [V2] wpa_supplicant: Add AVG_RSSI report in signal_poll

login
register
mail settings
Submitter Ilan Peer
Date June 6, 2013, 9:01 a.m.
Message ID <1370509310-2566-1-git-send-email-ilan.peer@intel.com>
Download mbox | patch
Permalink /patch/249347/
State Superseded
Headers show

Comments

Ilan Peer - June 6, 2013, 9:01 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.

Signed-hostap: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-hostap: 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(-)

Patch

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);