public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH 1/5] network: Add SignalStrength/Frequency properties to BSS interface
@ 2025-04-23 13:54 James Prestwood
  2025-04-23 13:54 ` [PATCH 2/5] station: update SignalStrength/Frequency for " James Prestwood
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: James Prestwood @ 2025-04-23 13:54 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

This patch adds SignalStrength and Frequencies properties to the
BSS interface, which will provide more information for individual
BSS's.
---
 src/network.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/network.c b/src/network.c
index 4602a110..2443d4c5 100644
--- a/src/network.c
+++ b/src/network.c
@@ -2194,10 +2194,39 @@ static bool network_bss_property_get_address(struct l_dbus *dbus,
 	return true;
 }
 
+static bool network_bss_property_get_signal(struct l_dbus *dbus,
+					struct l_dbus_message *message,
+					struct l_dbus_message_builder *builder,
+					void *user_data)
+{
+	struct scan_bss *bss = user_data;
+	int16_t signal = bss->signal_strength / 100;
+
+	l_dbus_message_builder_append_basic(builder, 'n', &signal);
+
+	return true;
+}
+
+static bool network_bss_property_get_freq(struct l_dbus *dbus,
+					struct l_dbus_message *message,
+					struct l_dbus_message_builder *builder,
+					void *user_data)
+{
+	struct scan_bss *bss = user_data;
+
+	l_dbus_message_builder_append_basic(builder, 'u', &bss->frequency);
+
+	return true;
+}
+
 static void setup_bss_interface(struct l_dbus_interface *interface)
 {
 	l_dbus_interface_property(interface, "Address", 0, "s",
 					network_bss_property_get_address, NULL);
+	l_dbus_interface_property(interface, "SignalStrength", 0, "n",
+					network_bss_property_get_signal, NULL);
+	l_dbus_interface_property(interface, "Frequency", 0, "u",
+					network_bss_property_get_freq, NULL);
 }
 
 static int network_init(void)
-- 
2.34.1


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

* [PATCH 2/5] station: update SignalStrength/Frequency for BSS interface
  2025-04-23 13:54 [PATCH 1/5] network: Add SignalStrength/Frequency properties to BSS interface James Prestwood
@ 2025-04-23 13:54 ` James Prestwood
  2025-04-23 14:52   ` Denis Kenzior
  2025-04-23 13:54 ` [PATCH 3/5] client: add SignalStrength/Frequency properties James Prestwood
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: James Prestwood @ 2025-04-23 13:54 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

When the BSS's signal or frequency changes, update those properties
---
 src/station.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/station.c b/src/station.c
index 14c93671..85ed2898 100644
--- a/src/station.c
+++ b/src/station.c
@@ -545,10 +545,21 @@ static bool station_register_bss(struct network *network, struct scan_bss *bss)
 	 * scan_bss pointer, as this one will be freed soon.
 	 */
 	old = l_dbus_object_get_data(dbus_get_bus(), path, IWD_BSS_INTERFACE);
-	if (old)
-		return l_dbus_object_set_data(dbus_get_bus(), path,
+	if (old) {
+		l_dbus_object_set_data(dbus_get_bus(), path,
 						IWD_BSS_INTERFACE, bss);
 
+		if (old->signal_strength != bss->signal_strength)
+			l_dbus_property_changed(dbus_get_bus(), path,
+					IWD_BSS_INTERFACE, "SignalStrength");
+
+		if (old->frequency != bss->frequency)
+			l_dbus_property_changed(dbus_get_bus(), path,
+					IWD_BSS_INTERFACE, "Frequency");
+
+		return true;
+	}
+
 	if (!l_dbus_object_add_interface(dbus_get_bus(), path,
 						IWD_BSS_INTERFACE, bss))
 		return false;
-- 
2.34.1


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

* [PATCH 3/5] client: add SignalStrength/Frequency properties
  2025-04-23 13:54 [PATCH 1/5] network: Add SignalStrength/Frequency properties to BSS interface James Prestwood
  2025-04-23 13:54 ` [PATCH 2/5] station: update SignalStrength/Frequency for " James Prestwood
@ 2025-04-23 13:54 ` James Prestwood
  2025-04-23 14:53   ` Denis Kenzior
  2025-04-23 13:54 ` [PATCH 4/5] client: fix get-bss command spacing/footer James Prestwood
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: James Prestwood @ 2025-04-23 13:54 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

---
 client/bss.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/client/bss.c b/client/bss.c
index def4de7f..19355f0b 100644
--- a/client/bss.c
+++ b/client/bss.c
@@ -32,6 +32,8 @@
 
 struct bss {
 	char *address;
+	int16_t signal;
+	uint32_t frequency;
 };
 
 static const char *get_address(const void *data)
@@ -57,8 +59,52 @@ static void update_address(void *data, struct l_dbus_message_iter *variant)
 	bss->address = l_strdup(value);
 }
 
