summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorJonathan Liu <net147@gmail.com>2022-02-15 21:19:40 +1100
committerDaniel Wagner <wagi@monom.org>2022-02-21 09:24:24 +0100
commit443d2c2ad2a1b481217dfcc8a207ee5e8519269a (patch)
treee94c35ab019354aadb09a6faab4d15e269a2a660 /plugins
parentdfe99793bb2469093176175784b3804970836b18 (diff)
downloadconnman-443d2c2ad2a1b481217dfcc8a207ee5e8519269a.tar.gz
iwd: Use same signal strength calculation as wpa_supplicant
Fixes the signal strength reported by connman being lower when using iwd compared to wpa_supplicant. In the wifi plugin for wpa_supplicant, the signal strength is calculated as follows: strength = 120 + g_supplicant_network_get_signal(supplicant_network); if (strength > 100) strength = 100; The g_supplicant_network_get_signal() function returns the signal strength in dBm. This means the signal strength calculation in connman for wpa_supplicant treats -20 dBm or higher as 100% signal strength. The iwd plugin is changed to use the same calculation but as iwd returns returns the signal strength as 100 * dBm, it needs to be divided by 100 to get the same dBm value as wpa_supplicant.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/iwd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/plugins/iwd.c b/plugins/iwd.c
index 357f2c36..8974e664 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -1128,7 +1128,9 @@ static unsigned char calculate_strength(int strength)
* ConnMan expects it in the range from 100 (strongest) to 0
* (weakest).
*/
- res = (unsigned char)((strength + 10000) / 100);
+ res = (unsigned char)(120 + strength / 100);
+ if (res > 100)
+ res = 100;
return res;
}