ConnMan network manager
 help / color / mirror / Atom feed
From: Jonathan Liu <net147@gmail.com>
To: connman@lists.linux.dev
Cc: Jonathan Liu <net147@gmail.com>
Subject: [PATCH v2] iwd: Use same signal strength calculation as wpa_supplicant
Date: Tue, 15 Feb 2022 21:19:40 +1100	[thread overview]
Message-ID: <20220215101940.598839-1-net147@gmail.com> (raw)

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

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


             reply	other threads:[~2022-02-15 10:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15 10:19 Jonathan Liu [this message]
2022-02-21  8:24 ` [PATCH v2] iwd: Use same signal strength calculation as wpa_supplicant Daniel Wagner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220215101940.598839-1-net147@gmail.com \
    --to=net147@gmail.com \
    --cc=connman@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox