summaryrefslogtreecommitdiff
path: root/src/utils/common.c
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2018-12-06 05:04:28 +0000
committerCy Schubert <cy@FreeBSD.org>2018-12-06 05:04:28 +0000
commit8a36c5c2ca4d1f8a900ca3d9ffde40b96463def7 (patch)
treeb9a3166587c75d5325dc46c7c83ca435f2e54917 /src/utils/common.c
parent765ef8a7642d07aa9616f2b1a9cdebb8e3552f6a (diff)
Diffstat (limited to 'src/utils/common.c')
-rw-r--r--src/utils/common.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/utils/common.c b/src/utils/common.c
index 04a533a05902f..1eb33705bef34 100644
--- a/src/utils/common.c
+++ b/src/utils/common.c
@@ -1200,3 +1200,24 @@ int str_starts(const char *str, const char *start)
{
return os_strncmp(str, start, os_strlen(start)) == 0;
}
+
+
+/**
+ * rssi_to_rcpi - Convert RSSI to RCPI
+ * @rssi: RSSI to convert
+ * Returns: RCPI corresponding to the given RSSI value, or 255 if not available.
+ *
+ * It's possible to estimate RCPI based on RSSI in dBm. This calculation will
+ * not reflect the correct value for high rates, but it's good enough for Action
+ * frames which are transmitted with up to 24 Mbps rates.
+ */
+u8 rssi_to_rcpi(int rssi)
+{
+ if (!rssi)
+ return 255; /* not available */
+ if (rssi < -110)
+ return 0;
+ if (rssi > 0)
+ return 220;
+ return (rssi + 110) * 2;
+}