Skip to content

Commit

Permalink
modules: hostap: Configure max idle period
Browse files Browse the repository at this point in the history
Support for configuring max idle period for STA mode.

Signed-off-by: Ajay Parida <[email protected]>
  • Loading branch information
ajayparida committed Jun 12, 2024
1 parent 35795fb commit 1ba794c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
22 changes: 22 additions & 0 deletions modules/hostap/src/supp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,28 @@ int z_wpa_supplicant_channel(const struct device *dev,
return wifi_mgmt_api->channel(dev, channel);
}

int z_wpa_supplicant_set_bss_max_idle_period(const struct device *dev,
unsigned short bss_max_idle_period)
{
struct wpa_supplicant *wpa_s;
int ret = 0;

k_mutex_lock(&wpa_supplicant_mutex, K_FOREVER);

wpa_s = get_wpa_s_handle(dev);

if (!wpa_s) {
wpa_printf(MSG_ERROR, "Interface %s not found", dev->name);
ret = -1;
goto out;
}

wpa_s->conf->bss_max_idle_period = bss_max_idle_period;
out:
k_mutex_unlock(&wpa_supplicant_mutex);
return ret;
}

#ifdef CONFIG_AP
int z_wpa_supplicant_ap_enable(const struct device *dev,
struct wifi_connect_req_params *params)
Expand Down
10 changes: 10 additions & 0 deletions modules/hostap/src/supp_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ int z_wpa_supplicant_filter(const struct device *dev,
int z_wpa_supplicant_channel(const struct device *dev,
struct wifi_channel_info *channel);

/**
* @brief Set Wi-Fi max idle period
*
* @param dev Wi-Fi interface handle to use
* @param bss_max_idle_period Maximum idle period to set
* @return 0 for OK; -1 for ERROR
*/
int z_wpa_supplicant_set_bss_max_idle_period(const struct device *dev,
unsigned short bss_max_idle_period);

#ifdef CONFIG_AP
/**
* @brief Set Wi-Fi AP configuration
Expand Down
2 changes: 2 additions & 0 deletions modules/hostap/src/supp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static const struct wifi_mgmt_ops wpa_supp_ops = {
.mode = z_wpa_supplicant_mode,
.filter = z_wpa_supplicant_filter,
.channel = z_wpa_supplicant_channel,
.set_bss_max_idle_period = z_wpa_supplicant_set_bss_max_idle_period,
#ifdef CONFIG_AP
.ap_enable = z_wpa_supplicant_ap_enable,
.ap_disable = z_wpa_supplicant_ap_disable,
Expand Down Expand Up @@ -184,6 +185,7 @@ static int z_wpas_add_interface(const char *ifname)

wpa_s->conf->filter_ssids = 1;
wpa_s->conf->ap_scan = 1;
wpa_s->conf->bss_max_idle_period = CONFIG_WIFI_MGMT_BSS_MAX_IDLE_TIME;

/* Default interface, kick start wpa_supplicant */
if (z_wpas_get_iface_count() == 1) {
Expand Down

0 comments on commit 1ba794c

Please sign in to comment.