[Xfce4-commits] [panel-plugins/xfce4-wavelan-plugin] 01/09: [bsd] convert rssi from dBm to %, probably fuzzy, but always better to have a positive value for the progressbar..

noreply at xfce.org noreply at xfce.org
Sun May 1 18:06:14 CEST 2016


This is an automated email from the git hooks/post-receive script.

landry pushed a commit to branch master
in repository panel-plugins/xfce4-wavelan-plugin.

commit 5fa22c4f49eb83e11c6abceae7be5745e1cf6779
Author: Landry Breuil <landry at xfce.org>
Date:   Sun May 1 17:58:48 2016 +0200

    [bsd] convert rssi from dBm to %, probably fuzzy, but always better to have a positive value for the progressbar..
---
 panel-plugin/wi_bsd.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/panel-plugin/wi_bsd.c b/panel-plugin/wi_bsd.c
index 62327e1..59d488b 100644
--- a/panel-plugin/wi_bsd.c
+++ b/panel-plugin/wi_bsd.c
@@ -158,7 +158,11 @@ wi_query(struct wi_device *device, struct wi_stats *stats)
   /* clear stats first */
   bzero((void *)stats, sizeof(*stats));
 
+#if defined(__OpenBSD__)
+  strlcpy(stats->ws_qunit, "%", 2);
+#else
   strlcpy(stats->ws_qunit, "dBm", 4);
+#endif
   /* check vendor (independent of carrier state) */
 #if defined(__FreeBSD_kernel__)
   if ((result = _wi_vendor(device, stats->ws_vendor, WI_MAXSTRLEN)) != WI_OK)
@@ -258,8 +262,15 @@ _wi_quality(const struct wi_device *device, int *quality)
   /* clearly broken, but stolen from ifconfig.c */
   if (nr.nr_max_rssi)
     *quality = IEEE80211_NODEREQ_RSSI(&nr); /* value in percentage */
+  /* nr_rssi is in dBm, convert to % via
+   http://stackoverflow.com/questions/15797920/how-to-convert-wifi-signal-strength-from-quality-percent-to-rssi-dbm
+  */
+  else if (nr.nr_rssi <= -100)
+    *quality = 0;
+  else if (nr.nr_rssi >= -50)
+    *quality = 100;
   else
-    *quality = nr.nr_rssi; /* value in decibels */
+    *quality = 2 * (100 + nr.nr_rssi);
 
   return(WI_OK);
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list