Skip to content

Commit 5aa9c40

Browse files
ArunmaniAlagarsamy2710rlubos
authored andcommitted
[nrf fromtree] net: l2: wifi: Fix mode change issue in Wi-Fi shell
The help message for the wifi mode -s command indicates it sets the Wi-Fi mode to station. However, the Zephyr Wi-Fi shell subsystem was incorrectly using a get operation instead of set. This commit corrects the behavior to properly set the Wi-Fi mode, aligning the implementation with the help message. Signed-off-by: Arunmani Alagarsamy <[email protected]> (cherry picked from commit 0faba15)
1 parent 9a65131 commit 5aa9c40

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2865,11 +2865,11 @@ void parse_mode_args_to_params(const struct shell *sh, int argc,
28652865
{"monitor", no_argument, 0, 'm'},
28662866
{"ap", no_argument, 0, 'a'},
28672867
{"softap", no_argument, 0, 'k'},
2868-
{"get", no_argument, 0, 'g'},
28692868
{"help", no_argument, 0, 'h'},
28702869
{0, 0, 0, 0}};
28712870

2872-
while ((opt = getopt_long(argc, argv, "i:smtpakgh",
2871+
mode->oper = WIFI_MGMT_GET;
2872+
while ((opt = getopt_long(argc, argv, "i:smtpakh",
28732873
long_options, &opt_index)) != -1) {
28742874
state = getopt_state_get();
28752875
switch (opt) {
@@ -2889,10 +2889,6 @@ void parse_mode_args_to_params(const struct shell *sh, int argc,
28892889
mode->mode |= WIFI_SOFTAP_MODE;
28902890
opt_num++;
28912891
break;
2892-
case 'g':
2893-
mode->oper = WIFI_MGMT_GET;
2894-
opt_num++;
2895-
break;
28962892
case 'i':
28972893
mode->if_index = (uint8_t)atoi(state->optarg);
28982894
/* Don't count iface as it's common for both get and set */
@@ -2908,7 +2904,7 @@ void parse_mode_args_to_params(const struct shell *sh, int argc,
29082904
}
29092905
}
29102906

2911-
if (opt_num == 0) {
2907+
if (opt_num != 0) {
29122908
mode->oper = WIFI_MGMT_SET;
29132909
}
29142910
}
@@ -4064,9 +4060,8 @@ SHELL_SUBCMD_ADD((wifi), mode, NULL,
40644060
"[-a, --ap] : AP mode\n"
40654061
"[-k, --softap] : Softap mode\n"
40664062
"[-h, --help] : Help\n"
4067-
"[-g, --get] : Get current mode for a specific interface index\n"
40684063
"Usage: Get operation example for interface index 1\n"
4069-
"wifi mode -g -i1\n"
4064+
"wifi mode -i1\n"
40704065
"Set operation example for interface index 1 - set station+promiscuous\n"
40714066
"wifi mode -i1 -sp.\n",
40724067
cmd_wifi_mode,

0 commit comments

Comments
 (0)