|
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 #include "T_L2CapConfigData.h" |
|
19 #include "T_BTUtil.h" |
|
20 |
|
21 /*@{*/ |
|
22 //Parameters |
|
23 _LIT(KMTUSize, "mtusize"); |
|
24 _LIT(KMRUSize, "mrusize"); |
|
25 _LIT(KSpecified, "specified"); |
|
26 _LIT(KTimer, "timer"); |
|
27 _LIT(KPriority, "priority"); |
|
28 _LIT(KChannelReliability, "reliability"); |
|
29 |
|
30 //Commands |
|
31 _LIT(KCmdTL2CapConfig, "TL2CapConfig"); |
|
32 _LIT(KCmdSetMaxTransmitUnitSize, "SetMaxTransmitUnitSize"); |
|
33 _LIT(KCmdMaxTransmitUnitSize, "MaxTransmitUnitSize"); |
|
34 _LIT(KCmdSetMaxReceiveUnitSize, "SetMaxReceiveUnitSize"); |
|
35 _LIT(KCmdMaxReceiveUnitSize, "MaxReceiveUnitSize"); |
|
36 _LIT(KCmdConfigureReliableChannel, "ConfigureReliableChannel"); |
|
37 _LIT(KCmdConfigureUnreliableChannel, "ConfigureUnreliableChannel"); |
|
38 _LIT(KCmdChannelReliability, "ChannelReliability"); |
|
39 _LIT(KCmdConfigureChannelPriority, "ConfigureChannelPriority"); |
|
40 _LIT(KCmdChannelPriority, "ChannelPriority"); |
|
41 |
|
42 // Logging |
|
43 _LIT(KLogMissingParameters, "Missing parameters '%S' or '%S'"); |
|
44 _LIT(KLogMissingParameter, "Missing parameter '%S'"); |
|
45 /*@}*/ |
|
46 |
|
47 ////////////////////////////////////////////////////////////////////// |
|
48 // Construction/Destruction |
|
49 ////////////////////////////////////////////////////////////////////// |
|
50 |
|
51 CT_L2CapConfigData* CT_L2CapConfigData::NewL() |
|
52 { |
|
53 CT_L2CapConfigData* ret=new (ELeave) CT_L2CapConfigData(); |
|
54 CleanupStack::PushL(ret); |
|
55 ret->ConstructL(); |
|
56 CleanupStack::Pop(ret); |
|
57 return ret; |
|
58 } |
|
59 |
|
60 |
|
61 CT_L2CapConfigData::CT_L2CapConfigData() |
|
62 : iData(NULL) |
|
63 { |
|
64 } |
|
65 |
|
66 |
|
67 void CT_L2CapConfigData::ConstructL() |
|
68 { |
|
69 } |
|
70 |
|
71 |
|
72 CT_L2CapConfigData::~CT_L2CapConfigData() |
|
73 { |
|
74 DestroyData(); |
|
75 } |
|
76 |
|
77 TAny* CT_L2CapConfigData::GetObject() |
|
78 { |
|
79 return iData; |
|
80 } |
|
81 |
|
82 void CT_L2CapConfigData::SetObjectL(TAny* aAny) |
|
83 { |
|
84 DestroyData(); |
|
85 iData = static_cast<TL2CapConfig*> (aAny); |
|
86 } |
|
87 |
|
88 |
|
89 void CT_L2CapConfigData::DisownObjectL() |
|
90 { |
|
91 iData = NULL; |
|
92 } |
|
93 |
|
94 |
|
95 void CT_L2CapConfigData::DestroyData() |
|
96 { |
|
97 delete iData; |
|
98 iData=NULL; |
|
99 } |
|
100 |
|
101 inline TCleanupOperation CT_L2CapConfigData::CleanupOperation() |
|
102 { |
|
103 return CleanupOperation; |
|
104 } |
|
105 |
|
106 void CT_L2CapConfigData::CleanupOperation(TAny* aAny) |
|
107 { |
|
108 //may be unnecessary |
|
109 TL2CapConfig* arg=static_cast<TL2CapConfig*>(aAny); |
|
110 delete arg; |
|
111 } |
|
112 |
|
113 TBool CT_L2CapConfigData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
114 { |
|
115 TBool ret = ETrue; |
|
116 if ( aCommand==KCmdTL2CapConfig ) |
|
117 { |
|
118 DoCmdTL2CapConfig(); |
|
119 } |
|
120 else if ( aCommand==KCmdSetMaxTransmitUnitSize ) |
|
121 { |
|
122 DoCmdSetMaxTransmitUnitSize(aSection); |
|
123 } |
|
124 else if ( aCommand==KCmdMaxTransmitUnitSize ) |
|
125 { |
|
126 DoCmdMaxTransmitUnitSize(aSection); |
|
127 } |
|
128 else if ( aCommand==KCmdSetMaxReceiveUnitSize ) |
|
129 { |
|
130 DoCmdSetMaxReceiveUnitSize(aSection); |
|
131 } |
|
132 else if ( aCommand==KCmdMaxReceiveUnitSize ) |
|
133 { |
|
134 DoCmdMaxReceiveUnitSize(aSection); |
|
135 } |
|
136 else if ( aCommand==KCmdConfigureReliableChannel ) |
|
137 { |
|
138 DoCmdConfigureReliableChannel(aSection); |
|
139 } |
|
140 else if ( aCommand==KCmdConfigureUnreliableChannel ) |
|
141 { |
|
142 DoCmdConfigureUnreliableChannel(aSection); |
|
143 } |
|
144 else if ( aCommand==KCmdChannelReliability ) |
|
145 { |
|
146 DoCmdChannelReliability(aSection); |
|
147 } |
|
148 else if ( aCommand==KCmdConfigureChannelPriority ) |
|
149 { |
|
150 DoCmdConfigureChannelPriority(aSection); |
|
151 } |
|
152 else if ( aCommand==KCmdChannelPriority ) |
|
153 { |
|
154 DoCmdChannelPriority(aSection); |
|
155 } |
|
156 else |
|
157 { |
|
158 ret=EFalse; |
|
159 } |
|
160 |
|
161 return ret; |
|
162 } |
|
163 |
|
164 |
|
165 /** |
|
166 Test TL2CapConfig() |
|
167 */ |
|
168 void CT_L2CapConfigData::DoCmdTL2CapConfig() |
|
169 { |
|
170 DestroyData(); |
|
171 INFO_PRINTF1(_L("TL2CapConfig Constructor Call")); |
|
172 iData = new (ELeave) TL2CapConfig(); |
|
173 |
|
174 if ( iData == NULL ) |
|
175 { |
|
176 ERR_PRINTF1(_L("TL2CapConfig is NULL")); |
|
177 SetBlockResult(EFail); |
|
178 } |
|
179 } |
|
180 |
|
181 |
|
182 /** |
|
183 Test SetMaxTransmitUnitSize() |
|
184 */ |
|
185 void CT_L2CapConfigData::DoCmdSetMaxTransmitUnitSize(const TDesC& aSection) |
|
186 { |
|
187 TInt size = 0; |
|
188 if(GetIntFromConfig(aSection, KMTUSize(), size) ) |
|
189 { |
|
190 INFO_PRINTF1(_L("TL2CapConfig SetMaxTransmitUnitSize Call")); |
|
191 TInt err = iData->SetMaxTransmitUnitSize((TUint16)size); |
|
192 INFO_PRINTF2(_L("SetMaxTransmitUnitSize result (%d)"), err); |
|
193 if ( err != KErrNone ) |
|
194 { |
|
195 ERR_PRINTF2(_L("SetMaxTransmitUnitSize failed with result (%d)"), err); |
|
196 SetError(err); |
|
197 } |
|
198 } |
|
199 else |
|
200 { |
|
201 ERR_PRINTF2(KLogMissingParameter, &KMTUSize()); |
|
202 SetBlockResult(EFail); |
|
203 } |
|
204 } |
|
205 |
|
206 |
|
207 /** |
|
208 Test MaxTransmitUnitSize() |
|
209 */ |
|
210 void CT_L2CapConfigData::DoCmdMaxTransmitUnitSize(const TDesC& aSection) |
|
211 { |
|
212 TBool specified = EFalse; |
|
213 INFO_PRINTF1(_L("TL2CapConfig MaxTransmitUnitSize Call")); |
|
214 TUint16 result = iData->MaxTransmitUnitSize(specified); |
|
215 INFO_PRINTF3(_L("Return value(%d) and specified result (%d)"), result, specified); |
|
216 |
|
217 TInt size = 0; |
|
218 TBool expected = EFalse; |
|
219 TBool foundParameter = EFalse; |
|
220 if(GetBoolFromConfig(aSection, KSpecified(), expected) ) |
|
221 { |
|
222 foundParameter = ETrue; |
|
223 if ( specified != expected) |
|
224 { |
|
225 ERR_PRINTF3(_L("Result (%d) is not as expected (%d)"), specified, expected); |
|
226 SetBlockResult(EFail); |
|
227 } |
|
228 else |
|
229 { |
|
230 if ( specified ) |
|
231 { |
|
232 INFO_PRINTF1(_L("Verify that MTU has been set with the expected value")); |
|
233 if(GetIntFromConfig(aSection, KMTUSize(), size) ) |
|
234 { |
|
235 foundParameter = ETrue; |
|
236 TUint16 mtu = (TUint16) size; |
|
237 if ( result != mtu ) |
|
238 { |
|
239 ERR_PRINTF3(_L("MTU value (%d) is not as expected (%d)"), result, mtu); |
|
240 SetBlockResult(EFail); |
|
241 } |
|
242 } |
|
243 } |
|
244 } |
|
245 } |
|
246 |
|
247 if ( !foundParameter ) |
|
248 { |
|
249 ERR_PRINTF2(KLogMissingParameter, &KMTUSize()); |
|
250 SetBlockResult(EFail); |
|
251 } |
|
252 } |
|
253 |
|
254 |
|
255 /** |
|
256 Test SetMaxReceiveUnitSize() |
|
257 */ |
|
258 void CT_L2CapConfigData::DoCmdSetMaxReceiveUnitSize(const TDesC& aSection) |
|
259 { |
|
260 TInt size = 0; |
|
261 |
|
262 if(GetIntFromConfig(aSection, KMRUSize(), size) ) |
|
263 { |
|
264 INFO_PRINTF1(_L("TL2CapConfig SetMaxReceiveUnitSize Call")); |
|
265 TInt err = iData->SetMaxReceiveUnitSize((TUint16)size); |
|
266 INFO_PRINTF2(_L("SetMaxReceiveUnitSize result (%d)"), err); |
|
267 if ( err != KErrNone ) |
|
268 { |
|
269 ERR_PRINTF2(_L("SetMaxReceiveUnitSize failed with result (%d)"), err); |
|
270 SetError(err); |
|
271 } |
|
272 } |
|
273 else |
|
274 { |
|
275 ERR_PRINTF2(KLogMissingParameter, &KMRUSize()); |
|
276 SetBlockResult(EFail); |
|
277 } |
|
278 } |
|
279 |
|
280 |
|
281 /** |
|
282 Test MaxReceiveUnitSize() |
|
283 */ |
|
284 void CT_L2CapConfigData::DoCmdMaxReceiveUnitSize(const TDesC& aSection) |
|
285 { |
|
286 TBool specified = EFalse; |
|
287 INFO_PRINTF1(_L("TL2CapConfig MaxReceiveUnitSize Call")); |
|
288 TUint16 result = iData->MaxReceiveUnitSize(specified); |
|
289 INFO_PRINTF3(_L("Return value(%d) and specified result (%d)"), result, specified); |
|
290 |
|
291 TInt size = 0; |
|
292 TBool expected = EFalse; |
|
293 TBool foundParameter = EFalse; |
|
294 if(GetBoolFromConfig(aSection, KSpecified(), expected) ) |
|
295 { |
|
296 foundParameter = ETrue; |
|
297 if ( specified != expected ) |
|
298 { |
|
299 ERR_PRINTF3(_L("Result (%d) is not as expected (%d)"), specified, expected); |
|
300 SetBlockResult(EFail); |
|
301 } |
|
302 else |
|
303 { |
|
304 if ( specified ) |
|
305 { |
|
306 INFO_PRINTF1(_L("Verify that MRU has been set with the expected value")); |
|
307 if(GetIntFromConfig(aSection, KMRUSize(), size) ) |
|
308 { |
|
309 foundParameter = ETrue; |
|
310 TUint16 mru = (TUint16) size; |
|
311 if ( result != mru ) |
|
312 { |
|
313 ERR_PRINTF3(_L("MRU value (%d) is not as expected (%d)"), result, mru); |
|
314 SetBlockResult(EFail); |
|
315 } |
|
316 } |
|
317 } |
|
318 } |
|
319 } |
|
320 |
|
321 if ( !foundParameter ) |
|
322 { |
|
323 ERR_PRINTF2(KLogMissingParameter, &KMRUSize()); |
|
324 SetBlockResult(EFail); |
|
325 } |
|
326 } |
|
327 |
|
328 |
|
329 /** |
|
330 Test ConfigureReliableChannel() |
|
331 */ |
|
332 void CT_L2CapConfigData::DoCmdConfigureReliableChannel(const TDesC& aSection) |
|
333 { |
|
334 TInt time = 0; |
|
335 |
|
336 if(GetIntFromConfig(aSection, KTimer(), time) ) |
|
337 { |
|
338 INFO_PRINTF1(_L("TL2CapConfig ConfigureReliableChannel Call")); |
|
339 TInt err = iData->ConfigureReliableChannel((TUint16)time); |
|
340 INFO_PRINTF2(_L("ConfigureReliableChannel result (%d)"), err); |
|
341 if ( err!=KErrNone ) |
|
342 { |
|
343 ERR_PRINTF2(_L("ConfigureReliableChannel failed with result (%d)"), err); |
|
344 SetError(err); |
|
345 } |
|
346 } |
|
347 else |
|
348 { |
|
349 ERR_PRINTF2(KLogMissingParameter, &KTimer()); |
|
350 SetBlockResult(EFail); |
|
351 } |
|
352 } |
|
353 |
|
354 |
|
355 /** |
|
356 Test ConfigureUnreliableChannel() |
|
357 */ |
|
358 void CT_L2CapConfigData::DoCmdConfigureUnreliableChannel(const TDesC& aSection) |
|
359 { |
|
360 TInt time = 0; |
|
361 |
|
362 if(GetIntFromConfig(aSection, KTimer(), time) ) |
|
363 { |
|
364 INFO_PRINTF1(_L("TL2CapConfig ConfigureUnreliableChannel Call")); |
|
365 TInt err = iData->ConfigureUnreliableChannel((TUint16)time); |
|
366 INFO_PRINTF2(_L("ConfigureUnreliableChannel result (%d)"), err); |
|
367 |
|
368 if ( err!=KErrNone ) |
|
369 { |
|
370 ERR_PRINTF2(_L("ConfigureUnreliableChannel failed with result (%d)"), err); |
|
371 SetError(err); |
|
372 } |
|
373 } |
|
374 else |
|
375 { |
|
376 ERR_PRINTF2(KLogMissingParameter, &KTimer()); |
|
377 SetBlockResult(EFail); |
|
378 } |
|
379 } |
|
380 |
|
381 |
|
382 /** |
|
383 Test ChannelReliability() |
|
384 */ |
|
385 void CT_L2CapConfigData::DoCmdChannelReliability(const TDesC& aSection) |
|
386 { |
|
387 TBool specified = EFalse; |
|
388 TUint16 associateTimer = 0; |
|
389 INFO_PRINTF1(_L("TL2CapConfig ChannelReliability Call")); |
|
390 TL2CapConfig::TChannelReliability result= iData->ChannelReliability (specified, associateTimer); |
|
391 INFO_PRINTF4(_L("ChannelReliability return result (%d), Specified (%d), Time (%d)"), result, specified, associateTimer); |
|
392 |
|
393 TBool foundParameter = EFalse; |
|
394 TBool expected = EFalse; |
|
395 TInt timer = 0; |
|
396 TL2CapConfig::TChannelReliability channeltype = TL2CapConfig::EReliableChannel; |
|
397 |
|
398 if(GetBoolFromConfig(aSection, KSpecified(), expected) ) |
|
399 { |
|
400 foundParameter = ETrue; |
|
401 if ( specified != expected ) |
|
402 { |
|
403 ERR_PRINTF3(_L("Result (%d) is not as expected (%d)"), specified, expected); |
|
404 SetBlockResult(EFail); |
|
405 } |
|
406 else |
|
407 { |
|
408 if ( specified ) |
|
409 { |
|
410 INFO_PRINTF1(_L("Verify that TChannelReliability has been set with the expected value")); |
|
411 CT_BTUtil::GetChannel(*this, channeltype, aSection, KChannelReliability()); |
|
412 if ( result != channeltype ) |
|
413 { |
|
414 ERR_PRINTF3(_L("TChannelReliability (%d) is not as expected (%d)"), result, channeltype); |
|
415 SetBlockResult(EFail); |
|
416 } |
|
417 else |
|
418 { |
|
419 INFO_PRINTF1(_L("Verify that aAssociatedTimer has been set with the expected value")); |
|
420 if(GetIntFromConfig(aSection, KTimer(), timer) ) |
|
421 { |
|
422 foundParameter = ETrue; |
|
423 TUint16 expTimer = (TUint16) timer; |
|
424 if ( associateTimer != expTimer ) |
|
425 { |
|
426 ERR_PRINTF3(_L("aAssociatedTimer (%d) is not as expected (%d)"), associateTimer, expTimer); |
|
427 SetBlockResult(EFail); |
|
428 } |
|
429 } |
|
430 } |
|
431 } |
|
432 } |
|
433 } |
|
434 |
|
435 if ( foundParameter == EFalse) |
|
436 { |
|
437 ERR_PRINTF3(KLogMissingParameters, &KSpecified(), &KTimer()); |
|
438 SetBlockResult(EFail); |
|
439 } |
|
440 } |
|
441 |
|
442 |
|
443 /** |
|
444 Test ConfigureChannelPriority() |
|
445 */ |
|
446 void CT_L2CapConfigData::DoCmdConfigureChannelPriority(const TDesC& aSection) |
|
447 { |
|
448 TL2CapConfig::TChannelPriority priority; |
|
449 CT_BTUtil::GetChannelPriority(*this, priority, aSection, KPriority()); |
|
450 INFO_PRINTF1(_L("TL2CapConfig ConfigureChannelPriority Call")); |
|
451 TInt err = iData->ConfigureChannelPriority (priority); |
|
452 INFO_PRINTF2(_L("ConfigureChannelPriority result (%d)"), err); |
|
453 if ( err != KErrNone ) |
|
454 { |
|
455 ERR_PRINTF2(_L("ConfigureChannelPriority failed with result (%d)"), err); |
|
456 SetError(err); |
|
457 } |
|
458 } |
|
459 |
|
460 |
|
461 /** |
|
462 Test ChannelPriority() |
|
463 */ |
|
464 void CT_L2CapConfigData::DoCmdChannelPriority(const TDesC& aSection) |
|
465 { |
|
466 TBool specified = EFalse; |
|
467 INFO_PRINTF1(_L("TL2CapConfig ChannelPriority Call")); |
|
468 TL2CapConfig::TChannelPriority result = iData->ChannelPriority(specified); |
|
469 INFO_PRINTF3(_L("Return value (%d) and specified result (%d)"), result, specified); |
|
470 |
|
471 TBool expected = EFalse; |
|
472 |
|
473 if(GetBoolFromConfig(aSection, KSpecified(), expected) ) |
|
474 { |
|
475 if ( specified != expected ) |
|
476 { |
|
477 ERR_PRINTF3(_L("Result (%d) is not as expected (%d)"), specified, expected); |
|
478 SetBlockResult(EFail); |
|
479 } |
|
480 else |
|
481 { |
|
482 if ( specified ) |
|
483 { |
|
484 INFO_PRINTF1(_L("Verify that TChannelPriority has been set with the expected value")); |
|
485 TL2CapConfig::TChannelPriority priority; |
|
486 CT_BTUtil::GetChannelPriority(*this, priority, aSection, KPriority()); |
|
487 if ( result != priority ) |
|
488 { |
|
489 ERR_PRINTF3(_L("TChannelPriority (%d) is not as expected (%d)"), result, priority); |
|
490 SetBlockResult(EFail); |
|
491 } |
|
492 } |
|
493 } |
|
494 } |
|
495 else |
|
496 { |
|
497 ERR_PRINTF2(KLogMissingParameter, &KSpecified()); |
|
498 SetBlockResult(EFail); |
|
499 } |
|
500 } |
|
501 |
|
502 |