+static const char *get_signal(const void *data)
+{
+	const struct bss *bss = data;
+	static char signal_str[7];
+
+	sprintf(signal_str, "%d", bss->signal);
+
+	return signal_str;
+}
+
+static void update_signal(void *data, struct l_dbus_message_iter *variant)
+{
+	struct bss *bss = data;
+	int16_t value;
+
+	if (!l_dbus_message_iter_get_variant(variant, "n", &value))
+		return;
+
+	bss->signal = value;
+}
+
+static const char *get_frequency(const void *data)
+{
+	const struct bss *bss = data;
+	static char freq_str[5];
+
+	sprintf(freq_str, "%u", bss->frequency);
+
+	return freq_str;
+}
+
+static void update_frequency(void *data, struct l_dbus_message_iter *variant)
+{
+	struct bss *bss = data;
+	uint32_t value;
+
+	if (!l_dbus_message_iter_get_variant(variant, "u", &value))
+		return;
+
+	bss->frequency = value;
+}
+
 static const struct proxy_interface_property bss_properties[] = {
-	{ "Address",       "s", update_address, get_address },
+	{ "Address",        "s", update_address, get_address },
+	{ "SignalStrength", "n", update_signal, get_signal },
+	{ "Frequency",      "u", update_frequency, get_frequency },
 	{ }
 };
 
-- 
2.34.1


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

* [PATCH 4/5] client: fix get-bss command spacing/footer
  2025-04-23 13:54 [PATCH 1/5] network: Add SignalStrength/Frequency properties to BSS interface James Prestwood
  2025-04-23 13:54 ` [PATCH 2/5] station: update SignalStrength/Frequency for " James Prestwood
  2025-04-23 13:54 ` [PATCH 3/5] client: add SignalStrength/Frequency properties James Prestwood
