17 |
17 |
18 /** |
18 /** |
19 @file |
19 @file |
20 */ |
20 */ |
21 |
21 |
|
22 |
|
23 #include "OstTraceDefinitions.h" |
|
24 #ifdef OST_TRACE_COMPILER_IN_USE |
|
25 #include "SenderTraces.h" |
|
26 #endif |
|
27 |
22 #include "Sender.h" |
28 #include "Sender.h" |
23 #include "Constants.h" |
29 #include "Constants.h" |
24 #include <es_ini.h> |
30 #include <es_ini.h> |
25 |
31 |
26 |
32 |
27 CSender::CSender(CBcaIoController& aObserver, CBttLogger* aTheLogger, TInt aMaxPacketSise) |
33 CSender::CSender(CBcaIoController& aObserver, TInt aMaxPacketSise) |
28 /** |
34 /** |
29 * Constructor. Performs standard active object initialisation. |
35 * Constructor. Performs standard active object initialisation. |
30 * |
|
31 * @param aObserver Reference to the observer of this state machine |
36 * @param aObserver Reference to the observer of this state machine |
32 */ |
37 */ |
33 : CActive(EPriorityUserInput), |
38 : CActive(EPriorityUserInput), |
34 iObserver(aObserver), |
39 iObserver(aObserver), |
35 iTheLogger(aTheLogger), |
|
36 iMaxPacketSize(aMaxPacketSise) |
40 iMaxPacketSize(aMaxPacketSise) |
37 { |
41 { |
38 // EPriorityUserInput is higher than the default priority but lower than |
42 // EPriorityUserInput is higher than the default priority but lower than |
39 // EPriorityHigh which is used on Receiving (DL having priority), however, |
43 // EPriorityHigh which is used on Receiving (DL having priority), however, |
40 // we want this to be handled in an expedited manner compared to other |
44 // we want this to be handled in an expedited manner compared to other |
41 // active objects in the thread. |
45 // active objects in the thread. |
42 CActiveScheduler::Add(this); |
46 CActiveScheduler::Add(this); |
43 } |
47 } |
44 |
48 |
45 CSender* CSender::NewL(CBcaIoController& aObserver, CBttLogger* aTheLogger, TInt aMaxPacketSise) |
49 CSender* CSender::NewL(CBcaIoController& aObserver, TInt aMaxPacketSise) |
46 /** |
50 /** |
47 * Two-phase constructor. Creates a new CBcaIoController object, performs |
51 * Two-phase constructor. Creates a new CBcaIoController object, performs |
48 * second-phase construction, then returns it. |
52 * second-phase construction, then returns it. |
49 * |
53 * |
50 * @param aObserver The observer, to which events will be reported |
54 * @param aObserver The observer, to which events will be reported |
51 * @param aTheLogger The logging object |
|
52 * @return A newly constructed CBcaIoController object |
55 * @return A newly constructed CBcaIoController object |
53 */ |
56 */ |
54 { |
57 { |
55 CSender* self = new (ELeave) CSender(aObserver, aTheLogger, aMaxPacketSise); |
58 CSender* self = new (ELeave) CSender(aObserver, aMaxPacketSise); |
56 CleanupStack::PushL(self); |
59 CleanupStack::PushL(self); |
57 self->ConstructL(); |
60 self->ConstructL(); |
58 CleanupStack::Pop(self); |
61 CleanupStack::Pop(self); |
59 return self; |
62 return self; |
60 } |
63 } |
83 void CSender::RunL() |
86 void CSender::RunL() |
84 /** |
87 /** |
85 * This method checks if any error occured in the write operation. |
88 * This method checks if any error occured in the write operation. |
86 */ |
89 */ |
87 { |
90 { |
88 _LOG_L1C2(_L8("CSender::RunL [iStatus=%d]"), iStatus.Int()); |
91 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_1, "CSender::RunL [iStatus=%d]", iStatus.Int()); |
89 |
92 |
90 if (iStatus!=KErrNone) |
93 if (iStatus!=KErrNone) |
91 { |
94 { |
92 if(iStatus == KErrNoMemory) |
95 if(iStatus == KErrNoMemory) |
93 { |
96 { |
94 _LOG_L2C1(_L8("WARNING! CSender: Write failed with KErrNoMemory")); |
97 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_2, "WARNING! CSender: Write failed with KErrNoMemory"); |
95 _LOG_L2C1(_L8("WARNING! CSender: Ignoring packet!!!!")); |
98 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_3, "WARNING! CSender: Ignoring packet!!!!"); |
96 // Write operation failed!! Nif will ignore this packet. |
99 // Write operation failed!! Nif will ignore this packet. |
97 iObserver.SendComplete(); |
100 iObserver.SendComplete(); |
98 } |
101 } |
99 else if (iStatus == KErrNotReady) |
102 else if (iStatus == KErrNotReady) |
100 { |
103 { |
101 _LOG_L2C1(_L8("WARNING! CSender: Write failed with KErrNotReady")); |
104 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_4, "WARNING! CSender: Write failed with KErrNotReady"); |
102 _LOG_L2C1(_L8("WARNING! CSender: Ignoring packet!!!!")); |
105 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_5, "WARNING! CSender: Ignoring packet!!!!"); |
103 // Write operation failed!! Nif will ignore this packet. |
106 // Write operation failed!! Nif will ignore this packet. |
104 iObserver.SendComplete(); |
107 iObserver.SendComplete(); |
105 } |
108 } |
106 else |
109 else |
107 { |
110 { |
108 _LOG_L2C1(_L8("ERROR! CSender: Write failed!!!!")); |
111 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_6, "ERROR! CSender: Write failed!!!!"); |
109 // Nif will shut down |
112 // Nif will shut down |
110 iObserver.Stop(iStatus.Int()); |
113 iObserver.Stop(iStatus.Int()); |
111 } |
114 } |
112 return; |
115 return; |
113 } |
116 } |
114 |
117 |
115 else |
118 else |
116 { |
119 { |
117 // The Ip packet was sent successfuly |
120 // The Ip packet was sent successfuly |
118 _LOG_L1C1(_L8("***** CSender: Packet Sent.")); |
121 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_7, "***** CSender: Packet Sent."); |
119 iObserver.SendComplete(); |
122 iObserver.SendComplete(); |
120 } |
123 } |
121 } |
124 } |
122 |
125 |
123 void CSender::DoCancel() |
126 void CSender::DoCancel() |
124 /** |
127 /** |
125 * Cancel active request |
128 * Cancel active request |
126 */ |
129 */ |
127 { |
130 { |
128 _LOG_L1C1(_L8("CSender::DoCancel")); |
131 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_DOCANCEL_1, "CSender::DoCancel"); |
129 |
132 |
130 (iObserver.Bca())->CancelWrite(); |
133 (iObserver.Bca())->CancelWrite(); |
131 } |
134 } |
132 |
135 |
133 void CSender::Send(RMBufChain& aPdu) |
136 void CSender::Send(RMBufChain& aPdu) |
136 * |
139 * |
137 * @param aPdu The IP packet to be sent. |
140 * @param aPdu The IP packet to be sent. |
138 * @return KStopSending, or KErrArgument if the packet is too large. |
141 * @return KStopSending, or KErrArgument if the packet is too large. |
139 */ |
142 */ |
140 { |
143 { |
141 _LOG_L1C1(_L8("CSender::Send")); |
144 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_SEND_1, "CSender::Send"); |
142 |
145 |
143 // Copy the IP portion of the RMBufChain to the buffer. |
146 // Copy the IP portion of the RMBufChain to the buffer. |
144 iSendBuffer.SetMax(); |
147 iSendBuffer.SetMax(); |
145 aPdu.CopyOut(iSendBuffer, aPdu.First()->Length()); |
148 aPdu.CopyOut(iSendBuffer, aPdu.First()->Length()); |
146 |
149 |