Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for BSSID configuration in connect call. #14654

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions modules/hostap/src/supp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ static int wpas_add_and_config_network(struct wpa_supplicant *wpa_s,
int ret;
struct add_network_resp resp = {0};
char *chan_list = NULL;
struct net_eth_addr mac = {0};

_wpa_cli_cmd_v("remove_network all");
ret = z_wpa_ctrl_add_network(&resp);
Expand Down Expand Up @@ -403,6 +404,25 @@ static int wpas_add_and_config_network(struct wpa_supplicant *wpa_s,
}
}

memcpy((void *)&mac, params->bssid, WIFI_MAC_ADDR_LEN);
if (net_eth_is_addr_broadcast(&mac) ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You move this check in to the below branch (!unspecified)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!unspecified checks for all 0s which is equivalent to not setting the BSSID. That is why I am returning error only for broadcast and multicast case.

net_eth_is_addr_multicast(&mac)) {
wpa_printf(MSG_ERROR, "Invalid BSSID. Configuration "
"of multicast or broadcast MAC is not allowed.");
ret = -EINVAL;
goto rem_net;
}

if (!net_eth_is_addr_unspecified(&mac)) {
char bssid_str[MAC_STR_LEN] = {0};

snprintf(bssid_str, MAC_STR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x",
params->bssid[0], params->bssid[1], params->bssid[2],
params->bssid[3], params->bssid[4], params->bssid[5]);
_wpa_cli_cmd_v("set_network %d bssid %s",
resp.network_id, bssid_str);
}

/* enable and select network */
_wpa_cli_cmd_v("enable_network %d", resp.network_id);
_wpa_cli_cmd_v("select_network %d", resp.network_id);
Expand Down
1 change: 1 addition & 0 deletions modules/hostap/src/supp_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#define MAX_SSID_LEN 32
#define MAC_ADDR_LEN 6
#define MAC_STR_LEN 18 /* for ':' or '-' separated MAC address string */
#define CHAN_NUM_LEN 6 /* for space-separated channel numbers string */

/**
Expand Down
2 changes: 1 addition & 1 deletion samples/wifi/shell/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CONFIG_NET_SHELL=y

# Memories
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_SHELL_STACK_SIZE=4096
CONFIG_SHELL_STACK_SIZE=4200
CONFIG_NET_TX_STACK_SIZE=4096
CONFIG_NET_RX_STACK_SIZE=4096

Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ manifest:
# https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/modules.html
- name: zephyr
repo-path: sdk-zephyr
revision: d4ee5b3ce2ae353412430857cba05dfe846049cd
revision: 700870d10917960e4799926b864189d755d95f83
import:
# In addition to the zephyr repository itself, NCS also
# imports the contents of zephyr/west.yml at the above
Expand Down
Loading