Skip to content

Commit

Permalink
[nrf fromtree] net: wifi: shell: Support BSSID configuration
Browse files Browse the repository at this point in the history
Add support for BSSID configuration in connect call.

Signed-off-by: Ravi Dondaputi <[email protected]>
(cherry picked from commit 73ed81c)
  • Loading branch information
rado17 committed Mar 27, 2024
1 parent 9aec635 commit b207d62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/zephyr/net/wifi_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ struct wifi_connect_req_params {
enum wifi_security_type security;
/** MFP options */
enum wifi_mfp_options mfp;
/** BSSID */
uint8_t bssid[WIFI_MAC_ADDR_LEN];
/** Connect timeout in seconds, SYS_FOREVER_MS for no timeout */
int timeout;
};
Expand Down
15 changes: 12 additions & 3 deletions subsys/net/l2/wifi/wifi_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
params->security = WIFI_SECURITY_TYPE_NONE;
params->mfp = WIFI_MFP_OPTIONAL;

while ((opt = getopt_long(argc, argv, "s:p:k:w:b:c:h", long_options, &opt_index)) != -1) {
while ((opt = getopt_long(argc, argv, "s:p:k:w:b:c:m:h", long_options, &opt_index)) != -1) {
state = getopt_state_get();
switch (opt) {
case 's':
Expand Down Expand Up @@ -561,6 +561,12 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
}
params->mfp = atoi(optarg);
break;
case 'm':
sscanf(optarg, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
&params->bssid[0], &params->bssid[1],
&params->bssid[2], &params->bssid[3],
&params->bssid[4], &params->bssid[5]);
break;
case 'h':
shell_help(sh);
break;
Expand All @@ -570,6 +576,7 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
return -EINVAL;
}
}

return 0;
}

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

0 comments on commit b207d62

Please sign in to comment.