All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iwd: Use same signal strength calculation as wpa_supplicant
@ 2022-02-14  2:13 Jonathan Liu
  2022-02-14  7:24 ` Marcel Holtmann
  2022-02-14  7:36 ` Daniel Wagner
  0 siblings, 2 replies; 8+ messages in thread
From: Jonathan Liu @ 2022-02-14  2:13 UTC (permalink / raw)
  To: connman; +Cc: 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(-)

diff --git a/plugins/iwd.c b/plugins/iwd.c
index ac3d1e17..2a245fe2 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;
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] iwd: Use same signal strength calculation as wpa_supplicant
  2022-02-14  2:13 [PATCH] iwd: Use same signal strength calculation as wpa_supplicant Jonathan Liu
@ 2022-02-14  7:24 ` Marcel Holtmann
  2022-02-14  7:36 ` Daniel Wagner
  1 sibling, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2022-02-14  7:24 UTC (permalink / raw)
  To: Jonathan Liu; +Cc: connman

Hi Jonathan,

> 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(-)
> 
> diff --git a/plugins/iwd.c b/plugins/iwd.c
> index ac3d1e17..2a245fe2 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;

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iwd: Use same signal strength calculation as wpa_supplicant
  2022-02-14  2:13 [PATCH] iwd: Use same signal strength calculation as wpa_supplicant Jonathan Liu
  2022-02-14  7:24 ` Marcel Holtmann
@ 2022-02-14  7:36 ` Daniel Wagner
  2022-02-14 11:31   ` Jonathan Liu
  1 sibling, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2022-02-14  7:36 UTC (permalink / raw)
  To: Jonathan Liu; +Cc: connman

Hi Jonathan,

On Mon, Feb 14, 2022 at 01:13:57PM +1100, Jonathan Liu wrote:
> 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(-)
> 
> diff --git a/plugins/iwd.c b/plugins/iwd.c
> index ac3d1e17..2a245fe2 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;

Can you explain your math here? The original code maps the reported
signal strength linearly to the ConnMan's range.

Daniel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iwd: Use same signal strength calculation as wpa_supplicant
  2022-02-14  7:36 ` Daniel Wagner
@ 2022-02-14 11:31   ` Jonathan Liu
  2022-02-14 14:30     ` Marcel Holtmann
  2022-02-14 15:23     ` Daniel Wagner
  0 siblings, 2 replies; 8+ messages in thread
From: Jonathan Liu @ 2022-02-14 11:31 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: connman

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

On Mon, 14 Feb 2022 at 18:36, Daniel Wagner <wagi@monom.org> wrote:
>
> Hi Jonathan,
>
> On Mon, Feb 14, 2022 at 01:13:57PM +1100, Jonathan Liu wrote:
> > 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(-)
> >
> > diff --git a/plugins/iwd.c b/plugins/iwd.c
> > index ac3d1e17..2a245fe2 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;
>
> Can you explain your math here? The original code maps the reported
> signal strength linearly to the ConnMan's range.
>
> Daniel
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iwd: Use same signal strength calculation as wpa_supplicant
  2022-02-14 11:31   ` Jonathan Liu
@ 2022-02-14 14:30     ` Marcel Holtmann
  2022-02-14 15:23     ` Daniel Wagner
  1 sibling, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2022-02-14 14:30 UTC (permalink / raw)
  To: Jonathan Liu; +Cc: Daniel Wagner, connman

Hi Jonathan,

> 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.

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iwd: Use same signal strength calculation as wpa_supplicant
  2022-02-14 11:31   ` Jonathan Liu
  2022-02-14 14:30     ` Marcel Holtmann
@ 2022-02-14 15:23     ` Daniel Wagner
  2022-02-14 21:41       ` Jonathan Liu
  1 sibling, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2022-02-14 15:23 UTC (permalink / raw)
  To: Jonathan Liu; +Cc: connman

On Mon, Feb 14, 2022 at 10:31:03PM +1100, Jonathan Liu wrote:
> 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.

Please add this information to the commit message.

Daniel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iwd: Use same signal strength calculation as wpa_supplicant
  2022-02-14 15:23     ` Daniel Wagner
@ 2022-02-14 21:41       ` Jonathan Liu
  2022-02-15  8:54         ` Daniel Wagner
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Liu @ 2022-02-14 21:41 UTC (permalink / raw)
  To: Daniel Wagner, Marcel Holtmann; +Cc: connman

Hi Daniel and Marcel,

On Tue, 15 Feb 2022 at 02:23, Daniel Wagner <wagi@monom.org> wrote:
>
> On Mon, Feb 14, 2022 at 10:31:03PM +1100, Jonathan Liu wrote:
> > 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.
>
> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iwd: Use same signal strength calculation as wpa_supplicant
  2022-02-14 21:41       ` Jonathan Liu
@ 2022-02-15  8:54         ` Daniel Wagner
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Wagner @ 2022-02-15  8:54 UTC (permalink / raw)
  To: Jonathan Liu; +Cc: Marcel Holtmann, connman

On Tue, Feb 15, 2022 at 08:41:35AM +1100, Jonathan Liu wrote:
> Can we first reach a consensus about whether to
> 1. Change the iwd signal calculation to match wpa_supplicant

Yes.

> 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

No, people will complain and think it's an regression.

> 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).

For sure.

> 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%.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-02-15  8:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-14  2:13 [PATCH] iwd: Use same signal strength calculation as wpa_supplicant Jonathan Liu
2022-02-14  7:24 ` Marcel Holtmann
2022-02-14  7:36 ` Daniel Wagner
2022-02-14 11:31   ` Jonathan Liu
2022-02-14 14:30     ` Marcel Holtmann
2022-02-14 15:23     ` Daniel Wagner
2022-02-14 21:41       ` Jonathan Liu
2022-02-15  8:54         ` Daniel Wagner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.