|
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 // INCLUDE FILES |
|
21 #include "dpdef.h" // dataport definitions |
|
22 #include <pipeisi.h> // isi pipe |
|
23 #include "pep_comm_types.h" // structures for isi-message interface |
|
24 |
|
25 #include "dpdataport.h" // dataport main and c32 interface |
|
26 #include "dpbreak.h" // break handling |
|
27 #include "dpdataconfig.h" // configuration store |
|
28 #include "dpdatabuffer.h" // base class for rx and tx buffers |
|
29 #include "dpmif.h" // message interface |
|
30 #include "dppif.h" // pipe interface |
|
31 #include "dplog.h" // dataport logging |
|
32 |
|
33 #include <pipe_sharedisi.h> |
|
34 #include "osttracedefinitions.h" |
|
35 #ifdef OST_TRACE_COMPILER_IN_USE |
|
36 #include "dpbreaktraces.h" |
|
37 #endif |
|
38 |
|
39 |
|
40 // LOCAL FUNCTION PROTOTYPES |
|
41 // none |
|
42 |
|
43 // ================= MEMBER FUNCTIONS ======================= |
|
44 |
|
45 // --------------------------------------------------------- |
|
46 // CDpBreak::CDpBreak |
|
47 // C++ default constructor. |
|
48 // |
|
49 // --------------------------------------------------------- |
|
50 CDpBreak::CDpBreak( |
|
51 CDpDataPort& aDataPort ) : |
|
52 iDataPort( aDataPort ), |
|
53 iRx( iDataPort.Rx() ), |
|
54 iBreakNotify( EFalse ) |
|
55 { |
|
56 OstTrace0( TRACE_NORMAL, CDPBREAK_CDPBREAK, "CDpBreak::CDpBreak" ); |
|
57 LOGM(" CDpBreak::CDpBreak"); |
|
58 |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------- |
|
62 // CDpBreak::~CDpBreak |
|
63 // Destructor |
|
64 // --------------------------------------------------------- |
|
65 CDpBreak::~CDpBreak() |
|
66 { |
|
67 OstTrace0( TRACE_NORMAL, DUP1_CDPBREAK_CDPBREAK, "CDpBreak::~CDpBreak" ); |
|
68 LOGM(" CDpBreak::~CDpBreak"); |
|
69 |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // CDpBreak::InitL |
|
74 // This method initializes member variables |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 void CDpBreak::Init() |
|
78 { |
|
79 OstTrace0( TRACE_NORMAL, CDPBREAK_INIT, "CDpBreak::Init" ); |
|
80 LOGM(" CDpBreak::Init"); |
|
81 |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------- |
|
85 // CDpBreak::CompleteBreakNotify |
|
86 // Break signal has been received from DCS and now we inform |
|
87 // the client about that by completing the nofify request. |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 TInt CDpBreak::CompleteBreakNotify() |
|
91 { |
|
92 OstTrace0( TRACE_NORMAL, CDPBREAK_COMPLETEBREAKNOTIFY, "CDpBreak::CompleteBreakNotify" ); |
|
93 LOGM(" CDpBreak::CompleteBreakNotify"); |
|
94 |
|
95 TUint8 signalType( iDataPort.DataConfig().DteTypeOfBreakSignal() ); |
|
96 TInt ret( KErrNone ); |
|
97 |
|
98 switch ( signalType ) |
|
99 { |
|
100 case PEP_COMM_BREAK_DESTRUCT: |
|
101 { |
|
102 // Send break to client, clear DTE transmit buffers |
|
103 iDataPort.BreakNotifyCompleted( KErrNone ); |
|
104 SetBreakNotify( EFalse ); |
|
105 iRx.Flush(); |
|
106 break; |
|
107 } |
|
108 case PEP_COMM_BREAK_EXPEDITED: |
|
109 { |
|
110 // Send break, then data |
|
111 iDataPort.BreakNotifyCompleted( KErrNone ); |
|
112 SetBreakNotify( EFalse ); |
|
113 break; |
|
114 } |
|
115 case PEP_COMM_BREAK_NON_EXPEDITED: |
|
116 { |
|
117 // Send all RX data buffered before break, then break |
|
118 iDataPort.SetRxBreakBytes( iRx.UsedBytes() ); |
|
119 break; |
|
120 } |
|
121 default: |
|
122 { |
|
123 LOG1(" ERROR - Unsupported break signal type: %d in Break::CompleteBreakNotify", |
|
124 signalType ); |
|
125 OstTraceExt1( TRACE_NORMAL, DUP1_CDPBREAK_COMPLETEBREAKNOTIFY, "CDpBreak:: ERROR - Unsupported break signal type: %hhu in Break::CompleteBreakNotify", signalType ); |
|
126 ret = KErrGeneral; |
|
127 } |
|
128 } |
|
129 |
|
130 return ret; |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------- |
|
134 // CDpBreak::GetBreakNotify |
|
135 // CDpCommPep::HandlePepStatusInd() method uses this to find |
|
136 // out, are we requested to notify the client about incoming |
|
137 // (DCS->Client) break signal. |
|
138 // --------------------------------------------------------- |
|
139 // |
|
140 void CDpBreak::GetBreakNotify( |
|
141 TBool& aBreakNotify ) const |
|
142 { |
|
143 OstTrace0( TRACE_NORMAL, CDPBREAK_GETBREAKNOTIFY, "CDpBreak::GetBreakNotify" ); |
|
144 LOGM(" CDpBreak::GetBreakNotify"); |
|
145 |
|
146 aBreakNotify = iBreakNotify; |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------- |
|
150 // CDpBreak::SetBreakNotify |
|
151 // This method sets break notify status active or deactive. |
|
152 // Break notify status indicates, whether a received break |
|
153 // signal must be notified to the client. |
|
154 // --------------------------------------------------------- |
|
155 // |
|
156 void CDpBreak::SetBreakNotify( |
|
157 const TBool aBreakNotify ) |
|
158 { |
|
159 OstTrace0( TRACE_NORMAL, CDPBREAK_SETBREAKNOTIFY, "CDpBreak::SetBreakNotify" ); |
|
160 LOGM(" CDpBreak::SetBreakNotify"); |
|
161 |
|
162 iBreakNotify = aBreakNotify; |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------- |
|
166 // CDpDataPort::SendBreak |
|
167 // This method sends break to DCS. This method is called from |
|
168 // CDpDataPort::Break() and CDpTx2Pn::HandleReturnValueL(). |
|
169 // NOTE: This method does not complete client's break request |
|
170 // --------------------------------------------------------- |
|
171 // |
|
172 TInt CDpBreak::SendBreak() |
|
173 { |
|
174 OstTrace0( TRACE_NORMAL, CDPBREAK_SENDBREAK, "CDpBreak::SendBreak" ); |
|
175 LOGM(" CDpBreak::SendBreak"); |
|
176 |
|
177 // Create PNS_PEP_STATUS_IND : PEP_COMM_IND_ID_BREAK message |
|
178 TBuf8<SIZE_PNS_PEP_STATUS_IND> messageData; |
|
179 // Pipe Handle |
|
180 messageData.Append( iDataPort.Pif().PipeHandle() ); |
|
181 // PEP Type |
|
182 messageData.Append( PN_PEP_TYPE_COMM ); |
|
183 // Indication ID |
|
184 messageData.Append( PEP_COMM_IND_ID_BREAK ); |
|
185 // Filler bytes |
|
186 messageData.Append( KDpPadding ); |
|
187 messageData.Append( KDpPadding ); |
|
188 |
|
189 // Send message |
|
190 #ifdef _DEBUG |
|
191 TInt ret = |
|
192 #endif |
|
193 iDataPort.Mif().SendMessage( |
|
194 PN_PIPE, |
|
195 iDataPort.CreateTransactionId(), |
|
196 PNS_PEP_STATUS_IND, |
|
197 messageData ); |
|
198 |
|
199 LOG(" <== PNS_PEP_STATUS_IND sent (PEP_COMM_IND_ID_BREAK)"); |
|
200 OstTrace0( TRACE_NORMAL, DUP1_CDPBREAK_SENDBREAK, "CDpBreak:: <== PNS_PEP_STATUS_IND sent (PEP_COMM_IND_ID_BREAK)" ); |
|
201 |
|
202 |
|
203 #ifdef _DEBUG |
|
204 if ( KErrNone != ret ) |
|
205 { |
|
206 LOG1("Error isc api send %d", ret ); |
|
207 OstTrace1( TRACE_NORMAL, DUP2_CDPBREAK_SENDBREAK, "CDpBreak:: Error isc api send %d", ret ); |
|
208 |
|
209 } |
|
210 // no else |
|
211 #endif |
|
212 |
|
213 return KErrNone; |
|
214 } |
|
215 |
|
216 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
217 // none |
|
218 |
|
219 // End of File |