wlan_bearer/wlanldd/wlan_common/umac_common/inc/umacsignalpredictor.h
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:   Declaration of the TWlanSignalPredictor class.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 7 %
       
    20 */
       
    21 
       
    22 #ifndef WLANSIGNALPREDICTOR_H
       
    23 #define WLANSIGNALPREDICTOR_H
       
    24 
       
    25 #ifndef RD_WLAN_DDK
       
    26 #include <wha_types.h>
       
    27 #else
       
    28 #include <wlanwha_types.h>
       
    29 #endif
       
    30 
       
    31 /**
       
    32  *  Signal Level Predictor machine.
       
    33  *
       
    34  *  @lib wlanumac.lib
       
    35  *  @since S60 v3.2
       
    36  */
       
    37 class WlanSignalPredictor
       
    38     {
       
    39 
       
    40 public:
       
    41 
       
    42     /**
       
    43      * Constructor.
       
    44      */
       
    45     WlanSignalPredictor();
       
    46 
       
    47     /**
       
    48      * Destructor.
       
    49      */
       
    50     inline ~WlanSignalPredictor();
       
    51 
       
    52     /**
       
    53      * Starts the Signal Predictor.
       
    54      * If signal predictor is stopped, Start command will start it.
       
    55      * By default it is started.
       
    56      * @since S60 v3.2
       
    57      */    
       
    58     inline void Start();
       
    59 
       
    60     /**
       
    61      * Stops the Signal Predictor.
       
    62      *
       
    63      * @since S60 v3.2
       
    64      */    
       
    65     inline void Stop();
       
    66 
       
    67     /**
       
    68      * Configure the Signal Predictor operation.
       
    69      *
       
    70      * Note! If given param is 0, then old value remains.
       
    71      * @since S60 v3.2
       
    72      * @param aTimeToWarnLevel Specifies the time (in microseconds)
       
    73      *        how far into the future signal prediction is done.
       
    74      * @param aTimeToNextInd The minimum time difference (in 
       
    75      *        microseconds) between two signal loss prediction indications.
       
    76      * @param aRcpiWarnLevel If this RCPI level is predicted to be
       
    77      *        reached within the time specified by aSpTimeToCountPrediction,
       
    78      *        a signal loss prediction indication is sent. 
       
    79      */
       
    80     void ConfigureSignalPredictor( 
       
    81         TUint32    aTimeToWarnLevel,
       
    82         TUint32    aTimeToNextInd,
       
    83         WHA::TRcpi aRcpiWarnLevel );
       
    84 
       
    85     /**
       
    86      * Insert new rcpi information into the Signal Predictor.
       
    87      *
       
    88      * @since S60 v3.2
       
    89      * @param aTimestamp 32-bit timestamp in microseconds.  
       
    90      * @param aRcpi rcpi value from HW
       
    91      * @return ETrue if signal loss prediction indication should be sent
       
    92      */
       
    93     TBool InsertNewRcpi( 
       
    94         TUint32    aTimestamp, 
       
    95         WHA::TRcpi aRcpi ); 
       
    96 
       
    97     /**
       
    98      * Get the latest median value from Signal Predictor.
       
    99      *
       
   100      * @since S60 v3.2
       
   101      * @param aTimestamp 32-bit timestamp in milliseconds.  
       
   102      * @param aLatestMedian reference to the median.
       
   103      * @return Boolean about if median value is available. 
       
   104      */
       
   105     TBool GetLatestMedian( 
       
   106         TUint32 aTimestamp,
       
   107         TUint8& aLatestMedian ) const;
       
   108 
       
   109     /**
       
   110      * Get the latest rcpi from Signal Predictor.
       
   111      *
       
   112      * @since S60 v3.2
       
   113      * @param aTimestamp 32-bit timestamp in milliseconds.  
       
   114      * @param aLatestRcpi reference to the rcpi.
       
   115      * @return Boolean about if rcpi value is available. 
       
   116      */    
       
   117     TBool GetLatestRcpi( 
       
   118         TUint32 aTimestamp,
       
   119         TUint8& aLatestRcpi );
       
   120 
       
   121 protected:
       
   122 
       
   123     /**
       
   124      * Checks if there are too old values in rcpi table.
       
   125      *
       
   126      * @since S60 v3.2
       
   127      * @param aTimestamp 32-bit timestamp in milliseconds.  
       
   128      */    
       
   129     void RemoveOldValues( 
       
   130         TUint32 aTimestamp );
       
   131     
       
   132     /**
       
   133      * removes an old value from rcpi table.
       
   134      *
       
   135      * @since S60 v3.2
       
   136      * @param aIndex Index of rcpi to be removed from rcpi table.
       
   137      */    
       
   138     void RemoveValue( 
       
   139         TUint8 aIndex );
       
   140     
       
   141     /**
       
   142      * Inserts new median value into median table.
       
   143      *
       
   144      * @since S60 v3.2
       
   145      * @param aTimestamp 32-bit timestamp in milliseconds.  
       
   146      * @param aMedian a new median value.
       
   147      * @return ETrue if signal loss prediction indication should be sent
       
   148      */    
       
   149     TBool InsertMedian( 
       
   150         TUint32 aTimestamp, 
       
   151         TUint8  aMedian );
       
   152     
       
   153     /**
       
   154      * Inserts new rcpi value into rcpi table.
       
   155      *
       
   156      * @since S60 v3.2
       
   157      * @param aTimestamp 32-bit timestamp in milliseconds.  
       
   158      * @param aRcpi a new rcpi value.
       
   159      * @return ETrue if signal loss prediction indication should be sent
       
   160      */    
       
   161     TBool InsertValue( 
       
   162         TUint32    aTimestamp, 
       
   163         WHA::TRcpi aRcpi );
       
   164     
       
   165     /**
       
   166      * Count the current median from the rcpi table.
       
   167      *
       
   168      * @since S60 v3.2
       
   169      * @return Current median value. 
       
   170      */    
       
   171     TUint8 GetCurrentMedian() const;
       
   172     
       
   173     /**
       
   174      * Counts the estimation about the signal behaviour.
       
   175      *
       
   176      * @since S60 v3.2
       
   177      * @return ETrue if signal loss prediction indication should be sent
       
   178      */    
       
   179     TBool GetPrediction();
       
   180     
       
   181     /**
       
   182      * Get the time interval between old and new times.
       
   183      *
       
   184      * @since S60 v3.2.
       
   185      * @param aOldTime 32-bit timestamp in milliseconds.
       
   186      * @param aNewTime 32-bit timestamp in milliseconds.
       
   187      * @return Time interval  in milliseconds.
       
   188      */    
       
   189     TUint32 Delay(
       
   190         TUint32 aOldTime, 
       
   191         TUint32 aNewTime ) const;
       
   192 
       
   193 private:
       
   194    
       
   195     struct TValue  /* value info element */
       
   196         {
       
   197         TUint32    iTimestamp; /* timestamp */
       
   198         TUint8     iPrev;      /* next smaller rcpi value */
       
   199         TUint8     iNext;      /* next bigger  rcpi value */
       
   200         WHA::TRcpi iRcpi;      /* rcpi value */
       
   201         TUint8     iPad;       /* padding byte */
       
   202         };
       
   203 
       
   204     struct TLastRoam /* roaming info element */
       
   205         {
       
   206         TUint32 iTimestamp;/* timestamp */
       
   207         TBool   iDone;     /* valid or not */
       
   208         };
       
   209 
       
   210     /**
       
   211     * Only one iten
       
   212     */
       
   213     static const TUint KOneValue = 1;
       
   214 
       
   215     /**
       
   216     * Just dummy data pattern
       
   217     */
       
   218     static const TUint8 KDummy = 0x55;
       
   219 
       
   220     /**
       
   221     * Rcpi table size
       
   222     */
       
   223     static const TUint32 KValueCountMax = 25;
       
   224 
       
   225     /**
       
   226     * Median table size
       
   227     */
       
   228     static const TUint32 KMedianCountMax = 2;
       
   229 
       
   230     /**
       
   231     * Minimum time delay which is needed to accept next rcpi value
       
   232     */
       
   233     static const TUint32 KValueDelay = 10;
       
   234 
       
   235     /**
       
   236     * Minimum time delay which is needed to accept next median value
       
   237     */
       
   238     static const TUint32 KMedianDelay = 35;
       
   239 
       
   240     /**
       
   241     * Window size in milliseconds
       
   242     */
       
   243     static const TUint32 KWindowSizeDefault = 1000;
       
   244 
       
   245     /**
       
   246     * Time to indication sending in milliseconds
       
   247     */
       
   248     static const TUint32 KTimeToIndicationLevel = 1000;
       
   249 
       
   250     /**
       
   251     * Minimum time in milliseconds to next signal loss prediction indication sending
       
   252     */
       
   253     static const TUint32 KTimeToNextIndication = 1000;
       
   254 
       
   255     /**
       
   256     * Rcpi level when signal loss prediction indication generated
       
   257     */
       
   258     static const TUint8 KRoamLevel = 80;
       
   259 
       
   260     /**
       
   261     * Rcpi level above which, the indication is not sent
       
   262     */
       
   263     static const TUint8 KDiffRoamLevel = 120;
       
   264 
       
   265     /**
       
   266     * Minimum count of rcpi values to get signal loss prediction
       
   267     */
       
   268     static const TUint8 KMinValueCountForPrediction = 10;
       
   269 
       
   270     /**
       
   271     *  rcpi table 
       
   272     */
       
   273     TValue iLevelTable[ KValueCountMax ];
       
   274 
       
   275     /**
       
   276     *  median table 
       
   277     */
       
   278     TValue iMedianTable[ KMedianCountMax ];
       
   279     
       
   280     /**
       
   281     *  time interval to the indication level in milliseconds 
       
   282     */
       
   283     TUint32 iTimeToWarnLevel;
       
   284 
       
   285     /**
       
   286     *  observation time interval in milliseconds 
       
   287     */
       
   288     TUint32 iWindowSize;
       
   289 
       
   290     /**
       
   291     *  minimum time interval between two signal loss prediction 
       
   292     *  indications, in milliseconds 
       
   293     */
       
   294     TUint32 iTimeToNextInd;
       
   295     
       
   296     /**
       
   297     *  level when roam indication in generated 
       
   298     */
       
   299     TUint8 iWarningLevel;
       
   300     
       
   301     /**
       
   302     *  rcpi count in the rcpi table 
       
   303     */
       
   304     TUint8 iValueCount;
       
   305     
       
   306     /**
       
   307     *  median count in the median table 
       
   308     */
       
   309     TUint8 iMedianCount;
       
   310     
       
   311     /**
       
   312     *  index of the latest median item in the median table 
       
   313     */
       
   314     TUint8 iLatestMedian;
       
   315     
       
   316     /**
       
   317     *  index of the latest rcpi item in the rcpi table 
       
   318     */
       
   319     TUint8 iOldestValue;
       
   320     
       
   321     /**
       
   322     *  index of the latest rcpi item in the rcpi table 
       
   323     */
       
   324     TUint8 iLatestValue;
       
   325     
       
   326     /**
       
   327     *  index of the least rcpi item in the rcpi table 
       
   328     */
       
   329     TUint8 iLeastRcpi;
       
   330     
       
   331     /**
       
   332     *  index of the biggest rcpi item in the rcpi table 
       
   333     */
       
   334     TUint8 iMaxRcpi;
       
   335 
       
   336     /**
       
   337     *  Used value count, max value is KValueCountMax 
       
   338     */
       
   339     TUint8 iValueCountMax;
       
   340 
       
   341     /**
       
   342     *  Used value count, max value is KValueCountMax 
       
   343     */
       
   344     TUint8 iMinValueCountForPrediction;
       
   345 
       
   346     /**
       
   347     *  State information */
       
   348     TBool iRunning;
       
   349 
       
   350     /**
       
   351     *  Last signal loss prediction indication info 
       
   352     */
       
   353     TLastRoam iRoamed;
       
   354     };
       
   355 
       
   356 #include "umacsignalpredictor.inl"
       
   357 
       
   358 #endif // WLANSIGNALPREDICTOR_H