From c1c2ca5e7f03f43e8d140b2b354ef29975fd5c88 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Mon, 18 Nov 2019 10:35:54 -0800 Subject: [PATCH] rrm: remove use of floating point math The RCPI value was using floating point values as per the spec. But instead we can just use the signal strength coming from the kernel in mili mdm and scale the hard coded values by a factor of 100. --- src/rrm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/rrm.c b/src/rrm.c index f96fe279..73cf01f2 100644 --- a/src/rrm.c +++ b/src/rrm.c @@ -25,7 +25,6 @@ #endif #include -#include #include #include @@ -247,7 +246,6 @@ static size_t build_report_for_bss(struct rrm_beacon_req_info *beacon, uint8_t *to) { uint8_t *start = to; - double dbms = bss->signal_strength / 100; *to++ = beacon->oper_class; *to++ = scan_freq_to_channel(bss->frequency, NULL); @@ -259,10 +257,10 @@ static size_t build_report_for_bss(struct rrm_beacon_req_info *beacon, *to++ = rrm_phy_type(bss); /* 802.11 Table 9-154 - RCPI values */ - if (dbms < -109.5) + if (bss->signal_strength < -10950) *to++ = 0; - else if (dbms >= -109.5 && dbms < 0) - *to++ = (uint8_t)floor(2 * (dbms + 110)); + else if (bss->signal_strength >= -10950 && bss->signal_strength < 0) + *to++ = (uint8_t)((2 * (bss->signal_strength + 11000)) / 100); else *to++ = 220;