From 189a96e91aa0fd65926e434d98defac08641adce Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 14 Sep 2018 21:20:03 -0500 Subject: [PATCH] client: Move Device.Scan method to Station --- client/device.c | 16 ---------------- client/station.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/client/device.c b/client/device.c index 0bf528d9..193b1530 100644 --- a/client/device.c +++ b/client/device.c @@ -518,21 +518,6 @@ static void check_errors_method_callback(struct l_dbus_message *message, dbus_message_has_error(message); } -static enum cmd_status cmd_scan(const char *device_name, - char **argv, int argc) -{ - const struct proxy_interface *proxy = - device_proxy_find_by_name(device_name); - - if (!proxy) - return CMD_STATUS_INVALID_ARGS; - - proxy_interface_method_call(proxy, "Scan", "", - check_errors_method_callback); - - return CMD_STATUS_TRIGGERED; -} - static enum cmd_status cmd_get_networks(const char *device_name, char **argv, int argc) { @@ -688,7 +673,6 @@ static char *set_property_cmd_arg_completion(const char *text, int state) static const struct command device_commands[] = { { NULL, "list", NULL, cmd_list, "List devices", true }, { "", "show", NULL, cmd_show, "Show device info", true }, - { "", "scan", NULL, cmd_scan, "Scan for networks" }, { "", "get-networks", "[rssi-dbms/rssi-bars]", cmd_get_networks, diff --git a/client/station.c b/client/station.c index a35050b6..e6a719b8 100644 --- a/client/station.c +++ b/client/station.c @@ -202,10 +202,28 @@ static enum cmd_status cmd_disconnect(const char *device_name, return CMD_STATUS_TRIGGERED; } +static enum cmd_status cmd_scan(const char *device_name, + char **argv, int argc) +{ + const struct proxy_interface *station_i = + device_proxy_find(device_name, IWD_STATION_INTERFACE); + + if (!station_i) { + display("No station on device: '%s'\n", device_name); + return CMD_STATUS_INVALID_VALUE; + } + + proxy_interface_method_call(station_i, "Scan", "", + check_errors_method_callback); + + return CMD_STATUS_TRIGGERED; +} + static const struct command station_commands[] = { { NULL, "list", NULL, cmd_list, "List Ad-Hoc devices", true }, { "", "disconnect", NULL, cmd_disconnect, "Disconnect" }, + { "", "scan", NULL, cmd_scan, "Scan for networks" }, { } };