Skip to content

Commit b207d62

Browse files
committed
[nrf fromtree] net: wifi: shell: Support BSSID configuration
Add support for BSSID configuration in connect call. Signed-off-by: Ravi Dondaputi <[email protected]> (cherry picked from commit 73ed81c)
1 parent 9aec635 commit b207d62

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

include/zephyr/net/wifi_mgmt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ struct wifi_connect_req_params {
359359
enum wifi_security_type security;
360360
/** MFP options */
361361
enum wifi_mfp_options mfp;
362+
/** BSSID */
363+
uint8_t bssid[WIFI_MAC_ADDR_LEN];
362364
/** Connect timeout in seconds, SYS_FOREVER_MS for no timeout */
363365
int timeout;
364366
};

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
477477
params->security = WIFI_SECURITY_TYPE_NONE;
478478
params->mfp = WIFI_MFP_OPTIONAL;
479479

480-
while ((opt = getopt_long(argc, argv, "s:p:k:w:b:c:h", long_options, &opt_index)) != -1) {
480+
while ((opt = getopt_long(argc, argv, "s:p:k:w:b:c:m:h", long_options, &opt_index)) != -1) {
481481
state = getopt_state_get();
482482
switch (opt) {
483483
case 's':
@@ -561,6 +561,12 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
561561
}
562562
params->mfp = atoi(optarg);
563563
break;
564+
case 'm':
565+
sscanf(optarg, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
566+
&params->bssid[0], &params->bssid[1],
567+
&params->bssid[2], &params->bssid[3],
568+
&params->bssid[4], &params->bssid[5]);
569+
break;
564570
case 'h':
565571
shell_help(sh);
566572
break;
@@ -570,6 +576,7 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
570576
return -EINVAL;
571577
}
572578
}
579+
573580
return 0;
574581
}
575582

@@ -1858,9 +1865,11 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands,
18581865
"[-k, --key-mgmt]: Key Management type (valid only for secure SSIDs)\n"
18591866
"0:None, 1:WPA2-PSK, 2:WPA2-PSK-256, 3:SAE, 4:WAPI, 5:EAP, 6:WEP, 7: WPA-PSK\n"
18601867
"[-w, --ieee-80211w]: MFP (optional: needs security type to be specified)\n"
1861-
": 0:Disable, 1:Optional, 2:Required.\n",
1868+
": 0:Disable, 1:Optional, 2:Required.\n"
1869+
"[-m, --bssid]: MAC address of the AP (BSSID).\n"
1870+
"[-h, --help]: Print out the help for the connect command.\n",
18621871
cmd_wifi_connect,
1863-
2, 5),
1872+
2, 7),
18641873
SHELL_CMD_ARG(disconnect, NULL, "Disconnect from the Wi-Fi AP.\n",
18651874
cmd_wifi_disconnect,
18661875
1, 0),

0 commit comments

Comments
 (0)