nRF7002 Extended Power Save Mode Issue

Hello,

Following this link I integrated the extended power save mode in my code, 

I put the nrf7002 in extended power save mode after successfully connecting to the AP.

Doing that I am getting below error. 

- DTIM period is selected by the AP only, it can't be set by STA device.
- faced error for setting power save mode.
- I: wifi_set_ps_wakeup_mode: Set wakeup mode: Listen interval
- E: wifi_set_ps_wakeup_mode: Setting wakeup mode failed. Reason Cannot set parameters while device connected

Attaching the code snippet I am using.

int nrf_wifi_ps_enabled = 0;
int nrf_wifi_ps_wakeup_mode = 0;

int wifi_set_ps_wakeup_mode();

int wifi_set_power_state()
{
    struct net_if *iface = net_if_get_first_wifi();

    /* STEP 2.1 - Define the Wi-Fi power save parameters structure */
    struct wifi_ps_params ps_params = {0};

    /* STEP 2.2 - Check if power saving is currently enabled */
    if (!nrf_wifi_ps_enabled)
    {
        ps_params.enabled = WIFI_PS_ENABLED;
    }
    else
    {
        ps_params.enabled = WIFI_PS_DISABLED;
    }

    /* STEP 2.3 - Send the power save request */
    if (net_mgmt(NET_REQUEST_WIFI_PS, iface, &ps_params, sizeof(ps_params)))
    {
        WB_ERR("Power save %s failed. Reason %s", ps_params.enabled ? "enable" : "disable",
               wifi_ps_get_config_err_code_str(ps_params.fail_reason));
        return -1;
    }

    WB_INF("Set power save: %s", ps_params.enabled ? "enable" : "disable");

    /* STEP 2.4 - Toggle the power save status */
    nrf_wifi_ps_enabled = nrf_wifi_ps_enabled ? 0 : 1;

    wifi_set_ps_wakeup_mode();

    return 0;
}

int wifi_set_ps_wakeup_mode()
{
    struct net_if *iface = net_if_get_default();

    /* STEP 6.2 - Define the Wi-Fi power save parameters structure */
    struct wifi_ps_params ps_params = {0};

    /* STEP 6.3 - Check and toggle the current wakeup mode */
    if (nrf_wifi_ps_wakeup_mode)
    {
        ps_params.wakeup_mode = WIFI_PS_WAKEUP_MODE_DTIM;
    }
    else
    {
        ps_params.wakeup_mode = WIFI_PS_WAKEUP_MODE_LISTEN_INTERVAL;
    }

    /* STEP 6.4 - Set the request type to wakeup mode. */
    ps_params.type = WIFI_PS_PARAM_WAKEUP_MODE;

    /* STEP 6.5 - Send the wakeup mode request */

    if (net_mgmt(NET_REQUEST_WIFI_PS, iface, &ps_params, sizeof(ps_params)))
    {
        WB_ERR("Setting wakeup mode failed. Reason %s",
               wifi_ps_get_config_err_code_str(ps_params.fail_reason));
        return -1;
    }

    WB_INF("Set wakeup mode: %s", ps_params.wakeup_mode ? "Listen interval" : "DTIM");

    if (ps_params.wakeup_mode == WIFI_PS_WAKEUP_MODE_LISTEN_INTERVAL)
    {
        /* STEP 6.6 - Set the listen interval */
        memset(&ps_params, 0x00, sizeof(ps_params));

        ps_params.type = WIFI_PS_PARAM_LISTEN_INTERVAL;
        ps_params.listen_interval = 10;

        /* Assuming 100ms DTIM interval, the listen interval should be 10 * 100ms = 1000ms */
        if (net_mgmt(NET_REQUEST_WIFI_PS, iface, &ps_params, sizeof(ps_params)))
        {
            WB_ERR("Setting wakeup mode failed. Reason %s",
                   wifi_ps_get_config_err_code_str(ps_params.fail_reason));
            return -1;
        }
    }

    /* STEP 6.6 - Toggle the wakeup mode status */
    nrf_wifi_ps_wakeup_mode = nrf_wifi_ps_wakeup_mode ? 0 : 1;

    return 0;
}

Can you point out what am doing wrong in this.

Parents Reply Children
No Data
Related