All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] client: add diagnostic interface definition
@ 2021-01-19 17:14 James Prestwood
  2021-01-19 17:14 ` [PATCH 2/2] client: add station diagnostic information to 'show' James Prestwood
  2021-01-19 19:12 ` [PATCH 1/2] client: add diagnostic interface definition Denis Kenzior
  0 siblings, 2 replies; 5+ messages in thread
From: James Prestwood @ 2021-01-19 17:14 UTC (permalink / raw)
  To: iwd

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

---
 client/dbus-proxy.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/client/dbus-proxy.h b/client/dbus-proxy.h
index a3304848..9c5c57e5 100644
--- a/client/dbus-proxy.h
+++ b/client/dbus-proxy.h
@@ -24,15 +24,16 @@
 
 struct proxy_interface;
 
-#define IWD_ADAPTER_INTERFACE          "net.connman.iwd.Adapter"
-#define IWD_ACCESS_POINT_INTERFACE     "net.connman.iwd.AccessPoint"
-#define IWD_AD_HOC_INTERFACE           "net.connman.iwd.AdHoc"
-#define IWD_AGENT_MANAGER_INTERFACE    "net.connman.iwd.AgentManager"
-#define IWD_DEVICE_INTERFACE           "net.connman.iwd.Device"
-#define IWD_KNOWN_NETWORK_INTREFACE    "net.connman.iwd.KnownNetwork"
-#define IWD_NETWORK_INTERFACE          "net.connman.iwd.Network"
-#define IWD_WSC_INTERFACE              "net.connman.iwd.SimpleConfiguration"
-#define IWD_STATION_INTERFACE          "net.connman.iwd.Station"
+#define IWD_ADAPTER_INTERFACE            "net.connman.iwd.Adapter"
+#define IWD_ACCESS_POINT_INTERFACE       "net.connman.iwd.AccessPoint"
+#define IWD_AD_HOC_INTERFACE             "net.connman.iwd.AdHoc"
+#define IWD_AGENT_MANAGER_INTERFACE      "net.connman.iwd.AgentManager"
+#define IWD_DEVICE_INTERFACE             "net.connman.iwd.Device"
+#define IWD_KNOWN_NETWORK_INTREFACE      "net.connman.iwd.KnownNetwork"
+#define IWD_NETWORK_INTERFACE            "net.connman.iwd.Network"
+#define IWD_WSC_INTERFACE                "net.connman.iwd.SimpleConfiguration"
+#define IWD_STATION_INTERFACE            "net.connman.iwd.Station"
+#define IWD_STATION_DIAGNOSTIC_INTERFACE "net.connman.iwd.StationDiagnostic"
 
 typedef bool (*proxy_property_match_func_t) (const void *a, const void *b);
 
-- 
2.26.2

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

* [PATCH 2/2] client: add station diagnostic information to 'show'
  2021-01-19 17:14 [PATCH 1/2] client: add diagnostic interface definition James Prestwood
@ 2021-01-19 17:14 ` James Prestwood
  2021-01-19 19:12 ` [PATCH 1/2] client: add diagnostic interface definition Denis Kenzior
  1 sibling, 0 replies; 5+ messages in thread
From: James Prestwood @ 2021-01-19 17:14 UTC (permalink / raw)
  To: iwd

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

The information requested with GetDiagnostics will now appear in
the "station <iface> show" command. If IWD is not connected, or
there is no diagnostic interface (older IWD version) 'show' will
behave as it always has, only showing scanning/connected.
---
 client/station.c | 106 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 102 insertions(+), 4 deletions(-)

diff --git a/client/station.c b/client/station.c
index b6b59239..93b1a4da 100644
--- a/client/station.c
+++ b/client/station.c
@@ -130,6 +130,10 @@ static struct proxy_interface_type station_interface_type = {
 	.ops = &station_ops,
 };
 
