Skip to content

Commit

Permalink
[nrf fromlist] wifi: shell: ap: Add a command to disconnect a station
Browse files Browse the repository at this point in the history
The shell commands can be used to disconnect a connected station in AP
mode.

Upstream PR: zephyrproject-rtos/zephyr#68007

Signed-off-by: Chaitanya Tata <[email protected]>
  • Loading branch information
krish2718 authored and nordicjm committed Jan 25, 2024
1 parent beb27ee commit 7265d08
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions subsys/net/l2/wifi/wifi_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,34 @@ static int cmd_wifi_ap_stations(const struct shell *sh, size_t argc,
return 0;
}

static int cmd_wifi_ap_sta_disconnect(const struct shell *sh, size_t argc,
char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
uint8_t mac[6];
int ret;

if (argc != 2) {
shell_fprintf(sh, SHELL_WARNING, "Invalid number of arguments\n");
shell_help(sh);
return -ENOEXEC;
}

if (net_bytes_from_str(mac, sizeof(mac), argv[1]) < 0) {
shell_fprintf(sh, SHELL_WARNING, "Invalid MAC address\n");
return -ENOEXEC;
}

ret = net_mgmt(NET_REQUEST_WIFI_AP_STA_DISCONNECT, iface, mac, sizeof(mac));
if (ret) {
shell_fprintf(sh, SHELL_WARNING, "AP station disconnect failed: %s\n",
strerror(-ret));
return -ENOEXEC;
}

shell_fprintf(sh, SHELL_NORMAL, "AP station disconnect requested\n");
return 0;
}

static int cmd_wifi_reg_domain(const struct shell *sh, size_t argc,
char *argv[])
Expand Down Expand Up @@ -1849,6 +1877,11 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_cmd_ap,
"List stations connected to the AP",
cmd_wifi_ap_stations,
1, 0),
SHELL_CMD_ARG(disconnect, NULL,
"Disconnect a station from the AP\n"
"<MAC address of the station>\n",
cmd_wifi_ap_sta_disconnect,
2, 0),
SHELL_SUBCMD_SET_END
);

Expand Down

0 comments on commit 7265d08

Please sign in to comment.