Skip to content

Commit 2af3400

Browse files
kapbhrlubos
authored andcommitted
[nrf fromlist] net: wifi: Add reset command for Wi-Fi statistics
Upstream PR: zephyrproject-rtos/zephyr#75768 Add "reset" as a subcommand of wifi statistics. Also add help option in statistics command. Signed-off-by: Kapil Bhatt <[email protected]>
1 parent 40ff936 commit 2af3400

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -886,10 +886,30 @@ static int cmd_wifi_stats(const struct shell *sh, size_t argc, char *argv[])
886886
struct net_stats_wifi stats = { 0 };
887887
int ret;
888888

889-
ret = net_mgmt(NET_REQUEST_STATS_GET_WIFI, iface,
890-
&stats, sizeof(stats));
891-
if (!ret) {
892-
print_wifi_stats(iface, &stats, sh);
889+
context.sh = sh;
890+
891+
if (argc == 1) {
892+
ret = net_mgmt(NET_REQUEST_STATS_GET_WIFI, iface,
893+
&stats, sizeof(stats));
894+
if (!ret) {
895+
print_wifi_stats(iface, &stats, sh);
896+
}
897+
}
898+
899+
if (argc > 1) {
900+
if (!strncasecmp(argv[1], "reset", 5)) {
901+
ret = net_mgmt(NET_REQUEST_STATS_RESET_WIFI, iface,
902+
&stats, sizeof(stats));
903+
if (!ret) {
904+
PR("Wi-Fi interface statistics have been reset.\n");
905+
}
906+
} else if (!strncasecmp(argv[1], "help", 4)) {
907+
shell_help(sh);
908+
} else {
909+
PR_WARNING("Invalid argument\n");
910+
shell_help(sh);
911+
return -ENOEXEC;
912+
}
893913
}
894914
#else
895915
ARG_UNUSED(argc);
@@ -2041,7 +2061,11 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands,
20412061
"[-h, --help] : Print out the help for the scan command.\n",
20422062
cmd_wifi_scan,
20432063
1, 8),
2044-
SHELL_CMD_ARG(statistics, NULL, "Wi-Fi interface statistics.\n", cmd_wifi_stats, 1, 0),
2064+
SHELL_CMD_ARG(statistics, NULL, "Wi-Fi interface statistics.\n"
2065+
"[reset] : Reset Wi-Fi interface statistics\n"
2066+
"[help] : Print out the help for the statistics command.",
2067+
cmd_wifi_stats,
2068+
1, 1),
20452069
SHELL_CMD_ARG(status, NULL, "Status of the Wi-Fi interface.\n", cmd_wifi_status, 1, 0),
20462070
SHELL_CMD(twt, &wifi_twt_ops, "Manage TWT flows.\n", NULL),
20472071
SHELL_CMD_ARG(reg_domain, NULL,

0 commit comments

Comments
 (0)