@ 2025-04-23 13:54 ` James Prestwood
  2025-04-23 13:54 ` [PATCH 5/5] doc: add new properties to BSS interface James Prestwood
  2025-04-23 14:51 ` [PATCH 1/5] network: Add SignalStrength/Frequency " Denis Kenzior
  4 siblings, 0 replies; 9+ messages in thread
From: James Prestwood @ 2025-04-23 13:54 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

With the new SignalStrength properties the column width needed to
be updated. In addition there was no table footer which caused
the auto-refresh to not work correctly.
---
 client/station.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/client/station.c b/client/station.c
index 5066a9f1..2c195f6b 100644
--- a/client/station.c
+++ b/client/station.c
@@ -765,10 +765,12 @@ static enum cmd_status cmd_get_bsses(const char *device_name,
 			continue;
 
 		display_table_row(MARGIN, 1, strlen(path), path);
-		proxy_properties_display_inline(bss_i, MARGIN, 10, 18);
+		proxy_properties_display_inline(bss_i, MARGIN, 14, 18);
 		display_table_row(MARGIN, 1, 1, "");
 	}
 
+	display_table_footer();
+
 	return CMD_STATUS_DONE;
 }
 
-- 
2.34.1


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

* [PATCH 5/5] doc: add new properties to BSS interface
  2025-04-23 13:54 [PATCH 1/5] network: Add SignalStrength/Frequency properties to BSS interface James Prestwood
                   ` (2 preceding siblings ...)
  2025-04-23 13:54 ` [PATCH 4/5] client: fix get-bss command spacing/footer James Prestwood
@ 2025-04-23 13:54 ` James Prestwood
  2025-04-23 14:51 ` [PATCH 1/5] network: Add SignalStrength/Frequency " Denis Kenzior
  4 siblings, 0 replies; 9+ messages in thread
From: James Prestwood @ 2025-04-23 13:54 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

This adds SignalStrength and Frequency properties
---
 doc/basic-service-set.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/doc/basic-service-set.txt b/doc/basic-service-set.txt
index f827ca02..32dc0d6f 100644
--- a/doc/basic-service-set.txt
+++ b/doc/basic-service-set.txt
@@ -8,3 +8,11 @@ Object path	/net/connman/iwd/{phy0,phy1,...}/{1,2,...}/Xxx
 Properties	string Address [readonly]
 
 			MAC address of BSS
+
+		int16 SignalStrength [readonly]
+
+			RSSI of BSS in dB
+
+		uint32 Frequency [readonly]
+
+			Frequency of BSS (MHz)
-- 
2.34.1


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

* Re: [PATCH 1/5] network: Add SignalStrength/Frequency properties to BSS interface
  2025-04-23 13:54 [PATCH 1/5] network: Add SignalStrength/Frequency properties to BSS interface James Prestwood
                   ` (3 preceding siblings ...)
  2025-04-23 13:54 ` [PATCH 5/5] doc: add new properties to BSS interface James Prestwood
@ 2025-04-23 14:51 ` Denis Kenzior
  4 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2025-04-23 14:51 UTC (permalink / raw)
  To: James Prestwood, iwd

Hi James,

On 4/23/25 8:54 AM, James Prestwood wrote:
> This patch adds SignalStrength and Frequencies properties to the
> BSS interface, which will provide more information for individual
> BSS's.
> ---
>   src/network.c | 29 +++++++++++++++++++++++++++++
>   1 file changed, 29 insertions(+)
> 
> diff --git a/src/network.c b/src/network.c
> index 4602a110..2443d4c5 100644
> --- a/src/network.c
> +++ b/src/network.c
> @@ -2194,10 +2194,39 @@ static bool network_bss_property_get_address(struct l_dbus *dbus,
>   	return true;
>   }
>   
> +static bool network_bss_property_get_signal(struct l_dbus *dbus,

nit: Can we use ..._get_signal_strength here?

> +					struct l_dbus_message *message,
> +					struct l_dbus_message_builder *builder,
> +					void *user_data)
> +{
> +	struct scan_bss *bss = user_data;
> +	int16_t signal = bss->signal_strength / 100;
> +
> +	l_dbus_message_builder_append_basic(builder, 'n', &signal);
> +
> +	return true;
> +}
> +
> +static bool network_bss_property_get_freq(struct l_dbus *dbus,

nit: ..._get_frequency

> +					struct l_dbus_message *message,
> +					struct l_dbus_message_builder *builder,
> +					void *user_data)
> +{
> +	struct scan_bss *bss = user_data;
> +
> +	l_dbus_message_builder_append_basic(builder, 'u', &bss->frequency);
> +
> +	return true;
> +}
> +
>   static void setup_bss_interface(struct l_dbus_interface *interface)
>   {
>   	l_dbus_interface_property(interface, "Address", 0, "s",
>   					network_bss_property_get_address, NULL);
> +	l_dbus_interface_property(interface, "SignalStrength", 0, "n",
> +					network_bss_property_get_signal, NULL);
> +	l_dbus_interface_property(interface, "Frequency", 0, "u",
> +					network_bss_property_get_freq, NULL);
>   }
>   
>   static int network_init(void)

Regards,
-Denis

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

