|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // These functions are called by parts of the stack that would like to issue |
|
15 // HCI commands. |
|
16 // The general pattern is for these functions create a new command and then |
|
17 // add it to the command Q, which takes ownership of the command. |
|
18 // |
|
19 // |
|
20 |
|
21 #include <bluetooth/logger.h> |
|
22 #include "hcifacade.h" |
|
23 #include "linkutil.h" |
|
24 #include "linkconsts.h" |
|
25 #include "hostresolver.h" |
|
26 |
|
27 #include <e32std.h> |
|
28 #include <bt_sock.h> |
|
29 #include "debug.h" |
|
30 #include <utf.h> |
|
31 #include <es_ini.h> |
|
32 #include <btextnotifiers.h> |
|
33 |
|
34 #include <bluetooth/hcicommandqueue.h> |
|
35 #include <bluetooth/hcicommandqitem.h> |
|
36 |
|
37 // Command Headers |
|
38 #include <bluetooth/hci/writescanenablecommand.h> |
|
39 #include <bluetooth/hci/createaclconnectioncommand.h> |
|
40 #include <bluetooth/hci/setupsynchronousconnectioncommand.h> |
|
41 #include <bluetooth/hci/acceptsynchronousconnectionrequestcommand.h> |
|
42 #include <bluetooth/hci/rejectsynchronousconnectionrequestcommand.h> |
|
43 #include <bluetooth/hci/disconnectcommand.h> |
|
44 #include <bluetooth/hci/writelinkpolicysettingscommand.h> |
|
45 #include <bluetooth/hci/hostnumberofcompletedpacketscommand.h> |
|
46 #include <bluetooth/hci/acceptconnectionrequestcommand.h> |
|
47 #include <bluetooth/hci/rejectconnectionrequestcommand.h> |
|
48 #include <bluetooth/hci/readremoteversioninfocommand.h> |
|
49 #include <bluetooth/hci/readremotesupportedfeaturescommand.h> |
|
50 #include <bluetooth/hci/readremoteextendedfeaturescommand.h> |
|
51 #include <bluetooth/hci/readclockoffsetcommand.h> |
|
52 #include <bluetooth/hci/remotenamerequestcommand.h> |
|
53 #include <bluetooth/hci/flushcommand.h> |
|
54 #include <bluetooth/hci/seteventmaskcommand.h> |
|
55 #include <bluetooth/hci/writelocalnamecommand.h> |
|
56 #include <bluetooth/hci/linkkeyrequestreplycommand.h> |
|
57 #include <bluetooth/hci/linkkeyrequestreplynegativecommand.h> |
|
58 #include <bluetooth/hci/changelinkkeycommand.h> |
|
59 #include <bluetooth/hci/pincoderequestreplycommand.h> |
|
60 #include <bluetooth/hci/pincoderequestreplynegativecommand.h> |
|
61 #include <bluetooth/hci/changeconnectionpackettypecommand.h> |
|
62 #include <bluetooth/hci/authenticationrequestedcommand.h> |
|
63 #include <bluetooth/hci/setconnectionencryptioncommand.h> |
|
64 #include <bluetooth/hci/sniffmodecommand.h> |
|
65 #include <bluetooth/hci/exitsniffmodecommand.h> |
|
66 #include <bluetooth/hci/holdmodecommand.h> |
|
67 #include <bluetooth/hci/parkmodecommand.h> |
|
68 #include <bluetooth/hci/exitparkmodecommand.h> |
|
69 #include <bluetooth/hci/switchrolecommand.h> |
|
70 #include <bluetooth/hci/writeclassofdevicecommand.h> |
|
71 #include <bluetooth/hci/setafhhostchannelclassificationcommand.h> |
|
72 #include <bluetooth/hci/writeafhchannelassessmentmodecommand.h> |
|
73 #include <bluetooth/hci/setcontrollertohostflowcontrolcommand.h> |
|
74 #include <bluetooth/hci/readclassofdevicecommand.h> |
|
75 #include <bluetooth/hci/readbuffersizecommand.h> |
|
76 #include <bluetooth/hci/hostbuffersizecommand.h> |
|
77 #include <bluetooth/hci/writecurrentiaclapcommand.h> |
|
78 #include <bluetooth/hci/vendordebugcommand.h> |
|
79 #include <bluetooth/hci/addscoconnectioncommand.h> |
|
80 #include <bluetooth/hci/remotenamerequestcancelcommand.h> |
|
81 #include <bluetooth/hci/refreshencryptionkeycommand.h> |
|
82 #include <bluetooth/hci/writelinksupervisiontimeoutcommand.h> |
|
83 |
|
84 |
|
85 void CHCIFacade::SCOConnectL(THCIConnHandle aACLHandle, TUint16 aPacketTypeMask, const TBTDevAddr& aBdaddr) |
|
86 /** |
|
87 @pre Callers should check that the ACL Handle exists |
|
88 |
|
89 Attempts to attach an SCO link to the baseband |
|
90 **/ |
|
91 { |
|
92 TBTDevHCIVersion hciVersion = iLinkMgrProtocol.GetHWHCIVersion(); // Read Hardware HCI Version |
|
93 if (hciVersion.iHCIVersion > EHWHCIv1_1) // May not support Add_SCO_Connection |
|
94 { |
|
95 #pragma message("KBTVoiceSetting - hardware specific value. KBTVoiceSetting should be replaced by HCI implementation, and should NOT be modified in a BT stack.") |
|
96 SetupSynchronousConnectionCommandL(aACLHandle,KBTSync64KBit,KBTSync64KBit,KeSCOMaxLatencyDontCare,KBTVoiceSetting,EeSCORetransmitDontCare,(aPacketTypeMask >> KSCOvsSyncHVOffset) | KNoEDReSCOPacketMask, aBdaddr); // Need to specify not to use EDR eSCO packets, as they are enabled by default |
|
97 } |
|
98 else // Supports Add_SCO_Connection |
|
99 { |
|
100 CAddSCOConnectionCommand* cmd = CAddSCOConnectionCommand::NewL(aACLHandle, aPacketTypeMask, aBdaddr); |
|
101 |
|
102 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
103 iCmdController->MhcqAddCommandL(cmd, *this); |
|
104 } |
|
105 } |
|
106 |
|
107 void CHCIFacade::SetupSynchronousConnectionCommandL(THCIConnHandle aACLHandle, |
|
108 TUint aTransmitBandwidth, TUint aReceiveBandwidth, TUint16 aMaxLatency, |
|
109 TUint16 aVoiceSettings, TUint8 aRetransmissionEffort, |
|
110 TBTSyncPacketTypes aPacketTypeMask, const TBTDevAddr& aBdaddr) |
|
111 /** |
|
112 @pre Callers should check that the ACL Handle exists |
|
113 |
|
114 Attempts to attach a synchronous link to the baseband |
|
115 **/ |
|
116 { |
|
117 CSetupSynchronousConnectionCommand* cmd = CSetupSynchronousConnectionCommand::NewL(aACLHandle, aTransmitBandwidth, aReceiveBandwidth, aMaxLatency, aVoiceSettings, aRetransmissionEffort, aPacketTypeMask, aBdaddr); |
|
118 #pragma message("NB. This message relates to the CommandsEvents of the HCI(v2). It appears here because CE source code is generated.") |
|
119 #pragma message("Value of iVoiceSetting (see HCI Command) member is closely related to hardware used. ") |
|
120 #pragma message("Bits: Input Coding, Input Data, Input Sample Size and Linear_PCM_Bit_pos, should be set...") |
|
121 #pragma message("...according to hardware capabilities, and OR-ed to create appropriate iVoiceSetting value.") |
|
122 |
|
123 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
124 iCmdController->MhcqAddCommandL(cmd, *this); |
|
125 } |
|
126 |
|
127 void CHCIFacade::AcceptSynchronousConnectionL(const TBTDevAddr& aBdaddr, |
|
128 TUint aTransmitBandwidth, TUint aReceiveBandwidth, TUint16 aMaxLatency, |
|
129 TUint16 aContentFormat, TUint8 aRetransmissionEffort, TBTSyncPacketTypes aPacketTypeMask) |
|
130 { |
|
131 CAcceptSynchronousConnectionRequestCommand* cmd = CAcceptSynchronousConnectionRequestCommand::NewL(aBdaddr, aTransmitBandwidth, aReceiveBandwidth, aMaxLatency, aContentFormat, aRetransmissionEffort, aPacketTypeMask); |
|
132 |
|
133 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
134 iCmdController->MhcqAddCommandL(cmd, *this); |
|
135 } |
|
136 |
|
137 |
|
138 void CHCIFacade::RejectSynchronousConnectionL(const TBTDevAddr& aBdaddr, THCIErrorCode aReason) |
|
139 { |
|
140 CRejectSynchronousConnectionRequestCommand* cmd = CRejectSynchronousConnectionRequestCommand::NewL(aBdaddr, aReason); |
|
141 |
|
142 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
143 iCmdController->MhcqAddCommandL(cmd, *this); |
|
144 } |
|
145 |
|
146 |
|
147 void CHCIFacade::ConnectL(const TBTDevAddr& aAddr, |
|
148 TUint16 aPacketType, |
|
149 TUint8 aPageScanRepetitionMode, |
|
150 TUint8 aPageScanMode, |
|
151 TUint16 aClockOffset, |
|
152 TUint8 aAllowRoleSwitch) |
|
153 { |
|
154 CCreateACLConnectionCommand* cmd = CCreateACLConnectionCommand::NewL(aAddr, aPacketType, aPageScanRepetitionMode, aPageScanMode, aClockOffset, aAllowRoleSwitch); |
|
155 |
|
156 // Before the CreateConnection command can be added to the queue we try |
|
157 // to ensure any inquiry is cancelled as some hardware will disallow the |
|
158 // connect otherwise. |
|
159 iLinkMgrProtocol.InquiryMgr().Suspend(); |
|
160 |
|
161 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
162 iCmdController->MhcqAddCommandL(cmd, *this); |
|
163 } |
|
164 |
|
165 void CHCIFacade::DisconnectL(THCIConnHandle aConnH, THCIErrorCode aErr) |
|
166 { |
|
167 CDisconnectCommand* cmd = CDisconnectCommand::NewL(aConnH, aErr); |
|
168 |
|
169 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
170 iCmdController->MhcqAddCommandL(cmd, *this); |
|
171 } |
|
172 |
|
173 void CHCIFacade::WriteLinkPolicySettingsL(THCIConnHandle aConnH, TUint16 aSettings) |
|
174 { |
|
175 CWriteLinkPolicySettingsCommand* cmd = CWriteLinkPolicySettingsCommand::NewL(aConnH, aSettings); |
|
176 |
|
177 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
178 iCmdController->MhcqAddCommandL(cmd, *this); |
|
179 } |
|
180 |
|
181 void CHCIFacade::WriteScanEnableL(THCIScanEnable aEnable) |
|
182 { |
|
183 CWriteScanEnableCommand* cmd = CWriteScanEnableCommand::NewL(aEnable); |
|
184 |
|
185 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
186 iCmdController->MhcqAddCommandL(cmd, *this); |
|
187 } |
|
188 |
|
189 void CHCIFacade::HostNumberOfCompletedPacketsL(THCIConnHandle aConnH, TUint16 aFrags) |
|
190 { |
|
191 RArray<THCIConnectionHandle> connHandles; |
|
192 connHandles.Append(aConnH); |
|
193 |
|
194 RArray<THCINumOfCompletedPackets> numPackets; |
|
195 numPackets.Append(aFrags); |
|
196 |
|
197 CHostNumberOfCompletedPacketsCommand* cmd = CHostNumberOfCompletedPacketsCommand::NewL(1, connHandles, numPackets); |
|
198 |
|
199 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
200 iCmdController->MhcqAddCommandL(cmd, *this); |
|
201 } |
|
202 |
|
203 void CHCIFacade::AcceptConnectionRequestL(const TBTDevAddr& aAddr, TUint8 aRole) |
|
204 { |
|
205 CAcceptConnectionRequestCommand* cmd = CAcceptConnectionRequestCommand::NewL(aAddr, aRole); |
|
206 |
|
207 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
208 iCmdController->MhcqAddCommandL(cmd, *this); |
|
209 } |
|
210 |
|
211 void CHCIFacade::RejectConnectionRequestL(const TBTConnect& aConnect, THCIErrorCode aReason) |
|
212 { |
|
213 CRejectConnectionRequestCommand* cmd = CRejectConnectionRequestCommand::NewL(aConnect.iBdaddr, aReason); |
|
214 |
|
215 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
216 iCmdController->MhcqAddCommandL(cmd, *this); |
|
217 } |
|
218 |
|
219 |
|
220 void CHCIFacade::ReadRemoteVersionL(THCIConnHandle aHandle) |
|
221 { |
|
222 CReadRemoteVersionInfoCommand* cmd = CReadRemoteVersionInfoCommand::NewL(aHandle); |
|
223 |
|
224 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
225 iCmdController->MhcqAddCommandL(cmd, *this); |
|
226 } |
|
227 |
|
228 void CHCIFacade::ReadRemoteSupportedFeaturesL(THCIConnHandle aHandle) |
|
229 { |
|
230 CReadRemoteSupportedFeaturesCommand* cmd = CReadRemoteSupportedFeaturesCommand::NewL(aHandle); |
|
231 |
|
232 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
233 iCmdController->MhcqAddCommandL(cmd, *this); |
|
234 } |
|
235 |
|
236 void CHCIFacade::ReadRemoteExtendedFeaturesL(THCIConnHandle aHandle, TUint8 aPageNumber) |
|
237 { |
|
238 TInt err = KErrNotSupported; |
|
239 TBTDevHCIVersion hciVersion = iLinkMgrProtocol.GetHWHCIVersion(); // Read Hardware HCI Version |
|
240 if (hciVersion.iHCIVersion > EHWHCIv1_1) // May not support Read_Remote_Extended_Features command |
|
241 { |
|
242 // Maybe migrate this to use HCIv2 so command is owned by physical link |
|
243 CReadRemoteExtendedFeaturesCommand* cmd = NULL; |
|
244 TRAP(err, cmd = CReadRemoteExtendedFeaturesCommand::NewL(aHandle, aPageNumber)); |
|
245 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
246 if(err == KErrNone) |
|
247 { |
|
248 TRAP(err, iCmdController->MhcqAddCommandL(cmd, *this)); |
|
249 } |
|
250 } |
|
251 if(err != KErrNone) |
|
252 { |
|
253 // Some error occured but we have to signal the SSP state |
|
254 iLinksMgr->ReadRemoteExtendedFeaturesComplete(EUnknownOpcode, aHandle, TUint64(0), KRemoteExtendedFeaturesPage1, 0); |
|
255 User::Leave(err); |
|
256 } |
|
257 } |
|
258 |
|
259 |
|
260 void CHCIFacade::ReadClockOffsetL(THCIConnHandle aHandle) |
|
261 /** |
|
262 Create a command to find remote clock offset |
|
263 **/ |
|
264 { |
|
265 CReadClockOffsetCommand* cmd = CReadClockOffsetCommand::NewL(aHandle); |
|
266 |
|
267 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
268 iCmdController->MhcqAddCommandL(cmd, *this); |
|
269 } |
|
270 |
|
271 void CHCIFacade::RefreshEncryptionKeyL(THCIConnHandle aHandle) |
|
272 { |
|
273 CRefreshEncryptionKeyCommand* cmd = CRefreshEncryptionKeyCommand::NewL(aHandle); |
|
274 |
|
275 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
276 iCmdController->MhcqAddCommandL(cmd, *this); |
|
277 } |
|
278 |
|
279 void CHCIFacade::WriteLinkSupervisionTimeoutL(THCIConnHandle aHandle, TInt aTimeout) |
|
280 { |
|
281 CWriteLinkSupervisionTimeoutCommand* cmd = CWriteLinkSupervisionTimeoutCommand::NewL(aHandle, aTimeout); |
|
282 |
|
283 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
284 iCmdController->MhcqAddCommandL(cmd, *this); |
|
285 } |
|
286 |
|
287 void CHCIFacade::FlushL(THCIConnHandle aConnH) |
|
288 { |
|
289 CFlushCommand* cmd = CFlushCommand::NewL(aConnH); |
|
290 |
|
291 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
292 iCmdController->MhcqAddCommandL(cmd, *this); |
|
293 } |
|
294 |
|
295 void CHCIFacade::SetEventMaskL(const THCIEventMask& aEventMask) |
|
296 { |
|
297 static const TUint8 KSizeOf64BitsInBytes = 8; |
|
298 TBuf8<KSizeOf64BitsInBytes> eventMask; |
|
299 eventMask.SetLength(KSizeOf64BitsInBytes); |
|
300 TUint8* ptr = const_cast<TUint8*>(eventMask.Ptr()); |
|
301 LittleEndian::Put32(ptr, aEventMask.iLoBytes); |
|
302 LittleEndian::Put32(ptr+sizeof(TUint32), aEventMask.iHiBytes); |
|
303 |
|
304 CSetEventMaskCommand* cmd = CSetEventMaskCommand::NewL(eventMask); |
|
305 |
|
306 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
307 iCmdController->MhcqAddCommandL(cmd, *this); |
|
308 } |
|
309 |
|
310 void CHCIFacade::WriteLocalNameL(const TDesC8& aName) |
|
311 { |
|
312 CWriteLocalNameCommand* cmd = CWriteLocalNameCommand::NewL(aName); |
|
313 |
|
314 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
315 iCmdController->MhcqAddCommandL(cmd, *this); |
|
316 } |
|
317 |
|
318 TInt CHCIFacade::LinkKeyRequestReply(const TBTDevAddr& aBdaddr, const TDesC8& aLinkKey) const |
|
319 /** |
|
320 We have obtained a linkkey, tell HC |
|
321 **/ |
|
322 { |
|
323 CLinkKeyRequestReplyCommand* cmd = NULL; |
|
324 TBTLinkKey linkkey; |
|
325 linkkey.Copy(aLinkKey); |
|
326 |
|
327 TRAPD(err, cmd = CLinkKeyRequestReplyCommand::NewL(aBdaddr, linkkey)); |
|
328 if (err == KErrNone) |
|
329 { |
|
330 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
331 TRAP(err, iCmdController->MhcqAddCommandL(cmd, const_cast<CHCIFacade&>(*this))); |
|
332 } |
|
333 return err; |
|
334 } |
|
335 |
|
336 TInt CHCIFacade::LinkKeyRequestNegativeReply(const TBTDevAddr& aBdaddr) const |
|
337 /** |
|
338 We have not obtained a linkkey, tell HC |
|
339 **/ |
|
340 { |
|
341 CLinkKeyRequestReplyNegativeCommand* cmd = NULL; |
|
342 |
|
343 TRAPD(err, cmd = CLinkKeyRequestReplyNegativeCommand::NewL(aBdaddr)); |
|
344 if (err == KErrNone) |
|
345 { |
|
346 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
347 TRAP(err, iCmdController->MhcqAddCommandL(cmd, const_cast<CHCIFacade&>(*this))); |
|
348 } |
|
349 return err; |
|
350 } |
|
351 |
|
352 TInt CHCIFacade::ChangeConnectionLinkKey(THCIConnHandle aConnHandle) |
|
353 /** |
|
354 Change the link key for the specified connection handle |
|
355 **/ |
|
356 { |
|
357 CChangeLinkKeyCommand* cmd = NULL; |
|
358 |
|
359 TRAPD(err, cmd = CChangeLinkKeyCommand::NewL(aConnHandle)); |
|
360 if (err == KErrNone) |
|
361 { |
|
362 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
363 TRAP(err, iCmdController->MhcqAddCommandL(cmd, *this)); |
|
364 } |
|
365 return err; |
|
366 } |
|
367 |
|
368 |
|
369 TInt CHCIFacade::PINCodeRequestReply(const TBTDevAddr& aBdaddr,const TDesC8& aPIN) const |
|
370 /** |
|
371 We have obtained a PIN, tell HC |
|
372 **/ |
|
373 { |
|
374 CPINCodeRequestReplyCommand* cmd = NULL; |
|
375 TBTPinCode pin; |
|
376 pin.Copy(aPIN); |
|
377 TPtrC8 pinContents(pin().iPIN, pin().iLength); |
|
378 |
|
379 TRAPD(err, cmd = CPINCodeRequestReplyCommand::NewL(aBdaddr, pin().iLength, pinContents)); |
|
380 if (err == KErrNone) |
|
381 { |
|
382 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
383 TRAP(err, iCmdController->MhcqAddCommandL(cmd, const_cast<CHCIFacade&>(*this))); |
|
384 } |
|
385 return err; |
|
386 } |
|
387 |
|
388 TInt CHCIFacade::PINCodeRequestNegativeReply(const TBTDevAddr& aBdaddr) const |
|
389 /** |
|
390 We have not obtained a PIN, tell HC |
|
391 **/ |
|
392 { |
|
393 CPINCodeRequestReplyNegativeCommand* cmd = NULL; |
|
394 |
|
395 TRAPD(err, cmd = CPINCodeRequestReplyNegativeCommand::NewL(aBdaddr)); |
|
396 if (err == KErrNone) |
|
397 { |
|
398 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
399 TRAP(err, iCmdController->MhcqAddCommandL(cmd, const_cast<CHCIFacade&>(*this))); |
|
400 } |
|
401 return err; |
|
402 } |
|
403 |
|
404 TInt CHCIFacade::ChangeConnectionPacketType(THCIConnHandle aConnHandle, TUint16 aType) |
|
405 { |
|
406 CChangeConnectionPacketTypeCommand* cmd = NULL; |
|
407 |
|
408 TRAPD(err, cmd = CChangeConnectionPacketTypeCommand::NewL(aConnHandle, aType)); |
|
409 if (err == KErrNone) |
|
410 { |
|
411 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
412 TRAP(err, iCmdController->MhcqAddCommandL(cmd, *this)); |
|
413 } |
|
414 return err; |
|
415 } |
|
416 |
|
417 void CHCIFacade::AuthenticateL(THCIConnHandle aConnHandle) |
|
418 /** |
|
419 Do an authentication |
|
420 **/ |
|
421 { |
|
422 CAuthenticationRequestedCommand* cmd = CAuthenticationRequestedCommand::NewL(aConnHandle); |
|
423 |
|
424 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
425 iCmdController->MhcqAddCommandL(cmd, *this); |
|
426 } |
|
427 |
|
428 void CHCIFacade::SetEncryptL(THCIConnHandle aConnHandle,TBool aEnable) |
|
429 /** |
|
430 Creates command to enable/disable encryption on a given link |
|
431 **/ |
|
432 { |
|
433 CSetConnectionEncryptionCommand* cmd = CSetConnectionEncryptionCommand::NewL(aConnHandle, aEnable); |
|
434 |
|
435 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
436 iCmdController->MhcqAddCommandL(cmd, *this); |
|
437 } |
|
438 |
|
439 void CHCIFacade::SniffL(THCIConnHandle aHandleToRemote) |
|
440 { |
|
441 CSniffModeCommand* cmd = CSniffModeCommand::NewL(aHandleToRemote, KBTSniffModeMaxInterval, KBTSniffModeMinInterval, KBTSniffModeAttempt, KBTSniffModeTimeout); |
|
442 |
|
443 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
444 iCmdController->MhcqAddCommandL(cmd, *this); |
|
445 } |
|
446 |
|
447 void CHCIFacade::ExitSniffL(THCIConnHandle aHandleToRemote) |
|
448 { |
|
449 CExitSniffModeCommand* cmd = CExitSniffModeCommand::NewL(aHandleToRemote); |
|
450 |
|
451 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
452 iCmdController->MhcqAddCommandL(cmd, *this); |
|
453 } |
|
454 |
|
455 void CHCIFacade::HoldL(THCIConnHandle aHandle) |
|
456 { |
|
457 CHoldModeCommand* cmd = CHoldModeCommand::NewL(aHandle, KBTHoldModeMaxInterval, KBTHoldModeMinInterval); |
|
458 |
|
459 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
460 iCmdController->MhcqAddCommandL(cmd, *this); |
|
461 } |
|
462 |
|
463 void CHCIFacade::ParkL(THCIConnHandle aHandle) |
|
464 { |
|
465 CParkModeCommand* cmd = CParkModeCommand::NewL(aHandle, KBTParkModeBeaconMaxInterval, KBTParkModeBeaconMinInterval); |
|
466 |
|
467 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
468 iCmdController->MhcqAddCommandL(cmd, *this); |
|
469 } |
|
470 |
|
471 void CHCIFacade::ExitParkL(THCIConnHandle aHandle) |
|
472 { |
|
473 CExitParkModeCommand* cmd = CExitParkModeCommand::NewL(aHandle); |
|
474 |
|
475 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
476 iCmdController->MhcqAddCommandL(cmd, *this); |
|
477 } |
|
478 |
|
479 void CHCIFacade::ChangeRoleL(TBTBasebandRole aRole, const TBTDevAddr& aAddr) |
|
480 { |
|
481 CSwitchRoleCommand* cmd = CSwitchRoleCommand::NewL(aAddr, aRole); |
|
482 |
|
483 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
484 iCmdController->MhcqAddCommandL(cmd, *this); |
|
485 } |
|
486 |
|
487 void CHCIFacade::WriteDeviceClassL(TUint aCoD) |
|
488 { |
|
489 CWriteClassOfDeviceCommand* cmd = CWriteClassOfDeviceCommand::NewL(aCoD); |
|
490 |
|
491 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
492 iCmdController->MhcqAddCommandL(cmd, *this); |
|
493 } |
|
494 |
|
495 void CHCIFacade::SetAFHHostChannelClassificationL(const TBTAFHHostChannelClassification& aChannelClassification) |
|
496 { |
|
497 __ASSERT_DEBUG(aChannelClassification.Validate()==KErrNone, |
|
498 __BTDEBUGGER()); |
|
499 if(aChannelClassification.Validate()!=KErrNone) |
|
500 { |
|
501 //NB If this is called by one of Bluetooth's "Publish |
|
502 //and Subscribe" subscribers, then the KErrNotSupported |
|
503 //will be dropped - no error will be reported to the user... |
|
504 //which is good - we do not want the user reacting to errors. |
|
505 User::Leave(KErrNotSupported); |
|
506 } |
|
507 if(iAFHTimer->IsActive()) |
|
508 { |
|
509 //Timer is active => a host channel classification has just been sent. |
|
510 //Setup timer so that this command is postponed to occur more than one second after |
|
511 //that last host channel classification command - as per spec. |
|
512 //NB You only need the latest Host Channel Classification command |
|
513 //when the timer fires. |
|
514 iAFHTimer->SetPending(aChannelClassification); |
|
515 } |
|
516 else |
|
517 { |
|
518 //Start AFHHost Channel Classification Command blocking timer with a |
|
519 //long timeout (in case command never completes). |
|
520 //This will be updated when/if the command does complete. |
|
521 iAFHTimer->After(KAFHHostChannelClassificationCommandCompleteTimer); |
|
522 |
|
523 CSetAFHHostChannelClassificationCommand* cmd = CSetAFHHostChannelClassificationCommand::NewL(aChannelClassification); |
|
524 |
|
525 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
526 iCmdController->MhcqAddCommandL(cmd, *this); |
|
527 } |
|
528 } |
|
529 |
|
530 void CHCIFacade::WriteAFHChannelAssessmentModeL(TBool aEnable) |
|
531 { |
|
532 CWriteAFHChannelAssessmentModeCommand* cmd = CWriteAFHChannelAssessmentModeCommand::NewL(aEnable?1:0); |
|
533 |
|
534 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
535 iCmdController->MhcqAddCommandL(cmd, *this); |
|
536 } |
|
537 |
|
538 void CHCIFacade::SetControllerToHostFlowControlL() |
|
539 { |
|
540 CSetControllerToHostFlowControlCommand* cmd = CSetControllerToHostFlowControlCommand::NewL(ETrue); |
|
541 |
|
542 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
543 iCmdController->MhcqAddCommandL(cmd, *this); |
|
544 } |
|
545 |
|
546 void CHCIFacade::ReadDeviceClassL() |
|
547 { |
|
548 CReadClassOfDeviceCommand* cmd = CReadClassOfDeviceCommand::NewL(); |
|
549 |
|
550 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
551 iCmdController->MhcqAddCommandL(cmd, *this); |
|
552 } |
|
553 |
|
554 |
|
555 void CHCIFacade::ObtainHostControllerBufferSizeL() |
|
556 { |
|
557 CReadBufferSizeCommand* cmd = CReadBufferSizeCommand::NewL(); |
|
558 |
|
559 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
560 iCmdController->MhcqAddCommandL(cmd, *this); |
|
561 } |
|
562 |
|
563 void CHCIFacade::AdvertiseHostBufferSizeL(TUint16 aNumBuffers) |
|
564 { |
|
565 CHostBufferSizeCommand* cmd = CHostBufferSizeCommand::NewL(KLinkMgrIncomingBufferSize, KStackSCOBuffersSize, aNumBuffers, KStackSCOBuffersNum); |
|
566 |
|
567 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
568 iCmdController->MhcqAddCommandL(cmd, *this); |
|
569 } |
|
570 |
|
571 void CHCIFacade::WriteIACLAPL(TUint8 aNumCurrentIAC, TUint aIAC_LAP[]) |
|
572 { |
|
573 RArray<TUint32> iacLap; |
|
574 |
|
575 for (TInt count = 0; count < aNumCurrentIAC; count++) |
|
576 { |
|
577 iacLap.Append(aIAC_LAP[count]); |
|
578 } |
|
579 |
|
580 CWriteCurrentIACLAPCommand* cmd = CWriteCurrentIACLAPCommand::NewL(aNumCurrentIAC, iacLap); |
|
581 |
|
582 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
583 iCmdController->MhcqAddCommandL(cmd, *this); |
|
584 } |
|
585 |
|
586 void CHCIFacade::VendorSpecificCommandL(const THCIOpcode aOpcode, |
|
587 const TDesC8& aParameters) |
|
588 { |
|
589 CVendorDebugCommand* cmd = CVendorDebugCommand::NewL(aOpcode); |
|
590 |
|
591 CleanupStack::PushL(cmd); |
|
592 if(aParameters.Length() > cmd->Command().MaxLength()) |
|
593 { |
|
594 User::Leave(KErrOverflow); |
|
595 } |
|
596 CleanupStack::Pop(); // We don't leave from this point on. |
|
597 |
|
598 cmd->Command() = aParameters; |
|
599 |
|
600 // Ownership of cmd transfered even if MhcqAddCommandL leaves |
|
601 iCmdController->MhcqAddCommandL(cmd, *this); |
|
602 } |