1 // Copyright (c) 1999-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // BT socket interface types
31 #include <d32comm.h> // for RS232 signal names for RFCOMM
32 #include <bluetooth/hci/hcierrors.h>
33 #include <btsecmanclient.h>
34 #include <bt_subscribe.h>
38 _LIT(KRFCOMMDesC,"RFCOMM"); /*!< Descriptor name for RFCOMM */
40 _LIT(KL2CAPDesC,"L2CAP"); /*!< Descriptor name for L2CAP */
46 const TUint KBTAddrFamily = 0x101; /*!< BT Address Family */
48 const TUint KBTLinkManager = 0x0099; /*!< Protocol Number for Link Manager */
49 const TUint KL2CAP = 0x0100; /*!< Protocol Number for L2CAP */
50 const TUint KRFCOMM = 0x0003; /*!< Protocol Number for RFCOMM */
51 const TUint KSDP = 0x0001; /*!< Protocol Number for SDP */
52 const TUint KAVCTP = 0x0017; /*!< Protocol Number for AVCTP */
53 const TInt KTCIL2CAP = 0xF100; /*!< Protocol Number for TCI L2CAP */
55 const TInt KBTMajor = 0; /*!< BT version number for major version */
56 const TInt KBTMinor = 1; /*!< BT version number for minor version */
57 const TInt KBTBuild = 1; /*!< BT version number for build version */
60 const TUint KSolBtBlog =0x1000; /*!< Logging socket option */
61 const TUint KSolBtHCI =0x1010; /*!< HCI socket option */
62 const TUint KSolBtLM =0x1011; /*!< Link Manager socket option */
63 const TUint KSolBtL2CAP =0x1012; /*!< L2CAP socket option */
64 const TUint KSolBtRFCOMM=0x1013; /*!< RFCOMM socket option */
65 const TUint KSolBtAVCTP =0x1014; /*!< AVCTP socket option */
66 const TUint KSolBtACL =0x1015; /*!< ACL socket option */
70 const TUint KSolBtAVDTPSignalling =0x1016;
74 const TUint KSolBtAVDTPMedia =0x1017;
78 const TUint KSolBtAVDTPReporting =0x1018;
82 const TUint KSolBtAVDTPRecovery =0x1019;
86 const TUint KSolBtAVDTPInternal =0x1020;
87 const TUint KSolBtLMProxy = 0x2011; /*!< Link Manager Proxy socket option */
88 const TUint KSolBtSAPBase = 0x2020; /*!< CBluetoothSAP handles SetOpt first */
90 const static TUint8 KSCOListenQueSize = 1; /*!< Length of SCO listening queue */
92 const static TUint16 KL2MinMTU = 48; /*!< BT Spec defined min. supported MTU size */
95 // All PSM values must be ODD, that is, the least significant bit of the least significant
96 // octet must be '1'. Also, all PSM values must be assigned such that the
97 // least significant bit of the most significant octet equals '0'.
98 const static TUint16 KMaxPSM = 0xFEFF; /*!< Max L2CAP PSM value */
101 * This is the minimum user PSM. Smaller PSM values are possible but are reserved for use by the
102 * Bluetooth stack only.
104 const static TUint16 KMinUserPSM = 0x1001;
107 * This constant has been deprecated since its name is misleading becasue it doesn't represent the
108 * absolute minimum PSM but the minimum user PSM instead.
109 * Use KMinUserPSM instead of this constant.
112 const static TUint16 KMinPSM = 0x1001;
115 An enumeration to represent the possible levels of Man-in-the-Middle protection
116 that a Bluetooth service may specify.
118 enum TBluetoothMitmProtection
120 EMitmNotRequired = 0x0, /*!< No Man-in-the-Middle protection is required. */
121 EMitmDesired = 0x1, /*!< Man-in-the-Middle protection should be used where possible. */
122 EMitmRequired = 0x2 /*!< Man-in-the-Middle protection is required. */
125 NONSHARABLE_CLASS(TBTAccessRequirements)
126 /** The access requirements set up by a bluetooth service.
128 An incoming connection must satisfy these criteria before the connection may proceed.
129 Not spectacularly useful for applications; mainly used by other Bluetooth libraries
135 IMPORT_C TBTAccessRequirements();
136 IMPORT_C void SetAuthentication(TBool aPreference);
137 IMPORT_C void SetAuthorisation(TBool aPreference);
138 IMPORT_C void SetEncryption(TBool aPreference);
139 IMPORT_C void SetDenied(TBool aPreference);
140 IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference);
141 IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);
142 IMPORT_C TBool AuthenticationRequired() const;
143 IMPORT_C TBool AuthorisationRequired() const;
144 IMPORT_C TBool EncryptionRequired() const;
145 IMPORT_C TBool Denied() const;
146 IMPORT_C TUint PasskeyMinLength() const;
147 IMPORT_C TBool operator==(const TBTAccessRequirements& aRequirements) const;
148 IMPORT_C TBluetoothMitmProtection MitmProtection() const;
151 TUint8 iRequirements;
152 TUint iPasskeyMinLength;
155 enum TBTServiceSecuritySettings
157 EAuthenticate = 0x01,
161 EMitm = 0x30, // 2 bit field for MITM
164 enum TBTAccessRequirementsMitmProtection
166 EAccessRequirementsMitmUndefined = 0x00,
167 EAccessRequirementsMitmNotRequired = 0x10,
168 EAccessRequirementsMitmDesired = 0x20,
169 EAccessRequirementsMitmRequired = 0x30
173 NONSHARABLE_CLASS(TBTServiceSecurity)
174 /** The security settings of a bluetooth service.
176 Contains information regarding the service UID and the access requirements.
182 IMPORT_C TBTServiceSecurity(const TBTServiceSecurity& aService);
183 IMPORT_C TBTServiceSecurity();
184 IMPORT_C void SetUid(TUid aUid);
185 IMPORT_C void SetAuthentication(TBool aPreference);
186 IMPORT_C void SetAuthorisation(TBool aPreference);
187 IMPORT_C void SetEncryption(TBool aPreference);
188 IMPORT_C void SetDenied(TBool aPreference);
189 IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference);
190 IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);
191 IMPORT_C TBool AuthorisationRequired() const;
192 IMPORT_C TBool EncryptionRequired() const;
193 IMPORT_C TBool AuthenticationRequired() const;
194 IMPORT_C TBool Denied() const;
195 IMPORT_C TUint PasskeyMinLength() const;
196 IMPORT_C TUid Uid() const;
197 IMPORT_C TBluetoothMitmProtection MitmProtection() const;
200 TUid iUid; ///<The UID of the service. Will be used by the UI to work out the name of the service when prompting the user.
201 TBTAccessRequirements iSecurityRequirements; ///<Whether the service requires authentication, authorisation, encryption or min passkey len.
204 typedef TPckgBuf<TBTServiceSecurity> TBTServiceSecurityPckg; /*!< Package definition for securty settings */
206 NONSHARABLE_CLASS(TBTSockAddr) : public TSockAddr
207 /** Bluetooth socket address
209 Stores bluetooth device address, and security - these are common to all Bluetooth addresses
214 struct SBTAddrSecurity
217 TBTServiceSecurity iSecurity;
221 IMPORT_C TBTSockAddr();
222 IMPORT_C TBTSockAddr(const TSockAddr& aAddr);
223 IMPORT_C TBTDevAddr BTAddr() const;
224 IMPORT_C void SetBTAddr(const TBTDevAddr& aRemote);
225 IMPORT_C void SetSecurity(const TBTServiceSecurity& aSecurity);
226 IMPORT_C TBTServiceSecurity BTSecurity() const;
227 IMPORT_C static TBTSockAddr& Cast(const TSockAddr& aAddr);
230 IMPORT_C TAny* EndBTSockAddrPtr() const;
233 SBTAddrSecurity& BTAddrSecStruct() const;
234 TPtr8 AddressPtr() const;
238 const static TInt KErrBtEskError = -6999; /*!< BT ESK error code */
241 // Options available for all Bluetooth protocols
246 /** Override device security */
247 KBTRegisterCodService = 0x998, /*!< Set a CoD Service bit(s) */
248 KBTSecurityDeviceOverride = 0x999,
251 typedef TPckgBuf<TBTServiceSecurityPerDevice> TBTServiceSecurityPerDeviceBuf; /*!< Package definition for securty settings */
254 // Link manager error codes.
255 const static TInt KLinkManagerErrBase = -6450; /*!< Link manager base error value */
256 const static TInt KErrInsufficientBasebandResources = KLinkManagerErrBase; /*!< Insufficient baseband resources error value */
257 const static TInt KErrProxyWriteNotAvailable = KLinkManagerErrBase-1; /*!< Proxy write not available error value */
258 const static TInt KErrReflexiveBluetoothLink = KLinkManagerErrBase-2; /*!< Reflexive BT link error value */
259 const static TInt KErrPendingPhysicalLink = KLinkManagerErrBase-3; /*!< Physical link connection already pending when trying to connect the physical link */
260 const static TInt KErrRemoteDeviceIndicatedNoBonding = KLinkManagerErrBase-4; /*!< Dedicated bonding attempt failure when the remote device responds with No-Bonding */
266 const static TInt KL2CAPErrBase = -6300; /*!< Base error value for L2CAP error codes */
267 const static TInt KErrBadAddress = KL2CAPErrBase; /*!< L2CAP Bad address error code */
268 const static TInt KErrSAPUnexpectedEvent = KL2CAPErrBase - 1; /*!< L2CAP unexpected SAP event error code */
269 const static TInt KErrBadPacketReceived = KL2CAPErrBase - 2; /*!< L2CAP bad packet received error code */
270 const static TInt KErrL2CAPBadResponse = KL2CAPErrBase - 3; /*!< L2CAP bad response error code */
271 const static TInt KErrHCIConnectFailed = KL2CAPErrBase - 4; /*!< L2CAP HCI connection failed error code */
272 const static TInt KErrHCILinkDisconnection = KL2CAPErrBase - 5; /*!< L2CAP HCI link disconnection error code */
273 const static TInt KErrSAPNotConnected = KL2CAPErrBase - 6; /*!< L2CAP SAP not connected error code */
274 const static TInt KErrConfigBadParams = KL2CAPErrBase - 7; /*!< L2CAP bad configuration parameters error code */
275 const static TInt KErrConfigRejected = KL2CAPErrBase - 8; /*!< L2CAP configuration rejected error code */
276 const static TInt KErrConfigUnknownOptions = KL2CAPErrBase - 9; /*!< L2CAP unknown configuration options error code */
277 const static TInt KErrL2PeerDisconnected = KL2CAPErrBase - 10; /*!< L2CAP peer disconnected error code */
278 const static TInt KErrL2CAPAccessRequestDenied = KL2CAPErrBase - 11; /*!< L2CAP access request denied error code */
279 const static TInt KErrL2CAPRequestTimeout = KL2CAPErrBase - 12; /*!< L2CAP request timeout error code */
280 const static TInt KErrL2PeerRejectedCommand = KL2CAPErrBase - 13; /*!< L2CAP peer rejected command error code */
281 const static TInt KErrHostResNameTooLong = KL2CAPErrBase - 14; /*!< L2CAP host resolver name too long error code */
282 const static TInt KErrL2CAPNoMorePSMs = KL2CAPErrBase - 15; /*!< L2CAP no more PSMs error code */
283 const static TInt KErrL2CAPMaxTransmitExceeded = KL2CAPErrBase - 16; /*!< L2CAP in reliable mode: the maximum L2Cap retransmissions have been made and channel will disconnect error code*/
284 const static TInt KErrL2CAPDataControllerDetached = KL2CAPErrBase - 17; /*!< L2CAP problems (e.g. no memory) whilst sending data error code*/
285 const static TInt KErrL2CAPConfigPending = KL2CAPErrBase - 18; /*!< L2CAP configuration is in progress error code
287 const static TInt KErrL2CAPConfigAlreadyInProgress = KL2CAPErrBase - 19;/*!< L2CAP attempt to alter config whilst configuration is in progress error code*/
288 const static TInt KErrL2CAPNoFreeCID = KL2CAPErrBase - 21; /*!< L2CAP no more channel IDs available error code*/
291 const static TInt KErrHostResNoMoreResults = KErrEof; /*!< Host resolver has no more results error code */
292 const static TUint KHostResInquiry = 1; /*!< Host resolver inquiry option */
293 const static TUint KHostResName = 2; /*!< Host resolver name option. This is mutually exclusive with KHostResEir */
294 const static TUint KHostResIgnoreCache = 16; /*!< A way of ignoring the cache */
295 const static TUint KHostResCache = 32; /*!< A way to get CoD from cache */
296 const static TUint KHostResEir = 64; /*!< Host resolver Eir option. This is mutually exclusive with KHostResName */
299 const static TInt KL2CAPEchoRequestIoctl = 0; /*!< Echo Request Ioctl name */
300 const static TInt KL2CAPIncomingMTUIoctl = 1; /*!< Change incoming MTU Ioctl name */
301 const static TInt KL2CAPOutgoingMTUIoctl = 2; /*!< Change outgoing MTU Ioctl name */
302 const static TInt KL2CAPUpdateChannelConfigIoctl = 3;/*!< Change conguration parameters Ioctl name */
305 // Link Manager Ioctls
307 /** Link manager Ioctl codes.*/
310 /** Disconnect ACL Ioctl code
313 KLMDisconnectACLIoctl,
314 /** Set Packet type Ioctl code
317 KLMSetPacketTypeIoctl,
318 /** Wait for SCO notification Ioctl code
321 KLMWaitForSCONotificationIoctl,
322 /** One-shot baseband notification Ioctl code
325 KLMBasebandEventOneShotNotificationIoctl,
326 /** Baseband event notification Ioctl code
329 KLMBasebandEventNotificationIoctl,
330 /** Read Failed Contact Counter Ioctl
333 KLMReadFailedContactCounterIoctl,
334 /** Read Link Quality Ioctl
337 KLMReadLinkQualityIoctl,
342 /** Read Current Transmit Power Level Ioctl
345 KLMReadCurrentTransmitPowerLevelIoctl,
349 /** Paging policy for baseband.*/
350 enum TBasebandPageTimePolicy
352 EPagingDontCare, /*!< Don't care setting */
353 EPagingNormal, /*!< Normal setting */
354 EPagingBestEffort, /*!< Best effort setting */
355 EPagingQuick, /*!< Quick paging setting */
358 struct TBasebandPolicyParams
359 /** Baseband policy parameters.*/
361 TBasebandPageTimePolicy iPageTimePolicy; /*!< Page time policy */
364 struct TSetBasebandPolicy
365 /** Set baseband policy.
368 @see RBTBaseband, TPhysicalLinkQuickConnectionToken
371 TBTDevAddr iDevAddr; /*!< Device Address */
372 TBasebandPolicyParams iPolicy; /*!< Policy parameters */
375 /** Package for SetBasebandPolicy structure
378 typedef TPckgBuf<TSetBasebandPolicy> TSetBasebandPolicyBuf;
380 struct TPhysicalLinkQuickConnectionToken
381 /** Specifies details for faster connection.*/
383 TBTNamelessDevice iDevice; /*!< Nameless device */
384 TBasebandPolicyParams iPolicy; /*!< New policy */
387 typedef TPckgBuf<TPhysicalLinkQuickConnectionToken> TPhysicalLinkQuickConnectionTokenBuf; /*!< Package for TPhysicalLinkQuickConnectionToken structure */
389 #define KBasebandSlotTime 0.000625 /*!< Baseband timeslot duration (0.000625 seconds) */
390 static const TUint KDefaultBasebandConnectionTimeout = 10; /*!< Default baseband connection timeout (10 seconds) */
393 struct TLMDisconnectACLIoctl
395 Structure to specify the remote ACL connection to disconnect.
396 The reason passed in iReason will be sent to the remote device.
398 Use with KLMDisconnectACLIoctl.
402 TBTDevAddr iDevAddr; /*!< Device address */
403 TUint8 iReason; /*!< Reason code */
406 typedef TPckgBuf<TLMDisconnectACLIoctl> TLMDisconnectACLBuf; /*!< Package for TLMDisconnectACLIoctl structure */
408 // private tokens for use by RBTBaseband facade and stack
409 _LIT8(KDisconnectOnePhysicalLink, "1"); /*!< Specifes one physical link should be disconnected */
410 _LIT8(KDisconnectAllPhysicalLinks, "A"); /*!< Specifes all physical links should be disconnected */
413 /** Link manager options.
418 ELMOutboundACLSize, /*!< Outbound ACL size option */
419 ELMInboundACLSize, /*!< Inbound ACL size option */
420 KLMGetACLHandle, /*!< Get ACL Handle option */
421 KLMGetACLLinkCount, /*!< Get ACL link count option */
422 KLMGetACLLinkArray, /*!< Get ACL link array option */
423 KLMSetBasebandConnectionPolicy, /*!< Set baseband connection policy option */
424 KLMGetBasebandHandle, /*!< Get baseband handle option */
425 EBBSubscribePhysicalLink, /*!< Subscribe physical link option */
426 EBBBeginRaw, /*!< Enable raw broadcast option */
427 EBBRequestRoleMaster, /*!< Request switch to master option */
428 EBBRequestRoleSlave, /*!< Request switch to slave option */
429 EBBCancelModeRequest, /*!< Cancel mode request option */
430 EBBRequestSniff, /*!< Request sniff mode option */
431 EBBRequestPark, /*!< Request park mode option */
432 EBBRequestPreventRoleChange, /*!< Request to prevent a role (master / slave) switch option */
433 EBBRequestAllowRoleChange, /*!< Request to allow a role (master / slave) switchoption */
434 EBBRequestChangeSupportedPacketTypes, /*!< Request to cange the current supported packet types option */
435 EBBEnumeratePhysicalLinks, /*!< Enumerate physical links option */
436 EBBGetPhysicalLinkState, /*!< Get the physical link state option */
437 EBBGetSniffInterval, /*!< Get Sniff Interval option */
438 EBBRequestLinkAuthentication, /*!< Request authentication on the link */
439 EBBRequestExplicitActiveMode, /*!< Explicitly request the link to go into active mode */
441 //Allow combination of options below...
442 EBBRequestPreventSniff = 0x100, /*!< Request to prevent entering sniff mode option */
443 EBBRequestPreventHold = 0x200, /*!< Request to prevent entering hold mode option */
444 EBBRequestPreventPark = 0x400, /*!< Request to prevent entering park mode option */
445 EBBRequestPreventAllLowPowerModes =
446 (EBBRequestPreventSniff |
447 EBBRequestPreventHold |
448 EBBRequestPreventPark), /*!< Request to prevent entering all modes option */
449 EBBRequestAllowSniff = 0x800, /*!< Request to allow entering sniff mode option */
450 EBBRequestAllowHold = 0x1000, /*!< Request to allow entering hold mode option */
451 EBBRequestAllowPark = 0x2000, /*!< Request to allow entering park mode option */
452 EBBRequestAllowAllLowPowerModes =
453 (EBBRequestAllowSniff |
454 EBBRequestAllowHold |
455 EBBRequestAllowPark), /*!< Request to allow entering-all-modes option. */
459 /** Add SCO connnection Ioctl
462 static const TUint KLMAddSCOConnIoctl =0;
463 /** Remove SCO connection Ioctl
466 static const TUint KHCIRemoveSCOConnIoctl =1;
467 /** Change packet types allowed Ioctl
470 static const TUint KHCIChangePacketTypeIoctl =2;
471 /** Request authorisation Ioctl
474 static const TUint KHCIAuthRequestIoctl =3;
475 /** Request encryption Ioctl
478 static const TUint KHCIEncryptIoctl =4;
479 /** Change link key Ioctl
482 static const TUint KHCIChangeLinkKeyIoctl =5;
483 /** Master link key Ioctl
486 static const TUint KHCIMasterLinkKeyIoctl =6;
487 /** Enable hold mode Ioctl
490 static const TUint KHCIHoldModeIoctl =7;
491 /** Enable sniff mode Ioctl
494 static const TUint KHCISniffModeIoctl =8;
495 /** Exit sniff mode Ioctl
498 static const TUint KHCIExitSniffModeIoctl =9;
499 /** Enable park mode Ioctl
502 static const TUint KHCIParkModeIoctl =10;
503 /** Exit park mode Ioctl
506 static const TUint KHCIExitParkModeIoctl =11;
508 /** Read page timeout Ioctl
511 static const TUint KHCIReadPageTimeoutIoctl =12;
512 /** Write page timeout Ioctl
515 static const TUint KHCIWritePageTimeoutIoctl =13;
516 /** Read scan enable Ioctl
520 static const TUint KHCIReadScanEnableIoctl =14;
521 /** Write scan enable Ioctl
525 static const TUint KHCIWriteScanEnableIoctl =15;
526 /** Read device class Ioctl
530 static const TUint KHCIReadDeviceClassIoctl =16;
531 /** Write device class Ioctl
535 static const TUint KHCIWriteDeviceClassIoctl =17;
536 /** Read voice settings Ioctl
539 static const TUint KHCIReadVoiceSettingIoctl =18;
540 /** Write voice settings Ioctl
543 static const TUint KHCIWriteVoiceSettingIoctl =19;
544 /** Read hold mode activity Ioctl
547 static const TUint KHCIReadHoldModeActivityIoctl=20;
548 /** Write hold mode activity Ioctl
551 static const TUint KHCIWriteHoldModeActivityIoctl=21;
552 /** Local version Ioctl
555 static const TUint KHCILocalVersionIoctl =22;
556 /** Local features Ioctl
559 static const TUint KHCILocalFeaturesIoctl =23;
560 /** Country code Ioctl
563 static const TUint KHCICountryCodeIoctl =24;
564 /** Local address Ioctl
568 static const TUint KHCILocalAddressIoctl =25;
569 /** Write discoverability Ioctl
573 static const TUint KHCIWriteDiscoverabilityIoctl=26;
574 /** Read discoverability Ioctl
578 static const TUint KHCIReadDiscoverabilityIoctl =27;
579 /** Read authentification enabled Ioctl
582 static const TUint KHCIReadAuthenticationEnableIoctl=33;
583 /** Write authentification enabled Ioctl
586 static const TUint KHCIWriteAuthenticationEnableIoctl=34;
589 // Structs for ioctl parameters
592 Enumerations for the four possible scan enable modes.
593 Use Inquiry scan for discoverability and Page scan for
596 Use with KHCIReadScanEnableIoctl and KHCIWriteScanEnableIoctl.
600 enum THCIScanEnableIoctl
602 EHCINoScansEnabled=0x00, /*!< No scans enabled. */
603 EHCIInquiryScanOnly, /*!< Inquiry scan only. */
604 EHCIPageScanOnly, /*!< Page scan only. */
605 EHCIInquiryAndPageScan /*!< Both inquiry and page scan enabled. */
608 Package for THCIScanEnableIoctl structure
611 typedef TPckgBuf<THCIScanEnableIoctl> THCIScanEnableBuf;
613 struct TLMAddSCOConnectionIoctl
615 Structure for specifying SCO type to add to a connected socket.
616 The connection handle for the SCO link is returned in iConnH when
619 Use with KHCIAddSCOConnIoctl.
623 TUint16 iPktType; /*!< Packet type */
626 Package for TLMAddSCOConnectionIoctl structure
629 typedef TPckgBuf<TLMAddSCOConnectionIoctl> TLMAddSCOConnectionBuf;
631 struct THCISetEncryptionIoctl
633 Request to change the encryption state of a connection.
634 iEncrypt specifies whether to turn encryption on or off.
636 Use with KHCIEncryptIoctl.
640 TBool iEncrypt; /*!< Encryption enabled / disabled */
643 Package for THCISetEncryptionIoctl structure
646 typedef TPckgBuf<THCISetEncryptionIoctl> THCISetEncryptionBuf;
648 struct THCIDeviceClassIoctl
650 Structure to specify the class of device when getting or setting
651 the local device class.
653 Use with KHCIReadDeviceClassIoctl and KHCIWriteDeviceClassIoctl.
658 TUint16 iMajorServiceClass; /*!< Major Service class */
659 TUint8 iMajorDeviceClass; /*!< Major Device class */
660 TUint8 iMinorDeviceClass; /*!< Minor Device class */
663 Package for THCIDeviceClassIoctl structure
666 typedef TPckgBuf<THCIDeviceClassIoctl> THCIDeviceClassBuf;
668 struct THCILocalVersionIoctl
670 Structure describing the local Bluetooth hardware version.
672 Use with KHCILocalVersionIoctl.
676 TUint8 iHCIVersion; /*!< HCI version */
677 TUint16 iHCIRevision; /*!< HCI Revision */
678 TUint8 iLMPVersion; /*!< LMP version */
679 TUint16 iLMPSubversion; /*!< LMP subversion */
680 TUint16 iManufacturerName; /*!< Manufacturer name */
683 Package for THCILocalVersionIoctl structure
686 typedef TPckgBuf<THCILocalVersionIoctl> THCILocalVersionBuf;
688 /** L2CAP Get / Set Options. */
692 Get the outbound MTU size taking into account both the negotiated MTU size
693 and best use of underlying packet sizes.
694 For example: If the default outgoing MTU of 672 has been negotiated for a L2CAP channel
695 that is in Retransmission or Flow control mode then this GetOpt will return an
696 outgoing MTU of 668 bytes. This allows a maximally sized SDU
697 (which due to this adjustment will be 668 bytes) to be sent in two DH5 packets.
698 KL2CAPOutboundMTUForBestPerformance may also be used to set the current negotiated
699 (or to be negotiated) outbound MTU size.
700 Note that the outbound MTU size returned when using KL2CAPOutboundMTUForBestPerformance
701 with a GetOpt may not be the same as the outbound MTU size previously set
702 when using KL2CAPOutboundMTUForBestPerformance with a SetOpt.
704 KL2CAPOutboundMTUForBestPerformance,
707 This is the legacy value for setting getting \ setting the outbound MTU size and behaves
708 in the same way as KL2CAPOutboundMTUForBestPerformance.
709 @see KL2CAPOutboundMTUForBestPerformance
711 KL2CAPGetOutboundMTU = KL2CAPOutboundMTUForBestPerformance,
713 KL2CAPGetDebug1, /*!< Debug Command */
714 KL2CAPInboundMTU, /*!< Get / Set the current inbound MTU size */
715 KL2CAPRTXTimer, /*!< Change the extended L2CAP command retransmission timeout */
716 KL2CAPERTXTimer, /*!< Change the L2CAP command retransmission timeout */
717 KL2CAPGetMaxOutboundMTU, /*!< Get the max outbound MTU supported by the stack */
718 KL2CAPGetMaxInboundMTU, /*!< Get the max inbound MTU supported by the stack */
719 KL2CAPUpdateChannelConfig, /*!< Get and Set the current configuration parameters */
721 /** Get / Set the current negotiated (or to be negotiated) outbound MTU size */
722 KL2CAPNegotiatedOutboundMTU,
728 KL2CAPDataPlaneConfig,
731 This is similar to KL2CAPOutboundMTUForBestPerformance except that the caller can specify
732 a restriction that the returned MTU shall not exceed. This is useful for layers above L2CAP
733 that still want an optimal MTU but have their own restrictions on packet size.
735 KL2CAPOutboundMTUForBestPerformanceWithRestriction,
738 typedef TUint16 TL2CAPPort; /*!< Definition of a L2CAP port number type */
740 const static TL2CAPPort KL2CAPPassiveAutoBind = KMaxTUint16; /*!< PSM out of the valid range used for passive auto bind operation */
742 NONSHARABLE_CLASS(TL2CAPSockAddr) : public TBTSockAddr
743 /** L2CAP Socket Address.
745 Use this class to specify a local or remote L2CAP connection end-point,
746 that is Device Address and PSM/CID.
747 When unconnected, the Port() specifies the PSM, once connected it refers to
755 IMPORT_C TL2CAPSockAddr();
756 IMPORT_C TL2CAPSockAddr(const TSockAddr& aSockAddr);
757 IMPORT_C static TL2CAPSockAddr& Cast(const TSockAddr& aSockAddr);
759 IMPORT_C TL2CAPPort Port() const;
760 IMPORT_C void SetPort(const TL2CAPPort aHomePort);
763 NONSHARABLE_CLASS(TInquirySockAddr) : public TSockAddr
764 /** Socket address class used for inquiries.
766 Used to specify the inquiry request, and then filled with information
767 about remote devices discovered through the inquiry process.
769 Use the BTAddr() method to extract the device address to connect to.
772 Note: Usage of RHostResolver class for Bluetooth protocol.
774 The RHostResolver class is a generic interface to host name
775 resolution services, such as DNS, that may be provided
776 by particular protocol modules.
778 The points to remember when using RHostResolver::GetByAddress(),
779 RHostResolver::GetByName(), or RHostResolver::Next()
780 with Bluetooth protocol are:
782 1) If you operate on one instance of RHostResolver you can perform
783 only one request by calling either RHostResolver::GetByAddress()
784 or RHostResolver::GetByName(). If these functions are called again
785 and if there is more than one possible response for a given host name
786 then that will be returned (The host resolving process will
787 not start from the beginning). It is exactly as if the RHostResolve::Next()
790 2) In order to start resolving new hosts from the beginning using the same
791 instance of RHostResolver, the instance must be closed and reopened again.
793 3) In order to perform several RHostResolver requests they should be issued on
794 separate instances of RHostResolver (many RHostResolver instances might
795 exist and perform requests at the same time).
797 4) The KHostResIgnoreCache flag is only valid when issuing RHostResolver::GetByAddress()
798 or RHostResolver::GetByName() request for the first time.
800 5) As an RHostResolver is only intended to be used once, it is recommended that it
801 be closed as soon as it is finished with as the semantics of Cancel merely
802 indicates that one client server request should be cancelled.
808 // Max size for this structure is 24 bytes (32 - 8, see TSockAddr). However, due to padding and to prevent BC breaks,
809 // only up to 3 TUint8(s) may be added after iFlags
813 TUint8 iFormatTypeField; // since 'Format Type' only occupies 2 bits (least significant), we use 4 bits (most significant) for version information (and leave 2 bits unused)
814 TUint16 iMajorServiceClass;
815 TUint8 iMajorDeviceClass;
816 TUint8 iMinorDeviceClass;
824 // This defines all the bit masks for the inquiry result
825 enum TResolverResultFlags
831 IMPORT_C TInquirySockAddr();
832 IMPORT_C TInquirySockAddr(const TSockAddr& aSockAddr);
833 IMPORT_C TBTDevAddr BTAddr() const;
834 IMPORT_C void SetBTAddr(const TBTDevAddr& aRemote);
836 IMPORT_C static TInquirySockAddr& Cast(const TSockAddr& aSockAddr);
837 IMPORT_C TUint16 MajorServiceClass() const;
838 IMPORT_C void SetMajorServiceClass(TUint16 aClass);
839 IMPORT_C TUint8 MajorClassOfDevice() const;
840 IMPORT_C void SetMajorClassOfDevice(TUint8 aMajorClassOfDevice);
841 IMPORT_C TUint8 MinorClassOfDevice() const;
842 IMPORT_C void SetMinorClassOfDevice(TUint8 aMinorClassOfDevice);
843 IMPORT_C TUint IAC() const;
844 IMPORT_C void SetIAC(const TUint aIAC);
845 IMPORT_C TUint8 Action() const;
846 IMPORT_C void SetAction(TUint8 aFlags);
847 IMPORT_C TVersion Version() const;
848 IMPORT_C TInt8 Rssi() const;
849 IMPORT_C void SetRssi(const TInt8 aRssi);
850 IMPORT_C TUint8 ResultFlags() const;
851 IMPORT_C void SetResultFlags(TUint8 aResultFlags);
854 void SetVersion(TVersion aVersion);
855 IMPORT_C TUint8 FormatTypeField() const;
856 void SetFormatTypeField(TUint8 aType);
859 SInquiryAddr& InquiryAddrStruct() const;
860 TPtr8 AddressPtr() const;
869 EACLPortRaw = 0x00, /*!< Raw port type */
870 EACLPortL2CAP = 0x01, /*!< L2CAP port type */
871 EACLPortUnset = 0xFF, /*!< Unspecified ACL port type */
875 // SAP types for baseband
879 static const TUint KSockBluetoothTypeACL = KMaxTUint;
880 /** Raw broadcast socket type
883 static const TUint KSockBluetoothTypeRawBroadcast = KMaxTUint-2;
885 NONSHARABLE_CLASS(TACLSockAddr) : public TBTSockAddr
886 /** ACL Socket Address.
888 Use this class to specify a local or remote baseband connection end-point,
889 This is tied to the flags field in ACL data packets
894 IMPORT_C TACLSockAddr();
895 IMPORT_C TACLSockAddr(const TSockAddr& aSockAddr);
896 IMPORT_C static TACLSockAddr& Cast(const TSockAddr& aSockAddr);
898 IMPORT_C TACLPort Port() const;
899 IMPORT_C void SetPort(TACLPort aPort);
907 const static TInt KRFErrorBase = -6350; /*!< RFCOMM base error code. */
908 const static TInt KErrRfcommSAPUnexpectedEvent = KRFErrorBase; /*!< RFCOMM unexpected event error code. */
909 const static TInt KErrRfcommAlreadyBound = KRFErrorBase-1; /*!< RFCOMM SAP already bound error code. */
910 const static TInt KErrRfcommBadAddress = KRFErrorBase-2; /*!< RFCOMM bad address error code. */
911 const static TInt KErrRfcommMTUSize = KRFErrorBase-3; /*!< RFCOMM MTU size exceeded error code. */
912 const static TInt KErrRfcommFrameResponseTimeout = KRFErrorBase-4; /*!< RFCOMM frame response timeout error code. */
913 const static TInt KErrRfcommMuxRemoteDisconnect = KRFErrorBase-5; /*!< RFCOMM remote end disconnected error code. */
914 const static TInt KErrRfcommNotBound = KRFErrorBase-6; /*!< RFCOMM SAP not bound error code. */
915 const static TInt KErrRfcommParameterNegotiationFailure = KRFErrorBase-7; /*!< RFCOMM parameter negotiation failure error code. */
916 const static TInt KErrRfcommNotListening = KRFErrorBase-8; /*!< RFCOMM not listening error code. */
917 const static TInt KErrRfcommNoMoreServerChannels = KRFErrorBase-9; /*!< RFCOMM no more server channels available error code. */
921 const static TInt KRFCOMMModemStatusCmdIoctl =0; /*!< RFCOMM status command Ioctl */
922 const static TInt KRFCOMMRemoteLineStatusCmdIoctl = 1; /*!< RFCOMM remote line status command Ioctl */
923 const static TInt KRFCOMMRemotePortNegCmdIoctl = 2; /*!< RFCOMM remote port negotiation command Ioctl */
924 const static TInt KRFCOMMRemotePortNegRequestIoctl = 3; /*!< RFCOMM remote port negotiation request Ioctl */
925 const static TInt KRFCOMMConfigChangeIndicationIoctl = 4; /*!< RFCOMM MSC activity Ioctl */
929 const static TInt KRFCOMMLocalPortParameter = 0; /*!< RFCOMM local port parameter option (Get + Set) */
930 /** RFCOMM Get Available server channel option (Get only)
933 const static TInt KRFCOMMGetAvailableServerChannel = 1;
935 const static TInt KRFCOMMMaximumSupportedMTU = 2; /*!< RFCOMM maximum supported option (Get + Set) */
936 const static TInt KRFCOMMGetDebug1 = 3; /*!< RFCOMM debug option (Get only) */
937 const static TInt KRFCOMMGetRemoteModemStatus = 4; /*!< RFCOMM remote modem status option (Get + Set) */
939 const static TInt KRFCOMMGetTransmitCredit = 5; /*!< RFCOMM get transmit credits option */
940 const static TInt KRFCOMMGetReceiveCredit = 6; /*!< RFCOMM get receive credits option */
941 const static TInt KRFCOMMGetReUsedCount = 7; /*!< RFCOMM get number of remote used credits option */
942 const static TInt KRFCOMMFlowTypeCBFC = 8; /*!< RFCOMM Credit based flow control option (Get + Set) */
943 const static TInt KRFCOMMErrOnMSC = 9; /*!< RFCOMM set the value of MSC signals that will cause a disconnect error to be generated */
944 const static TUint KRFCOMMLocalModemStatus = 10; /*!< RFCOMM local modem status option (Get + Set) */
945 const static TUint KRFCOMMForgiveCBFCOverflow = 11; /*!< RFCOMM only when credit-based flow control is used. When unset (default), the remote overflowing us will cause us to disconnect. When set, we keep the connection up and process as much of the data as we can (i.e. RFCOMM becomes unreliable). (Set only) */
947 const static TInt KRFCOMMMaximumMTU = 12; /*!< RFCOMM maximum optimal MTU (Get only) */
949 // Masks for interpreting signalling commands
950 const static TUint8 KModemSignalFC = 0x01; /*!< RFCOMM FC signalling command mask */
951 const static TUint8 KModemSignalRTC = 0x02; /*!< RFCOMM RTC signalling command mask */
952 const static TUint8 KModemSignalRTR = 0x04; /*!< RFCOMM RTR signalling command mask */
953 const static TUint8 KModemSignalIC = 0x20; /*!< RFCOMM IC signalling command mask */
954 const static TUint8 KModemSignalDV = 0x40; /*!< RFCOMM DV signalling command mask */
956 enum TRPNParameterMask
957 /** Remote port negotiation parameter masks
960 EPMBitRate = 0x0001, /*!< Remote port negotiation parameter masks for bit rate */
961 EPMDataBits = 0x0002, /*!< Remote port negotiation parameter masks for data bits */
962 EPMStopBit = 0x0004, /*!< Remote port negotiation parameter masks for stop bit */
963 EPMParity = 0x0008, /*!< Remote port negotiation parameter masks for parity */
964 EPMParityType = 0x0010, /*!< Remote port negotiation parameter masks for parity type */
965 EPMXOnChar = 0x0020, /*!< Remote port negotiation parameter masks for on character */
966 EPMXOffChar = 0x0040, /*!< Remote port negotiation parameter masks for off character */
968 EPMXOnOffInput = 0x0100, /*!< Remote port negotiation parameter masks for XOn/Off input */
969 EPMXOnOffOutput = 0x0200, /*!< Remote port negotiation parameter masks for XOn/Off output */
970 EPMRTRInput = 0x0400, /*!< Remote port negotiation parameter masks for read to receive input */
971 EPMRTROutput = 0x0800, /*!< Remote port negotiation parameter masks for read to receive output */
972 EPMRTCInput = 0x1000, /*!< Remote port negotiation parameter masks for RTC input */
973 EPMRTCOutput = 0x2000 /*!< Remote port negotiation parameter masks for RTC output */
978 enum TRPNFlowCtrlMask
979 /** Remote port negotiation flow control masks
982 EFCXOnOffInput =0x01, /*!< Remote port negotiation flow control masks for XOn/Off input */
983 EFCXOnOffOutput =0x02, /*!< Remote port negotiation flow control masks for XOn/Off output */
984 EFCRTRInput =0x04, /*!< Remote port negotiation flow control masks for ready to receive input */
985 EFCRTROutput =0x08, /*!< Remote port negotiation flow control masks for ready to receive output */
986 EFCRTCInput =0x10, /*!< Remote port negotiation flow control masks for RTC input */
987 EFCRTCOutput =0x20 /*!< Remote port negotiation flow control masks for RTC output */
990 enum TRPNValidityMask
991 /** Remote port negotiation validity masks
994 EVMBitRate = 0x01, /*!< Remote port negotiation validity masks for bit rate */
995 EVMDataBits = 0x02, /*!< Remote port negotiation validity masks for data bits */
996 EVMStopBit = 0x04, /*!< Remote port negotiation validity masks for stop bit */
997 EVMParity = 0x08, /*!< Remote port negotiation validity masks for parity */
998 EVMFlowCtrl = 0x10, /*!< Remote port negotiation validity masks for flow control */
999 EVMXOnChar = 0x20, /*!< Remote port negotiation validity masks for XOn charater */
1000 EVMXOffChar = 0x40 /*!< Remote port negotiation validity masks for XOff charater */
1003 // structs for RFCOMM Ioctls
1005 class TRfcommRPNTransaction;
1007 NONSHARABLE_CLASS(TRfcommRemotePortParams)
1008 /** RF COMM remote port parameters.
1015 IMPORT_C TRfcommRemotePortParams();
1016 IMPORT_C TUint8 IsValid() const;
1017 IMPORT_C TBool GetBitRate(TBps& aBitRate) const;
1018 IMPORT_C TInt SetBitRate(TBps aBitRate);
1019 IMPORT_C TBool GetDataBits(TDataBits& aDataBits) const;
1020 IMPORT_C TInt SetDataBits(TDataBits aDataBits);
1021 IMPORT_C TBool GetStopBit(TStopBits& aStopBit) const;
1022 IMPORT_C TInt SetStopBit(TStopBits aStopBit);
1023 IMPORT_C TBool GetParity(TParity& aParity) const;
1024 IMPORT_C TInt SetParity(TParity aParity);
1025 IMPORT_C TBool GetFlowCtrl(TUint8& aFlowCtrl) const;
1026 IMPORT_C TInt SetFlowCtrl(TUint8 aFlowCtrl);
1027 IMPORT_C TBool GetXOnChar(TUint8& aXOnChar) const;
1028 IMPORT_C TInt SetXOnChar(TUint8 aXOnChar);
1029 IMPORT_C TBool GetXOffChar(TUint8& aXOffChar) const;
1030 IMPORT_C TInt SetXOffChar(TUint8 aXOffChar);
1031 IMPORT_C void UpdateFlowCtrlBit(TUint8 aFlowCtrl, TRPNFlowCtrlMask aFCMask);
1032 IMPORT_C void UpdateWholeFlowCtrl(TUint16 aParamMask, TUint8 aFlowCtrl);
1033 IMPORT_C void UpdateFromRPNTransaction(const TRfcommRPNTransaction&
1037 TDataBits iDataBits;
1038 TStopBits iStopBit; //It's really only one bit - ignore what the type implies...
1045 // This data padding has been added to help prevent future binary compatibility breaks
1046 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
1051 // structs for RFCOMM Ioctls
1053 NONSHARABLE_CLASS(TRfcommRPNTransaction)
1054 /** RF COMM IO control structs.
1060 public: // Functions
1061 IMPORT_C TRfcommRPNTransaction();
1062 public: // Variables
1063 TRfcommRemotePortParams iPortParams; /*!< Remote port parameters */
1064 TUint16 iParamMask; /*!< Parameter mask */
1069 typedef TUint8 TRfcommChannel; /*!< RFCOMM channel type definition */
1071 const static TRfcommChannel KMinRfcommServerChannel = 1; /*!< Minimum RFCOMM server channel value */
1072 const static TRfcommChannel KMaxRfcommServerChannel = 30; /*!< Maximum RFCOMM server channel value */
1074 const static TRfcommChannel KRfcommPassiveAutoBind = KMaxTUint8; /*!< Channel value out of the valid range used for passive auto bind. */
1076 NONSHARABLE_CLASS(TRfcommSockAddr) : public TBTSockAddr
1077 /** Defines the format of an Rfcomm address.
1079 This class uses the TSockAddr data area to hold the address so that
1080 it can be passed through the ESOCK boundary.
1081 Assumes that the remote RFCOMM instance is always bound to PSM 3 on
1082 L2CAP, so there is no way of specifying another remote PSM.
1090 IMPORT_C TRfcommSockAddr();
1091 IMPORT_C TRfcommSockAddr(const TSockAddr& aSockAddr);
1092 IMPORT_C static TRfcommSockAddr& Cast(const TSockAddr& aSockAddr);
1095 /*****BASEBAND CLIENT*********/
1097 class CBTBasebandSocketProxy;
1098 class CBTBasebandPropertySubscriber;
1100 class MBasebandObserver;
1101 /** Array of device addresses
1102 @see Enumerate method
1104 typedef RArray<TBTDevAddr> RBTDevAddrArray;
1106 NONSHARABLE_CLASS(RBTBaseband)
1107 /** API useful for Bluetooth as seen from a single physical link perspective
1114 //API useful for Bluetooth as seen from a single physical link perspective
1115 TInt Open(RSocketServ& aSocketServ, RSocket& aSocket);
1116 TInt Open(RSocketServ& aSocketServ, const TBTDevAddr& aDevAddr);
1118 TInt PhysicalLinkState(TUint32& aState);
1119 TInt BasebandState(TUint32& aState);
1120 TInt PreventRoleSwitch();
1121 TInt AllowRoleSwitch();
1122 TInt RequestMasterRole();
1123 TInt RequestSlaveRole();
1124 TInt PreventLowPowerModes(TUint32 aLowPowerModes);
1125 TInt AllowLowPowerModes(TUint32 aLowPowerModes);
1126 TInt ActivateSniffRequester();
1127 TInt ActivateParkRequester();
1128 TInt CancelLowPowerModeRequester();
1129 TInt RequestExplicitActiveMode(TBool aActive);
1130 TInt RequestChangeSupportedPacketTypes(TUint16 aPacketTypes);
1131 //THE TWO NOTIFY METHODS BELOW MUST NOT BE CALLED CONCURRENTLY
1132 //Method to be used if only the next event should be notified
1133 void ActivateNotifierForOneShot(TBTBasebandEvent& aEventNotification,
1134 TRequestStatus& aStatus,
1135 TUint32 aEventMask);
1136 //Method to be used if it is intended to call it again
1137 //(or call CancelNextBasebandChangeEventNotifier) when it completes
1138 // - this sets up a continuous monitoring of events on the server.
1139 //Each time ActivateNotifierForOneShot is called it will either return
1140 //the next event in the servers notification queue or if the
1141 //queue is empty it will await the next event.
1142 void ActivateNotifierForRecall(TBTBasebandEvent& aEventNotification,
1143 TRequestStatus& aStatus,
1144 TUint32 aEventMask);
1145 void ReadNewPhysicalLinkMetricValue(TRequestStatus& aStatus,
1147 TBTLMIoctls aIoctl);
1148 void CancelPhysicalLinkMetricUpdate();
1149 void CancelNextBasebandChangeEventNotifier();
1150 TInt Authenticate();
1152 //API useful for Bluetooth as seen from a device perspective
1153 TInt Open(RSocketServ& aSocketServ);
1154 void Connect(const TBTDevAddr& aDevAddr, TRequestStatus& aStatus);
1155 void Connect(const TPhysicalLinkQuickConnectionToken& aToken, TRequestStatus& aStatus);
1156 TInt Broadcast(const TDesC8& aData); // testing broadcast writes
1157 TInt ReadRaw(TDes8& aData);
1158 TInt Enumerate(RBTDevAddrArray& aBTDevAddrArray, TUint aMaxNumber);
1159 void TerminatePhysicalLink(TInt aReason);
1160 void TerminatePhysicalLink(TInt aReason, TRequestStatus& aStatus);
1161 void TerminatePhysicalLink(TInt aReason, const TBTDevAddr& aDevAddr, TRequestStatus& aStatus);
1162 void ShutdownPhysicalLink(TRequestStatus& aStatus);
1163 void TerminateAllPhysicalLinks(TInt aReason);
1164 void TerminateAllPhysicalLinks(TInt aReason, TRequestStatus& aStatus);
1165 TInt SubSessionHandle() const;
1168 TInt RequestRole(TBTLMOptions aRole);
1169 TInt RequestEncrypt(THCIEncryptModeFlag aEnable);
1170 void LocalComplete(TRequestStatus& aStatus, TInt aErr);
1171 void SetClientPending(TRequestStatus& aStatus);
1172 void DoConnect(TRequestStatus& aStatus);
1173 TInt Enumerate(TDes8& aData);
1177 TAny* iUnusedPointer;
1180 TRequestStatus* iClientRequestStatus;
1181 TBTSockAddr iSocketAddress;
1182 TPhysicalLinkQuickConnectionTokenBuf iConnectToken;
1183 TBuf8<1> iConnectInData; // not used yet - needed tho!
1184 TBuf8<1> iDummySCOShutdownDescriptor;
1186 // This data padding has been added to help prevent future binary compatibility breaks
1187 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
1192 NONSHARABLE_CLASS(RBTPhysicalLinkAdapter)
1193 /** Class to enable modification of a physical link:
1195 Modifications may be requested or prevented (blocked).
1196 Whilst a modification is being prevented, any request to
1197 perform that modification by this or any other
1198 RBTPhysicalLinkAdapter client will be ignored.
1199 If a low power mode is being used on the physical link, a
1200 call to prevent that low power mode will, if possible, cause
1201 the physical link to exit that low power mode. An
1202 arbitration between all RBTPhysicalLinkAdapter clients will then occur
1203 to decide whether the physical link should remain active or
1204 enter another low power mode. (If all low power modes are prevented
1205 then that arbitration will result in the physical link remaining
1208 Methods to prevent modifications begin 'Prevent...'
1210 Methods to cancel the prevention of modification begin 'Allow...'
1212 Requests for low power mode modifications, and notification of modifications
1213 take the form of continuously repeated requests which can be switched on or
1216 Only one low power mode requester may active on a single RBTPhysicalLinkAdapter
1217 client at a time. If several RBTPhysicalLinkAdapter clients have differing low
1218 power mode requests active at a given moment then the priority will be:
1223 Methods to perform these requests start 'Activate...'
1225 Methods to cancel these requests start 'Cancel...'
1231 IMPORT_C RBTPhysicalLinkAdapter();
1232 IMPORT_C TInt Open(RSocketServ& aSocketServ, RSocket& aSocket);
1233 IMPORT_C TInt Open(RSocketServ& aSocketServ, const TBTDevAddr& aDevAddr);
1234 IMPORT_C TBool IsOpen() const;
1235 IMPORT_C void Close();
1236 IMPORT_C TInt PhysicalLinkState(TUint32& aState);
1237 IMPORT_C TInt PreventRoleSwitch();
1238 IMPORT_C TInt AllowRoleSwitch();
1239 IMPORT_C TInt RequestMasterRole();
1240 IMPORT_C TInt RequestSlaveRole();
1241 IMPORT_C TInt PreventLowPowerModes(TUint32 aLowPowerModes);
1242 IMPORT_C TInt AllowLowPowerModes(TUint32 aLowPowerModes);
1243 IMPORT_C TInt ActivateSniffRequester();
1244 IMPORT_C TInt ActivateParkRequester();
1245 IMPORT_C TInt ActivateActiveRequester();
1246 IMPORT_C TInt CancelLowPowerModeRequester();
1247 IMPORT_C TInt RequestChangeSupportedPacketTypes(TUint16 aPacketTypes);
1248 IMPORT_C void NotifyNextBasebandChangeEvent(TBTBasebandEvent& aEventNotification,
1249 TRequestStatus& aStatus,
1250 TUint32 aEventMask = ENotifyAnyPhysicalLinkState);
1252 IMPORT_C void CancelNextBasebandChangeEventNotifier();
1253 IMPORT_C TInt Authenticate();
1256 RBTBaseband iBTBaseband;
1258 // This data padding has been added to help prevent future binary compatibility breaks
1259 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
1265 This allows for notification of events relating to a CBluetoothPhysicalLinkMetrics object.
1267 These notifications will be called when the value of a physical link metric that has been
1268 subscribed to in CBluetoothPhysicalLinkMetrics changes. If the notification is not called,
1269 the value has not changed since the last notification
1271 Mixin class to be used with CBluetoothPhysicalLinkMetrics
1275 class MBluetoothPhysicalLinkMetricsObserver
1279 Notification for the initial RSSI (received signal strengh indication) value
1280 and whenever the RSSI changes
1281 @param aRssi Current RSSI Value in dB
1283 virtual void MbplmoRssiChanged(TInt8 aRssi) = 0;
1286 Notification for the initial Link Quality value and whenever the Link Quality changes.
1287 @param aLinkQuality Link quality for this connection where the higher value represents a better quality link
1289 virtual void MbplmoLinkQualityChanged(TUint8 aLinkQuality) = 0;
1292 Notification for the initial failed contact counter value, and whenever the failed contact counter changes.
1293 @param aFailedContactCounter Number of consecutive failed contacts for this connection
1295 virtual void MbplmoFailedContactCounterChanged(TUint16 aFailedContactCounter) = 0;
1298 Notification for the initial transmit power level, and whenever the transmit power level changes.
1299 @param aTransmitPowerLevel Transmit power level in dBm
1301 virtual void MbplmoTransmitPowerLevelChanged(TInt8 aTransmitPowerLevel) = 0;
1304 Notification that an error has occured. When this is called, the current
1305 subscriptions will be cancelled.
1306 If a link disconnection occurs, the CBluetoothPhysicalLinkMetrics object will
1307 no longer be valid, so it is recommended to delete the object in this callback
1309 virtual void MbplmoError(TInt aError) = 0;
1312 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
1313 @param aInterface UID of the interface to return
1314 @return The container for another interface as specified by aInterface
1316 IMPORT_C virtual TAny* MbplmoExtensionInterfaceL(TUid aInterface);
1319 class CBluetoothPhysicalLinkMetricSubscriber;
1322 Class to subscribe to physical link metrics
1326 NONSHARABLE_CLASS(CBluetoothPhysicalLinkMetrics): public CBase
1329 IMPORT_C static CBluetoothPhysicalLinkMetrics* NewL(
1330 MBluetoothPhysicalLinkMetricsObserver& aObserver,
1331 RSocketServ& aSockServ,
1332 RSocket& aConnectedSocket);
1334 IMPORT_C static CBluetoothPhysicalLinkMetrics* NewL(
1335 MBluetoothPhysicalLinkMetricsObserver& aObserver,
1336 RSocketServ& aSockServ,
1337 const TBTDevAddr& aAddr);
1339 IMPORT_C ~CBluetoothPhysicalLinkMetrics();
1340 IMPORT_C void SubscribeRssi();
1341 IMPORT_C void SubscribeLinkQuality();
1342 IMPORT_C void SubscribeFailedContactCounter();
1343 IMPORT_C void SubscribeTransmitPowerLevel();
1344 IMPORT_C void Cancel();
1346 void RssiChanged(TInt8 aRssi);
1347 void LinkQualityChanged(TUint8 aLinkQuality);
1348 void FailedContactCounterChanged(TUint16 aFailedContactCounter);
1349 void TransmitPowerLevelChanged(TInt8 aTransmitPowerLevel);
1350 void SubscribeError(TInt aError);
1354 CBluetoothPhysicalLinkMetrics(MBluetoothPhysicalLinkMetricsObserver& aObserver);
1355 template<class T> void ConstructL(RSocketServ& aSockServ, T& aLinkIdentifier);
1358 MBluetoothPhysicalLinkMetricsObserver& iObserver;
1359 CBluetoothPhysicalLinkMetricSubscriber* iRssiBaseband;
1360 CBluetoothPhysicalLinkMetricSubscriber* iLinkQualityBaseband;
1361 CBluetoothPhysicalLinkMetricSubscriber* iFailedContactCounterBaseband;
1362 CBluetoothPhysicalLinkMetricSubscriber* iTransmitPowerLevelBaseband;
1366 class MBluetoothSocketNotifier
1367 /** This allows for notification of events relating to a CBluetoothSocket object.
1369 Such notification consists of notification of logical link events (for example receipt
1370 of a user packet) and physical link state events (for example change of power mode).
1372 Mixin class to be used with CBluetoothSocket
1378 /** Notification of a connection complete event.
1380 If no error is reported, then the connection is ready for use.
1381 @note If the implementation of this function needs to delete associated
1382 CBluetoothSocket object, it should NOT use delete operator. The implementation
1383 should call CBluetoothSocket::AsyncDelete() method instead.
1384 @param aErr the returned error
1386 virtual void HandleConnectCompleteL(TInt aErr) = 0;
1388 /** Notification of an accept complete event.
1390 If no error is reported, then we have accepted a connection request
1391 and that connection is ready for use.
1392 @note If the implementation of this function needs to delete associated
1393 CBluetoothSocket object, it should NOT use delete operator. The implementation
1394 should call CBluetoothSocket::AsyncDelete() method instead.
1395 @param aErr the returned error
1397 virtual void HandleAcceptCompleteL(TInt aErr) = 0;
1399 /** Notification of a shutdown complete event.
1401 If no error is reported, then the connection has been closed.
1402 @note If the implementation of this function needs to delete associated
1403 CBluetoothSocket object, it should NOT use delete operator. The implementation
1404 should call CBluetoothSocket::AsyncDelete() method instead.
1405 @param aErr the returned error
1407 virtual void HandleShutdownCompleteL(TInt aErr) = 0;
1409 /** Notification of a send complete event.
1411 If no error is reported, then an attempt to send data over Bluetooth has succeeded.
1412 @note If the implementation of this function needs to delete associated
1413 CBluetoothSocket object, it should NOT use delete operator. The implementation
1414 should call CBluetoothSocket::AsyncDelete() method instead.
1415 @param aErr the returned error
1417 virtual void HandleSendCompleteL(TInt aErr) = 0;
1419 /** Notification of a receive complete event.
1421 If no error is reported, then then we have successfully received
1422 a specified quantity of data.
1423 @note If the implementation of this function needs to delete associated
1424 CBluetoothSocket object, it should NOT use delete operator. The implementation
1425 should call CBluetoothSocket::AsyncDelete() method instead.
1426 @param aErr the returned error
1428 virtual void HandleReceiveCompleteL(TInt aErr) = 0;
1430 /** Notification of a ioctl complete event.
1432 An HCI request that has an associated command complete has completed.
1433 @note If the implementation of this function needs to delete associated
1434 CBluetoothSocket object, it should NOT use delete operator. The implementation
1435 should call CBluetoothSocket::AsyncDelete() method instead.
1436 @param aErr the returned error
1438 virtual void HandleIoctlCompleteL(TInt aErr) = 0;
1440 /** Notification of a baseband event.
1442 If no error is reported, then a baseband event has been retrieved successfully.
1443 @note If the implementation of this function needs to delete associated
1444 CBluetoothSocket object, it should NOT use delete operator. The implementation
1445 should call CBluetoothSocket::AsyncDelete() method instead.
1446 @param aErr the returned error
1447 @param TBTBasebandEventNotification Bit(s) set in TBTBasebandEventNotification bitmap indicate what event has taken place.
1448 @see TBTPhysicalLinkStateNotifier
1450 virtual void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification& aEventNotification) = 0;
1453 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
1454 @param aInterface UID of the interface to return
1455 @param aObject the container for another interface as specified by aInterface
1457 IMPORT_C virtual void MBSN_ExtensionInterfaceL(TUid aInterface, void*& aObject);
1463 class CBTShutdowner;
1467 class CBTBasebandChangeEventNotifier;
1468 class CAutoSniffDelayTimer;
1469 class CBTBasebandManager;
1470 class CBTBasebandChangeEventDelegate;
1472 NONSHARABLE_CLASS(CBluetoothSocket): public CBase
1473 /** This allows Bluetooth ACL socket-based services to be run.
1475 It allows all user-plane data flow to occur, plus control-plane Bluetooth
1476 baseband modification capabilities.
1478 For a more detailed description of RBTBaseband functionality see the class and function documentation for
1479 RBTPhysicalLinkAdapter.
1481 This class doesn't provide the functionality to directly activate Active mode
1482 (this is implementated in class RBTPhysicalLinkAdapter.)
1483 @see RBTPhysicalLinkAdapter::ActivateActiveRequester()
1484 Explicit Active mode requests are made automatically when using the Automatic Sniff Requester
1485 utility provided by this class.
1486 @see CBluetoothSocket::SetAutomaticSniffMode
1488 @see RBTPhysicalLinkAdapter
1493 friend class CBTAccepter;
1495 IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier,
1496 RSocketServ& aServer,TUint aSockType,
1498 IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier,
1499 RSocketServ& aServer,TUint aSockType,
1501 IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier,
1502 RSocketServ& aServer,TUint aSockType,
1504 RConnection& aConnection);
1505 IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier,
1506 RSocketServ& aServer,
1507 TUint aSockType,TUint aProtocol,
1508 RConnection& aConnection);
1509 IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier,
1510 RSocketServ& aServer,
1511 const TDesC& aName);
1512 IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier,
1513 RSocketServ& aServer,
1514 const TDesC& aName);
1515 IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier,
1516 RSocketServ& aServer);
1517 IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier,
1518 RSocketServ& aServer);
1519 IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier,
1520 RSocketServ& aServer,
1522 IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier,
1523 RSocketServ& aServer,
1525 IMPORT_C ~CBluetoothSocket();
1527 //Forwarding functions to RSocket
1528 IMPORT_C TInt Send(const TDesC8& aDesc,TUint someFlags);
1529 IMPORT_C TInt Send(const TDesC8& aDesc,TUint someFlags,TSockXfrLength& aLen);
1530 IMPORT_C void CancelSend();
1531 IMPORT_C TInt Recv(TDes8& aDesc,TUint flags);
1532 IMPORT_C TInt Recv(TDes8& aDesc,TUint flags,TSockXfrLength& aLen);
1533 IMPORT_C TInt RecvOneOrMore(TDes8& aDesc,TUint flags,TSockXfrLength& aLen);
1534 IMPORT_C void CancelRecv();
1535 IMPORT_C TInt Read(TDes8& aDesc);
1536 IMPORT_C void CancelRead();
1537 IMPORT_C TInt Write(const TDesC8& aDesc);
1538 IMPORT_C void CancelWrite();
1539 IMPORT_C TInt SendTo(const TDesC8& aDesc,TSockAddr& aSockAddr,TUint flags);
1540 IMPORT_C TInt SendTo(const TDesC8& aDesc,TSockAddr& aSockAddr,TUint flags,TSockXfrLength& aLen);
1541 IMPORT_C TInt RecvFrom(TDes8& aDesc,TSockAddr& aSockAddr,TUint flags);
1542 IMPORT_C TInt RecvFrom(TDes8& aDesc,TSockAddr& aSockAddr,TUint flags,TSockXfrLength& aLen);
1543 IMPORT_C TInt Connect(TBTSockAddr& aSockAddr);
1544 IMPORT_C TInt Connect(TBTSockAddr& aSockAddr,const TDesC8& aConnectDataOut,TDes8& aConnectDataIn);
1545 IMPORT_C TInt Connect(TBTSockAddr& aAddr, TUint16 aServiceBits);
1546 IMPORT_C void CancelConnect();
1547 IMPORT_C TInt Bind(TSockAddr& aSockAddr);
1548 IMPORT_C TInt SetLocalPort(TInt aPort);
1549 IMPORT_C TInt Accept(CBluetoothSocket& aBlankSocket);
1550 IMPORT_C TInt Accept(CBluetoothSocket& aBlankSocket,TDes8& aConnectData);
1551 IMPORT_C void CancelAccept();
1552 IMPORT_C TInt Listen(TUint qSize);
1553 IMPORT_C TInt Listen(TUint qSize,const TDesC8& aConnectData);
1554 IMPORT_C TInt Listen(TUint qSize, TUint16 aServiceBits);
1555 IMPORT_C TInt SetOpt(TUint aOptionName,TUint aOptionLevel,TInt aOption);
1556 IMPORT_C TInt SetOption(TUint aOptionName,TUint aOptionLevel,const TDesC8& aOption);
1557 IMPORT_C TInt GetOpt(TUint aOptionName,TUint aOptionLevel,TDes8& aOption);
1558 IMPORT_C TInt GetOpt(TUint aOptionName,TUint aOptionLevel,TInt &aOption);
1559 IMPORT_C TInt Ioctl(TUint aLevel, TUint aCommand, TDes8* aDesc);
1560 IMPORT_C void CancelIoctl();
1561 IMPORT_C TInt GetDisconnectData(TDes8& aDesc);
1562 IMPORT_C void LocalName(TSockAddr& aSockAddr);
1563 IMPORT_C TUint LocalPort();
1564 IMPORT_C void RemoteName(TSockAddr& aSockAddr);
1565 IMPORT_C TInt Shutdown(RSocket::TShutdown aHow);
1566 IMPORT_C TInt Shutdown(RSocket::TShutdown aHow,const TDesC8& aDisconnectDataOut,TDes8& aDisconnectDataIn);
1567 IMPORT_C void CancelAll();
1568 IMPORT_C TInt Info(TProtocolDesc& aProtocol);
1569 IMPORT_C TInt Name(TName& aName);
1570 IMPORT_C TInt Transfer(RSocketServ& aServer, const TDesC& aName);
1573 //Forwarding functions to RBTBaseband
1574 IMPORT_C TInt PhysicalLinkState(TUint32& aState);
1575 IMPORT_C TInt PreventRoleSwitch();
1576 IMPORT_C TInt AllowRoleSwitch();
1577 IMPORT_C TInt RequestMasterRole();
1578 IMPORT_C TInt RequestSlaveRole();
1579 IMPORT_C TInt PreventLowPowerModes(TUint32 aLowPowerModes);
1580 IMPORT_C TInt AllowLowPowerModes(TUint32 aLowPowerModes);
1581 IMPORT_C TInt ActivateSniffRequester();
1582 IMPORT_C TInt ActivateParkRequester();
1583 IMPORT_C TInt CancelLowPowerModeRequester();
1584 IMPORT_C TInt RequestChangeSupportedPacketTypes(TUint16 aPacketTypes);
1585 IMPORT_C TInt ActivateBasebandEventNotifier(TUint32 aEventTypes);
1586 IMPORT_C void CancelBasebandEventNotifier();
1588 IMPORT_C void SetNotifier(MBluetoothSocketNotifier& aNewNotifier);
1589 IMPORT_C TInt SetAutomaticSniffMode(TBool aAutoSniffMode);
1590 IMPORT_C TInt SetAutomaticSniffMode(TBool aAutoSniffMode, TInt aIdleSecondsBeforeSniffRequest);
1591 IMPORT_C TBool AutomaticSniffMode() const;
1593 IMPORT_C void AsyncDelete();
1595 //Callback functions called by active object RunLs.
1596 // NB These functions kill the active objects that call them (cf mating spiders)
1597 MBluetoothSocketNotifier& Notifier();
1598 void HandleConnectCompleteL(TInt aErr);
1599 void HandleAcceptCompleteL(TInt aErr);
1600 void HandleShutdownCompleteL(TInt aErr);
1601 void HandleSendCompleteL(TInt aErr);
1602 void HandleReceiveCompleteL(TInt aErr);
1603 void HandleIoctlCompleteL(TInt aErr);
1604 void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification aEventNotification);
1609 IMPORT_C TInt Ioctl(TUint aCommand,TDes8* aDesc=NULL,TUint aLevel=KLevelUnspecified);
1614 IMPORT_C TInt SetOpt(TUint aOptionName,TUint aOptionLevel,const TDesC8& aOption=TPtrC8(NULL,0));
1617 RSocketServ& SocketServer();
1618 RBTBaseband& BTBaseband();
1619 CBTBasebandManager& BTBasebandManager();
1622 CBluetoothSocket(MBluetoothSocketNotifier& aNotifier, RSocketServ& aServer);
1623 void ConstructL(TUint aSockType,TUint aProtocol);
1624 void ConstructL(TUint aSockType,TUint aProtocol, RConnection& aConnection);
1625 void ConstructL(const TDesC& aName);
1627 void ConstructL(RSocket& aSocket);
1629 static TInt AsyncDeleteCallBack(TAny *aThisPtr);
1630 void ConfigureSocket();
1634 RSocketServ& iSockServer;
1635 TBTSockAddr iSockAddr;
1637 MBluetoothSocketNotifier* iNotifier;
1639 CBTConnecter* iBTConnecter;
1640 CBTAccepter* iBTAccepter;
1641 CBTShutdowner* iBTShutdowner;
1642 CBTReceiver* iBTReceiver; //for read, recv etc
1643 CBTSender* iBTSender; //for send, write etc
1644 CBTIoctler* iBTIoctler;
1645 CBTBasebandChangeEventNotifier* iBTBasebandChangeEventNotifier;
1646 TUint32 iNotifierEventMask;
1650 RBTBaseband iBTBaseband;
1651 CAutoSniffDelayTimer* iAutoSniffDelayTimer;
1652 CBTBasebandManager* iBTBasebandManager;
1653 CBTBasebandChangeEventDelegate* iBTBasebandChangeEventDelegate;
1655 CAsyncCallBack* iAsyncDestroyer; //for async deletion
1659 class MBluetoothSynchronousLinkNotifier
1660 /** SCO and eSCO link notification events.
1662 This allows for notification of Connect, Disconnect, Send and
1663 Receive events relating to SCO and eSCO links.
1665 Mixin class to be used with CBluetoothSynchronousLink
1666 Note that although the function signatures allow it, these functions should
1667 not be allowed to leave as the error will be ignored.
1674 /** Notification that a synchronous link (SCO) has been set up
1676 If no error is reported, then the synchronous link is ready for use.
1677 @note 1) Observe that although the function signature allows it, this function should
1678 not be allowed to leave as the error will be ignored.
1679 @note 2) The implementation of this function should NOT be used to delete the associated
1680 CBluetoothSynchronousLink object.
1681 @param aErr the returned error
1683 virtual void HandleSetupConnectionCompleteL(TInt aErr) = 0;
1685 /** Notification that a synchronous link (SCO) has disconnected
1687 If no error is reported, then the synchronous link has been closed.
1688 @note 1) Observe that although the function signature allows it, this function should
1689 not be allowed to leave as the error will be ignored.
1690 @note 2) The implementation of this function should NOT be used to delete the associated
1691 CBluetoothSynchronousLink object.
1692 @param aErr the returned error
1694 virtual void HandleDisconnectionCompleteL(TInt aErr) = 0;
1696 /** Notification that a synchronous link (SCO) has been accepted
1698 If no error is reported, then we have accepted a request for a synchronous link.
1699 That synchronous link is ready for use.
1700 @note 1) Observe that although the function signature allows it, this function should
1701 not be allowed to leave as the error will be ignored.
1702 @note 2) The implementation of this function should NOT be used to delete the associated
1703 CBluetoothSynchronousLink object.
1704 @param aErr the returned error
1706 virtual void HandleAcceptConnectionCompleteL(TInt aErr) = 0;
1708 /** Notification of a send complete event
1710 If no error is reported, then an attempt to send synchronous (SCO) data
1711 (e.g. voice) over Bluetooth has succeeded.
1712 @note 1) Observe that although the function signature allows it, this function should
1713 not be allowed to leave as the error will be ignored.
1714 @note 2) The implementation of this function should NOT be used to delete the associated
1715 CBluetoothSynchronousLink object.
1716 @param aErr the returned error
1718 virtual void HandleSendCompleteL(TInt aErr) = 0;
1720 /** Notification of a receive complete event
1722 If no error is reported, then then we have successfully received
1723 a specified quantity of synchronous (SCO) data.
1724 @note 1) Observe that although the function signature allows it, this function should
1725 not be allowed to leave as the error will be ignored.
1726 @note 2) The implementation of this function should NOT be used to delete the associated
1727 CBluetoothSynchronousLink object.
1728 @param aErr the returned error
1730 virtual void HandleReceiveCompleteL(TInt aErr) = 0;
1733 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
1734 @param aInterface UID of the interface to return
1735 @param aObject the container for another interface as specified by aInterface
1737 IMPORT_C virtual void MBSLN_ExtensionInterfaceL(TUid aInterface, void*& aObject);
1740 class CBTSynchronousLinkAttacher;
1741 class CBTSynchronousLinkDetacher;
1742 class CBTSynchronousLinkAccepter;
1743 class CBTSynchronousLinkSender;
1744 class CBTSynchronousLinkReceiver;
1745 class CBTSynchronousLinkBaseband;
1751 A pair of transmit and receive bandwidths for use on synchronous Bluetooth links
1753 NONSHARABLE_CLASS(TBTSyncBandwidth)
1756 IMPORT_C TBTSyncBandwidth();
1757 IMPORT_C TBTSyncBandwidth(TUint aBandwidth);
1763 // This data padding has been added to help prevent future binary compatibility breaks
1764 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
1770 eSCO 64Kbit link utility constant.
1772 static const TUint KBTSync64KBit = (64000 / 8);
1776 Used internally to hold eSCO link parameters. Not intended for use.
1778 NONSHARABLE_CLASS(TBTeSCOLinkParams)
1781 TBTeSCOLinkParams() {};
1782 TBTeSCOLinkParams(TUint aBandwidth, TUint16 aCoding, TUint16 aLatency, TUint8 aRetransmission);
1784 TBTSyncBandwidth iBandwidth;
1787 TUint8 iRetransmissionEffort;
1791 /** Bluetooth link SCO type
1795 ESCO=0x01, /*!< Synchronous Connection Oriented link */
1796 EeSCO=0x02 /*!< eSCO link */
1799 NONSHARABLE_CLASS(CBluetoothSynchronousLink): public CBase
1800 /** Provides Bluetooth SCO functionality.
1802 This allows Bluetooth SCO (synchronous) link Connect, Disconnect, Send and Receive.
1808 IMPORT_C static CBluetoothSynchronousLink* NewL(MBluetoothSynchronousLinkNotifier& aNotifier,
1809 RSocketServ& aServer);
1810 IMPORT_C static CBluetoothSynchronousLink* NewLC(MBluetoothSynchronousLinkNotifier& aNotifier,
1811 RSocketServ& aServer);
1812 IMPORT_C ~CBluetoothSynchronousLink();
1814 IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr);
1815 IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr, const TUint16 aPacketTypes);
1816 IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr, const TBTSyncPackets& aPacketTypes);
1817 IMPORT_C void CancelSetup();
1818 IMPORT_C TInt Disconnect();
1819 IMPORT_C TInt Send(const TDesC8& aData);
1820 IMPORT_C void CancelSend();
1821 IMPORT_C TInt Receive(TDes8& aData);
1822 IMPORT_C void CancelReceive();
1823 IMPORT_C TInt AcceptConnection();
1824 IMPORT_C TInt AcceptConnection(const TBTSyncPackets& aPacketTypes);
1825 IMPORT_C void CancelAccept();
1827 IMPORT_C void SetCoding(TUint16 aVoiceSetting);
1828 IMPORT_C void SetMaxBandwidth(TBTSyncBandwidth aMaximum);
1829 IMPORT_C void SetMaxLatency(TUint16 aLatency);
1830 IMPORT_C void SetRetransmissionEffort(TBTeSCORetransmissionTypes aRetransmissionEffort);
1832 IMPORT_C TUint16 Coding();
1833 IMPORT_C TBTSyncBandwidth Bandwidth();
1834 IMPORT_C TUint16 Latency();
1835 IMPORT_C TUint8 RetransmissionEffort();
1837 IMPORT_C void RemoteName(TSockAddr& aAddr);
1839 IMPORT_C void SetNotifier(MBluetoothSynchronousLinkNotifier& aNotifier);
1841 MBluetoothSynchronousLinkNotifier& Notifier();
1842 RSocket& SCOSocket();
1843 RSocket& ESCOSocket();
1844 RSocket& ListeningSCOSocket();
1845 RSocket& ListeningESCOSocket();
1846 RSocketServ& SocketServer();
1847 RBTBaseband& Baseband();
1850 //Callback methods called by active object RunLs.
1851 void HandleSetupConnectionCompleteL(TInt aErr, TSCOType aSCOType);
1852 void HandleAcceptConnectionCompleteL(TInt aErr, TSCOType aSCOType);
1853 void HandleDisconnectionCompleteL(TInt aErr);
1854 void HandleSendCompleteL(TInt aErr);
1855 void HandleReceiveCompleteL(TInt aErr);
1858 CBluetoothSynchronousLink(MBluetoothSynchronousLinkNotifier& aNotifier, RSocketServ& aServer);
1860 void UpdateLinkParams(TSCOType aSCOType);
1861 TInt LinkUp(TBTDevAddr aAddr);
1865 CBTSynchronousLinkSender* iBTSynchronousLinkSenderSCO;
1866 CBTSynchronousLinkSender* iBTSynchronousLinkSenderESCO;
1867 CBTSynchronousLinkReceiver* iBTSynchronousLinkReceiverSCO;
1868 CBTSynchronousLinkReceiver* iBTSynchronousLinkReceiverESCO;
1869 CBTSynchronousLinkAccepter* iBTSynchronousLinkAccepterSCO;
1870 CBTSynchronousLinkAccepter* iBTSynchronousLinkAccepterESCO;
1871 CBTSynchronousLinkAttacher* iBTSynchronousLinkAttacherSCO;
1872 CBTSynchronousLinkAttacher* iBTSynchronousLinkAttacherESCO;
1873 CBTSynchronousLinkDetacher* iBTSynchronousLinkDetacherSCO;
1874 CBTSynchronousLinkDetacher* iBTSynchronousLinkDetacherESCO;
1875 CBTSynchronousLinkBaseband* iBTSynchronousLinkBaseband;
1876 MBluetoothSynchronousLinkNotifier* iNotifier;
1878 RSocket iESCOSocket;
1879 RSocket iListeningSCOSocket;
1880 RSocket iListeningESCOSocket;
1881 RBTBaseband iBaseband;
1882 RSocketServ& iSockServer;
1883 TBTSockAddr iSockAddr;
1884 TBuf8<1> iDummySCOShutdownDescriptor;
1886 TBTeSCOLinkParams iRequestedLink;
1887 TBTeSCOLinkParams iNegotiatedLink;
1897 class MBluetoothPhysicalLinksNotifier
1898 /** This allows for notifications of Physical link connections & disconnections
1900 Mixin class to be used with CBluetoothPhysicalLinks
1908 /** Notification of a requested connection coming up
1910 If no error is reported, then that connection is ready for use.
1911 @note 1) While this function may leave, any errors are ignored. Implementers are
1912 responsible for performing their own cleanup prior to exiting the function.
1913 @note 2) The implementation of this function should NOT be used to delete the associated
1914 CBluetoothPhysicalLinks object.
1916 @param aErr the returned error
1918 virtual void HandleCreateConnectionCompleteL(TInt aErr) = 0;
1920 /** Notification of a requested disconnection having taken place
1922 If no error is reported, then that connection has been closed.
1923 @note 1) While this function may leave, any errors are ignored. Implementers are
1924 responsible for performing their own cleanup prior to exiting the function.
1925 @note 2) The implementation of this function should NOT be used to delete the associated
1926 CBluetoothPhysicalLinks object.
1927 @param aErr the returned error
1929 virtual void HandleDisconnectCompleteL(TInt aErr) = 0;
1931 /** Notification that all existing connections have been torn down
1933 If no error is reported, then there are no Bluetooth connections existing.
1934 @note 1) While this function may leave, any errors are ignored. Implementers are
1935 responsible for performing their own cleanup prior to exiting the function.
1936 @note 2) The implementation of this function should NOT be used to delete the associated
1937 CBluetoothPhysicalLinks object.
1938 @param aErr the returned error
1940 virtual void HandleDisconnectAllCompleteL(TInt aErr) = 0;
1943 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
1944 @param aInterface UID of the interface to return
1945 @param aObject the container for another interface as specified by aInterface
1947 IMPORT_C virtual void MBPLN_ExtensionInterfaceL(TUid aInterface, void*& aObject);
1951 class CBTBasebandConnecter;
1952 class CBTBasebandShutdowner;
1953 class CBTDisconnector;
1955 NONSHARABLE_CLASS(CBluetoothPhysicalLinks): public CBase
1956 /** This is used to enumerate members of piconet, and attach and remove members thereof
1958 It may also be used for non-service dependent reads and writes.
1964 IMPORT_C static CBluetoothPhysicalLinks* NewL(MBluetoothPhysicalLinksNotifier& aNotifier,
1965 RSocketServ& aServer);
1966 IMPORT_C static CBluetoothPhysicalLinks* NewLC(MBluetoothPhysicalLinksNotifier& aNotifier,
1967 RSocketServ& aServer);
1968 IMPORT_C ~CBluetoothPhysicalLinks();
1970 IMPORT_C TInt CreateConnection(const TBTDevAddr& aDevAddr);
1971 IMPORT_C void CancelCreateConnection();
1972 IMPORT_C TInt Disconnect(const TBTDevAddr& aDevAddr);
1973 IMPORT_C TInt DisconnectAll();
1975 IMPORT_C TInt Broadcast(const TDesC8& aData);
1976 IMPORT_C TInt ReadRaw(TDes8& aData);
1977 IMPORT_C TInt Enumerate(RBTDevAddrArray& aBTDevAddrArray, TUint aMaxNumber);
1980 //Callback methods called by active object RunLs.
1981 //NB These methods kill the active objects that call them
1985 void HandleCreateConnectionCompleteL(TInt aErr);
1989 void HandleDisconnectCompleteL(TInt aErr);
1993 void HandleDisconnectAllCompleteL(TInt aErr);
1998 RSocketServ& SockServer();
2002 RBTBaseband& BTBaseband();
2006 MBluetoothPhysicalLinksNotifier& Notifier();
2010 CBluetoothPhysicalLinks(MBluetoothPhysicalLinksNotifier& aNotifier,
2011 RSocketServ& aServer);
2015 CBTBasebandConnecter* iBTBasebandConnecter;
2016 CBTDisconnector* iBTDisconnector;
2017 MBluetoothPhysicalLinksNotifier& iNotifier;
2018 RSocketServ& iSockServer;
2019 RBTBaseband iBTBaseband;
2025 NONSHARABLE_CLASS(RBluetoothPowerSwitch)
2026 /** This is intended for controlling whether the Bluetooth hardware is switched on or not.
2030 @see HCI_v2 documentation
2035 IMPORT_C RBluetoothPowerSwitch();
2036 IMPORT_C void RequestSwitchOn();
2037 IMPORT_C void RequestSwitchOff();
2042 class RHCIServerSession;
2043 class RSocketBasedHciDirectAccess;
2045 NONSHARABLE_CLASS(RHCIDirectAccess)
2047 API used for licensee-specific direct HCI access
2049 This class allows vendor-specific messages to be passed through to the HCI for
2050 customised (licensee-specific) HCI functionality.
2052 Note: No use of this class should be required by default. It is provided to
2053 assist with hardware workarounds, or link policy not implemented by the
2056 Do not use unless entirely familar with this API and the specific HCI in use!!!!
2063 IMPORT_C RHCIDirectAccess();
2064 //API used for licensee-specific direct HCI access
2065 IMPORT_C TInt Open();
2066 IMPORT_C TInt Open(RSocketServ& aSocketServ);
2067 IMPORT_C void Close();
2069 IMPORT_C void Ioctl(TUint aCommand, TRequestStatus &aStatus, TDes8* aDesc=NULL,TUint aLevel = KSolBtHCI);
2070 IMPORT_C void CancelIoctl();
2072 IMPORT_C void AsyncMessage(TUint aCommand, TRequestStatus &aStatus, TDes8* aDesc);
2073 IMPORT_C void CancelAsyncMessage();
2075 IMPORT_C TInt SubSessionHandle();
2077 RHCIServerSession* iHCIServerSession;
2078 RSocketBasedHciDirectAccess* iSocketAccess;
2079 TUint32 iReserved; // Padding for possible future "per-copy" state.