* Re: [PATCH 2/5] station: update SignalStrength/Frequency for BSS interface
  2025-04-23 13:54 ` [PATCH 2/5] station: update SignalStrength/Frequency for " James Prestwood
@ 2025-04-23 14:52   ` Denis Kenzior
  2025-04-23 18:50     ` James Prestwood
  0 siblings, 1 reply; 9+ messages in thread
From: Denis Kenzior @ 2025-04-23 14:52 UTC (permalink / raw)
  To: James Prestwood, iwd

Hi James,

On 4/23/25 8:54 AM, James Prestwood wrote:
> When the BSS's signal or frequency changes, update those properties
> ---
>   src/station.c | 15 +++++++++++++--
>   1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/src/station.c b/src/station.c
> index 14c93671..85ed2898 100644
> --- a/src/station.c
> +++ b/src/station.c
> @@ -545,10 +545,21 @@ static bool station_register_bss(struct network *network, struct scan_bss *bss)
>   	 * scan_bss pointer, as this one will be freed soon.
>   	 */
>   	old = l_dbus_object_get_data(dbus_get_bus(), path, IWD_BSS_INTERFACE);
> -	if (old)
> -		return l_dbus_object_set_data(dbus_get_bus(), path,
> +	if (old) {
> +		l_dbus_object_set_data(dbus_get_bus(), path,
>   						IWD_BSS_INTERFACE, bss);
>   
> +		if (old->signal_strength != bss->signal_strength)
> +			l_dbus_property_changed(dbus_get_bus(), path,
> +					IWD_BSS_INTERFACE, "SignalStrength");
> +
> +		if (old->frequency != bss->frequency)
> +			l_dbus_property_changed(dbus_get_bus(), path,
> +					IWD_BSS_INTERFACE, "Frequency");
> +
> +		return true;

nit: This return probably deserves its own commit + Fixes tag.

> +	}
> +
>   	if (!l_dbus_object_add_interface(dbus_get_bus(), path,
>   						IWD_BSS_INTERFACE, bss))
>   		return false;

Regards,
-Denis

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

* Re: [PATCH 3/5] client: add SignalStrength/Frequency properties
  2025-04-23 13:54 ` [PATCH 3/5] client: add SignalStrength/Frequency properties James Prestwood
@ 2025-04-23 14:53   ` Denis Kenzior
  0 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2025-04-23 14:53 UTC (permalink / raw)
  To: James Prestwood, iwd

Hi James,

On 4/23/25 8:54 AM, James Prestwood wrote:
> ---
>   client/bss.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 47 insertions(+), 1 deletion(-)
> 
> diff --git a/client/bss.c b/client/bss.c
> index def4de7f..19355f0b 100644
> --- a/client/bss.c
> +++ b/client/bss.c
> @@ -32,6 +32,8 @@
>   
>   struct bss {
>   	char *address;
> +	int16_t signal;
signal_strength? or rssi?
> +	uint32_t frequency;
>   };
>   
>   static const char *get_address(const void *data)
> @@ -57,8 +59,52 @@ static void update_address(void *data, struct l_dbus_message_iter *variant)
>   	bss->address = l_strdup(value);
>   }
>   
> +static const char *get_signal(const void *data)

signal_strength?

> +{
> +	const struct bss *bss = data;
> +	static char signal_str[7];
> +
> +	sprintf(signal_str, "%d", bss->signal);
> +
> +	return signal_str;
> +}
> +
> +static void update_signal(void *data, struct l_dbus_message_iter *variant)
> +{
> +	struct bss *bss = data;
> +	int16_t value;
> +
> +	if (!l_dbus_message_iter_get_variant(variant, "n", &value))
> +		return;
> +
> +	bss->signal = value;

ditto

> +}
> +
> +static const char *get_frequency(const void *data)
> +{
> +	const struct bss *bss = data;
> +	static char freq_str[5];

There is hardware that supports frequencies in the 60G range.  Might want to 
future proof this somewhat.

> +
> +	sprintf(freq_str, "%u", bss->frequency);
> +
> +	return freq_str;
> +}
> +
> +static void update_frequency(void *data, struct l_dbus_message_iter *variant)
> +{
> +	struct bss *bss = data;
> +	uint32_t value;
> +
> +	if (!l_dbus_message_iter_get_variant(variant, "u", &value))
> +		return;
> +
> +	bss->frequency = value;
> +}
> +
>   static const struct proxy_interface_property bss_properties[] = {
> -	{ "Address",       "s", update_address, get_address },
> +	{ "Address",        "s", update_address, get_address },
> +	{ "SignalStrength", "n", update_signal, get_signal },
> +	{ "Frequency",      "u", update_frequency, get_frequency },
>   	{ }
>   };
>   

Regards,
-Denis

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

* Re: [PATCH 2/5] station: update SignalStrength/Frequency for BSS interface
  2025-04-23 14:52   ` Denis Kenzior
