From 569ffdd50881b9da66e8f7bfe1baa873ad3cadca Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Tue, 26 Feb 2019 09:51:31 -0800 Subject: [PATCH] client: Add 'show' command to device in station mode --- client/station.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/client/station.c b/client/station.c index 6b1ff190..585e50ea 100644 --- a/client/station.c +++ b/client/station.c @@ -136,6 +136,23 @@ static void check_errors_method_callback(struct l_dbus_message *message, dbus_message_has_error(message); } +static void display_station(const char *device_name, + const struct proxy_interface *proxy) +{ + const struct station *station = proxy_interface_get_data(proxy); + char *caption = l_strdup_printf("%s: %s", "Station", device_name); + + proxy_properties_display(proxy, caption, MARGIN, 20, 47); + l_free(caption); + + if (station->connected_network) + display("%s%*s %-*s%-*s\n", MARGIN, 8, "", 20, + "Connected network", 47, + network_get_name(station->connected_network)); + + display_table_footer(); +} + static void display_station_inline(const char *margin, const void *data) { const struct proxy_interface *station_i = data; @@ -578,6 +595,22 @@ static enum cmd_status cmd_scan(const char *device_name, return CMD_STATUS_TRIGGERED; } +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); + + if (!station) { + display("No station on device: '%s'\n", device_name); + return CMD_STATUS_INVALID_VALUE; + } + + display_station(device_name, station); + + return CMD_STATUS_DONE; +} + static const struct command station_commands[] = { { NULL, "list", NULL, cmd_list, "List devices in Station mode", true }, { "", "connect", @@ -601,6 +634,7 @@ static const struct command station_commands[] = { cmd_get_hidden_access_points, "Get hidden APs", true }, { "", "scan", NULL, cmd_scan, "Scan for networks" }, + { "", "show", NULL, cmd_show, "Show station info", true }, { } };