iwd: Use same signal strength calculation as wpa_supplicant
PATCH 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.
--- plugins/iwd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
plugins/iwd.c +3 -1
@@ -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
Hi Jonathan,
Quoted 11 lines
Fixes the signal strength reported by connman being lower when using iwd compared to
wpa_supplicant.
---plugins/iwd.c| 4 +++-1 file changed, 3 insertions(+), 1 deletion(-)plugins/iwd.c +0
-0
plugins/iwd.c static unsigned char calculate_strength(int strength) · line 1133
Quoted 7 lines
plugins/iwd.c +3
-1@@ -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 ;
I think it would be better to fix wpa_supplicant plugin to adjust to iwd. Since the iwd signal strength calculation should not be seconded guessed. That will get you into trouble at some point.
Regards
Marcel
Hi Jonathan,
Quoted 11 lines · Jonathan Liu
Fixes the signal strength reported by connman being lower when using iwd compared to
wpa_supplicant.--- plugins/iwd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)plugins/iwd.c +0
-0
plugins/iwd.c static unsigned char calculate_strength(int strength) · line 1133
Quoted 7 lines
plugins/iwd.c +3
-1@@ -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 ;
Can you explain your math here? The original code maps the reported signal strength linearly to the ConnMan's range.
Daniel
Hi Daniel,
It is the same mapping of dBm to 0-100 range as
https://git.kernel.org/pub/scm/network/connman/connman.git/tree/plugins/wifi.c#n2805
For wpa_supplicant, g_supplicant_network_get_signal(supplicant_network) returns the dBm value.
For iwd, you need to divide the number by 100 to get dBm value.
Regards,
Jonathan
Quoted 28 lines · Daniel Wagner
Hi Jonathan,
Quoted 11 lines · Jonathan Liu
Fixes the signal strength reported by connman being lower when using iwd compared to
wpa_supplicant.--- plugins/iwd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)plugins/iwd.c +0
-0plugins/iwd.c static unsigned char calculate_strength(int strength) · line 1133
Quoted 7 lines
plugins/iwd.c +3
-1@@ -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 ;Can you explain your math here? The original code maps the reported signal strength linearly to the ConnMan's range.
Daniel
Hi Jonathan,
Quoted 6 lines
It is the same mapping of dBm to 0-100 range as
https://git.kernel.org/pub/scm/network/connman/connman.git/tree/plugins/wifi.c#n2805
Forwpa_supplicant,g_supplicant_network_get_signal(supplicant_network)returns the dBm value.
For iwd, you need to divide the number by 100 to get dBm value.
from iwd documentation.
int16 SignalStrength
Network's maximum signal strength expressed in 100 * dBm. The value is the range of 0 (strongest signal) to -10000 (weakest signal)
Anyway, the signal strength in % expression is a total mess since every hardware reports different value and none of them are normalized.
It is better to fix the GSupplicant code to do exactly what iwd does.
Regards
Marcel
Quoted 6 lines · Jonathan Liu
It is the same mapping of dBm to 0-100 range as
https://git.kernel.org/pub/scm/network/connman/connman.git/tree/plugins/wifi.c#n2805
Forwpa_supplicant,g_supplicant_network_get_signal(supplicant_network)returns the dBm value.
For iwd, you need to divide the number by 100 to get dBm value.
Please add this information to the commit message.
Daniel
Hi Daniel and Marcel,
Quoted 10 lines · Daniel Wagner
Quoted 6 lines · Jonathan Liu
It is the same mapping of dBm to 0-100 range as
https://git.kernel.org/pub/scm/network/connman/connman.git/tree/plugins/wifi.c#n2805
Forwpa_supplicant,g_supplicant_network_get_signal(supplicant_network)returns the dBm value.
For iwd, you need to divide the number by 100 to get dBm value.Please add this information to the commit message.
Can we first reach a consensus about whether to
1. Change the iwd signal calculation to match wpa_supplicant
2. Change the wpa_supplicant signal calculation to match iwd
3. Do nothing to either plugin to avoid changing behavior of existing devices/applications or Linux distributions using connman
If we change the wpa_supplicant calculation then I imagine people would complain about reduced signal strength after updating (e.g. in OSMC and many other devices/applications or Linux distributions using connman).
The wpa_supplicant calculation regards a signal level of -20 dBm or higher as 100%.
The iwd calculation regards a signal level of -20 dBm as 80% and 0 dBm as 100%.
Thanks.
Regards,
Jonathan
Quoted 2 lines · Jonathan Liu
Can we first reach a consensus about whether to
1. Change the iwd signal calculation to matchwpa_supplicant
Yes.
Quoted 3 lines
2. Change the
wpa_supplicantsignal calculation to match iwd
3. Do nothing to either plugin to avoid changing behavior of existing devices/applications or Linux distributions using connman
No, people will complain and think it's an regression.
Quoted 4 lines
If we change the
wpa_supplicantcalculation then I imagine people would complain about reduced signal strength after updating (e.g. in OSMC and many other devices/applications or Linux distributions using connman).
For sure.
Quoted 3 lines
The
wpa_supplicantcalculation regards a signal level of -20 dBm or higher as 100%.
The iwd calculation regards a signal level of -20 dBm as 80% and 0 dBm as 100%.
The signal strength is used to sort the services internally. IIRC, this might trigger the connect algorithm for wpa_supplicant but for iwd it shouldn't as we rely on iwd to do the right thing (see the 'native' connect mode). So we should not change the wpa_supplicant signal strenght math (check the git history on this topic).
Daniel