@ 2025-04-23 18:50     ` James Prestwood
  0 siblings, 0 replies; 9+ messages in thread
From: James Prestwood @ 2025-04-23 18:50 UTC (permalink / raw)
  To: Denis Kenzior, iwd


On 4/23/25 10:52 AM, Denis Kenzior wrote:
> Hi James,
>
> On 4/23/25 8:54 AM, James Prestwood wrote:
>> When the BSS's signal or frequency changes, update those properties
>> ---
>>   src/station.c | 15 +++++++++++++--
>>   1 file changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/station.c b/src/station.c
>> index 14c93671..85ed2898 100644
>> --- a/src/station.c
>> +++ b/src/station.c
>> @@ -545,10 +545,21 @@ static bool station_register_bss(struct network 
>> *network, struct scan_bss *bss)
>>        * scan_bss pointer, as this one will be freed soon.
>>        */
>>       old = l_dbus_object_get_data(dbus_get_bus(), path, 
>> IWD_BSS_INTERFACE);
>> -    if (old)
>> -        return l_dbus_object_set_data(dbus_get_bus(), path,
>> +    if (old) {
>> +        l_dbus_object_set_data(dbus_get_bus(), path,
>>                           IWD_BSS_INTERFACE, bss);
>>   +        if (old->signal_strength != bss->signal_strength)
>> +            l_dbus_property_changed(dbus_get_bus(), path,
>> +                    IWD_BSS_INTERFACE, "SignalStrength");
>> +
>> +        if (old->frequency != bss->frequency)
>> +            l_dbus_property_changed(dbus_get_bus(), path,
>> +                    IWD_BSS_INTERFACE, "Frequency");
>> +
>> +        return true;
>
> nit: This return probably deserves its own commit + Fixes tag.

This specifically isn't fixing anything. I just needed to set the new 
BSS object prior to emitting the property changed signal. Technically 
this does change the function logic but we don't actually check the 
return of station_register_bss() anywhere, this could just be made into 
a void return I suppose if you'd like.

>
>> +    }
>> +
>>       if (!l_dbus_object_add_interface(dbus_get_bus(), path,
>>                           IWD_BSS_INTERFACE, bss))
>>           return false;
>
> Regards,
> -Denis

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

end of thread, other threads:[~2025-04-23 18:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-23 13:54 [PATCH 1/5] network: Add SignalStrength/Frequency properties to BSS interface James Prestwood
2025-04-23 13:54 ` [PATCH 2/5] station: update SignalStrength/Frequency for " James Prestwood
2025-04-23 14:52   ` Denis Kenzior
2025-04-23 18:50     ` James Prestwood
2025-04-23 13:54 ` [PATCH 3/5] client: add SignalStrength/Frequency properties James Prestwood
2025-04-23 14:53   ` Denis Kenzior
2025-04-23 13:54 ` [PATCH 4/5] client: fix get-bss command spacing/footer James Prestwood
2025-04-23 13:54 ` [PATCH 5/5] doc: add new properties to BSS interface James Prestwood
2025-04-23 14:51 ` [PATCH 1/5] network: Add SignalStrength/Frequency " Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox