Skip to content

Commit

Permalink
modules: hostap: Support BSSID configuration for connect command
Browse files Browse the repository at this point in the history
Support BSSID configuration while setting up the network information
as part of the connect command processing.

Signed-off-by: Ravi Dondaputi <[email protected]>
  • Loading branch information
rado17 committed Apr 15, 2024
1 parent b0c3411 commit 042decc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 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,19 @@ 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) &&
!net_eth_is_addr_multicast(&mac) &&
!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

0 comments on commit 042decc

Please sign in to comment.