hti/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommEcomPlugin/inc/HtiBtCommEcomPlugin.h
branchRCL_3
changeset 59 8ad140f3dd41
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     1 /*
       
     2 * Copyright (c) 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 "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:  ECOM plugin to communicate over BT serial port
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CHTIBTCOMMECOMPLUGIN_H
       
    20 #define CHTIBTCOMMECOMPLUGIN_H
       
    21 
       
    22 class CBtSerialClient;
       
    23 
       
    24 // INCLUDES
       
    25 #include <c32comm.h>
       
    26 #include <HtiCommPluginInterface.h> // defined in HtiFramework project
       
    27 
       
    28 #include "HtiBtCommInterface.h" // RHtiBtCommInterface
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CHtiCfg;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 /**
       
    35 * ECOM plugin module for communicating with PC using serial port.
       
    36 *
       
    37 */
       
    38 class CHtiBtCommEcomPlugin :
       
    39     public CHTICommPluginInterface
       
    40     {
       
    41 public:
       
    42 
       
    43     /**
       
    44     * Create instance of plugin.
       
    45     * @return Connected plugin instance.
       
    46     */
       
    47     static CHtiBtCommEcomPlugin* NewL();
       
    48 
       
    49     /**
       
    50     * Destructor
       
    51     */
       
    52     ~CHtiBtCommEcomPlugin();
       
    53 
       
    54 public: // CHTICommPluginInterface interface implementation
       
    55 
       
    56     /**
       
    57     * Receive data from Bluetooth.
       
    58     * The size of supplied buffer must equal to size given by GetBufferSize.
       
    59     * The number of received bytes may be anything between 1 and GetBufferSize.
       
    60     *
       
    61     * @param aRawdataBuf Buffer where the result is written
       
    62     * @param aStatus Request status
       
    63     */
       
    64     void Receive( TDes8& aRawdataBuf, TRequestStatus& aStatus );
       
    65 
       
    66     /**
       
    67     * Send data to Bluetooth. The size of data must not exceed GetBufferSize.
       
    68     * @param aRawdataBuf Buffer where the data is read from.
       
    69     * @param aStatus Request status
       
    70     */
       
    71     void Send( const TDesC8& aRawdataBuf, TRequestStatus& aStatus );
       
    72 
       
    73     /**
       
    74     * Cancel read operation
       
    75     */
       
    76     void CancelReceive();
       
    77 
       
    78     /**
       
    79     * Cancel send operation
       
    80     */
       
    81     void CancelSend();
       
    82 
       
    83     /**
       
    84      *  Return required buffer size for Send operation.
       
    85      */
       
    86     TInt GetSendBufferSize();
       
    87 
       
    88     /**
       
    89      *  Return required buffer size for Receive operation.
       
    90      */
       
    91     TInt GetReceiveBufferSize();
       
    92 
       
    93 private:
       
    94 
       
    95     /**
       
    96     * Constructor of this plugin.
       
    97     */
       
    98     CHtiBtCommEcomPlugin();
       
    99 
       
   100     /**
       
   101     * Second phase construction. Connects the Bluetooth.
       
   102     */
       
   103     void ConstructL();
       
   104 
       
   105     /**
       
   106     * Load configuration file.
       
   107     */
       
   108     void LoadConfigL();
       
   109 
       
   110     /**
       
   111     * Read and parse the configuration values.
       
   112     */
       
   113     void ReadConfig();
       
   114 
       
   115     /**
       
   116      * Parse the possible port (channel) number value from name or address param
       
   117      */
       
   118      TInt ParsePortNumber();
       
   119 
       
   120      /**
       
   121      * StorePortNumberL()
       
   122      * Store the given port number to configuration file
       
   123      * @param aPortNumber the port number to store
       
   124      */
       
   125      void StorePortNumberL( TInt aPortNumber );
       
   126 
       
   127 private: // Data
       
   128 
       
   129     RHtiBtCommInterface iBtCommInterface;
       
   130 
       
   131     CHtiCfg* iCfg;
       
   132     HBufC8*  iBtDeviceNameOrAddress;
       
   133     TInt     iPort;
       
   134 
       
   135     };
       
   136 
       
   137 #endif // CHTIBTCOMMECOMPLUGIN_H