|
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 "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 /******************************************************************************** |
|
21 * |
|
22 * Stat USB Transport |
|
23 * |
|
24 *******************************************************************************/ |
|
25 #ifndef __STATUSB_H__ |
|
26 #define __STATUSB_H__ |
|
27 |
|
28 /******************************************************************************** |
|
29 * |
|
30 * System Includes |
|
31 * |
|
32 *******************************************************************************/ |
|
33 #include <d32usbc.h> |
|
34 |
|
35 /******************************************************************************** |
|
36 * |
|
37 * Local Includes |
|
38 * |
|
39 *******************************************************************************/ |
|
40 #include "filedump.h" |
|
41 #include "../../../../common/inc/SerialPacketSize.h" |
|
42 |
|
43 /******************************************************************************** |
|
44 * |
|
45 * Class |
|
46 * |
|
47 *******************************************************************************/ |
|
48 class CStatApiUsb : public CActive, public MStatNetwork |
|
49 { |
|
50 public: |
|
51 // construction |
|
52 static CStatApiUsb* NewL( void ); |
|
53 CStatApiUsb(); |
|
54 ~CStatApiUsb(); |
|
55 |
|
56 // from MStatNetwork |
|
57 TInt GetPacketSize(); |
|
58 TInt InitialiseL( MNotifyStatTransport *iTransport ); |
|
59 TInt ConnectL( TDesC *aRemoteHost ); |
|
60 TInt RequestSend( TDesC8 *aCommandData, const TUint aDataLength ); |
|
61 TInt RequestReceive( TUint aByteCount ); |
|
62 TInt Disconnect( void ); |
|
63 TInt Release( void ); |
|
64 TText8 *Error( void ); |
|
65 TUint NtoHl( TUint aValue ) const; |
|
66 TUint HtoNl( TUint aValue ) const; |
|
67 void Reset( void ); |
|
68 |
|
69 // from CActive |
|
70 void RunL( void ); |
|
71 void DoCancel( void ); |
|
72 |
|
73 private: |
|
74 void ConstructL(void); |
|
75 |
|
76 void SetStatus( TCommStatus aNewStatus ); |
|
77 |
|
78 // Finalise the initialisation started by a call to InitialiseL. |
|
79 // Called directly by InitialiseL in a synchronous |
|
80 // initialisation; called from RunL in an asynchronous |
|
81 // initialisation (such as USB). |
|
82 TInt OnInitialiseL(TInt resultCode); |
|
83 |
|
84 private: |
|
85 TBool iReEnum; |
|
86 TCommStatus iUsbStatus; |
|
87 TReadWriteStatus iRWStatus; |
|
88 MNotifyStatTransport *iTransport; |
|
89 |
|
90 // Store the packetsize. |
|
91 TInt iMaxPacketSize; |
|
92 |
|
93 //USB interface |
|
94 TUsbcInterfaceInfoBuf ifc; |
|
95 |
|
96 //USB channel |
|
97 RDevUsbcClient iPort; |
|
98 |
|
99 //Timer to wait for device reenumeration |
|
100 RTimer iTimer; |
|
101 |
|
102 typedef enum { EEnum, EWait, EConnect } TConnectingState; |
|
103 |
|
104 TConnectingState iConnectingState; |
|
105 |
|
106 HBufC8 *iBuffer; |
|
107 TInt iLength; |
|
108 |
|
109 }; |
|
110 |
|
111 |
|
112 inline TUint CStatApiUsb::NtoHl( TUint aValue ) const |
|
113 { |
|
114 return ( aValue ); |
|
115 } |
|
116 |
|
117 inline TUint CStatApiUsb::HtoNl( TUint aValue ) const |
|
118 { |
|
119 return ( aValue ); |
|
120 } |
|
121 #endif |