Initial signal level notification
Jesse Lentz
PATCH 1/2 Initial signal level notification
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(-)
src/netdev.c +5 -0
@@ -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)
src/netdev.h +1 -0
@@ -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);
src/station.c +12 -4
@@ -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); }
Signature · 1 line
2.36.0
Jesse Lentz
PATCH 2/2 Document initial signal level notification
Document the initial "Changed" method call following SignalLevelAgent registration.
--- doc/station-api.txt | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
doc/station-api.txt +14 -13
@@ -182,16 +182,17 @@ Methods void Release(object device) [noreply] void Changed(object device, uint8 level) [noreply] This method gets called when the signal strength - measurement for the device's connected network - changes enough to go from one level to another out - of the N ranges defined by the array of (N-1) - threshold values passed to RegisterSignalLevelAgent(). - The level parameter is in the range from 0 to N, - 0 being the strongest signal or above the first - threshold value in the array, and N being the - weakest and below the last threshold value. For - example if RegisterSignalLevelAgent was called with - the array [-40, -50, -60], the 'level' parameter of - 0 would mean signal is received at -40 or more dBm - and 3 would mean below -60 dBm and might correspond - to 1 out of 4 bars on a UI signal meter. + measurement for the device's connected network changes + enough to go from one level to another out of the N + ranges defined by the array of (N-1) threshold values + passed to RegisterSignalLevelAgent(). It also gets + called immediately after the signal level agent is + registered. The level parameter is in the range from 0 + to N, 0 being the strongest signal or above the first + threshold value in the array, and N being the weakest + and below the last threshold value. For example if + RegisterSignalLevelAgent was called with the array [-40, + -50, -60], the 'level' parameter of 0 would mean signal + is received at -40 or more dBm and 3 would mean below + -60 dBm and might correspond to 1 out of 4 bars on a UI + signal meter.
Signature · 1 line
2.36.0
Denis Kenzior
Re: [PATCH 2/2] Document initial signal level notification
Hi Jesse,
Quoted 27 lines · Jesse Lentz
Document the initial "Changed" method call following SignalLevelAgent registration.
--- doc/station-api.txt | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)doc/station-api.txt +0
-13@@ -182,16 +182,17 @@ Methods void Release(object device) [noreply] void Changed(object device, uint8 level) [noreply] This method gets called when the signal strength - measurement for the device's connected network - changes enough to go from one level to another out - of the N ranges defined by the array of (N-1) - threshold values passed to RegisterSignalLevelAgent(). - The level parameter is in the range from 0 to N, - 0 being the strongest signal or above the first - threshold value in the array, and N being the - weakest and below the last threshold value. For - example if RegisterSignalLevelAgent was called with - the array [-40, -50, -60], the 'level' parameter of - 0 would mean signal is received at -40 or more dBm - and 3 would mean below -60 dBm and might correspond - to 1 out of 4 bars on a UI signal meter.
doc/station-api.txt Methods void Release(object device) [noreply] · line 194
Quoted 10 lines
doc/station-api.txt +10
-0+ measurement for the device's connected network changes + enough to go from one level to another out of the N + ranges defined by the array of (N-1) threshold values + passed to RegisterSignalLevelAgent(). It also gets + called immediately after the signal level agent is + registered. The level parameter is in the range from 0 + to N, 0 being the strongest signal or above the first + threshold value in the array, and N being the weakest + and below the last threshold value. For example if + RegisterSignalLevelAgent was called with the array [-40,
I think this line might be over 80 chars.
doc/station-api.txt Methods void Release(object device) [noreply] · line 198
Quoted 5 lines
doc/station-api.txt +4
-0+ -50, -60], the 'level' parameter of 0 would mean signal + is received at -40 or more dBm and 3 would mean below + -60 dBm and might correspond to 1 out of 4 bars on a UI + signal meter.
Otherwise looks good!
Regards,
-Denis
Jesse Lentz
Re: [PATCH 2/2] Document initial signal level notification
Hi Denis,
The comma is in column 80 according to Vim's ruler. Do you recommend reflowing it with a smaller tw value?
Sincerely,
Jesse
Denis Kenzior
Re: [PATCH 2/2] Document initial signal level notification
Hi Jesse,
Quoted 5 lines · Jesse Lentz
Hi Denis,
The comma is in column 80 according to Vim's ruler. Do you recommend reflowing it with a smaller tw value?
Ah you're right. No changes are required.
Regards,
-Denis
Denis Kenzior
Hi Jesse,
Quoted 8 lines · Jesse Lentz
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>
Quoted 4 lines
src/station.c +0
-0
<snip>
src/station.c static struct l_dbus_message *station_dbus_signal_agent_register( · line 3774
Quoted 12 lines
src/station.c +2
-4@@ -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.
src/station.c static struct l_dbus_message *station_dbus_signal_agent_register( · line 3775
Quoted 2 lines
src/station.c +0
-0}
Regards,
-Denis
Jesse Lentz
Hi Denis,
Thanks for the feedback; I'll submit a revised patch.
Sincerely,
Jesse