+static struct proxy_interface_type station_diagnostic_interface = {
+	.interface = IWD_STATION_DIAGNOSTIC_INTERFACE,
+};
+
 static void check_errors_method_callback(struct l_dbus_message *message,
 								void *user_data)
 {
@@ -137,7 +141,8 @@ static void check_errors_method_callback(struct l_dbus_message *message,
 }
 
 static void display_station(const char *device_name,
-					const struct proxy_interface *proxy)
+					const struct proxy_interface *proxy,
+					bool *connected)
 {
 	const struct station *station = proxy_interface_get_data(proxy);
 	char *caption = l_strdup_printf("%s: %s", "Station", device_name);
@@ -145,10 +150,15 @@ static void display_station(const char *device_name,
 	proxy_properties_display(proxy, caption, MARGIN, 20, 47);
 	l_free(caption);
 
-	if (station->connected_network)
+	if (station->connected_network) {
 		display("%s%*s  %-*s%-*s\n", MARGIN, 8, "", 20,
 				"Connected network", 47,
 				network_get_name(station->connected_network));
+		*connected = true;
+		return;
+	}
+
+	*connected = false;
 
 	display_table_footer();
 }
@@ -583,20 +593,106 @@ static enum cmd_status cmd_scan(const char *device_name,
 	return CMD_STATUS_TRIGGERED;
 }
 
+static void get_diagnostics_callback(struct l_dbus_message *message,
+					void *user_data)
+{
+	struct l_dbus_message_iter iter;
+	struct l_dbus_message_iter variant;
+	const char *key;
+
+	if (dbus_message_has_error(message))
+		return;
+
+	if (!l_dbus_message_get_arguments(message, "a{sv}", &iter)) {
+		l_error("Failed to parse GetDiagnostics message");
+		goto done;
+	}
+
+	while (l_dbus_message_iter_next_entry(&iter, &key, &variant)) {
+		const char *s_value;
+		uint32_t u_value;
+		int16_t i_value;
+		uint8_t y_value;
+
+		if (!strcmp(key, "ConnectedBss") || !strcmp(key, "RxMode") ||
+				!strcmp(key, "TxMode")) {
+			/* String variants with no special handling */
+
+			l_dbus_message_iter_get_variant(&variant, "s",
+							&s_value);
+
+			display("%s%*s  %-*s%-*s\n", MARGIN, 8, "", 20,
+				key, 47, s_value);
+		} else if (!strcmp(key, "RxBitrate") ||
+				!strcmp(key, "TxBitrate")) {
+			/* Bitrates expressed in 100Kbit/s */
+
+			l_dbus_message_iter_get_variant(&variant, "u",
+							&u_value);
+			display("%s%*s  %-*s%u Kbit/s\n", MARGIN, 8, "", 20,
+				key, u_value * 100);
+		} else if (!strcmp(key, "ExpectedThroughput")) {
+			/* ExpectedThroughput expressed in Kbit/s */
+
+			l_dbus_message_iter_get_variant(&variant, "u",
+							&u_value);
+			display("%s%*s  %-*s%u Kbit/s\n", MARGIN, 8, "", 20,
+				key, u_value);
+		} else if (!strcmp(key, "RSSI")) {
+			/* RSSI expressed in dBm */
+
+			l_dbus_message_iter_get_variant(&variant, "n",
+							&i_value);
+			display("%s%*s  %-*s%i dBm\n", MARGIN, 8, "", 20,
+				key, i_value);
+		} else if (!strcmp(key, "RxMCS") || !strcmp(key, "TxMCS")) {
+			/* MCS index's are single byte integers */
+
+			l_dbus_message_iter_get_variant(&variant, "y",
+							&y_value);
+			display("%s%*s  %-*s%u\n", MARGIN, 8, "", 20,
+				key, y_value);
+		}
+	}
+
+done:
+	/* Finish the table started by cmd_show */
+	display_table_footer();
+	display_refresh_reset();
+}
+
 static enum cmd_status cmd_show(const char *device_name,
 						char **argv, int argc)
 {
 	const struct proxy_interface *station =
 			device_proxy_find(device_name, IWD_STATION_INTERFACE);
+	const struct proxy_interface *diagnostic =
+					device_proxy_find(device_name,
+					IWD_STATION_DIAGNOSTIC_INTERFACE);
+	bool connected;
 
 	if (!station) {
 		display("No station on device: '%s'\n", device_name);
 		return CMD_STATUS_INVALID_VALUE;
 	}
 
-	display_station(device_name, station);
+	display_station(device_name, station, &connected);
 
-	return CMD_STATUS_DONE;
+	/*
+	 * No need to query additional diagnostic information if not connected,
+	 * or IWD has no diagnostic interface.
+	 */
+	if (!connected || !diagnostic) {
+		display_table_footer();
+		display_refresh_reset();
+		return CMD_STATUS_DONE;
+	}
+
+	proxy_interface_method_call(diagnostic, "GetDiagnostics", "",
+					get_diagnostics_callback);
+
+	/* Don't display table footer, this will be done in the callback */
+	return CMD_STATUS_TRIGGERED;
 }
 
 static const struct command station_commands[] = {
@@ -663,6 +759,7 @@ COMMAND_FAMILY(station_command_family, station_command_family_init,
 static int station_interface_init(void)
 {
 	proxy_interface_type_register(&station_interface_type);
+	proxy_interface_type_register(&station_diagnostic_interface);
 
 	return 0;
 }
@@ -670,6 +767,7 @@ static int station_interface_init(void)
 static void station_interface_exit(void)
 {
 	proxy_interface_type_unregister(&station_interface_type);
+	proxy_interface_type_unregister(&station_diagnostic_interface);
 }
 
 INTERFACE_TYPE(station_interface_type,
-- 
2.26.2

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

* Re: [PATCH 1/2] client: add diagnostic interface definition
  2021-01-19 17:14 [PATCH 1/2] client: add diagnostic interface definition James Prestwood
  2021-01-19 17:14 ` [PATCH 2/2] client: add station diagnostic information to 'show' James Prestwood
@ 2021-01-19 19:12 ` Denis Kenzior
  1 sibling, 0 replies; 5+ messages in thread
From: Denis Kenzior @ 2021-01-19 19:12 UTC (permalink / raw)
  To: iwd

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

Hi James,

On 1/19/21 11:14 AM, James Prestwood wrote:
> ---
>   client/dbus-proxy.h | 19 ++++++++++---------
>   1 file changed, 10 insertions(+), 9 deletions(-)
> 

Both applied, thanks.

Regards,
-Denis

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

* Re: [PATCH 1/2] client: add diagnostic interface definition
  2021-01-19 17:13 James Prestwood
@ 2021-01-19 17:34 ` James Prestwood
  0 siblings, 0 replies; 5+ messages in thread
From: James Prestwood @ 2021-01-19 17:34 UTC (permalink / raw)
  To: iwd

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

Please disregard. Had some issues sending this out and apparently it
got sent twice.

On Tue, 2021-01-19 at 09:13 -0800, James Prestwood wrote:
> ---
>  client/dbus-proxy.h | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/client/dbus-proxy.h b/client/dbus-proxy.h
> index a3304848..9c5c57e5 100644
> --- a/client/dbus-proxy.h
> +++ b/client/dbus-proxy.h
> @@ -24,15 +24,16 @@
>  
>  struct proxy_interface;
>  
> -#define IWD_ADAPTER_INTERFACE          "net.connman.iwd.Adapter"
> -#define IWD_ACCESS_POINT_INTERFACE     "net.connman.iwd.AccessPoint"
> -#define IWD_AD_HOC_INTERFACE           "net.connman.iwd.AdHoc"
> -#define
> IWD_AGENT_MANAGER_INTERFACE    "net.connman.iwd.AgentManager"
> -#define IWD_DEVICE_INTERFACE           "net.connman.iwd.Device"
> -#define
> IWD_KNOWN_NETWORK_INTREFACE    "net.connman.iwd.KnownNetwork"
> -#define IWD_NETWORK_INTERFACE          "net.connman.iwd.Network"
> -#define
> IWD_WSC_INTERFACE              "net.connman.iwd.SimpleConfiguration"
> -#define IWD_STATION_INTERFACE          "net.connman.iwd.Station"
> +#define IWD_ADAPTER_INTERFACE            "net.connman.iwd.Adapter"
> +#define
> IWD_ACCESS_POINT_INTERFACE       "net.connman.iwd.AccessPoint"
> +#define IWD_AD_HOC_INTERFACE             "net.connman.iwd.AdHoc"
> +#define
> IWD_AGENT_MANAGER_INTERFACE      "net.connman.iwd.AgentManager"
> +#define IWD_DEVICE_INTERFACE             "net.connman.iwd.Device"
> +#define
> IWD_KNOWN_NETWORK_INTREFACE      "net.connman.iwd.KnownNetwork"
> +#define IWD_NETWORK_INTERFACE            "net.connman.iwd.Network"
> +#define
> IWD_WSC_INTERFACE                "net.connman.iwd.SimpleConfiguration
> "
> +#define IWD_STATION_INTERFACE            "net.connman.iwd.Station"
> +#define IWD_STATION_DIAGNOSTIC_INTERFACE
> "net.connman.iwd.StationDiagnostic"
>  
>  typedef bool (*proxy_property_match_func_t) (const void *a, const
> void *b);
>  

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

* [PATCH 1/2] client: add diagnostic interface definition
@ 2021-01-19 17:13 James Prestwood
  2021-01-19 17:34 ` James Prestwood
  0 siblings, 1 reply; 5+ messages in thread
From: James Prestwood @ 2021-01-19 17:13 UTC (permalink / raw)
  To: iwd

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

---
 client/dbus-proxy.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/client/dbus-proxy.h b/client/dbus-proxy.h
index a3304848..9c5c57e5 100644
--- a/client/dbus-proxy.h
+++ b/client/dbus-proxy.h
@@ -24,15 +24,16 @@
 
 struct proxy_interface;
 
-#define IWD_ADAPTER_INTERFACE          "net.connman.iwd.Adapter"
-#define IWD_ACCESS_POINT_INTERFACE     "net.connman.iwd.AccessPoint"
-#define IWD_AD_HOC_INTERFACE           "net.connman.iwd.AdHoc"
-#define IWD_AGENT_MANAGER_INTERFACE    "net.connman.iwd.AgentManager"
-#define IWD_DEVICE_INTERFACE           "net.connman.iwd.Device"
-#define IWD_KNOWN_NETWORK_INTREFACE    "net.connman.iwd.KnownNetwork"
-#define IWD_NETWORK_INTERFACE          "net.connman.iwd.Network"
-#define IWD_WSC_INTERFACE              "net.connman.iwd.SimpleConfiguration"
-#define IWD_STATION_INTERFACE          "net.connman.iwd.Station"
+#define IWD_ADAPTER_INTERFACE            "net.connman.iwd.Adapter"
+#define IWD_ACCESS_POINT_INTERFACE       "net.connman.iwd.AccessPoint"
+#define IWD_AD_HOC_INTERFACE             "net.connman.iwd.AdHoc"
+#define IWD_AGENT_MANAGER_INTERFACE      "net.connman.iwd.AgentManager"
+#define IWD_DEVICE_INTERFACE             "net.connman.iwd.Device"
+#define IWD_KNOWN_NETWORK_INTREFACE      "net.connman.iwd.KnownNetwork"
+#define IWD_NETWORK_INTERFACE            "net.connman.iwd.Network"
+#define IWD_WSC_INTERFACE                "net.connman.iwd.SimpleConfiguration"
+#define IWD_STATION_INTERFACE            "net.connman.iwd.Station"
+#define IWD_STATION_DIAGNOSTIC_INTERFACE "net.connman.iwd.StationDiagnostic"
 
 typedef bool (*proxy_property_match_func_t) (const void *a, const void *b);
 
-- 
2.26.2

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

end of thread, other threads:[~2021-01-19 19:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19 17:14 [PATCH 1/2] client: add diagnostic interface definition James Prestwood
2021-01-19 17:14 ` [PATCH 2/2] client: add station diagnostic information to 'show' James Prestwood
2021-01-19 19:12 ` [PATCH 1/2] client: add diagnostic interface definition Denis Kenzior
  -- strict thread matches above, loose matches on Subject: below --
2021-01-19 17:13 James Prestwood
2021-01-19 17:34 ` James Prestwood

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.