Skip to contentSkip to conversation

iwd: Use same signal strength calculation as wpa_supplicant

PATCH In review Jonathan Liu 2 participants 2 messages Feb 15, 2022 – Feb 21, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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.

---
 plugins/iwd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
plugins/iwd.c +3 -1
index ac3d1e17..2a245fe2 100644
@@ -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;
 }
Signature · 1 line
2.35.1
#1 lore raw

Hi,

Quoted 9 lines · Jonathan Liu

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;
Quoted 7 lines

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.

Patch applied.

Thanks,
Daniel