epoc32/include/bt_sock.h
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     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
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    13 // Description:
    13 // Description:
    14 // BT socket interface types
    14 // BT socket interface types
    15 // 
    15 // 
    16 //
    16 //
    17 
    17 
    18 
       
    19 
       
    20 /**
    18 /**
    21  @file
    19  @file
    22  @publishedAll
    20  @publishedAll
    23  @released
    21  @released
    24 */
    22 */
    25 
    23 
    26 #ifndef BT_SOCK_H
    24 #ifndef BT_SOCK_H
    27 #define BT_SOCK_H
    25 #define BT_SOCK_H
       
    26 
       
    27 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    28 #include <bthci.h>
       
    29 #include <bluetooth/lmoptions.h>
       
    30 #endif
       
    31 
       
    32 #include <bluetooth/btscoparams.h>
       
    33 #include <bluetooth/btbaseband.h>
       
    34 #include <btsocketoptionlevels.h>
       
    35 #include <btdevice.h>
    28 
    36 
    29 #include <es_sock.h>
    37 #include <es_sock.h>
    30 #include <bttypes.h>
    38 #include <bttypes.h>
    31 #include <d32comm.h>	// for RS232 signal names for RFCOMM
    39 #include <d32comm.h>	// for RS232 signal names for RFCOMM
    32 #include <bluetooth/hci/hcierrors.h>
    40 #include <bluetooth/hci/hcierrors.h>
    33 #include <btsecmanclient.h>
    41 #include <btmanclient.h>
    34 #include <bt_subscribe.h>
    42 #include <bt_subscribe.h>
       
    43 #include <btsockaddr.h>
       
    44 #include <btsecurity.h>
       
    45 #include <btbasebandpolicy.h>
       
    46 #include <btsyncbandwidth.h>
    35 
    47 
    36 
    48 
    37 
    49 
    38 _LIT(KRFCOMMDesC,"RFCOMM");	/*!< Descriptor name for RFCOMM */
    50 _LIT(KRFCOMMDesC,"RFCOMM");	/*!< Descriptor name for RFCOMM */
    39 
    51 
    54 
    66 
    55 const TInt KBTMajor = 0;				/*!< BT version number for major version */
    67 const TInt KBTMajor = 0;				/*!< BT version number for major version */
    56 const TInt KBTMinor = 1;				/*!< BT version number for minor version */
    68 const TInt KBTMinor = 1;				/*!< BT version number for minor version */
    57 const TInt KBTBuild = 1;				/*!< BT version number for build version */
    69 const TInt KBTBuild = 1;				/*!< BT version number for build version */
    58 
    70 
    59 // Socket Options
    71 // The Socket Options are now in btsocketoptionlevels.h
    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 
    72 
    90 const static TUint8 KSCOListenQueSize = 1; /*!< Length of SCO listening queue */
    73 const static TUint8 KSCOListenQueSize = 1; /*!< Length of SCO listening queue */
    91 
    74 
    92 const static TUint16 KL2MinMTU = 48; 			/*!< BT Spec defined min. supported MTU size */
    75 const static TUint16 KL2MinMTU = 48; 			/*!< BT Spec defined min. supported MTU size */
    93 
    76 
   108  * absolute minimum PSM but the minimum user PSM instead. 
    91  * absolute minimum PSM but the minimum user PSM instead. 
   109  * Use KMinUserPSM instead of this constant.
    92  * Use KMinUserPSM instead of this constant.
   110  * @deprecated
    93  * @deprecated
   111  */
    94  */
   112 const static TUint16 KMinPSM = 0x1001;
    95 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 
    96 
   238 const static TInt KErrBtEskError = -6999;	/*!< BT ESK error code */
    97 const static TInt KErrBtEskError = -6999;	/*!< BT ESK error code */
   239 
    98 
   240 
    99 
   241 // Options available for all Bluetooth protocols
   100 // Options available for all Bluetooth protocols
   284 const static TInt KErrL2CAPDataControllerDetached = KL2CAPErrBase - 17;	/*!< L2CAP problems (e.g. no memory) whilst sending data error code*/
   143 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 
   144 const static TInt KErrL2CAPConfigPending = KL2CAPErrBase - 18;			/*!< L2CAP configuration is in progress error code 
   286 																			 @internalComponent*/
   145 																			 @internalComponent*/
   287 const static TInt KErrL2CAPConfigAlreadyInProgress = KL2CAPErrBase - 19;/*!< L2CAP attempt to alter config whilst configuration is in progress error code*/
   146 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*/
   147 const static TInt KErrL2CAPNoFreeCID = KL2CAPErrBase - 21;				/*!< L2CAP no more channel IDs available error code*/
       
   148 const static TInt KErrL2CAPPeerDoesNotSupportRequestedChannelMode = KL2CAPErrBase - 22; /*!< L2CAP peer doesn't support channel modes satisfying requested channel configuration. */
       
   149 const static TInt KErrL2CAPInvalidPacketSequenceNumber = KL2CAPErrBase - 23;	/*!< L2CAP packet with an invalid sequence number was received */
       
   150 const static TInt KErrL2CAPInvalidAcknowledgementNumber = KL2CAPErrBase - 24;	/*!< L2CAP invalid acknowledgment number was received */
       
   151 const static TInt KErrL2CAPIllegalRemoteBehavior = KL2CAPErrBase - 25;			/*!< L2CAP remote broke the L2CAP specification */
       
   152 const static TInt KErrL2CAPNegotiatedDifferentModesForEachDirection = KL2CAPErrBase - 26; /*!< L2CAP different channel modes were negotiated for incoming and outgoing direction */
       
   153 const static TInt KErrL2CAPIncomingSduSegmentationError = KL2CAPErrBase - 27;	/*!< L2CAP received I-Frame does not match the sequence of start, continuation, end of SDU */
       
   154 const static TInt KErrL2CAPIncomingSduTooBig = KL2CAPErrBase - 28;		/*!< L2CAP received SDU size is larger than the negotiated MTU */
       
   155 const static TInt KErrL2CAPIncomingIFrameTooSmall = KL2CAPErrBase - 29;	/*!< L2CAP Incoming I-Frame size is too small */
       
   156 const static TInt KErrL2CAPIncomingIFrameTooBig = KL2CAPErrBase - 30;	/*!< L2CAP Incoming I-Frame information payload is larger than the negotiated MPS */
       
   157 const static TInt KErrL2CAPInvalidIncomingSFrameSize = KL2CAPErrBase - 31; /*!< L2CAP Incoming S-Frame size is incorrect */
       
   158 const static TInt KErrL2CAPAttemptToSetMinMtuGreaterThanMtu = KL2CAPErrBase - 32; /*!< L2CAP An attempt to configure minimal acceptable MTU that's larger than the preferred MTU was made */
       
   159 const static TInt KErrL2CAPAttemptToSetMinMruGreaterThanMru = KL2CAPErrBase - 33; /*!< L2CAP An attempt to configure minimal acceptable MRU that's larger than the preferred MRU was made */
   289 
   160 
   290 // Host Resolver
   161 // Host Resolver
   291 const static TInt KErrHostResNoMoreResults = KErrEof;  					/*!< Host resolver has no more results error code */
   162 const static TInt KErrHostResNoMoreResults = KErrEof;  					/*!< Host resolver has no more results error code */
   292 const static TUint KHostResInquiry = 1;			/*!< Host resolver inquiry option */ 
   163 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 */ 
   164 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 */ 
   165 const static TUint KHostResIgnoreCache = 16; 	/*!< A way of ignoring the cache */ 
   295 const static TUint KHostResCache = 32; 			/*!< A way to get CoD from cache */
   166 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  */
   167 const static TUint KHostResEir = 64; 			/*!< Host resolver Eir option. This is mutually exclusive with KHostResName  */
   297 
   168 
   298 // L2CAP Ioctls
   169 // L2CAP Ioctls
   299 const static TInt KL2CAPEchoRequestIoctl	= 0;		/*!< Echo Request Ioctl name */
   170 const static TInt KL2CAPEchoRequestIoctl			= 0;	/*!< Echo Request Ioctl name */
   300 const static TInt KL2CAPIncomingMTUIoctl	= 1;		/*!< Change incoming MTU Ioctl name */
   171 const static TInt KL2CAPIncomingMTUIoctl			= 1;	/*!< Change incoming MTU Ioctl name */
   301 const static TInt KL2CAPOutgoingMTUIoctl    = 2;		/*!< Change outgoing MTU Ioctl name */
   172 const static TInt KL2CAPOutgoingMTUIoctl			= 2;	/*!< Change outgoing MTU Ioctl name */
   302 const static TInt KL2CAPUpdateChannelConfigIoctl	= 3;/*!< Change conguration parameters Ioctl name */
   173 const static TInt KL2CAPUpdateChannelConfigIoctl	= 3;	/*!< Change configuration parameters Ioctl name */
   303 
   174 const static TInt KL2CAPPretendIncomingSduQFull		= 4;	/*!< Pretend incoming SDU Queue is full - internal testing only @internalComponent */
   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 
   175 
   393 struct TLMDisconnectACLIoctl
   176 struct TLMDisconnectACLIoctl
   394 /**
   177 /**
   395 Structure to specify the remote ACL connection to disconnect.
   178 Structure to specify the remote ACL connection to disconnect.
   396 The reason passed in iReason will be sent to the remote device.
   179 The reason passed in iReason will be sent to the remote device.
   406 typedef TPckgBuf<TLMDisconnectACLIoctl> TLMDisconnectACLBuf;	/*!< Package for TLMDisconnectACLIoctl structure */
   189 typedef TPckgBuf<TLMDisconnectACLIoctl> TLMDisconnectACLBuf;	/*!< Package for TLMDisconnectACLIoctl structure */
   407 
   190 
   408 // private tokens for use by RBTBaseband facade and stack
   191 // private tokens for use by RBTBaseband facade and stack
   409 _LIT8(KDisconnectOnePhysicalLink, "1");		/*!< Specifes one physical link should be disconnected */
   192 _LIT8(KDisconnectOnePhysicalLink, "1");		/*!< Specifes one physical link should be disconnected */
   410 _LIT8(KDisconnectAllPhysicalLinks, "A");	/*!< Specifes all physical links should be disconnected */
   193 _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 
   194 
   458 // HCI Ioctls
   195 // HCI Ioctls
   459 /** Add SCO connnection Ioctl
   196 /** Add SCO connnection Ioctl
   460 @deprecated
   197 @deprecated
   461 */
   198 */
   720 
   457 
   721 	/** Get / Set the current negotiated (or to be negotiated) outbound MTU size */
   458 	/** Get / Set the current negotiated (or to be negotiated) outbound MTU size */
   722 	KL2CAPNegotiatedOutboundMTU,    
   459 	KL2CAPNegotiatedOutboundMTU,    
   723 
   460 
   724 	KL2CAPTestConfigure,	
   461 	KL2CAPTestConfigure,	
   725 	KL2CAPDebugFlush,
   462 	KL2CAPDebugFlush,				// not implemented anymore, just a placeholder for BC
   726 	KL2CAPVersion1_2,
   463 	KL2CAPVersion1_2,
   727 	KL2CAPHeapAlloc,
   464 	KL2CAPHeapAlloc,
   728 	KL2CAPDataPlaneConfig,
   465 	KL2CAPDataPlaneConfig,
   729 	
   466 	
   730 	/**
   467 	/**
   731 	This is similar to KL2CAPOutboundMTUForBestPerformance except that the caller can specify
   468 	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
   469 	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.
   470 	that still want an optimal MTU but have their own restrictions on packet size.
   734 	*/
   471 	*/
   735 	KL2CAPOutboundMTUForBestPerformanceWithRestriction,
   472 	KL2CAPOutboundMTUForBestPerformanceWithRestriction,
       
   473 	KL2CAPLocalPSM,					/*!< Return local PSM of the socket (only works before the socket is accepted, stack internal use only) @internalTechnology */
       
   474 	KL2CAPNegotiatedChannelMode		/*!< Get the negotiated L2CAP channel mode */
   736 	};
   475 	};
   737 
   476 
   738 typedef TUint16 TL2CAPPort;			/*!< Definition of a L2CAP port number type */
   477 typedef TUint16 TL2CAPPort;			/*!< Definition of a L2CAP port number type */
   739 
   478 
   740 const static TL2CAPPort KL2CAPPassiveAutoBind = KMaxTUint16;  /*!< PSM out of the valid range used for passive auto bind operation */
   479 const static TL2CAPPort KL2CAPPassiveAutoBind = KMaxTUint16;  /*!< PSM out of the valid range used for passive auto bind operation */
   857 	
   596 	
   858 private:
   597 private:
   859 	SInquiryAddr& InquiryAddrStruct() const;
   598 	SInquiryAddr& InquiryAddrStruct() const;
   860 	TPtr8 AddressPtr() const;
   599 	TPtr8 AddressPtr() const;
   861 	};
   600 	};
   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 
   601 
   903 //
   602 //
   904 // RFCOMM
   603 // RFCOMM
   905 //
   604 //
   906 
   605 
  1096 
   795 
  1097 class CBTBasebandSocketProxy;
   796 class CBTBasebandSocketProxy;
  1098 class CBTBasebandPropertySubscriber;
   797 class CBTBasebandPropertySubscriber;
  1099 
   798 
  1100 class MBasebandObserver;
   799 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 		
   800 		
  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)
   801 NONSHARABLE_CLASS(RBTPhysicalLinkAdapter)
  1193 /** Class to enable modification of a physical link:
   802 /** Class to enable modification of a physical link:
  1194 
   803 
  1195 Modifications may be requested or prevented (blocked).
   804 Modifications may be requested or prevented (blocked).
  1196 Whilst a modification is being prevented, any request to
   805 Whilst a modification is being prevented, any request to
  1743 class CBTSynchronousLinkSender;
  1352 class CBTSynchronousLinkSender;
  1744 class CBTSynchronousLinkReceiver;
  1353 class CBTSynchronousLinkReceiver;
  1745 class CBTSynchronousLinkBaseband;
  1354 class CBTSynchronousLinkBaseband;
  1746 
  1355 
  1747 /**
  1356 /**
  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.
  1357 eSCO 64Kbit link utility constant.
  1771 */
  1358 */
  1772 static const TUint KBTSync64KBit = (64000 / 8);
  1359 static const TUint KBTSync64KBit = (64000 / 8);
  1773 
  1360 
  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
  1361 NONSHARABLE_CLASS(CBluetoothSynchronousLink): public CBase
  1800 /** Provides Bluetooth SCO functionality.
  1362 /** Provides Bluetooth SCO functionality.
  1801 
  1363 
  1802 This allows Bluetooth SCO (synchronous) link Connect, Disconnect, Send and Receive.
  1364 This allows Bluetooth SCO (synchronous) link Connect, Disconnect, Send and Receive.
  1803 @publishedAll
  1365 @publishedAll
  1978 
  1540 
  1979 	
  1541 	
  1980 	//Callback methods called by active object RunLs.
  1542 	//Callback methods called by active object RunLs.
  1981 	//NB These methods kill the active objects that call them
  1543 	//NB These methods kill the active objects that call them
  1982 	/**
  1544 	/**
       
  1545 	This method is for internal sub-system use only and should be not be used otherwise.
  1983 	@internalTechnology
  1546 	@internalTechnology
  1984 	*/
  1547 	*/
  1985 	void HandleCreateConnectionCompleteL(TInt aErr);
  1548 	void HandleCreateConnectionCompleteL(TInt aErr);
  1986 	/**
  1549 	/**
       
  1550 	This method is for internal sub-system use only and should be not be used otherwise.
  1987 	@internalTechnology
  1551 	@internalTechnology
  1988 	*/
  1552 	*/
  1989 	void HandleDisconnectCompleteL(TInt aErr);
  1553 	void HandleDisconnectCompleteL(TInt aErr);
  1990 	/**
  1554 	/**
       
  1555 	This method is for internal sub-system use only and should be not be used otherwise.
  1991 	@internalTechnology
  1556 	@internalTechnology
  1992 	*/
  1557 	*/
  1993 	void HandleDisconnectAllCompleteL(TInt aErr);
  1558 	void HandleDisconnectAllCompleteL(TInt aErr);
  1994 
  1559 
  1995 	/**
  1560 	/**
       
  1561 	This method is for internal sub-system use only and should be not be used otherwise.
  1996 	@internalTechnology
  1562 	@internalTechnology
  1997 	*/
  1563 	*/
  1998 	RSocketServ& SockServer();
  1564 	RSocketServ& SockServer();
  1999 	/**
  1565 	/**
       
  1566 	This method is for internal sub-system use only and should be not be used otherwise.
  2000 	@internalTechnology
  1567 	@internalTechnology
  2001 	*/
  1568 	*/
  2002 	RBTBaseband& BTBaseband();
  1569 	RBTBaseband& BTBaseband();
  2003 	/**
  1570 	/**
       
  1571 	This method is for internal sub-system use only and should be not be used otherwise.
  2004 	@internalTechnology
  1572 	@internalTechnology
  2005 	*/
  1573 	*/
  2006 	MBluetoothPhysicalLinksNotifier& Notifier();
  1574 	MBluetoothPhysicalLinksNotifier& Notifier();
  2007 
  1575 
  2008 
  1576 
  2017 	MBluetoothPhysicalLinksNotifier& iNotifier;
  1585 	MBluetoothPhysicalLinksNotifier& iNotifier;
  2018 	RSocketServ& iSockServer;
  1586 	RSocketServ& iSockServer;
  2019 	RBTBaseband iBTBaseband;
  1587 	RBTBaseband iBTBaseband;
  2020 	};
  1588 	};
  2021 
  1589 
  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
  1590 #endif