wlan_bearer/wlanldd/wlan_common/umac_common/src/umacdot11pwrmgmttransitionmode.cpp
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Implementation of the WlanDot11PwrMgmtTransitionMode class.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 22 %
       
    20 */
       
    21 
       
    22 #include "config.h"
       
    23 #include "umacdot11pwrmgmttransitionmode.h"
       
    24 #include "UmacContextImpl.h"
       
    25 #include "UmacWsaSetPsMode.h"
       
    26 #include "UmacWsaWriteMib.h"
       
    27 
       
    28 #ifndef NDEBUG
       
    29 const TInt8 WlanDot11PwrMgmtTransitionMode::iName[] 
       
    30     = "dot11-pwrmgmttransitionmode";
       
    31 
       
    32 const TUint8 WlanDot11PwrMgmtTransitionMode::iStateName
       
    33     [ESTATEMAX][KMaxStateStringLength] = 
       
    34     {
       
    35         {"EINIT"},
       
    36         {"ESETAWAKEMODE"},
       
    37         {"ESETWAKEUPINTERVAL"},
       
    38         {"ESETPSMODE"},
       
    39         {"EWAIT4PWRMGMTTRANSITCOMPLETE"},
       
    40         {"ECONTINUEDOT11TRAVERSE"}
       
    41     };
       
    42 
       
    43 const TUint8 WlanDot11PwrMgmtTransitionMode::iEventName
       
    44     [EEVENTMAX][KMaxEventStringLength] = 
       
    45     {
       
    46         {"ESTATEENTRY"}, 
       
    47         {"ETXCOMPLETE"},
       
    48         {"EPWRMGMTTRANSITCOMPLETE"},
       
    49         {"EABORT"}
       
    50     };
       
    51 #endif
       
    52 
       
    53 // this flag is set if we only need to set the wakeup interval.
       
    54 const TUint32 KOnlySetWakeupInterval        = ( 1 << 0 );
       
    55 // this flag is set if the status of the latest Set Ps Mode cmd was Success
       
    56 const TUint32 KSetPsModeSuccess             = ( 1 << 1 );
       
    57 
       
    58 // ============================ MEMBER FUNCTIONS ===============================
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // The internal state transition method.
       
    62 // It is guaranteed by the FSM framework that no WHA command is pending
       
    63 // when this method is entered
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 void WlanDot11PwrMgmtTransitionMode::ChangeInternalState( 
       
    67     WlanContextImpl& aCtxImpl, 
       
    68     TState aNewState )
       
    69     {
       
    70     iState = aNewState;
       
    71     Fsm( aCtxImpl, ESTATEENTRY );
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // The event dispatcher method.
       
    76 // It is guaranteed by the FSM framework that no WHA command is pending
       
    77 // when this method is entered
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void WlanDot11PwrMgmtTransitionMode::Fsm( 
       
    81     WlanContextImpl& aCtxImpl, 
       
    82     TEvent aEvent )
       
    83     {
       
    84     OsTracePrint( KPwrStateTransition, 
       
    85         (TUint8*)("UMAC * dot11-pwrmgmttransitionmode * FSM EVENT") );
       
    86 #ifndef NDEBUG
       
    87     OsTracePrint( KPwrStateTransition, (TUint8*)("event:"));
       
    88     OsTracePrint( KPwrStateTransition, iEventName[aEvent] );
       
    89     OsTracePrint( KPwrStateTransition, (TUint8*)("state:"));
       
    90     OsTracePrint( KPwrStateTransition, iStateName[iState] );
       
    91 #endif
       
    92 
       
    93     switch ( aEvent )
       
    94         {
       
    95         case ESTATEENTRY:
       
    96             OnStateEntryEvent( aCtxImpl );
       
    97             break;
       
    98         case ETXCOMPLETE:
       
    99             OnTxCompleteEvent( aCtxImpl );
       
   100             break;
       
   101         case EPWRMGMTTRANSITCOMPLETE:
       
   102             OnPwrMgmtTransitCompleteEvent( aCtxImpl );
       
   103             break;
       
   104         case EABORT:
       
   105             OnAbortEvent( aCtxImpl );
       
   106             break;
       
   107         default:
       
   108             // catch internal FSM programming error
       
   109 #ifndef NDEBUG
       
   110             OsTracePrint( KErrorLevel, (TUint8*)("event:"));
       
   111             OsTracePrint( KErrorLevel, iEventName[aEvent] );                
       
   112 #endif
       
   113             OsAssert( (TUint8*)("* UMAC * panic"), 
       
   114                 (TUint8*)(WLAN_FILE), __LINE__ );
       
   115             break;
       
   116         }
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // Handler for the event.
       
   121 // It is guaranteed by the FSM framework that no WHA command is pending
       
   122 // when this method is entered
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 void WlanDot11PwrMgmtTransitionMode::OnStateEntryEvent( 
       
   126     WlanContextImpl& aCtxImpl )
       
   127     {
       
   128     TState state( ESTATEMAX );
       
   129 
       
   130     switch ( iState )
       
   131         {
       
   132         case EINIT:
       
   133             iFlags = 0;
       
   134             // start of fsm traversal
       
   135             // disable oid request so we run this fsm in non pre-emptive mode
       
   136             // regarding oid commands
       
   137             OsTracePrint( KPwrStateTransition, (TUint8*)
       
   138                 ("UMAC * dot11-pwrmgmttransitionmode * disable oid events") );
       
   139 
       
   140             aCtxImpl.Disable( WlanEventDispatcher::KOidChannel );
       
   141 
       
   142             if (// PS mode desired
       
   143                 aCtxImpl.DesiredDot11PwrMgmtMode() == WHA::KPsEnable
       
   144                 && // AND
       
   145                 // current mode is CAM
       
   146                 aCtxImpl.CurrentDot11PwrMgmtMode() == WHA::KPsDisable )
       
   147                 {
       
   148                 // change to dot11 PS mode 
       
   149                 // start by setting the  wakeup interval
       
   150                 state = ESETWAKEUPINTERVAL;
       
   151                 }
       
   152             else if (// CAM mode desired
       
   153                 aCtxImpl.DesiredDot11PwrMgmtMode() == WHA::KPsDisable
       
   154                 && // AND
       
   155                 // current mode is PS mode
       
   156                 aCtxImpl.CurrentDot11PwrMgmtMode() == WHA::KPsEnable )
       
   157                 {
       
   158                 // change to dot11 CAM mode
       
   159                 state = ESETAWAKEMODE;
       
   160                 }
       
   161             else
       
   162                 {
       
   163                 // we have a dot11 power management mode match.
       
   164                 // We can land here e.g. if user changes desired 
       
   165                 // dot11 power management mode when we are excuting this fsm
       
   166                 // as we dispacth an oid as the fsm entry action.
       
   167                 // We can come here also when only the wakeup interval needs
       
   168                 // to be changed
       
   169 
       
   170                 // if the current mode is PS mode we have to make sure 
       
   171                 // that we have a wakeup interval match
       
   172                 if ( aCtxImpl.CurrentDot11PwrMgmtMode() == WHA::KPsEnable )
       
   173                     {
       
   174                     // the way to do that is by re-setting (only) the wakeup
       
   175                     // interval - if necessary
       
   176                     iFlags |= KOnlySetWakeupInterval;
       
   177                     state = ESETWAKEUPINTERVAL;
       
   178                     }
       
   179                 else
       
   180                     {                    
       
   181                     // the current mode is CAM, so the wakeup interval is
       
   182                     // not relevant; and we are done
       
   183                     state = ECONTINUEDOT11TRAVERSE;
       
   184                     }                
       
   185                 }
       
   186 
       
   187             ChangeInternalState( aCtxImpl, state );
       
   188             break;
       
   189         case ESETAWAKEMODE:
       
   190             ActivateDot11AwakeMode( aCtxImpl );
       
   191             break;
       
   192         case ESETWAKEUPINTERVAL:
       
   193             {
       
   194             // first check if the wake-up setting already is what it should be.
       
   195             // if that's the case, we won't set it again
       
   196             
       
   197             if ( DifferenceInPsModeWakeupSettings( aCtxImpl ) )
       
   198                 {
       
   199                 // it's not what it needs to be, so set it
       
   200                 SetWakeUpInterval( aCtxImpl );                
       
   201                 }
       
   202             else
       
   203                 {
       
   204                 // the wake-up setting is already correct, skip setting it again 
       
   205                 // and simulate ETXCOMPLETE event instead
       
   206                 Fsm( aCtxImpl, ETXCOMPLETE );
       
   207                 }            
       
   208             break;
       
   209             }
       
   210         case ESETPSMODE:
       
   211             ActivateDot11PsMode( aCtxImpl );
       
   212             break;
       
   213         case EWAIT4PWRMGMTTRANSITCOMPLETE:
       
   214             // nothing to do here than just wait for completion
       
   215             break;
       
   216         case ECONTINUEDOT11TRAVERSE:
       
   217             ContinueDot11StateTraversal( aCtxImpl );
       
   218             break;
       
   219         default:
       
   220             // catch internal FSM programming error
       
   221 #ifndef NDEBUG
       
   222             OsTracePrint( KErrorLevel, (TUint8*)("state:"));
       
   223             OsTracePrint( KErrorLevel, iStateName[iState] );
       
   224 #endif
       
   225             OsAssert( (TUint8*)("* UMAC * panic"), 
       
   226                 (TUint8*)(WLAN_FILE), __LINE__ );
       
   227             break;
       
   228         }    
       
   229     }
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // Handler for the event.
       
   233 // It is guaranteed by the FSM framework that no WHA command is pending
       
   234 // when this method is entered
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 void WlanDot11PwrMgmtTransitionMode::OnTxCompleteEvent( 
       
   238     WlanContextImpl& aCtxImpl )
       
   239     {
       
   240     switch ( iState )
       
   241         {
       
   242         case ESETAWAKEMODE:
       
   243         case ESETPSMODE:
       
   244             // as transition has sterted now we just wait for it to complete
       
   245             ChangeInternalState( aCtxImpl, EWAIT4PWRMGMTTRANSITCOMPLETE );
       
   246             break;
       
   247         case ESETWAKEUPINTERVAL:
       
   248             if ( iFlags & KOnlySetWakeupInterval )
       
   249                 {
       
   250                 // we only needed to set the wakeup interval. So we are
       
   251                 // done now
       
   252                 ChangeInternalState( aCtxImpl, ECONTINUEDOT11TRAVERSE );
       
   253                 }
       
   254             else                
       
   255                 {
       
   256                 // we also need to set the PS mode. This is the most common case
       
   257                 ChangeInternalState( aCtxImpl, ESETPSMODE );                
       
   258                 }
       
   259             break;
       
   260         case EWAIT4PWRMGMTTRANSITCOMPLETE:
       
   261             // a re-entry to this state has occurred while waiting for the 
       
   262             // CommandComplete event to the SetPsMode cmd.
       
   263             // This will happen when we autonomously issue a (new) WHA cmd -
       
   264             // during the above mentioned wait period - to react to a change 
       
   265             // which has occurred in the network (e.g. in the Use Protection 
       
   266             // setting or in the QoS parameters).
       
   267             // Anyhow, no action is required here (except to allow for this
       
   268             // re-entry to happen)
       
   269             break;
       
   270         default:
       
   271             // catch internal FSM programming error
       
   272 #ifndef NDEBUG
       
   273             OsTracePrint( KErrorLevel, (TUint8*)("state:"));
       
   274             OsTracePrint( KErrorLevel, iStateName[iState] );
       
   275 #endif
       
   276             OsAssert( (TUint8*)("* UMAC * panic"), 
       
   277                 (TUint8*)(WLAN_FILE), __LINE__ );
       
   278             break;
       
   279         }
       
   280     }
       
   281 
       
   282 // -----------------------------------------------------------------------------
       
   283 // Handler for the event.
       
   284 // It is guaranteed by the FSM framework that no WHA command is pending
       
   285 // when this method is entered
       
   286 // -----------------------------------------------------------------------------
       
   287 //
       
   288 void WlanDot11PwrMgmtTransitionMode::OnPwrMgmtTransitCompleteEvent( 
       
   289     WlanContextImpl& aCtxImpl )
       
   290     {
       
   291     // we can continue dot11 state traversal
       
   292     ChangeInternalState( aCtxImpl, ECONTINUEDOT11TRAVERSE );
       
   293     }
       
   294 
       
   295 // ---------------------------------------------------------
       
   296 // simulate macnotresponding error
       
   297 // ---------------------------------------------------------
       
   298 //
       
   299 void WlanDot11PwrMgmtTransitionMode::OnAbortEvent( 
       
   300     WlanContextImpl& aCtxImpl )
       
   301     {
       
   302     OsTracePrint( KWarningLevel, 
       
   303         (TUint8*)("UMAC * dot11-pwrmgmttransitionmode * abort") );
       
   304 
       
   305     DoErrorIndication( aCtxImpl, WHA::KErrorMacNotResponding );
       
   306     }
       
   307 
       
   308 // -----------------------------------------------------------------------------
       
   309 // Handler for the event.
       
   310 // It is guaranteed by the FSM framework that no WHA command is pending
       
   311 // when this method is entered
       
   312 // -----------------------------------------------------------------------------
       
   313 //
       
   314 void WlanDot11PwrMgmtTransitionMode::ActivateDot11AwakeMode( 
       
   315     WlanContextImpl& aCtxImpl )
       
   316     {
       
   317     WlanWsaSetPsMode& wha_cmd( aCtxImpl.WsaSetPsMode() );
       
   318     wha_cmd.Set( aCtxImpl, WHA::KPsDisable );
       
   319 
       
   320     // change global state: entry procedure triggers action
       
   321     ChangeState( aCtxImpl, 
       
   322         *this,      // prev state
       
   323         wha_cmd     // next state
       
   324         );
       
   325     }
       
   326   
       
   327 // -----------------------------------------------------------------------------
       
   328 // Handler for the event.
       
   329 // It is guaranteed by the FSM framework that no WHA command is pending
       
   330 // when this method is entered
       
   331 // -----------------------------------------------------------------------------
       
   332 //  
       
   333 void WlanDot11PwrMgmtTransitionMode::SetWakeUpInterval( 
       
   334     WlanContextImpl& aCtxImpl )
       
   335     {
       
   336     WHA::SwlanWakeUpInterval* mib 
       
   337         = static_cast<WHA::SwlanWakeUpInterval*>
       
   338         (os_alloc( sizeof( WHA::SwlanWakeUpInterval ) )); 
       
   339 
       
   340     if ( !mib )
       
   341         {
       
   342         // allocation failed
       
   343         // simulate macnotresponding error
       
   344         OsTracePrint( KWarningLevel, (TUint8*)
       
   345             ("UMAC: WlanDot11PwrMgmtTransitionMode::SetWakeUpInterval: alloc failed, abort") );
       
   346         Fsm( aCtxImpl, EABORT );
       
   347         return;
       
   348         }
       
   349 
       
   350     // determine the desired new wake-up setting
       
   351     const TDot11PsModeWakeupSetting KDesiredPsModeConfig (
       
   352         aCtxImpl.DesiredPsModeConfig() );    
       
   353 
       
   354     // take it into use
       
   355 
       
   356     mib->iMode = KDesiredPsModeConfig.iWakeupMode;
       
   357     mib->iListenInterval = KDesiredPsModeConfig.iListenInterval;
       
   358     
       
   359     WlanWsaWriteMib& wha_cmd = aCtxImpl.WsaWriteMib();
       
   360 
       
   361     wha_cmd.Set( 
       
   362         aCtxImpl, WHA::KMibWlanWakeUpInterval, sizeof(*mib), mib );
       
   363 
       
   364     OsTracePrint( KPwrStateTransition, (TUint8*)
       
   365         ("UMAC: UMAC: WlanDot11PwrMgmtTransitionMode::SetWakeUpInterval: desired mode: %d"), 
       
   366         mib->iMode );
       
   367     OsTracePrint( KPwrStateTransition, 
       
   368         (TUint8*)("UMAC: desired listeninterval: %d"), mib->iListenInterval );
       
   369 
       
   370     // store the new setting also locally
       
   371     aCtxImpl.iWlanMib.iWlanWakeupInterval = mib->iMode;
       
   372     aCtxImpl.iWlanMib.iWlanListenInterval = mib->iListenInterval;
       
   373 
       
   374     // change global state: entry procedure triggers action
       
   375     ChangeState( aCtxImpl, 
       
   376         *this,              // prev state
       
   377         wha_cmd             // next state
       
   378         );           
       
   379 
       
   380     // as the parameters have been supplied we can now deallocate
       
   381     os_free( mib );        
       
   382     }
       
   383 
       
   384 // -----------------------------------------------------------------------------
       
   385 // Handler for the event.
       
   386 // It is guaranteed by the FSM framework that no WHA command is pending
       
   387 // when this method is entered
       
   388 // -----------------------------------------------------------------------------
       
   389 //
       
   390 void WlanDot11PwrMgmtTransitionMode::ActivateDot11PsMode( 
       
   391     WlanContextImpl& aCtxImpl )
       
   392     {
       
   393     WlanWsaSetPsMode& wha_cmd( aCtxImpl.WsaSetPsMode() );
       
   394     wha_cmd.Set( aCtxImpl, WHA::KPsEnable );
       
   395 
       
   396     // change global state: entry procedure triggers action
       
   397     ChangeState( aCtxImpl, 
       
   398         *this,      // prev state
       
   399         wha_cmd     // next state
       
   400         );
       
   401     }
       
   402 
       
   403 // -----------------------------------------------------------------------------
       
   404 // Handler for the event.
       
   405 // It is guaranteed by the FSM framework that no WHA command is pending
       
   406 // when this method is entered
       
   407 // -----------------------------------------------------------------------------
       
   408 //
       
   409 void WlanDot11PwrMgmtTransitionMode::ContinueDot11StateTraversal( 
       
   410     WlanContextImpl& aCtxImpl )
       
   411     {
       
   412     if ( !( iFlags & KOnlySetWakeupInterval ) )
       
   413         {
       
   414         // we have tried to change the power mgmt mode with SetPsMode
       
   415         // WHA command
       
   416         
       
   417         if ( iFlags & KSetPsModeSuccess )
       
   418             {
       
   419             // the Set PS Mode WHA cmd was successfully executed, which means 
       
   420             // that we were able to communicate with the AP.
       
   421             // So we can indicate BSS Regained; if necessary
       
   422             DoRegainedBSSIndication( aCtxImpl );
       
   423             }
       
   424         else
       
   425             {
       
   426             if ( !aCtxImpl.SetPsModeCount() )
       
   427                 {
       
   428                 // the set power mgmt mode counter has counted down to zero, so
       
   429                 // we will indicate Consecutive Power Mode Set Failures (unless
       
   430                 // already indicated) to WLAN Mgmt Client
       
   431                 DoConsecutivePwrModeSetFailuresIndication( aCtxImpl );
       
   432                 // reset the counter
       
   433                 aCtxImpl.SetPsModeCount();
       
   434                 // it's possible that we come to this branch again shortly,
       
   435                 // but it really doesn't matter. In any case we will indicate 
       
   436                 // Consecutive Power Mode Set Failures only once at maximum
       
   437                 }
       
   438             else
       
   439                 {
       
   440                 // we have made one (more) unsuccessful attempt to set the power
       
   441                 // mgmt mode, so decrement the counter by one
       
   442                 aCtxImpl.DecrementSetPsModeCount();
       
   443                 }        
       
   444             }
       
   445         }
       
   446 
       
   447     TBool dot11PwrMgmtTransitComplete ( EFalse );
       
   448     const WHA::TPsMode KCurrentPwrMgmtMode( 
       
   449         aCtxImpl.CurrentDot11PwrMgmtMode() );
       
   450             
       
   451     if ( KCurrentPwrMgmtMode == aCtxImpl.DesiredDot11PwrMgmtMode() )
       
   452         {
       
   453         // current dot11 power management mode equals to desired mode
       
   454         
       
   455         if ( KCurrentPwrMgmtMode == WHA::KPsEnable )
       
   456             {
       
   457             // as the current and desired mode is PS, we are only done
       
   458             // if also the wakeup settings are as desired
       
   459             if ( !DifferenceInPsModeWakeupSettings( aCtxImpl ) )
       
   460                 {
       
   461                 dot11PwrMgmtTransitComplete = ETrue;                
       
   462                 }
       
   463             else 
       
   464                 {
       
   465                 OsTracePrint( KPwrStateTransition, 
       
   466                     (TUint8*)("UMAC: wakeup settings not as desired") );                
       
   467                 }
       
   468             }
       
   469         else
       
   470             {
       
   471             // as the current and desired mode is CAM, we are done
       
   472             dot11PwrMgmtTransitComplete = ETrue;
       
   473             }
       
   474         }
       
   475     else
       
   476         {
       
   477         // current dot11 power management mode does not equal to desired mode.
       
   478         // Se we are not done and will need to try to do the mode change again.
       
   479         // No action here. 
       
   480         }
       
   481 
       
   482     if ( dot11PwrMgmtTransitComplete )
       
   483         {
       
   484         // desired dot11 power management mode - and settings if the desired
       
   485         // mode is PS - have been acquired
       
   486         
       
   487         ChangeState( aCtxImpl, 
       
   488             *this,                                          // prev state
       
   489             aCtxImpl.iStates.iInfrastructureNormalMode );   // next state
       
   490 
       
   491         if ( aCtxImpl.CurrentDot11PwrMgmtMode() == WHA::KPsEnable )
       
   492             {
       
   493             // as we have entered PS mode, it is time to resume QoS null
       
   494             // data frame sending, if applicable
       
   495             aCtxImpl.ResumeQosNullSending();
       
   496             }
       
   497         }
       
   498     else
       
   499         {
       
   500         // dot11 power management mode/settings are not as desired, yet.
       
   501         // We shall repeat this process
       
   502         
       
   503         ChangeState( aCtxImpl, 
       
   504             *this,  // prev state
       
   505             *this   // next state
       
   506             );        
       
   507         }
       
   508     }
       
   509 
       
   510 // -----------------------------------------------------------------------------
       
   511 // 
       
   512 // -----------------------------------------------------------------------------
       
   513 //
       
   514 void WlanDot11PwrMgmtTransitionMode::Entry( 
       
   515     WlanContextImpl& aCtxImpl )
       
   516     {
       
   517     if ( aCtxImpl.WsaCmdActive() )
       
   518         {
       
   519         // sanity checking code
       
   520         OsAssert( 
       
   521             (TUint8*)("UMAC * panic"), (TUint8*)(WLAN_FILE), __LINE__ );
       
   522         }
       
   523 
       
   524     if ( !(aCtxImpl.DispatchEvent()) )
       
   525         {
       
   526         // no state transition occurred
       
   527         // dispatcher might or might not have had an event to be dispatched
       
   528         // in any case we are still in the current state and can continue...
       
   529         if ( iState != EINIT )
       
   530             {
       
   531             // this is NOT the start of the the FSM actions
       
   532             // note that we send the ETXCOMPLETE event as the states
       
   533             // that wait for it are the only ones that can be interrupted
       
   534             // as they are asynchronous operations by nature
       
   535             // and wait for corresponding WHA completion method
       
   536             Fsm( aCtxImpl, ETXCOMPLETE );
       
   537             }
       
   538         else
       
   539             {
       
   540             // this is the start of the the FSM actions
       
   541             Fsm( aCtxImpl, ESTATEENTRY );
       
   542             }
       
   543         }
       
   544     else    // --- !(aCtxImpl.DispatchEvent())
       
   545         {
       
   546         // state transition occurred
       
   547         // we are no longer in the current state,
       
   548         // so we won't do anything as we might mess things up
       
   549         }
       
   550     }
       
   551 
       
   552 // -----------------------------------------------------------------------------
       
   553 // 
       
   554 // -----------------------------------------------------------------------------
       
   555 //
       
   556 void WlanDot11PwrMgmtTransitionMode::Exit( 
       
   557     WlanContextImpl& aCtxImpl)
       
   558     {
       
   559     // reset fsm
       
   560     iState = EINIT;
       
   561 
       
   562     // enable oid requests as we are exiting this dot11 state
       
   563     OsTracePrint( KPwrStateTransition, (TUint8*)
       
   564         ("UMAC * dot11-pwrmgmttransitionmode * enable oid events") );
       
   565 
       
   566     aCtxImpl.Enable( WlanEventDispatcher::KOidChannel );
       
   567     }
       
   568 
       
   569 #ifndef NDEBUG 
       
   570 // -----------------------------------------------------------------------------
       
   571 // 
       
   572 // -----------------------------------------------------------------------------
       
   573 //
       
   574 const TInt8* WlanDot11PwrMgmtTransitionMode::GetStateName( 
       
   575     TUint8& aLength ) const
       
   576     {
       
   577     aLength = sizeof( iName );
       
   578     return iName;
       
   579     }
       
   580 #endif
       
   581 
       
   582 // -----------------------------------------------------------------------------
       
   583 // 
       
   584 // -----------------------------------------------------------------------------
       
   585 //
       
   586 TBool WlanDot11PwrMgmtTransitionMode::CommandComplete( 
       
   587     WlanContextImpl& aCtxImpl, 
       
   588     WHA::TCompleteCommandId aCompleteCommandId, 
       
   589     WHA::TStatus aStatus,
       
   590     const WHA::UCommandCompletionParams& 
       
   591     aCommandCompletionParams )
       
   592     {
       
   593     if ( aCompleteCommandId != WHA::ESetPsModeComplete )
       
   594         {
       
   595         // implementation error
       
   596         OsTracePrint( KErrorLevel, (TUint8*)("UMAC: command id: %d"), aCompleteCommandId);
       
   597         OsAssert( (TUint8*)("UMAC panic"), (TUint8*)(WLAN_FILE), __LINE__ );
       
   598         }
       
   599 
       
   600     OsTracePrint( KPwrStateTransition, 
       
   601         (TUint8*)("UMAC: WlanDot11PwrMgmtTransitionMode::CommandComplete"));
       
   602 
       
   603     const WHA::TPsMode KCurrentPwrMgmtMode( 
       
   604         aCommandCompletionParams.iSetPsModeComplete.iDot11PowerManagementMode );
       
   605     aCtxImpl.CurrentDot11PwrMgmtMode( KCurrentPwrMgmtMode );
       
   606 
       
   607     // make a note whether the SetPsMode WHA command was executed successfully 
       
   608     // or not
       
   609     if ( aStatus == WHA::KSuccess )
       
   610         {
       
   611         iFlags |= KSetPsModeSuccess;
       
   612 
       
   613         OsTracePrint( KPwrStateTransition, 
       
   614             (TUint8*)("UMAC: transition success: current mode: %d"), 
       
   615             KCurrentPwrMgmtMode);
       
   616         }
       
   617     else
       
   618         {
       
   619         iFlags &= ~KSetPsModeSuccess;
       
   620         
       
   621         OsTracePrint( KWarningLevel | KPwrStateTransition, 
       
   622             (TUint8*)("UMAC: transition failure: current mode: %d"), 
       
   623             KCurrentPwrMgmtMode);
       
   624         }
       
   625 
       
   626     // continue fsm
       
   627     Fsm( aCtxImpl, EPWRMGMTTRANSITCOMPLETE );
       
   628 
       
   629     // signal global state transition
       
   630     return ETrue;
       
   631     }
       
   632 
       
   633 // -----------------------------------------------------------------------------
       
   634 // as oid reception is disbaled in this dot11 state, reception of this oid
       
   635 // is a result of a manual oid dispatching
       
   636 // -----------------------------------------------------------------------------
       
   637 //
       
   638 TBool WlanDot11PwrMgmtTransitionMode::SetPowerMode(
       
   639     WlanContextImpl& aCtxImpl,
       
   640     TPowerMode aPowerMode,
       
   641     TBool aDisableDynamicPowerModeManagement,
       
   642     TWlanWakeUpInterval aWakeupModeInLightPs, 
       
   643     TUint8 aListenIntervalInLightPs,
       
   644     TWlanWakeUpInterval aWakeupModeInDeepPs,
       
   645     TUint8 aListenIntervalInDeepPs )
       
   646     {
       
   647     OsTracePrint( KPwrStateTransition, 
       
   648         (TUint8*)("UMAC: WlanDot11PwrMgmtTransitionMode::SetPowerMode: desired power mode: %d"),
       
   649         aPowerMode );
       
   650 
       
   651     // store desired new dot11 power management mode by WLAN Mgmt Client
       
   652     aCtxImpl.ClientDot11PwrMgmtMode( aPowerMode );
       
   653     
       
   654     aCtxImpl.DynamicPwrModeMgtDisabled( aDisableDynamicPowerModeManagement );
       
   655     
       
   656     // it is now also our desired dot11 power management mode
       
   657     aCtxImpl.DesiredDot11PwrMgmtMode( aCtxImpl.ClientDot11PwrMgmtMode() );
       
   658 
       
   659     aCtxImpl.SetClientLightPsModeConfig( 
       
   660         aWakeupModeInLightPs, 
       
   661         aListenIntervalInLightPs );
       
   662 
       
   663     aCtxImpl.SetClientDeepPsModeConfig( 
       
   664             aWakeupModeInDeepPs, 
       
   665             aListenIntervalInDeepPs );
       
   666     
       
   667     // in case WLAN Mgmt Client wishes to use PS mode, Light PS is the initial
       
   668     // desired PS mode configuration
       
   669     aCtxImpl.SetDesiredPsModeConfig( 
       
   670                 aCtxImpl.ClientLightPsModeConfig() );
       
   671     
       
   672     // complete the mgmt command
       
   673     OnOidComplete( aCtxImpl );
       
   674 
       
   675     // signal that no state transition occurred
       
   676     return EFalse;
       
   677     }