Skip to content

Commit 7ed70d1

Browse files
raintamercvinayak
authored andcommitted
[nrf fromtree] net: wifi: shell: update wifi ap enable to use get opt parsing
The commit 8256d02 introduced getopt parsing for the wifi connect command This needs to be updated for the wifi ap enable since ap enable also uses the same parsing as connect. The use of getopt removes the parameter ordering restrictions Signed-off-by: Brad Kemp <[email protected]> (cherry picked from commit 3e2c067)
1 parent b3f32d2 commit 7ed70d1

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,8 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
496496
}
497497
break;
498498
case 'p':
499-
if (secure_connection) {
500-
params->psk = optarg;
501-
params->psk_length = strlen(params->psk);
502-
} else {
503-
PR_WARNING("Passphrase provided without security configuration\n");
504-
}
499+
params->psk = optarg;
500+
params->psk_length = strlen(params->psk);
505501
break;
506502
case 'c':
507503
long channel = strtol(optarg, &endptr, 10);
@@ -568,15 +564,17 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
568564
&params->bssid[4], &params->bssid[5]);
569565
break;
570566
case 'h':
571-
shell_help(sh);
567+
return -ENOEXEC;
572568
break;
573569
default:
574570
PR_ERROR("Invalid option %c\n", opt);
575571
shell_help(sh);
576572
return -EINVAL;
577573
}
578574
}
579-
575+
if (params->psk && !secure_connection) {
576+
PR_WARNING("Passphrase provided without security configuration\n");
577+
}
580578
return 0;
581579
}
582580

@@ -1242,7 +1240,7 @@ static int cmd_wifi_ap_enable(const struct shell *sh, size_t argc,
12421240
int ret;
12431241

12441242
context.sh = sh;
1245-
if (__wifi_args_to_params(sh, argc - 1, &argv[1], &cnx_params, WIFI_MODE_AP)) {
1243+
if (__wifi_args_to_params(sh, argc, &argv[0], &cnx_params, WIFI_MODE_AP)) {
12461244
shell_help(sh);
12471245
return -ENOEXEC;
12481246
}
@@ -1811,15 +1809,18 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_cmd_ap,
18111809
cmd_wifi_ap_disable,
18121810
1, 0),
18131811
SHELL_CMD_ARG(enable, NULL,
1814-
"\"<SSID>\"\n"
1815-
"<channel number>\n"
1816-
"[PSK: valid only for secure SSIDs]\n"
1817-
"[Security type: valid only for secure SSIDs]\n"
1812+
"-s --ssid=<SSID>\n"
1813+
"-c --channel=<channel number>\n"
1814+
"-p --passphrase=<PSK> (valid only for secure SSIDs)\n"
1815+
"-k --key-mgmt=<Security type> (valid only for secure SSIDs)\n"
18181816
"0:None, 1:WPA2-PSK, 2:WPA2-PSK-256, 3:SAE, 4:WAPI, 5:EAP, 6:WEP, 7: WPA-PSK\n"
1819-
"[MFP (optional: needs security type to be specified)]\n"
1820-
": 0:Disable, 1:Optional, 2:Required.\n",
1817+
"-w --ieee-80211w=<MFP> (optional: needs security type to be specified)\n"
1818+
"0:Disable, 1:Optional, 2:Required\n"
1819+
"-b --band=<band> (2 -2.6GHz, 5 - 5Ghz, 6 - 6GHz)\n"
1820+
"-m --bssid=<BSSID>\n"
1821+
"-h --help (prints help)",
18211822
cmd_wifi_ap_enable,
1822-
3, 3),
1823+
2, 13),
18231824
SHELL_CMD_ARG(stations, NULL,
18241825
"List stations connected to the AP",
18251826
cmd_wifi_ap_stations,

0 commit comments

Comments
 (0)