wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanbgscan.h
branchRCL_3
changeset 3 6524e815f76f
parent 0 c40eb8fe8501
child 8 e0f767079796
equal deleted inserted replaced
0:c40eb8fe8501 3:6524e815f76f
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    14 * Description:  Class implementing WLAN background scan logic
    14 * Description:  Class implementing WLAN background scan logic
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 7 %
    19 * %version: 9 %
    20 */
    20 */
    21 
    21 
    22 #ifndef WLANBGSCAN_H
    22 #ifndef WLANBGSCAN_H
    23 #define WLANBGSCAN_H
    23 #define WLANBGSCAN_H
    24 
    24 
    25 #include "awsinterface.h"
    25 #include "awsinterface.h"
    26 #include "awsenginebase.h"
    26 #include "awsenginebase.h"
    27 #include "wlanscanproviderinterface.h"
    27 #include "wlanscanproviderinterface.h"
    28 #include "wlantimerservices.h"
    28 #include "wlantimerserviceinterface.h"
    29 #include "wlanbgscanawscomms.h"
    29 #include "wlanbgscanawscommsinterface.h"
       
    30 #include "wlanbgscancommandlistener.h"
       
    31 #include "wlanbgscanstates.h"
       
    32 
       
    33 
    30 
    34 
    31 /**
    35 /**
    32  *  WLAN Background Scan
    36  *  WLAN Background Scan
    33  *  This class implements WLAN Background Scan logic.
    37  *  This class implements WLAN Background Scan logic.
    34  *  
    38  *  
    35  *  @since S60 S60 v5.2
    39  *  @since S60 S60 v5.2
    36  */
    40  */
    37 NONSHARABLE_CLASS( CWlanBgScan ) :
    41 NONSHARABLE_CLASS( CWlanBgScan ) :
    38     public MWlanBgScanProvider,
    42     public MWlanBgScanProvider,
    39     public MWlanTimerServiceCallback,
    43     public MWlanTimerServiceCallback,
    40     public MWlanBgScanCommandListener
    44     public MWlanBgScanCommandListener,
       
    45     public CWlanBgScanStates
    41     {
    46     {
    42 
    47 
    43 public:
    48 public:
    44         
    49             
    45     /**
       
    46      * States for WLAN Background Scan.
       
    47      */
       
    48     enum TWlanBgScanState
       
    49         {
       
    50         EBgScanOff = 0,
       
    51         EBgScanOn,
       
    52         EBgScanAuto,
       
    53         EBgScanAutoAws
       
    54         };
       
    55     
       
    56     /**
    50     /**
    57      * States for Auto period.
    51      * States for Auto period.
    58      */
    52      */
    59     enum TWlanBgScanAutoPeriod
    53     enum TWlanBgScanAutoPeriod
    60         {
    54         {
    70         {
    64         {
    71         ESmaller,
    65         ESmaller,
    72         EInsideRange,
    66         EInsideRange,
    73         EGreater
    67         EGreater
    74         };
    68         };
       
    69     
       
    70     /**
       
    71      * Possible statuses for AWS presence.
       
    72      */
       
    73     enum TAwsPresence
       
    74         {
       
    75         EAwsPresent,
       
    76         EAwsNotPresent,
       
    77         EAwsStarting
       
    78         };
    75 
    79 
    76     /**
    80     /**
    77      * Two-phased constructor.
    81      * Two-phased constructor.
    78      */
    82      */
    79     static CWlanBgScan* NewL( MWlanScanResultProvider& aProvider, CWlanTimerServices& aTimerServices );
    83     static CWlanBgScan* NewL( MWlanScanResultProvider& aProvider, MWlanTimerServices& aTimerServices );
    80     
    84     
    81     /**
    85     /**
    82     * Destructor.
    86     * Destructor.
    83     */
    87     */
    84     virtual ~CWlanBgScan();
    88     virtual ~CWlanBgScan();
    85 
    89 
    86     /**
    90     /**
    87      * From MWlanBgScanProvider.
    91      * From MWlanBgScanProvider.
    88      * Called when Scan has been completed.
    92      * Called when Scan has been completed.
    89      * 
       
    90      * \msc
       
    91      * ScanResultProvider,CWlanBgScan;
       
    92      * --- [label="Scan is done"];
       
    93      * ScanResultProvider=>CWlanBgScan [label="ScanComplete()"];
       
    94      * ScanResultProvider<=CWlanBgScan [label="Scan()"];
       
    95      * --- [label="New scan request is placed to queue or"];
       
    96      * --- [label="existing request's scan time is updated"];
       
    97      * ScanResultProvider>>CWlanBgScan [label="return"];
       
    98      * ScanResultProvider<<CWlanBgScan [label="return"];
       
    99      * \endmsc
       
   100      * 
       
   101      *
    93      *
   102      * @since S60 v5.2
    94      * @since S60 v5.2
   103      */
    95      */
   104     void ScanComplete();
    96     void ScanComplete();
   105         
    97         
   106     /**
    98     /**
   107      * From MWlanBgScanProvider.
    99      * From MWlanBgScanProvider.
   108      * Issued when WLAN is disconnected.
   100      * Issued when WLAN is disconnected.
   109      *
       
   110      * \msc
       
   111      * ScanResultProvider,CWlanBgScan;
       
   112      * --- [label="WLAN is disconnected"];
       
   113      * ScanResultProvider=>CWlanBgScan [label="NotConnected()"];
       
   114      * ScanResultProvider<=CWlanBgScan [label="Scan( aMaxDelay=0 )"];
       
   115      * ScanResultProvider>>CWlanBgScan [label="return"];
       
   116      * ScanResultProvider<<CWlanBgScan [label="return"];
       
   117      * \endmsc
       
   118      *
   101      *
   119      * @since S60 v5.2
   102      * @since S60 v5.2
   120      */
   103      */
   121     void NotConnected();
   104     void NotConnected();
   122     
   105     
   142     
   125     
   143     /**
   126     /**
   144      * From MAwsBgScanProvider.
   127      * From MAwsBgScanProvider.
   145      * Set new background scan interval.
   128      * Set new background scan interval.
   146      * Asynchronous method to set new background scan interval, executed in
   129      * Asynchronous method to set new background scan interval, executed in
   147      * AWS thread.
   130      * AWS thread context.
   148      *
   131      *
   149      * @since S60 v5.2
   132      * @since S60 v5.2
   150      * @param aNewInterval new interval to be taken into use
   133      * @param aNewInterval new interval to be taken into use
   151      * @param aStatus Status of the calling active object. On successful
   134      * @param aStatus Status of the calling active object. On successful
   152      *                completion contains KErrNone, otherwise one of the
   135      *                completion contains KErrNone, otherwise one of the
   170      * interval change request is processed.
   153      * interval change request is processed.
   171      * @param aNewInterval new interval to be taken into use
   154      * @param aNewInterval new interval to be taken into use
   172      */
   155      */
   173     void DoSetInterval( TUint32 aNewInterval );
   156     void DoSetInterval( TUint32 aNewInterval );
   174     
   157     
       
   158     /**
       
   159      * This method is called by the command queue when
       
   160      * AWS startup has been completed.
       
   161      * 
       
   162      * @since S60 v5.2
       
   163      */
       
   164     void AwsStartupComplete( TInt aStatus );
       
   165     
       
   166     /**
       
   167      * This method is called by the command queue when
       
   168      * AWS command has been completed.
       
   169      * 
       
   170      * @param aCommand completed command
       
   171      * @param aStatus completion code of the command
       
   172      * 
       
   173      * @since S60 v5.2
       
   174      */
       
   175     void AwsCommandComplete( MWlanBgScanAwsComms::TAwsCommand& aCommand, TInt aStatus );
       
   176     
       
   177     /**
       
   178      * Send AWS command
       
   179      * 
       
   180      * @param aCommand command to be sent
       
   181      * 
       
   182      * @since S60 v5.2
       
   183      */
       
   184     void AwsCommand( MWlanBgScanAwsComms::TAwsMessage& aCommand );
       
   185     
       
   186     /**
       
   187      * AWS presence status.
       
   188      *
       
   189      * @since S60 v5.2
       
   190      * @return EAwsPresent if AWS is available,
       
   191      *         EAwsNotPresent if AWS is not available,
       
   192      *         EAwsStarting if AWS is still starting up 
       
   193      *         
       
   194      */
       
   195     CWlanBgScan::TAwsPresence AwsPresence();
       
   196     
       
   197     /**
       
   198      * Request callback when interval change should take place.
       
   199      *
       
   200      * @since S60 v5.2
       
   201      */
       
   202     void ScheduleAutoIntervalChange();
       
   203     
       
   204     /**
       
   205      * Get current Auto Background Scan interval.
       
   206      *
       
   207      * @since S60 v5.2
       
   208      * 
       
   209      * @return interval
       
   210      */
       
   211     TUint32 CurrentAutoInterval();
       
   212   
       
   213     /**
       
   214      * Start aggressive background scanning.
       
   215      *
       
   216      * @since S60 v5.2
       
   217      * @param aInterval scan interval for aggressive mode, in seconds
       
   218      * @param aTimeout aggressive mode duration, in microseconds
       
   219      */
       
   220     void StartAggressiveBgScan( TUint32& aInterval, TUint32& aTimeout );
       
   221 
   175 private:
   222 private:
   176     
   223     
   177     /**
   224     /**
   178      * Constructor.
   225      * Constructor.
   179      */
   226      */
   180     CWlanBgScan( MWlanScanResultProvider& aProvider, CWlanTimerServices& aTimerServices  );
   227     CWlanBgScan( MWlanScanResultProvider& aProvider, MWlanTimerServices& aTimerServices );
       
   228     
       
   229     /**
       
   230      * Default constructor, no implementation.
       
   231      */
       
   232     CWlanBgScan();
   181     
   233     
   182     /**
   234     /**
   183      * Two-phased constructor.
   235      * Two-phased constructor.
   184      */
   236      */
   185     void ConstructL();
   237     void ConstructL();
   186         
   238         
   187     /**
       
   188      * Main state machine
       
   189      *
       
   190      * @since S60 v5.2
       
   191      * @param aNewBgScanSetting new background scan setting to be taken into use
       
   192      */
       
   193     void NextState( TUint32 aNewBgScanSetting );
       
   194     
       
   195     /**
       
   196      * State machine for Off state
       
   197      *
       
   198      * @since S60 v5.2
       
   199      * @param aState reference to state
       
   200      * @param aNewInterval new background scan setting to be taken into use
       
   201      */
       
   202     void InStateOff( TWlanBgScanState& aState, TUint32 aNewBgScanSetting );
       
   203     
       
   204     /**
       
   205      * State machine for On state
       
   206      *
       
   207      * @since S60 v5.2
       
   208      * @param aState reference to state
       
   209      * @param aNewBgScanSetting new background scan setting to be taken into use
       
   210      */
       
   211     void InStateOn( TWlanBgScanState& aState, TUint32 aNewBgScanSetting );
       
   212 
       
   213     /**
       
   214      * State machine for Auto state
       
   215      *
       
   216      * @since S60 v5.2
       
   217      * @param aState reference to state
       
   218      * @param aNewBgScanSetting new background scan setting to be taken into use
       
   219      */
       
   220     void InStateAuto( TWlanBgScanState& aState, TUint32 aNewBgScanSetting );
       
   221     
       
   222     /**
       
   223      * State machine for Auto with AWS state
       
   224      *
       
   225      * @since S60 v5.2
       
   226      * @param aState reference to state
       
   227      * @param aNewBgScanSetting new background scan setting to be taken into use
       
   228      */
       
   229     void InStateAutoAws( TWlanBgScanState& aState, TUint32 aNewBgScanSetting );
       
   230     
       
   231     /**
       
   232      * Request callback when interval change should take place.
       
   233      *
       
   234      * @since S60 v5.2
       
   235      */
       
   236     void ScheduleAutoIntervalChange();
       
   237     
       
   238     /**
       
   239      * Get current Auto Background Scan interval.
       
   240      *
       
   241      * @since S60 v5.2
       
   242      * 
       
   243      * @return interval
       
   244      */
       
   245     TUint32 CurrentAutoInterval();
       
   246     
       
   247     /**
       
   248      * Get current interval.
       
   249      *
       
   250      * @since S60 v5.2
       
   251      * @return current interval in use
       
   252      */
       
   253     TUint32 GetInterval();
       
   254     
       
   255     /**
       
   256      * Set current interval.
       
   257      *
       
   258      * @param aInterval interval to take into use
       
   259      * @since S60 v5.2
       
   260      */
       
   261     void SetInterval( TUint32 aInterval );
       
   262     
       
   263     /**
   239     /**
   264      * Get next time when to change Auto interval.
   240      * Get next time when to change Auto interval.
   265      *
   241      *
   266      * @since S60 v5.2
   242      * @since S60 v5.2
   267      * 
   243      * 
   279      * @since S60 v5.2
   255      * @since S60 v5.2
   280      */
   256      */
   281     TRelation TimeRelationToRange( const TTime& aTime, TUint aRangeStart, TUint aRangeEnd ) const;
   257     TRelation TimeRelationToRange( const TTime& aTime, TUint aRangeStart, TUint aRangeEnd ) const;
   282     
   258     
   283     /**
   259     /**
   284      * Deliver new background interval.
       
   285      *
       
   286      * @since S60 v5.2
       
   287      * 
       
   288      * @param aNewInterval new interval to be taken into use
       
   289      */
       
   290     void IntervalChanged( TUint32 aNewInterval );
       
   291     
       
   292     /**
       
   293      * Is AWS present in system.
       
   294      *
       
   295      * @since S60 v5.2
       
   296      * @return ETrue if background scan is enabled,
       
   297      *         EFalse otherwise.
       
   298      */
       
   299     TBool IsAwsPresent();
       
   300     
       
   301     /**
       
   302      * Check the proposed settings are valid.
   260      * Check the proposed settings are valid.
   303      *
   261      *
   304      * @since S60 v5.2
   262      * @since S60 v5.2
   305      *
   263      *
   306      * @param aSettingsToUse settings that can be used [OUT]
   264      * @param aSettingsToUse settings that can be used [OUT]
   325      * Reference to the Scan Result Provider
   283      * Reference to the Scan Result Provider
   326      */
   284      */
   327     MWlanScanResultProvider& iProvider;
   285     MWlanScanResultProvider& iProvider;
   328     
   286     
   329     /**
   287     /**
   330      * Actually used interval for backgroundscan. 
   288      * Interface to AWS comms object. 
   331      */
   289      */
   332     TUint32 iCurrentBgScanInterval;
   290     MWlanBgScanAwsComms* iAwsComms;
   333     
       
   334     /**
       
   335      * Reference to BgScan <-> AWS communications object. 
       
   336      */
       
   337     CWlanBgScanAwsComms* iAwsComms;
       
   338     
       
   339     /**
       
   340      * Current background scan state. 
       
   341      */
       
   342     TWlanBgScanState iBgScanState;
       
   343     
   291     
   344     /**
   292     /**
   345      * Current Auto period. 
   293      * Current Auto period. 
   346      */
   294      */
   347     TWlanBgScanAutoPeriod iAutoPeriod;
   295     TWlanBgScanAutoPeriod iAutoPeriod;
   348     
   296     
   349     /**
   297     /**
   350      * Reference to WLAN Timer services. 
   298      * Whether AWS is ok or not. 
   351      */
   299      */
   352     CWlanTimerServices& iTimerServices;
   300     TBool iAwsOk;
   353 
   301     
   354     /**
   302     /**
   355      * Id of the timer service request regarding 
   303      * Current PSM server mode. 
   356      * background scan interval change.
   304      */
   357      */
   305     TUint iCurrentPsmServerMode;
   358     TUint iIntervalChangeRequestId;
   306             
   359 
       
   360     /**
       
   361      * Background scan peak start time.
       
   362      */
       
   363     TUint iBgScanPeakStartTime;
       
   364     
       
   365     /**
       
   366      * Background scan peak end time.
       
   367      */
       
   368     TUint iBgScanPeakEndTime;
       
   369     
       
   370     /**
       
   371      * Peak time interval.
       
   372      */
       
   373     TUint iBgScanIntervalPeak;
       
   374     
       
   375     /**
       
   376      * Off-peak time interval.
       
   377      */
       
   378     TUint iBgScanIntervalOffPeak;
       
   379         
       
   380     };
   307     };
   381 
   308 
   382 #endif // WLANBGSCAN_H
   309 #endif // WLANBGSCAN_H