All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 1/2] Initial signal level notification
@ 2022-05-20 20:11 Denis Kenzior
  0 siblings, 0 replies; 5+ messages in thread
From: Denis Kenzior @ 2022-05-20 20:11 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]

Hi Jesse,

On 5/20/22 13:59, Jesse Lentz wrote:
> After registration of a SignalLevelAgent, make iwd inform the client of
> the initial signal level via a "Changed" method call.
> ---
>   src/netdev.c  |  5 +++++
>   src/netdev.h  |  1 +
>   src/station.c | 16 ++++++++++++----
>   3 files changed, 18 insertions(+), 4 deletions(-)
> 

<snip>

> diff --git a/src/station.c b/src/station.c
> index 2d85054c..7be256fe 100644
> --- a/src/station.c
> +++ b/src/station.c

<snip>

> @@ -3758,10 +3768,8 @@ static struct l_dbus_message *station_dbus_signal_agent_register(
>   
>   	l_debug("agent %s path %s", sender, path);
>   
> -	/*
> -	 * TODO: send an initial notification in a oneshot idle callback,
> -	 * if state is connected.
> -	 */
> +	if (station->connected_network)
> +		l_idle_oneshot(signal_agent_notify_initial, station, NULL);
>   
>   	return l_dbus_message_new_method_return(message);

I'd rather not use l_idle_oneshot here.  There's a astronomically tiny chance 
that station will be wiped out before the idle callback fires on the next loop 
iteration.  It should also be easy to avoid:

struct l_dbus_message *reply;

...

reply = l_dbus_message_new_method_return(message);
l_dbus_send(dbus, reply);

if (station->connected_network)
	station_signal_agent_notify(...);

return NULL;

This ensures the reply goes out prior to the Changed method being invoked.

>   }
> 

Regards,
-Denis

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

* Re: [PATCH 1/2] Initial signal level notification
@ 2022-05-20 22:00 Denis Kenzior
  0 siblings, 0 replies; 5+ messages in thread
From: Denis Kenzior @ 2022-05-20 22:00 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 581 bytes --]

Hi Jesse,

On 5/20/22 16:53, Jesse Lentz wrote:
> After registration of a SignalLevelAgent, make iwd inform the client of
> the initial signal level via a "Changed" method call.
> ---
>   src/netdev.c  |  5 +++++
>   src/netdev.h  |  1 +
>   src/station.c | 19 ++++++++++++++-----
>   3 files changed, 20 insertions(+), 5 deletions(-)
> 

I added a 'station:' prefix to the commit message and...

> +	if (station->connected_network)
> +	{

... since we use the kernel coding style, I amended this to:
if (..) {

Both patches applied, thanks!

Regards,
-Denis

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

* [PATCH 1/2] Initial signal level notification
@ 2022-05-20 21:53 Jesse Lentz
  0 siblings, 0 replies; 5+ messages in thread
From: Jesse Lentz @ 2022-05-20 21:53 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 2420 bytes --]

After registration of a SignalLevelAgent, make iwd inform the client of
the initial signal level via a "Changed" method call.
---
 src/netdev.c  |  5 +++++
 src/netdev.h  |  1 +
 src/station.c | 19 ++++++++++++++-----
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/netdev.c b/src/netdev.c
index e483edf8..8b2143fd 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -450,6 +450,11 @@ const char *netdev_get_path(struct netdev *netdev)
 	return path;
 }
 
+uint8_t netdev_get_rssi_level_idx(struct netdev *netdev)
+{
+	return netdev->cur_rssi_level_idx;
+}
+
 static void netdev_set_powered_result(int error, uint16_t type,
 					const void *data,
 					uint32_t len, void *user_data)
diff --git a/src/netdev.h b/src/netdev.h
index 0094d5f9..f093c499 100644
--- a/src/netdev.h
+++ b/src/netdev.h
@@ -145,6 +145,7 @@ bool netdev_get_4addr(struct netdev *netdev);
 const char *netdev_get_name(struct netdev *netdev);
 bool netdev_get_is_up(struct netdev *netdev);
 const char *netdev_get_path(struct netdev *netdev);
+uint8_t netdev_get_rssi_level_idx(struct netdev *netdev);
 
 struct handshake_state *netdev_handshake_state_new(struct netdev *netdev);
 struct handshake_state *netdev_get_handshake(struct netdev *netdev);
