epoc32/include/bt_sock.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // BT socket interface types
    15 // 
    16 //
    17 
    18 
    19 
    20 /**
    21  @file
    22  @publishedAll
    23  @released
    24 */
    25 
    26 #ifndef BT_SOCK_H
    27 #define BT_SOCK_H
    28 
    29 #include <es_sock.h>
    30 #include <bttypes.h>
    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>
    35 
    36 
    37 
    38 _LIT(KRFCOMMDesC,"RFCOMM");	/*!< Descriptor name for RFCOMM */
    39 
    40 _LIT(KL2CAPDesC,"L2CAP"); 	/*!< Descriptor name for L2CAP */
    41 
    42 //
    43 // BT Protocol Family
    44 //
    45 
    46 const TUint KBTAddrFamily = 0x101; 		/*!< BT Address Family */
    47 
    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 */
    54 
    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 */
    58 
    59 // Socket Options
    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 */
    67 /**
    68 Decimal Value: 4118.
    69 */
    70 const TUint	KSolBtAVDTPSignalling	=0x1016;
    71 /**
    72 Decimal Value: 4119.
    73 */
    74 const TUint	KSolBtAVDTPMedia		=0x1017;
    75 /**
    76 Decimal Value: 4120.
    77 */
    78 const TUint	KSolBtAVDTPReporting	=0x1018;
    79 /**
    80 Decimal Value: 4121.
    81 */
    82 const TUint	KSolBtAVDTPRecovery		=0x1019;
    83 /**
    84 Decimal Value: 4128.
    85 */
    86 const TUint KSolBtAVDTPInternal		=0x1020;
    87 const TUint KSolBtLMProxy = 0x2011;		/*!< Link Manager Proxy socket option */
    88 const TUint KSolBtSAPBase  = 0x2020;	/*!< CBluetoothSAP handles SetOpt first */
    89 
    90 const static TUint8 KSCOListenQueSize = 1; /*!< Length of SCO listening queue */
    91 
    92 const static TUint16 KL2MinMTU = 48; 			/*!< BT Spec defined min. supported MTU size */
    93 
    94 
    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 */
    99 
   100 /**
   101  * This is the minimum user PSM. Smaller PSM values are possible but are reserved for use by the 
   102  * Bluetooth stack only.
   103  */
   104 const static TUint16 KMinUserPSM = 0x1001;
   105 
   106 /**
   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.
   110  * @deprecated
   111  */
   112 const static TUint16 KMinPSM = 0x1001;
   113 
   114 /**
   115 An enumeration to represent the possible levels of Man-in-the-Middle protection
   116 that a Bluetooth service may specify.
   117 */
   118 enum TBluetoothMitmProtection
   119 	{
   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. */
   123 	};
   124 
   125 NONSHARABLE_CLASS(TBTAccessRequirements)
   126 /** The access requirements set up by a bluetooth service.
   127 
   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
   130 @publishedAll
   131 @released
   132 */
   133 	{
   134 public:
   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;
   149 	
   150 private:
   151 	TUint8 iRequirements;
   152 	TUint  iPasskeyMinLength;
   153 	
   154 private:
   155 	enum TBTServiceSecuritySettings
   156 		{
   157 		EAuthenticate = 0x01,
   158 		EAuthorise = 0x02,
   159 		EEncrypt = 0x04,
   160 		EDenied = 0x08,
   161 		EMitm = 0x30, // 2 bit field for MITM
   162 		};
   163 	
   164 	enum TBTAccessRequirementsMitmProtection
   165 		{
   166 		EAccessRequirementsMitmUndefined = 0x00,
   167 		EAccessRequirementsMitmNotRequired = 0x10,
   168 		EAccessRequirementsMitmDesired = 0x20,
   169 		EAccessRequirementsMitmRequired = 0x30
   170 		};
   171 	};
   172 
   173 NONSHARABLE_CLASS(TBTServiceSecurity)
   174 /** The security settings of a bluetooth service.
   175 
   176 Contains information regarding the service UID and the access requirements.
   177 @publishedAll
   178 @released
   179 */
   180 	{
   181 public:
   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;
   198 	
   199 private:
   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.
   202 	};
   203 
   204 typedef TPckgBuf<TBTServiceSecurity> TBTServiceSecurityPckg;	/*!< Package definition for securty settings */
   205 
   206 NONSHARABLE_CLASS(TBTSockAddr) : public TSockAddr
   207 /** Bluetooth socket address
   208 
   209 Stores bluetooth device address, and security - these are common to all Bluetooth addresses
   210 @publishedAll
   211 @released
   212 */
   213 	{
   214 struct SBTAddrSecurity
   215 	{		
   216 	TBTDevAddr iAddress;
   217 	TBTServiceSecurity iSecurity;
   218 	};
   219 	
   220 public:
   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);
   228 	
   229 protected:
   230 	IMPORT_C TAny* EndBTSockAddrPtr() const;
   231 	
   232 private:
   233 	SBTAddrSecurity& BTAddrSecStruct() const;
   234 	TPtr8 AddressPtr() const;
   235 	};
   236 
   237 
   238 const static TInt KErrBtEskError = -6999;	/*!< BT ESK error code */
   239 
   240 
   241 // Options available for all Bluetooth protocols
   242 
   243 /** BT options. */
   244 enum TBTOptions
   245 	{
   246 	/** Override device security */
   247 	KBTRegisterCodService = 0x998,		/*!< Set a CoD Service bit(s) */
   248 	KBTSecurityDeviceOverride = 0x999,
   249 	};
   250 
   251 typedef TPckgBuf<TBTServiceSecurityPerDevice> TBTServiceSecurityPerDeviceBuf;	/*!< Package definition for securty settings */
   252 
   253 
   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 */
   261 
   262 //
   263 // L2CAP
   264 //
   265 
   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 
   286 																			 @internalComponent*/
   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*/
   289 
   290 // Host Resolver
   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  */
   297 
   298 // L2CAP Ioctls
   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 */
   303 
   304 
   305 // Link Manager Ioctls
   306 
   307 /** Link manager Ioctl codes.*/
   308 enum TBTLMIoctls
   309 	{
   310 	/** Disconnect ACL Ioctl code
   311 	@deprecated
   312 	*/
   313 	KLMDisconnectACLIoctl,
   314 	/** Set Packet type Ioctl code
   315 	@deprecated
   316 	*/
   317 	KLMSetPacketTypeIoctl,
   318 	/** Wait for SCO notification Ioctl code
   319 	@internalComponent
   320 	*/
   321 	KLMWaitForSCONotificationIoctl,
   322 	/** One-shot baseband notification Ioctl code
   323 	@internalComponent
   324 	*/	
   325 	KLMBasebandEventOneShotNotificationIoctl,
   326 	/** Baseband event notification Ioctl code
   327 	@internalComponent
   328 	*/	
   329 	KLMBasebandEventNotificationIoctl,
   330 	/** Read Failed Contact Counter Ioctl
   331 	@internalComponent
   332 	*/	
   333 	KLMReadFailedContactCounterIoctl,
   334 	/** Read Link Quality Ioctl
   335 	@internalComponent
   336 	*/	
   337 	KLMReadLinkQualityIoctl,
   338 	/** Read RSSI Ioctl
   339 	@internalComponent
   340 	*/	
   341 	KLMReadRssiIoctl,
   342 	/** Read Current Transmit Power Level Ioctl
   343 	@internalComponent
   344 	*/	
   345 	KLMReadCurrentTransmitPowerLevelIoctl,
   346 	};
   347 
   348 
   349 /** Paging policy for baseband.*/
   350 enum TBasebandPageTimePolicy
   351     {
   352 	EPagingDontCare,	/*!< Don't care setting */
   353     EPagingNormal,		/*!< Normal setting */
   354     EPagingBestEffort,	/*!< Best effort setting */
   355     EPagingQuick,		/*!< Quick paging setting */
   356     };
   357 
   358 struct TBasebandPolicyParams
   359 /** Baseband policy parameters.*/
   360 	{
   361 	TBasebandPageTimePolicy		iPageTimePolicy;	/*!< Page time policy */
   362 	};
   363 
   364 struct TSetBasebandPolicy
   365 /** Set baseband policy.
   366 
   367 @deprecated
   368 @see RBTBaseband, TPhysicalLinkQuickConnectionToken
   369 */
   370 	{
   371 	TBTDevAddr				iDevAddr;	/*!< Device Address */
   372 	TBasebandPolicyParams	iPolicy;	/*!< Policy parameters */
   373 	};
   374 
   375 /** Package for SetBasebandPolicy structure
   376 @deprecated
   377 */
   378 typedef TPckgBuf<TSetBasebandPolicy> TSetBasebandPolicyBuf;	
   379 
   380 struct TPhysicalLinkQuickConnectionToken
   381 /** Specifies details for faster connection.*/
   382 	{
   383 	TBTNamelessDevice		iDevice;	/*!< Nameless device */
   384 	TBasebandPolicyParams	iPolicy;	/*!< New policy */
   385 	};
   386 	
   387 typedef TPckgBuf<TPhysicalLinkQuickConnectionToken> TPhysicalLinkQuickConnectionTokenBuf;	/*!< Package for TPhysicalLinkQuickConnectionToken structure */
   388 
   389 #define KBasebandSlotTime 0.000625	/*!< Baseband timeslot duration (0.000625 seconds) */
   390 static const TUint KDefaultBasebandConnectionTimeout = 10;  /*!< Default baseband connection timeout (10 seconds) */
   391 
   392 
   393 struct TLMDisconnectACLIoctl
   394 /**
   395 Structure to specify the remote ACL connection to disconnect.
   396 The reason passed in iReason will be sent to the remote device.
   397 
   398 Use with KLMDisconnectACLIoctl.
   399 @deprecated
   400 */
   401 	{
   402 	TBTDevAddr	iDevAddr;	/*!< Device address */
   403 	TUint8		iReason;	/*!< Reason code */
   404 	};
   405 
   406 typedef TPckgBuf<TLMDisconnectACLIoctl> TLMDisconnectACLBuf;	/*!< Package for TLMDisconnectACLIoctl structure */
   407 
   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 */
   411 
   412 
   413 /** Link manager options.
   414 @internalComponent
   415 */
   416 enum TBTLMOptions
   417 	{
   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 */
   440 	
   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. */
   456 	};
   457 
   458 // HCI Ioctls
   459 /** Add SCO connnection Ioctl
   460 @deprecated
   461 */
   462 static const TUint KLMAddSCOConnIoctl			=0;
   463 /** Remove SCO connection Ioctl
   464 @deprecated
   465 */
   466 static const TUint KHCIRemoveSCOConnIoctl		=1;
   467 /** Change packet types allowed Ioctl
   468 @deprecated
   469 */
   470 static const TUint KHCIChangePacketTypeIoctl	=2;
   471 /** Request authorisation Ioctl 
   472 @deprecated
   473 */
   474 static const TUint KHCIAuthRequestIoctl			=3;
   475 /** Request encryption Ioctl
   476 @deprecated
   477 */
   478 static const TUint KHCIEncryptIoctl				=4;
   479 /** Change link key Ioctl
   480 @deprecated
   481 */
   482 static const TUint KHCIChangeLinkKeyIoctl		=5;
   483 /** Master link key Ioctl
   484 @deprecated
   485 */
   486 static const TUint KHCIMasterLinkKeyIoctl		=6;
   487 /** Enable hold mode Ioctl
   488 @deprecated
   489 */
   490 static const TUint KHCIHoldModeIoctl			=7;
   491 /** Enable sniff mode Ioctl
   492 @deprecated
   493 */
   494 static const TUint KHCISniffModeIoctl			=8;
   495 /** Exit sniff mode Ioctl
   496 @deprecated
   497 */
   498 static const TUint KHCIExitSniffModeIoctl		=9;
   499 /** Enable park mode Ioctl
   500 @deprecated
   501 */
   502 static const TUint KHCIParkModeIoctl			=10;
   503 /** Exit park mode Ioctl
   504 @deprecated
   505 */
   506 static const TUint KHCIExitParkModeIoctl		=11;
   507 
   508 /** Read page timeout Ioctl
   509 @deprecated
   510 */
   511 static const TUint KHCIReadPageTimeoutIoctl		=12;
   512 /** Write page timeout Ioctl
   513 @deprecated
   514 */
   515 static const TUint KHCIWritePageTimeoutIoctl	=13;
   516 /** Read scan enable Ioctl
   517 @deprecated
   518 @see bt_subscribe.h
   519 */
   520 static const TUint KHCIReadScanEnableIoctl		=14;
   521 /** Write scan enable Ioctl
   522 @deprecated
   523 @see bt_subscribe.h
   524 */
   525 static const TUint KHCIWriteScanEnableIoctl		=15;
   526 /** Read device class Ioctl
   527 @deprecated
   528 @see bt_subscribe.h
   529 */
   530 static const TUint KHCIReadDeviceClassIoctl		=16;
   531 /** Write device class Ioctl
   532 @deprecated
   533 @see bt_subscribe.h
   534 */
   535 static const TUint KHCIWriteDeviceClassIoctl	=17;
   536 /** Read voice settings Ioctl
   537 @deprecated
   538 */
   539 static const TUint KHCIReadVoiceSettingIoctl	=18;
   540 /** Write voice settings Ioctl
   541 @deprecated
   542 */
   543 static const TUint KHCIWriteVoiceSettingIoctl	=19;
   544 /** Read hold mode activity Ioctl
   545 @deprecated
   546 */
   547 static const TUint KHCIReadHoldModeActivityIoctl=20;
   548 /** Write hold mode activity Ioctl
   549 @deprecated
   550 */
   551 static const TUint KHCIWriteHoldModeActivityIoctl=21;
   552 /** Local version Ioctl
   553 @deprecated
   554 */
   555 static const TUint KHCILocalVersionIoctl		=22;
   556 /** Local features Ioctl
   557 @deprecated
   558 */
   559 static const TUint KHCILocalFeaturesIoctl		=23;
   560 /** Country code Ioctl
   561 @deprecated
   562 */
   563 static const TUint KHCICountryCodeIoctl			=24;
   564 /** Local address Ioctl
   565 @deprecated
   566 @see bt_subscribe.h
   567 */
   568 static const TUint KHCILocalAddressIoctl		=25;
   569 /** Write discoverability Ioctl
   570 @deprecated
   571 @see bt_subscribe.h
   572 */
   573 static const TUint KHCIWriteDiscoverabilityIoctl=26;
   574 /** Read discoverability Ioctl
   575 @deprecated
   576 @see bt_subscribe.h
   577 */
   578 static const TUint KHCIReadDiscoverabilityIoctl	=27;
   579 /** Read authentification enabled Ioctl
   580 @deprecated
   581 */
   582 static const TUint KHCIReadAuthenticationEnableIoctl=33;
   583 /** Write authentification enabled Ioctl
   584 @deprecated
   585 */
   586 static const TUint KHCIWriteAuthenticationEnableIoctl=34;
   587 
   588 
   589 // Structs for ioctl parameters
   590 
   591 /**
   592 Enumerations for the four possible scan enable modes.
   593 Use Inquiry scan for discoverability and Page scan for
   594 connectability.
   595 
   596 Use with KHCIReadScanEnableIoctl and KHCIWriteScanEnableIoctl.
   597 @deprecated
   598 @see bt_subscribe.h
   599 */
   600 enum THCIScanEnableIoctl 
   601     {
   602      EHCINoScansEnabled=0x00,          /*!< No scans enabled. */
   603      EHCIInquiryScanOnly,              /*!< Inquiry scan only. */
   604      EHCIPageScanOnly,                 /*!< Page scan only. */
   605      EHCIInquiryAndPageScan            /*!< Both inquiry and page scan enabled. */
   606     };
   607 /**
   608 Package for THCIScanEnableIoctl structure 
   609 @deprecated
   610 */
   611 typedef TPckgBuf<THCIScanEnableIoctl> THCIScanEnableBuf;	
   612 
   613 struct TLMAddSCOConnectionIoctl
   614 /**
   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
   617 the Ioctl completes.
   618 
   619 Use with KHCIAddSCOConnIoctl.
   620 @deprecated
   621 */
   622 	{
   623 	TUint16        iPktType;	/*!< Packet type */
   624 	};
   625 /**
   626 Package for TLMAddSCOConnectionIoctl structure
   627 @deprecated
   628 */
   629 typedef TPckgBuf<TLMAddSCOConnectionIoctl> TLMAddSCOConnectionBuf;	
   630 
   631 struct THCISetEncryptionIoctl
   632 /**
   633 Request to change the encryption state of a connection.
   634 iEncrypt specifies whether to turn encryption on or off.
   635 
   636 Use with KHCIEncryptIoctl.
   637 @deprecated
   638 */
   639 	{
   640 	TBool             iEncrypt;		/*!< Encryption enabled / disabled */
   641 	};
   642 /**
   643 Package for THCISetEncryptionIoctl structure 
   644 @deprecated
   645 */
   646 typedef TPckgBuf<THCISetEncryptionIoctl> THCISetEncryptionBuf;
   647 
   648 struct THCIDeviceClassIoctl
   649 /**
   650 Structure to specify the class of device when getting or setting
   651 the local device class.
   652 
   653 Use with KHCIReadDeviceClassIoctl and KHCIWriteDeviceClassIoctl.
   654 @deprecated
   655 @see bt_subscribe.h
   656 */
   657 	{
   658 	TUint16    iMajorServiceClass;		/*!< Major Service class */
   659 	TUint8     iMajorDeviceClass;		/*!< Major Device class */
   660 	TUint8     iMinorDeviceClass;		/*!< Minor Device class */
   661 	};
   662 /**
   663 Package for THCIDeviceClassIoctl structure 
   664 @deprecated
   665 */
   666 typedef TPckgBuf<THCIDeviceClassIoctl> THCIDeviceClassBuf;
   667 	
   668 struct THCILocalVersionIoctl
   669 /**
   670 Structure describing the local Bluetooth hardware version.
   671 
   672 Use with KHCILocalVersionIoctl.
   673 @deprecated
   674 */
   675 	{
   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 */
   681 	};
   682 /**
   683 Package for THCILocalVersionIoctl structure 
   684 @deprecated
   685 */
   686 typedef TPckgBuf<THCILocalVersionIoctl> THCILocalVersionBuf;	
   687 
   688 /** L2CAP Get / Set Options. */
   689 enum TBTL2CAPOptions
   690 	{
   691 	/** 
   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.
   703 	*/ 
   704 	KL2CAPOutboundMTUForBestPerformance,	
   705 
   706 	/** 
   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
   710 	*/ 
   711 	KL2CAPGetOutboundMTU = KL2CAPOutboundMTUForBestPerformance,
   712 
   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 */
   720 
   721 	/** Get / Set the current negotiated (or to be negotiated) outbound MTU size */
   722 	KL2CAPNegotiatedOutboundMTU,    
   723 
   724 	KL2CAPTestConfigure,	
   725 	KL2CAPDebugFlush,
   726 	KL2CAPVersion1_2,
   727 	KL2CAPHeapAlloc,
   728 	KL2CAPDataPlaneConfig,
   729 	
   730 	/**
   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.
   734 	*/
   735 	KL2CAPOutboundMTUForBestPerformanceWithRestriction,
   736 	};
   737 
   738 typedef TUint16 TL2CAPPort;			/*!< Definition of a L2CAP port number type */
   739 
   740 const static TL2CAPPort KL2CAPPassiveAutoBind = KMaxTUint16;  /*!< PSM out of the valid range used for passive auto bind operation */
   741 
   742 NONSHARABLE_CLASS(TL2CAPSockAddr) : public TBTSockAddr
   743 /** L2CAP Socket Address.
   744 
   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
   748 the CID.
   749 @see TBTSockAddr
   750 @publishedAll
   751 @released
   752 */
   753 	{
   754 public:
   755 	IMPORT_C TL2CAPSockAddr();
   756 	IMPORT_C TL2CAPSockAddr(const TSockAddr& aSockAddr);
   757 	IMPORT_C static TL2CAPSockAddr& Cast(const TSockAddr& aSockAddr);
   758 
   759 	IMPORT_C TL2CAPPort Port() const;
   760 	IMPORT_C void SetPort(const TL2CAPPort aHomePort);
   761 	};
   762 
   763 NONSHARABLE_CLASS(TInquirySockAddr) : public TSockAddr
   764 /** Socket address class used for inquiries.
   765 
   766 Used to specify the inquiry request, and then filled with information
   767 about remote devices discovered through the inquiry process.
   768 
   769 Use the BTAddr() method to extract the device address to connect to.
   770 
   771 
   772 Note: Usage of RHostResolver class for Bluetooth protocol.
   773 
   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.
   777 
   778 The points to remember when using RHostResolver::GetByAddress(), 
   779 RHostResolver::GetByName(), or RHostResolver::Next() 
   780 with Bluetooth protocol are:
   781 
   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() 
   788 	method was called.
   789 
   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.
   792 	
   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).
   796 	
   797 4)  The KHostResIgnoreCache flag is only valid when issuing RHostResolver::GetByAddress() 
   798 	or RHostResolver::GetByName() request for the first time.
   799 
   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.
   803 	
   804 @publishedAll
   805 @released
   806 */
   807 	{
   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
   810 	struct SInquiryAddr
   811 		{
   812 		TBTDevAddr iAddress;
   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;
   817 		TUint iIAC;
   818 		TUint8 iActionFlags;
   819 		TUint8 iResultFlags;
   820 		TInt8 iRssi;
   821 		};
   822 	
   823 public:
   824 	// This defines all the bit masks for the inquiry result
   825 	enum TResolverResultFlags
   826 		{
   827 		ERssiValid = 0x1,
   828 		};
   829 
   830 public:
   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);
   835 
   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);
   852 
   853 protected:
   854 	void SetVersion(TVersion aVersion);
   855 	IMPORT_C TUint8 FormatTypeField() const;
   856 	void SetFormatTypeField(TUint8 aType);
   857 	
   858 private:
   859 	SInquiryAddr& InquiryAddrStruct() const;
   860 	TPtr8 AddressPtr() const;
   861 	};
   862 
   863 
   864 enum TACLPort
   865 /** ACL port types.
   866 @internalComponent
   867 */
   868 	{
   869 	EACLPortRaw		= 0x00,		/*!< Raw port type */
   870 	EACLPortL2CAP	= 0x01,		/*!< L2CAP port type */
   871 	EACLPortUnset	= 0xFF,		/*!< Unspecified ACL port type */
   872 	};
   873 
   874 
   875 // SAP types for baseband
   876 /** ACL socket type
   877 @internalTechnology
   878 */
   879 static const TUint KSockBluetoothTypeACL = KMaxTUint;
   880 /** Raw broadcast socket type
   881 @internalTechnology
   882 */
   883 static const TUint KSockBluetoothTypeRawBroadcast = KMaxTUint-2;
   884 
   885 NONSHARABLE_CLASS(TACLSockAddr) : public TBTSockAddr
   886 /** ACL Socket Address.
   887 
   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
   890 @internalComponent
   891 */
   892 	{
   893 public:
   894 	IMPORT_C TACLSockAddr();
   895 	IMPORT_C TACLSockAddr(const TSockAddr& aSockAddr);
   896 	IMPORT_C static TACLSockAddr& Cast(const TSockAddr& aSockAddr);
   897 	//
   898 	IMPORT_C TACLPort Port() const;
   899 	IMPORT_C void SetPort(TACLPort aPort);
   900 	};
   901 
   902 
   903 //
   904 // RFCOMM
   905 //
   906 
   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. */
   918 
   919 //RFCOMMIoctls
   920 
   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 */
   926 
   927 // RFCOMM Options
   928 
   929 const static TInt KRFCOMMLocalPortParameter = 0;	/*!< RFCOMM local port parameter option (Get + Set) */
   930 /** RFCOMM Get Available server channel option (Get only)
   931 @deprecated
   932 */
   933 const static TInt KRFCOMMGetAvailableServerChannel = 1;
   934 
   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) */
   938 
   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) */
   946 
   947 const static TInt KRFCOMMMaximumMTU = 12; 	/*!< RFCOMM maximum optimal MTU (Get only) */
   948 
   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 */
   955 
   956 enum TRPNParameterMask
   957 /** Remote port negotiation parameter masks
   958 */
   959 	{
   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 */
   967 	// RESERVED		= 0x0080		
   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 */
   974 	// RESERVED		= 0x4000
   975 	// RESERVED		= 0x8000
   976 	};
   977 
   978 enum TRPNFlowCtrlMask
   979 /** Remote port negotiation flow control masks
   980 */
   981 	{
   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 */
   988 	};
   989 
   990 enum TRPNValidityMask
   991 /** Remote port negotiation validity masks
   992 */
   993 	{
   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 */
  1001 	};
  1002 
  1003 // structs for RFCOMM Ioctls
  1004 
  1005 class TRfcommRPNTransaction;
  1006 
  1007 NONSHARABLE_CLASS(TRfcommRemotePortParams)
  1008 /** RF COMM remote port parameters. 
  1009 
  1010 @publishedAll
  1011 @released
  1012 */
  1013 	{
  1014 public:
  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& 
  1034 											aRPNTransaction);	
  1035 private:	
  1036 	TBps iBitRate;
  1037 	TDataBits iDataBits;
  1038 	TStopBits iStopBit; //It's really only one bit - ignore what the type implies...
  1039 	TParity iParity;
  1040 	TUint8 iFlowCtrl;
  1041 	TUint8 iXOnChar;
  1042 	TUint8 iXOffChar;
  1043 	TUint8 iValidMask;
  1044 		
  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
  1047 	TUint32     iPadding1; 
  1048 	TUint32     iPadding2; 
  1049 	};
  1050 
  1051 // structs for RFCOMM Ioctls
  1052 
  1053 NONSHARABLE_CLASS(TRfcommRPNTransaction)
  1054 /** RF COMM IO control structs.
  1055 
  1056 @publishedAll
  1057 @released
  1058 */
  1059 	{
  1060 public: // Functions
  1061 	IMPORT_C TRfcommRPNTransaction();
  1062 public: // Variables
  1063 	TRfcommRemotePortParams iPortParams;	/*!< Remote port parameters */
  1064 	TUint16 iParamMask;						/*!< Parameter mask */
  1065 	};
  1066 
  1067 // RFCOMM addresses
  1068 
  1069 typedef TUint8 TRfcommChannel;	/*!< RFCOMM channel type definition */
  1070 
  1071 const static TRfcommChannel KMinRfcommServerChannel = 1;	/*!< Minimum RFCOMM server channel value */
  1072 const static TRfcommChannel KMaxRfcommServerChannel = 30;	/*!< Maximum RFCOMM server channel value */
  1073 
  1074 const static TRfcommChannel KRfcommPassiveAutoBind = KMaxTUint8;	/*!< Channel value out of the valid range used for passive auto bind. */
  1075 
  1076 NONSHARABLE_CLASS(TRfcommSockAddr) : public TBTSockAddr
  1077 /** Defines the format of an Rfcomm address.
  1078 
  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.
  1083 
  1084 @see TBTSockAddr
  1085 @publishedAll   
  1086 @released
  1087 */
  1088 	{
  1089 public:
  1090 	IMPORT_C TRfcommSockAddr();
  1091 	IMPORT_C TRfcommSockAddr(const TSockAddr& aSockAddr);
  1092 	IMPORT_C static TRfcommSockAddr& Cast(const TSockAddr& aSockAddr);
  1093 	};
  1094 
  1095 /*****BASEBAND CLIENT*********/
  1096 
  1097 class CBTBasebandSocketProxy;
  1098 class CBTBasebandPropertySubscriber;
  1099 
  1100 class MBasebandObserver;
  1101 /** Array of device addresses
  1102 @see Enumerate method
  1103 */
  1104 typedef RArray<TBTDevAddr> RBTDevAddrArray;		
  1105 
  1106 NONSHARABLE_CLASS(RBTBaseband)
  1107 /** API useful for Bluetooth as seen from a single physical link perspective
  1108 @internalTechnology
  1109 @released
  1110 */
  1111 	{
  1112 public:
  1113 	RBTBaseband();
  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);
  1117 	void Close();
  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,
  1146 								TDes8& aData,
  1147 								TBTLMIoctls aIoctl);
  1148 	void CancelPhysicalLinkMetricUpdate();
  1149 	void CancelNextBasebandChangeEventNotifier();
  1150 	TInt Authenticate();
  1151 	
  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;
  1166 	
  1167 private:
  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);
  1174 	TInt Construct();
  1175 		
  1176 private:
  1177 	TAny*					iUnusedPointer;
  1178 	RSocket					iSocket;
  1179 
  1180 	TRequestStatus*							iClientRequestStatus;
  1181 	TBTSockAddr								iSocketAddress;				
  1182 	TPhysicalLinkQuickConnectionTokenBuf	iConnectToken;
  1183 	TBuf8<1>								iConnectInData; // not used yet - needed tho!
  1184 	TBuf8<1>								iDummySCOShutdownDescriptor;
  1185 	
  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
  1188 	TUint32     iPadding1; 
  1189 	TUint32     iPadding2; 	
  1190 	};
  1191 
  1192 NONSHARABLE_CLASS(RBTPhysicalLinkAdapter)
  1193 /** Class to enable modification of a physical link:
  1194 
  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
  1206 active.)
  1207 
  1208 Methods to prevent modifications begin 'Prevent...'
  1209 
  1210 Methods to cancel the prevention of modification begin 'Allow...'
  1211 
  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 
  1214 switched off. 
  1215 
  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:
  1219 	Hold
  1220 	Sniff
  1221 	Park
  1222 
  1223 Methods to perform these requests start 'Activate...'
  1224 
  1225 Methods to cancel these requests start 'Cancel...'
  1226 @publishedAll
  1227 @released
  1228 */
  1229 	{
  1230 public:
  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);
  1251 
  1252 	IMPORT_C void CancelNextBasebandChangeEventNotifier();
  1253 	IMPORT_C TInt Authenticate();
  1254 	
  1255 private:
  1256 	RBTBaseband iBTBaseband;
  1257 	
  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
  1260 	TUint32     iPadding1; 
  1261 	TUint32     iPadding2; 	
  1262 	};
  1263 
  1264 /**
  1265 This allows for notification of events relating to a CBluetoothPhysicalLinkMetrics object.
  1266 
  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
  1270 
  1271 Mixin class to be used with CBluetoothPhysicalLinkMetrics
  1272 @publishedAll
  1273 @released
  1274 */
  1275 class MBluetoothPhysicalLinkMetricsObserver
  1276 	{
  1277 public:
  1278 	/**
  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
  1282 	*/
  1283 	virtual void MbplmoRssiChanged(TInt8 aRssi) = 0;
  1284 	
  1285 	/**
  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
  1288 	*/
  1289 	virtual void MbplmoLinkQualityChanged(TUint8 aLinkQuality) = 0;
  1290 	
  1291 	/**
  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
  1294 	*/
  1295 	virtual void MbplmoFailedContactCounterChanged(TUint16 aFailedContactCounter) = 0;
  1296 	
  1297 	/**
  1298 	Notification for the initial transmit power level, and whenever the transmit power level changes.
  1299 	@param aTransmitPowerLevel Transmit power level in dBm
  1300 	*/
  1301 	virtual void MbplmoTransmitPowerLevelChanged(TInt8 aTransmitPowerLevel) = 0;
  1302 	
  1303 	/**
  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
  1308 	*/
  1309 	virtual void MbplmoError(TInt aError) = 0;
  1310 	
  1311 	/**
  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
  1315 	*/
  1316 	IMPORT_C virtual TAny* MbplmoExtensionInterfaceL(TUid aInterface);
  1317 	};
  1318 
  1319 class CBluetoothPhysicalLinkMetricSubscriber;
  1320 
  1321 /**
  1322 Class to subscribe to physical link metrics
  1323 @publishedAll
  1324 @released
  1325 */
  1326 NONSHARABLE_CLASS(CBluetoothPhysicalLinkMetrics): public CBase
  1327 	{
  1328 public:
  1329 	IMPORT_C static CBluetoothPhysicalLinkMetrics* NewL(
  1330 						MBluetoothPhysicalLinkMetricsObserver& aObserver,
  1331 						RSocketServ& aSockServ,
  1332 						RSocket& aConnectedSocket);
  1333 	
  1334 	IMPORT_C static CBluetoothPhysicalLinkMetrics* NewL(
  1335 						MBluetoothPhysicalLinkMetricsObserver& aObserver,
  1336 						RSocketServ& aSockServ,
  1337 						const TBTDevAddr& aAddr);
  1338 	
  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();
  1345 	
  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);
  1351 
  1352 	
  1353 private:
  1354 	CBluetoothPhysicalLinkMetrics(MBluetoothPhysicalLinkMetricsObserver& aObserver);
  1355 	template<class T> void ConstructL(RSocketServ& aSockServ, T& aLinkIdentifier);	
  1356 	
  1357 private:
  1358 	MBluetoothPhysicalLinkMetricsObserver& iObserver;
  1359 	CBluetoothPhysicalLinkMetricSubscriber* iRssiBaseband;
  1360 	CBluetoothPhysicalLinkMetricSubscriber* iLinkQualityBaseband;
  1361 	CBluetoothPhysicalLinkMetricSubscriber* iFailedContactCounterBaseband;
  1362 	CBluetoothPhysicalLinkMetricSubscriber* iTransmitPowerLevelBaseband;
  1363 	};
  1364 
  1365 
  1366 class MBluetoothSocketNotifier
  1367 /** This allows for notification of events relating to a CBluetoothSocket object.
  1368 
  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).
  1371 
  1372 Mixin class to be used with CBluetoothSocket
  1373 @publishedAll
  1374 @released
  1375 */
  1376 	{
  1377 public:
  1378 	/** Notification of a connection complete event.
  1379 	
  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
  1385 	*/
  1386 	virtual void HandleConnectCompleteL(TInt aErr) = 0;
  1387 
  1388 	/** Notification of an accept complete event.
  1389 	
  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
  1396 	*/
  1397 	virtual void HandleAcceptCompleteL(TInt aErr) = 0;
  1398 
  1399 	/** Notification of a shutdown complete event.
  1400 	
  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
  1406 	*/
  1407 	virtual void HandleShutdownCompleteL(TInt aErr) = 0;
  1408 
  1409 	/** Notification of a send complete event.
  1410 	
  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
  1416 	*/
  1417 	virtual void HandleSendCompleteL(TInt aErr) = 0;
  1418 
  1419 	/** Notification of a receive complete event.
  1420 	
  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
  1427 	*/
  1428 	virtual void HandleReceiveCompleteL(TInt aErr) = 0;
  1429 
  1430 	/** Notification of a ioctl complete event.
  1431 	
  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
  1437 	*/
  1438 	virtual void HandleIoctlCompleteL(TInt aErr) = 0;
  1439 
  1440 	/** Notification of a baseband event.
  1441 	
  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
  1449 	*/
  1450 	virtual void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification& aEventNotification) = 0;
  1451 	
  1452     /**
  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
  1456 	 */
  1457 	IMPORT_C virtual void MBSN_ExtensionInterfaceL(TUid aInterface, void*& aObject);	
  1458 	};
  1459 
  1460 
  1461 class CBTConnecter;
  1462 class CBTAccepter;
  1463 class CBTShutdowner;
  1464 class CBTReceiver;
  1465 class CBTSender;
  1466 class CBTIoctler;
  1467 class CBTBasebandChangeEventNotifier;
  1468 class CAutoSniffDelayTimer;
  1469 class CBTBasebandManager;
  1470 class CBTBasebandChangeEventDelegate;
  1471 
  1472 NONSHARABLE_CLASS(CBluetoothSocket): public CBase
  1473     /** This allows Bluetooth ACL socket-based services to be run.
  1474 
  1475     It allows all user-plane data flow to occur, plus control-plane Bluetooth 
  1476     baseband modification capabilities.
  1477     
  1478     For a more detailed description of RBTBaseband functionality see the class and function documentation for
  1479     RBTPhysicalLinkAdapter.
  1480     
  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	
  1487 
  1488     @see RBTPhysicalLinkAdapter
  1489     @publishedAll
  1490     @released
  1491     */
  1492 	{
  1493 friend class CBTAccepter;		
  1494 public:
  1495 	IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, 
  1496 										   RSocketServ& aServer,TUint aSockType,
  1497 										   TUint aProtocol);
  1498 	IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, 
  1499 										   RSocketServ& aServer,TUint aSockType,
  1500 										   TUint aProtocol);
  1501 	IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, 
  1502 										   RSocketServ& aServer,TUint aSockType,
  1503 										   TUint aProtocol, 
  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,
  1521 										   RSocket& aSocket);
  1522 	IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, 
  1523 										   RSocketServ& aServer,
  1524 										   RSocket& aSocket);								
  1525 	IMPORT_C ~CBluetoothSocket();
  1526 
  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);
  1571 
  1572 	
  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();
  1587 	
  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;
  1592 	
  1593 	IMPORT_C void AsyncDelete();
  1594 	
  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);
  1605 
  1606 	/**
  1607 	@deprecated
  1608 	*/
  1609 	IMPORT_C TInt Ioctl(TUint aCommand,TDes8* aDesc=NULL,TUint aLevel=KLevelUnspecified);
  1610 
  1611 	/**
  1612 	@deprecated
  1613 	*/
  1614 	IMPORT_C TInt SetOpt(TUint aOptionName,TUint aOptionLevel,const TDesC8& aOption=TPtrC8(NULL,0));
  1615 public:
  1616 	RSocket& Socket();
  1617 	RSocketServ& SocketServer();
  1618 	RBTBaseband& BTBaseband();
  1619 	CBTBasebandManager& BTBasebandManager();
  1620 
  1621 private:
  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);
  1626 	void ConstructL();
  1627 	void ConstructL(RSocket& aSocket);
  1628 	void InitialiseL();
  1629 	static TInt AsyncDeleteCallBack(TAny *aThisPtr);
  1630 	void ConfigureSocket();
  1631 
  1632 private:
  1633 	RSocket							iSocket;
  1634 	RSocketServ&					iSockServer;
  1635 	TBTSockAddr						iSockAddr;
  1636 
  1637 	MBluetoothSocketNotifier*		iNotifier;
  1638 
  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;
  1647 	TBool							iSending;
  1648 	TBool							iReceiving;
  1649 
  1650 	RBTBaseband 					iBTBaseband;
  1651 	CAutoSniffDelayTimer*			iAutoSniffDelayTimer;
  1652 	CBTBasebandManager*				iBTBasebandManager;
  1653 	CBTBasebandChangeEventDelegate*	iBTBasebandChangeEventDelegate;
  1654 	
  1655 	CAsyncCallBack*					iAsyncDestroyer;	//for async deletion
  1656 	};
  1657 
  1658 
  1659 class MBluetoothSynchronousLinkNotifier
  1660 /** SCO and eSCO link notification events.
  1661 
  1662 This allows for notification of Connect, Disconnect, Send and
  1663 Receive events relating to SCO and eSCO links.
  1664 
  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.
  1668 
  1669 @publishedAll
  1670 @released
  1671 */
  1672 	{
  1673 public:
  1674 	/** Notification that a synchronous link (SCO) has been set up
  1675 	
  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
  1682 	*/
  1683 	virtual void HandleSetupConnectionCompleteL(TInt aErr) = 0;
  1684 
  1685 	/** Notification that a synchronous link (SCO) has disconnected
  1686 	
  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
  1693 	*/
  1694 	virtual void HandleDisconnectionCompleteL(TInt aErr) = 0;
  1695 
  1696 	/** Notification that a synchronous link (SCO) has been accepted
  1697 	
  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
  1705 	*/
  1706 	virtual void HandleAcceptConnectionCompleteL(TInt aErr) = 0;
  1707 
  1708 	/** Notification of a send complete event
  1709 	
  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
  1717 	*/
  1718 	virtual void HandleSendCompleteL(TInt aErr) = 0;
  1719 
  1720 	/** Notification of a receive complete event
  1721 	
  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
  1729 	*/
  1730 	virtual void HandleReceiveCompleteL(TInt aErr) = 0;
  1731 	
  1732     /**
  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
  1736 	 */
  1737 	IMPORT_C virtual void MBSLN_ExtensionInterfaceL(TUid aInterface, void*& aObject);	
  1738 	};
  1739 
  1740 class CBTSynchronousLinkAttacher;
  1741 class CBTSynchronousLinkDetacher;
  1742 class CBTSynchronousLinkAccepter;
  1743 class CBTSynchronousLinkSender;
  1744 class CBTSynchronousLinkReceiver;
  1745 class CBTSynchronousLinkBaseband;
  1746 
  1747 /**
  1748 @publishedAll
  1749 @released
  1750 
  1751 A pair of transmit and receive bandwidths for use on synchronous Bluetooth links
  1752 */
  1753 NONSHARABLE_CLASS(TBTSyncBandwidth)
  1754 	{
  1755 	public:
  1756 		IMPORT_C TBTSyncBandwidth();
  1757 		IMPORT_C TBTSyncBandwidth(TUint aBandwidth);
  1758 		
  1759 		TUint32 iTransmit;
  1760 		TUint32 iReceive;
  1761 	
  1762 	private:
  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
  1765 		TUint32     iPadding1; 
  1766 		TUint32     iPadding2; 		
  1767 	};
  1768 
  1769 /**
  1770 eSCO 64Kbit link utility constant.
  1771 */
  1772 static const TUint KBTSync64KBit = (64000 / 8);
  1773 
  1774 /**
  1775 @internalTechnology
  1776 Used internally to hold eSCO link parameters.  Not intended for use.
  1777 */
  1778 NONSHARABLE_CLASS(TBTeSCOLinkParams)
  1779 	{
  1780 	public:
  1781 		TBTeSCOLinkParams() {};
  1782 		TBTeSCOLinkParams(TUint aBandwidth, TUint16 aCoding, TUint16 aLatency, TUint8 aRetransmission);
  1783 		
  1784 		TBTSyncBandwidth iBandwidth;
  1785 		TUint16 iCoding;
  1786 		TUint16 iLatency;
  1787 		TUint8 iRetransmissionEffort;	
  1788 	};
  1789 
  1790 enum TSCOType
  1791 /** Bluetooth link SCO type
  1792 @internalTechnology
  1793 */
  1794 	{
  1795 	ESCO=0x01,	/*!< Synchronous Connection Oriented link */
  1796 	EeSCO=0x02	/*!< eSCO link */
  1797 	};	
  1798 		
  1799 NONSHARABLE_CLASS(CBluetoothSynchronousLink): public CBase
  1800 /** Provides Bluetooth SCO functionality.
  1801 
  1802 This allows Bluetooth SCO (synchronous) link Connect, Disconnect, Send and Receive.
  1803 @publishedAll
  1804 @released
  1805 */
  1806 	{
  1807 public:
  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();
  1813 
  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();
  1826 	
  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);
  1831 	
  1832 	IMPORT_C TUint16 Coding();
  1833 	IMPORT_C TBTSyncBandwidth Bandwidth();
  1834 	IMPORT_C TUint16 Latency();
  1835 	IMPORT_C TUint8 RetransmissionEffort();
  1836 	
  1837 	IMPORT_C void RemoteName(TSockAddr& aAddr);
  1838 	
  1839 	IMPORT_C void SetNotifier(MBluetoothSynchronousLinkNotifier& aNotifier);
  1840 
  1841 	MBluetoothSynchronousLinkNotifier& Notifier();
  1842     RSocket& SCOSocket();
  1843 	RSocket& ESCOSocket();
  1844 	RSocket& ListeningSCOSocket();
  1845 	RSocket& ListeningESCOSocket();
  1846 	RSocketServ& SocketServer();
  1847 	RBTBaseband& Baseband();
  1848 
  1849 	
  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);
  1856 
  1857 private:
  1858 	CBluetoothSynchronousLink(MBluetoothSynchronousLinkNotifier& aNotifier, RSocketServ& aServer);
  1859 	void ConstructL();
  1860 	void UpdateLinkParams(TSCOType aSCOType);
  1861 	TInt LinkUp(TBTDevAddr aAddr);
  1862 	void LinkDown();
  1863 
  1864 private:
  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;
  1877 	RSocket								iSCOSocket;
  1878 	RSocket								iESCOSocket;
  1879 	RSocket 							iListeningSCOSocket;
  1880 	RSocket 							iListeningESCOSocket;
  1881 	RBTBaseband							iBaseband;
  1882 	RSocketServ& 						iSockServer;
  1883 	TBTSockAddr 						iSockAddr;
  1884 	TBuf8<1> 							iDummySCOShutdownDescriptor;
  1885 	
  1886 	TBTeSCOLinkParams					iRequestedLink;
  1887 	TBTeSCOLinkParams					iNegotiatedLink;
  1888 	
  1889 	TUint8		 						iSCOTypes;
  1890 	
  1891 	TBool								iOpeningSCO;
  1892 	TBool								iOpeningESCO;
  1893 	TBool								iOpenedSCO;
  1894 	};
  1895 
  1896 
  1897 class MBluetoothPhysicalLinksNotifier
  1898 /** This allows for notifications of Physical link connections & disconnections
  1899 
  1900 Mixin class to be used with CBluetoothPhysicalLinks
  1901 
  1902 
  1903 @publishedAll
  1904 @released
  1905 */
  1906 	{
  1907 public:
  1908 	/** Notification of a requested connection coming up
  1909 	
  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.
  1915 	 
  1916 	 @param aErr the returned error
  1917 	*/
  1918 	virtual void HandleCreateConnectionCompleteL(TInt aErr) = 0;
  1919 
  1920 	/** Notification of a requested disconnection having taken place
  1921 	
  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
  1928 	*/
  1929 	virtual void HandleDisconnectCompleteL(TInt aErr) = 0;
  1930 
  1931 	/** Notification that all existing connections have been torn down
  1932 	
  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
  1939 	*/
  1940 	virtual void HandleDisconnectAllCompleteL(TInt aErr) = 0;
  1941 
  1942     /**
  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
  1946 	 */
  1947 	IMPORT_C virtual void MBPLN_ExtensionInterfaceL(TUid aInterface, void*& aObject);	
  1948 	};
  1949 
  1950 
  1951 class CBTBasebandConnecter;
  1952 class CBTBasebandShutdowner;
  1953 class CBTDisconnector;
  1954 
  1955 NONSHARABLE_CLASS(CBluetoothPhysicalLinks): public CBase
  1956 /** This is used to enumerate members of piconet, and attach and remove members thereof
  1957 
  1958 It may also be used for non-service dependent reads and writes.
  1959 @publishedAll
  1960 @released
  1961 */
  1962 	{
  1963 public:
  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();
  1969 
  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();
  1974 	
  1975 	IMPORT_C TInt Broadcast(const TDesC8& aData);
  1976 	IMPORT_C TInt ReadRaw(TDes8& aData);
  1977 	IMPORT_C TInt Enumerate(RBTDevAddrArray& aBTDevAddrArray, TUint aMaxNumber);
  1978 
  1979 	
  1980 	//Callback methods called by active object RunLs.
  1981 	//NB These methods kill the active objects that call them
  1982 	/**
  1983 	@internalTechnology
  1984 	*/
  1985 	void HandleCreateConnectionCompleteL(TInt aErr);
  1986 	/**
  1987 	@internalTechnology
  1988 	*/
  1989 	void HandleDisconnectCompleteL(TInt aErr);
  1990 	/**
  1991 	@internalTechnology
  1992 	*/
  1993 	void HandleDisconnectAllCompleteL(TInt aErr);
  1994 
  1995 	/**
  1996 	@internalTechnology
  1997 	*/
  1998 	RSocketServ& SockServer();
  1999 	/**
  2000 	@internalTechnology
  2001 	*/
  2002 	RBTBaseband& BTBaseband();
  2003 	/**
  2004 	@internalTechnology
  2005 	*/
  2006 	MBluetoothPhysicalLinksNotifier& Notifier();
  2007 
  2008 
  2009 private:
  2010 	CBluetoothPhysicalLinks(MBluetoothPhysicalLinksNotifier& aNotifier, 
  2011 							RSocketServ& aServer);
  2012 	void ConstructL();
  2013 
  2014 private:
  2015 	CBTBasebandConnecter* iBTBasebandConnecter;
  2016 	CBTDisconnector* iBTDisconnector;
  2017 	MBluetoothPhysicalLinksNotifier& iNotifier;
  2018 	RSocketServ& iSockServer;
  2019 	RBTBaseband iBTBaseband;
  2020 	};
  2021 
  2022 
  2023 
  2024 
  2025 NONSHARABLE_CLASS(RBluetoothPowerSwitch)
  2026 /** This is intended for controlling whether the Bluetooth hardware is switched on or not.
  2027 
  2028 @publishedPartner
  2029 @deprecated
  2030 @see HCI_v2 documentation
  2031 */
  2032 	{
  2033 	public:
  2034 
  2035 	IMPORT_C RBluetoothPowerSwitch();
  2036 	IMPORT_C void RequestSwitchOn();
  2037 	IMPORT_C void RequestSwitchOff();
  2038 	};
  2039 
  2040 
  2041 
  2042 class RHCIServerSession;
  2043 class RSocketBasedHciDirectAccess;
  2044 
  2045 NONSHARABLE_CLASS(RHCIDirectAccess)
  2046 /**
  2047 API used for licensee-specific direct HCI access
  2048 
  2049 This class allows vendor-specific messages to be passed through to the HCI for
  2050 customised (licensee-specific) HCI functionality.
  2051 
  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
  2054 Bluetooth stack.
  2055 
  2056 Do not use unless entirely familar with this API and the specific HCI in use!!!!
  2057 
  2058 @publishedPartner
  2059 @released
  2060 */
  2061 	{
  2062 public:
  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();
  2068 
  2069 	IMPORT_C void Ioctl(TUint aCommand, TRequestStatus &aStatus, TDes8* aDesc=NULL,TUint aLevel = KSolBtHCI); 
  2070 	IMPORT_C void CancelIoctl();
  2071 
  2072 	IMPORT_C void AsyncMessage(TUint aCommand, TRequestStatus &aStatus, TDes8* aDesc); 
  2073 	IMPORT_C void CancelAsyncMessage();
  2074 
  2075 	IMPORT_C TInt SubSessionHandle();
  2076 private:
  2077 	RHCIServerSession* iHCIServerSession;
  2078 	RSocketBasedHciDirectAccess* iSocketAccess;
  2079 	TUint32 iReserved; // Padding for possible future "per-copy" state.
  2080 	};
  2081 
  2082 #endif