Example #1
0
/*******************************************************************************
  Function:
    void WF_PsPollEnable(t_psPollContext *p_context)

  Summary:
    Enables PS Poll mode.

  Description:
    Enables PS Poll mode.  PS-Poll (Power-Save Poll) is a mode allowing for
    longer battery life.  The MRF24W coordinates with the Access Point to go
    to sleep and wake up at periodic intervals to check for data messages, which
    the Access Point will buffer.  The listenInterval in the Connection
    Algorithm defines the sleep interval.  By default, PS-Poll mode is disabled.

    When PS Poll is enabled, the WF Host Driver will automatically force the
    MRF24W to wake up each time the Host sends Tx data or a control message
    to the MRF24W.  When the Host message transaction is complete the
    MRF24W driver will automatically re-enable PS Poll mode.

    When the application is likely to experience a high volume of data traffic
    then PS-Poll mode should be disabled for two reasons:
    1. No power savings will be realized in the presence of heavy data traffic.
    2. Performance will be impacted adversely as the WiFi Host Driver
        continually activates and deactivates PS-Poll mode via SPI messages.

  Precondition:
    MACInit must be called first.

  Parameters:
    p_context -  pointer to ps poll context

  Returns:
    None.

  Remarks:
    None.
  *****************************************************************************/
void WF_PsPollEnable(t_psPollContext *p_context)
{
    t_WFPwrModeReq   pwrModeReq;

    // if not currently connected then return
    if(UdGetConnectionState() != CS_CONNECTED)
    {
        EventEnqueue(WF_EVENT_ERROR, UD_INVALID_PS_POLL_ERROR);
        return;
    }

    // save the Ps-Poll context
    UdEnablePsPoll(p_context);

    SetListenInterval(p_context->listenInterval);
    SetDtimInterval(p_context->dtimInterval);

    // fill in request structure and send message to MRF24WG
    pwrModeReq.mode     = PS_POLL_ENABLED;
    pwrModeReq.wake     = 0;
    pwrModeReq.rcvDtims = p_context->useDtim;
    SendPowerModeMsg(&pwrModeReq);

    WFConfigureLowPowerMode(WF_LOW_POWER_MODE_ON);

    if (p_context->useDtim)
    {
        PowerStateSet(WF_PS_PS_POLL_DTIM_ENABLED);
    }
    else
    {
        PowerStateSet(WF_PS_PS_POLL_DTIM_DISABLED);
    }
}
Example #2
0
/*******************************************************************************
  Function:
    void DRV_WIFI_PsPollEnable(DRV_WIFI_PS_POLL_CONTEXT *p_context);

  Summary:
    Enables PS Poll mode.

  Description:
    Enables PS Poll mode.  PS-Poll (Power-Save Poll) is a mode allowing for
    longer battery life.  The MRF24W coordinates with the Access Point to go
    to sleep and wake up at periodic intervals to check for data messages, which
    the Access Point will buffer.  The listenInterval in the Connection
    Algorithm defines the sleep interval.  By default, PS-Poll mode is disabled.

    When PS Poll is enabled, the WF Host Driver will automatically force the
    MRF24W to wake up each time the Host sends Tx data or a control message
    to the MRF24W.  When the Host message transaction is complete the
    MRF24W driver will automatically re-enable PS Poll mode.

    When the application is likely to experience a high volume of data traffic
    then PS-Poll mode should be disabled for two reasons:
    1. No power savings will be realized in the presence of heavy data traffic.
    2. Performance will be impacted adversely as the WiFi Host Driver
        continually activates and deactivates PS-Poll mode via SPI messages.

  Parameters:
     p_context -  Pointer to ps poll context.  See DRV_WIFI_PS_POLL_CONTEXT
                  structure.

  Returns:
    None.

  Remarks:
    None.
  *****************************************************************************/
void DRV_WIFI_PsPollEnable(DRV_WIFI_PS_POLL_CONTEXT *p_context)
{
    t_wfPwrModeReq   pwrModeReq;

    // if not currently connected
    if (!WFisConnected())
    {
        // save caller parameters for later, when we can enable this mode
        g_savedPsPollContext.listenInterval = p_context->listenInterval;
        g_savedPsPollContext.dtimInterval   = p_context->dtimInterval;
        g_savedPsPollContext.useDtim        = p_context->useDtim;
        SetAppPowerSaveMode(true);
        return;
    }

    SetListenInterval(p_context->listenInterval);
    SetDtimInterval(p_context->dtimInterval);

    // fill in request structure and send message to MRF24WG
    pwrModeReq.mode     = PS_POLL_ENABLED;
    pwrModeReq.wake     = 0;
    pwrModeReq.rcvDtims = p_context->useDtim;
    SendPowerModeMsg(&pwrModeReq);

    if (p_context->useDtim)
    {
        SetPowerSaveState(DRV_WIFI_PS_PS_POLL_DTIM_ENABLED);
    }
    else
    {
        SetPowerSaveState(DRV_WIFI_PS_PS_POLL_DTIM_DISABLED);
    }

    WFConfigureLowPowerMode(WF_LOW_POWER_MODE_ON);
    SetAppPowerSaveMode(true);
}