network: Add SignalStrength/Frequency properties to BSS interface
PATCH 1/5 network: Add SignalStrength/Frequency properties to BSS interface
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(+)
src/network.c +29 -0
@@ -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 )
Signature · 1 line
2.34.1
PATCH 2/5 station: update SignalStrength/Frequency for BSS interface
When the BSS's signal or frequency changes, update those properties
--- src/station.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
src/station.c +13 -2
@@ -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;
Signature · 1 line
2.34.1
Re: [PATCH 2/5] station: update SignalStrength/Frequency for BSS interface
Hi James,
Quoted 18 lines · James Prestwood
When the BSS's signal or frequency changes, update those properties
--- src/station.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)src/station.c +2
-2@@ -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);
src/station.c static bool station_register_bss(struct network *network, struct scan_bss *bss) · line 560
Quoted 10 lines
src/station.c +9
-0+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.
src/station.c static bool station_register_bss(struct network *network, struct scan_bss *bss) · line 565
Quoted 5 lines
src/station.c +2
-0+ } +if (!l_dbus_object_add_interface (dbus_get_bus (), path,IWD_BSS_INTERFACE , bss))return false;
Regards,
-Denis
Re: [PATCH 2/5] station: update SignalStrength/Frequency for BSS interface
Quoted 25 lines · Denis Kenzior
Hi James,
Quoted 22 lines · James Prestwood
When the BSS's signal or frequency changes, update those properties
---
src/station.c| 15 +++++++++++++--1 file changed, 13 insertions(+), 2 deletions(-)src/station.c +4
-2@@ -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");
Quoted 8 lines
src/station.c static bool station_register_bss(struct network *network, struct scan_bss *bss) · line 560
Quoted 6 lines
src/station.c +6
-0+ + 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.
Quoted 9 lines
Quoted 6 lines
src/station.c +2
-0+ } + if (!l_dbus_object_add_interface(dbus_get_bus(), path, IWD_BSS_INTERFACE, bss))return false;
Regards,
-Denis
PATCH 3/5 client: add SignalStrength/Frequency properties
In reply to James Prestwood--- client/bss.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-)
client/bss.c +47 -1
@@ -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 }, { } };
Signature · 1 line
2.34.1
Re: [PATCH 3/5] client: add SignalStrength/Frequency properties
Hi James,
client/bss.c line 35
Quoted 13 lines · James Prestwood
--- client/bss.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-)client/bss.c +1
-0@@ -32,6 +32,8 @@struct bss {char *address; +int16_t signal;
signal_strength? or rssi?
client/bss.c static void update_address(void *data, struct l_dbus_message_iter *variant) · line 62
Quoted 9 lines
client/bss.c +2
-0+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?
Quoted 8 lines
client/bss.c +8
-0+{ +const struct bss *bss = data; +static char signal_str[7 ]; + +sprintf (signal_str,"%d" , bss->signal); + +return signal_str; +}
client/bss.c static void update_address(void *data, struct l_dbus_message_iter *variant) · line 80
Quoted 10 lines
client/bss.c +10
-0+ +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
client/bss.c static void update_address(void *data, struct l_dbus_message_iter *variant) · line 86
Quoted 6 lines
client/bss.c +6
-0+} + +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.
Quoted 15 lines
client/bss.c +15
-0+ +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;
client/bss.c static void update_address(void *data, struct l_dbus_message_iter *variant) · line 110
Quoted 10 lines
client/bss.c +5
-1+} +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
PATCH 4/5 client: fix get-bss command spacing/footer
In reply to James PrestwoodWith 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(-)
client/station.c +3 -1
@@ -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 ; }
Signature · 1 line
2.34.1
PATCH 5/5 doc: add new properties to BSS interface
In reply to James PrestwoodThis adds SignalStrength and Frequency properties
--- doc/basic-service-set.txt | 8 ++++++++ 1 file changed, 8 insertions(+)
doc/basic-service-set.txt +8 -0
@@ -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)
Signature · 1 line
2.34.1
Hi James,
Quoted 12 lines · 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(+)src/network.c +0
-0
src/network.c static bool network_bss_property_get_address(struct l_dbus *dbus, · line 2197
Quoted 4 lines
src/network.c +1
-0@@ -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?
src/network.c static bool network_bss_property_get_address(struct l_dbus *dbus, · line 2210
Quoted 13 lines
src/network.c +13
-0+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
Quoted 12 lines
src/network.c +11
-0+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)
src/network.c static bool network_bss_property_get_address(struct l_dbus *dbus, · line 2232
Quoted 10 lines
src/network.c +4
-0{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