adaptationlayer/tsy/nokiatsy_dll/inc/cmmdatautility.h
changeset 0 63b37f68c1ce
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CMMDATAUTILITY_H
       
    21 #define CMMDATAUTILITY_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <etelmm.h>
       
    25 #include "nokia_csd_defs.h"
       
    26 
       
    27 // CONSTANTS  
       
    28 // Min length of response from modem
       
    29 const TInt KMinModemRespLength = 2;
       
    30 
       
    31 // Carriage Return
       
    32 const TInt KCarriageReturn = 13;
       
    33 
       
    34 // Line Feed
       
    35 const TInt KLineFeed = 10;
       
    36 
       
    37 // MACROS  
       
    38     // none
       
    39 
       
    40 // DATA TYPES  
       
    41     // none
       
    42 
       
    43 // EXTERNAL DATA STRUCTURES  
       
    44     // none
       
    45 
       
    46 // FUNCTION PROTOTYPES  
       
    47     // none
       
    48 
       
    49 // FORWARD DECLARATIONS
       
    50 class CMmDataPortHandler;
       
    51 
       
    52 /**
       
    53 * Dataport writer Active object for writing AT commands to modem
       
    54 */
       
    55 class CDataPortWriter : public CActive
       
    56     {
       
    57     
       
    58     public: // Constructors and destructor
       
    59 
       
    60         /**
       
    61         * Two-phased constructor.
       
    62         * @param CMmDataPortHandler* aMmDataPortHandler: pointer to the dataport handler
       
    63         * @param RComm& aDataPort: Reference to the dataport
       
    64         * @return CDataPortWriter*: pointer to the dataport writer
       
    65         */
       
    66         static CDataPortWriter* NewL(
       
    67             CMmDataPortHandler* aMmDataPortHandler, 
       
    68             const RComm& aDataPort );
       
    69 
       
    70         /**
       
    71         * Destructor.
       
    72         */
       
    73         ~CDataPortWriter();
       
    74 
       
    75     public: // New functions
       
    76 
       
    77         /**
       
    78         * Wakes DP up with NULL string.
       
    79         */
       
    80         void Init();
       
    81 
       
    82         /**
       
    83         * Returns AT command enum buffer for sent AT commands.
       
    84         * @return CArrayFixFlat<TUint>* iAtCommandBuffer
       
    85         */
       
    86         CArrayFixFlat<TUint>* GetAtBuffer();
       
    87 
       
    88         /**
       
    89         * Writes AT commands into dataport.
       
    90         * @param TDesC8& aData: AT command
       
    91         * @param TAtCommand aCommand: AT command enum
       
    92         */
       
    93         void Write( const TDesC8& aData, TLastAtCommandSent aCommand );
       
    94 
       
    95         /**
       
    96         * Writes next AT command.
       
    97         */
       
    98         void WriteNextL();
       
    99     
       
   100         /**
       
   101         * Blocks writing to dataport.
       
   102         */
       
   103         void BlockWrite();
       
   104 
       
   105     public: // Functions from base classes
       
   106         //none
       
   107 
       
   108     protected: // New functions        
       
   109         //none
       
   110 
       
   111     protected: // Functions from base classes
       
   112         //none
       
   113 
       
   114     private: // New functions
       
   115 
       
   116         /**
       
   117         * Constructor.
       
   118         */
       
   119         CDataPortWriter();
       
   120 
       
   121         /**
       
   122         * Class attributes are created in ConstructL.
       
   123         */
       
   124         void ConstructL();
       
   125 
       
   126         /**
       
   127         * Appends AT command enum into iAtCommandBuffer.
       
   128         * @param TAtCommand aCommand: AT command enum
       
   129         */
       
   130         void AppendCommandL( TLastAtCommandSent aCommand );
       
   131 
       
   132     private: // Functions from base classes
       
   133 
       
   134         /**
       
   135         * Activates active object when request is completed.
       
   136         */
       
   137         void RunL();
       
   138 
       
   139         /**
       
   140         * When RunL leaves, RunError is called.
       
   141         * @param TInt aError: Error from RunL
       
   142         * @return TInt: KErrNone
       
   143         */
       
   144         TInt RunError( TInt aError );
       
   145 
       
   146         /**
       
   147         * Cancels active object request.
       
   148         */
       
   149         void DoCancel();
       
   150 
       
   151     public: // Data
       
   152         // none
       
   153     
       
   154     protected: // Data
       
   155         // none
       
   156 
       
   157     private: // Data
       
   158 
       
   159         // A pointer to the dataport handler object
       
   160         CMmDataPortHandler* iDataPortHandler;
       
   161     
       
   162         // Is writing continued
       
   163         TBool iContinueWrite;
       
   164     
       
   165         // Is write completed
       
   166         TBool iWriteCompleted;
       
   167     
       
   168         // Dataport handle
       
   169         RComm iDataPort;
       
   170     
       
   171         // FIFO buffer for AT commands
       
   172         CArrayPtrSeg<HBufC8>* iWriteBuffer;
       
   173     
       
   174         // FIFO buffer for AT command enums
       
   175         CArrayFixFlat<TUint>* iAtCommandBuffer;
       
   176     
       
   177         // Internal buffer to write data to DP
       
   178         TPtrC8 iDataToDpPtr;
       
   179     };
       
   180 
       
   181 /**
       
   182 * Dataport reader Active object for reading AT commands and responses from 
       
   183 * modem
       
   184 */
       
   185 class CDataPortReader : public CActive
       
   186     {
       
   187     public: // Constructors and destructor
       
   188         
       
   189         /**
       
   190         * Two-phased constructor.
       
   191         * @param CMmDataPortHandler* aDataPortHandler: Pointer to the dataport handler
       
   192         * @param RComm& aDataPort: Reference to the dataport
       
   193         * @param CDataPortWriter* aDataPortWriter: Pointer to the DP writer
       
   194         * @return CDataPortReader*: pointer to the dataport reader
       
   195         */
       
   196         static CDataPortReader* NewL(
       
   197             CMmDataPortHandler* aMmDataPortHandler,
       
   198             const RComm& aDataPort,
       
   199             CDataPortWriter* aDataPortWriter );
       
   200 
       
   201         /**
       
   202         * Destructor.
       
   203         */
       
   204         ~CDataPortReader();
       
   205 
       
   206     public: // New functions
       
   207 
       
   208         /**
       
   209         * Reads responses from the modem through dataport.
       
   210         */
       
   211         void Read();
       
   212 
       
   213         /**
       
   214         * Reads all data available from the modem through dataport.
       
   215         */
       
   216         void ReadAll();
       
   217 
       
   218         /**
       
   219         * Cancels Read request from the modem through dataport.
       
   220         */
       
   221         void ReadCancel();
       
   222 
       
   223         /**
       
   224         * Modem initialisation completed.
       
   225         */
       
   226         void ModemInitComplete();
       
   227 
       
   228     protected: // New functions
       
   229         //none
       
   230 
       
   231     protected: // Functions from base classes
       
   232         //none
       
   233 
       
   234     private: // New functions
       
   235 
       
   236         /**
       
   237         * Constructor.
       
   238         */
       
   239         CDataPortReader();
       
   240 
       
   241     private: // Functions from base classes
       
   242 
       
   243         /**
       
   244         * Activates active object when request is completed.
       
   245         */
       
   246         void RunL();
       
   247 
       
   248         /**
       
   249         * When RunL leaves, RunError is called.
       
   250         * @param TInt aError: Error from RunL
       
   251         * @return TInt: KErrNone
       
   252         */
       
   253         TInt RunError( TInt aError );
       
   254 
       
   255         /**
       
   256         * Cancels active object request.
       
   257         */
       
   258         void DoCancel();
       
   259 
       
   260     public: // Data
       
   261         // none
       
   262     
       
   263     protected: // Data
       
   264         // none
       
   265 
       
   266     private: // Data
       
   267 
       
   268         // Response from the modem
       
   269         TBuf8<KDataBufLength> iResp;
       
   270     
       
   271         // Is modem initialisation complete
       
   272         TBool iModemInitComplete;
       
   273     
       
   274         // Is reading continued
       
   275         TBool iContinueRead;
       
   276 
       
   277         // A pointer to the dataport handler object
       
   278         CMmDataPortHandler* iDataPortHandler;
       
   279 
       
   280         // Dataport handle
       
   281         RComm iDataPort;
       
   282     
       
   283         // Dataport writer
       
   284         CDataPortWriter* iDataPortWriter;
       
   285     
       
   286         // Used when DP reader should empty RX buffer before new call is made
       
   287         TBool iReaAllComplete;
       
   288 
       
   289     public: // Friend classes
       
   290         // none
       
   291         
       
   292     protected: // Friend classes
       
   293         // none
       
   294         
       
   295     private: // Friend classes
       
   296         // none
       
   297                 
       
   298     };
       
   299 
       
   300 #endif // CMMDATAUTILITY_H
       
   301 
       
   302 // End of File