diff --git a/src/station.c b/src/station.c
index 2d85054c..61dd690b 100644
--- a/src/station.c
+++ b/src/station.c
@@ -3716,6 +3716,7 @@ static struct l_dbus_message *station_dbus_signal_agent_register(
 {
 	struct station *station = user_data;
 	const char *path, *sender;
+	struct l_dbus_message *reply;
 	struct l_dbus_message_iter level_iter;
 	int8_t levels[16];
 	int err;
@@ -3758,12 +3759,20 @@ static struct l_dbus_message *station_dbus_signal_agent_register(
 
 	l_debug("agent %s path %s", sender, path);
 
-	/*
-	 * TODO: send an initial notification in a oneshot idle callback,
-	 * if state is connected.
-	 */
+	reply = l_dbus_message_new_method_return(message);
+	l_dbus_send(dbus, reply);
 
-	return l_dbus_message_new_method_return(message);
+	if (station->connected_network)
+	{
+		struct netdev *netdev = station->netdev;
+		uint8_t level = netdev_get_rssi_level_idx(netdev);
+
+		station_signal_agent_notify(station->signal_agent,
+						netdev_get_path(netdev),
+						level);
+	}
+
+	return NULL;
 }
 
 static struct l_dbus_message *station_dbus_signal_agent_unregister(
-- 
2.36.0

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

* Re: [PATCH 1/2] Initial signal level notification
@ 2022-05-20 20:50 Jesse Lentz
  0 siblings, 0 replies; 5+ messages in thread
From: Jesse Lentz @ 2022-05-20 20:50 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 87 bytes --]

Hi Denis,

Thanks for the feedback; I'll submit a revised patch.

Sincerely,
Jesse

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

* [PATCH 1/2] Initial signal level notification
@ 2022-05-20 18:59 Jesse Lentz
  0 siblings, 0 replies; 5+ messages in thread
From: Jesse Lentz @ 2022-05-20 18:59 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 2404 bytes --]

After registration of a SignalLevelAgent, make iwd inform the client of
the initial signal level via a "Changed" method call.
---
 src/netdev.c  |  5 +++++
 src/netdev.h  |  1 +
 src/station.c | 16 ++++++++++++----
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/netdev.c b/src/netdev.c
index e483edf8..8b2143fd 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -450,6 +450,11 @@ const char *netdev_get_path(struct netdev *netdev)
 	return path;
 }
 
+uint8_t netdev_get_rssi_level_idx(struct netdev *netdev)
+{
+	return netdev->cur_rssi_level_idx;
+}
+
 static void netdev_set_powered_result(int error, uint16_t type,
 					const void *data,
 					uint32_t len, void *user_data)
diff --git a/src/netdev.h b/src/netdev.h
index 0094d5f9..f093c499 100644
--- a/src/netdev.h
+++ b/src/netdev.h
@@ -145,6 +145,7 @@ bool netdev_get_4addr(struct netdev *netdev);
 const char *netdev_get_name(struct netdev *netdev);
 bool netdev_get_is_up(struct netdev *netdev);
 const char *netdev_get_path(struct netdev *netdev);
+uint8_t netdev_get_rssi_level_idx(struct netdev *netdev);
 
 struct handshake_state *netdev_handshake_state_new(struct netdev *netdev);
 struct handshake_state *netdev_get_handshake(struct netdev *netdev);
diff --git a/src/station.c b/src/station.c
index 2d85054c..7be256fe 100644
--- a/src/station.c
+++ b/src/station.c
@@ -3709,6 +3709,16 @@ static void signal_agent_disconnect(struct l_dbus *dbus, void *user_data)
 	netdev_set_rssi_report_levels(station->netdev, NULL, 0);
 }
 
+static void signal_agent_notify_initial(void *user_data)
+{
+	struct station *station = user_data;
+	struct netdev *netdev = station->netdev;
+
+	station_signal_agent_notify(station->signal_agent,
+					netdev_get_path(netdev),
+					netdev_get_rssi_level_idx(netdev));
+}
+
 static struct l_dbus_message *station_dbus_signal_agent_register(
 						struct l_dbus *dbus,
 						struct l_dbus_message *message,
@@ -3758,10 +3768,8 @@ static struct l_dbus_message *station_dbus_signal_agent_register(
 
 	l_debug("agent %s path %s", sender, path);
 
-	/*
-	 * TODO: send an initial notification in a oneshot idle callback,
-	 * if state is connected.
-	 */
+	if (station->connected_network)
+		l_idle_oneshot(signal_agent_notify_initial, station, NULL);
 
 	return l_dbus_message_new_method_return(message);
 }
-- 
2.36.0

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

end of thread, other threads:[~2022-05-20 22:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20 20:11 [PATCH 1/2] Initial signal level notification Denis Kenzior
  -- strict thread matches above, loose matches on Subject: below --
2022-05-20 22:00 Denis Kenzior
2022-05-20 21:53 Jesse Lentz
2022-05-20 20:50 Jesse Lentz
2022-05-20 18:59 Jesse Lentz

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.