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
williamr@2
     1
// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@2
     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
williamr@2
     5
// which accompanies this distribution, and is available
williamr@2
     6
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
// BT socket interface types
williamr@2
    15
// 
williamr@2
    16
//
williamr@2
    17
williamr@2
    18
williamr@2
    19
williamr@2
    20
/**
williamr@2
    21
 @file
williamr@2
    22
 @publishedAll
williamr@2
    23
 @released
williamr@2
    24
*/
williamr@2
    25
williamr@2
    26
#ifndef BT_SOCK_H
williamr@2
    27
#define BT_SOCK_H
williamr@2
    28
williamr@2
    29
#include <es_sock.h>
williamr@2
    30
#include <bttypes.h>
williamr@2
    31
#include <d32comm.h>	// for RS232 signal names for RFCOMM
williamr@2
    32
#include <bluetooth/hci/hcierrors.h>
williamr@2
    33
#include <btsecmanclient.h>
williamr@2
    34
#include <bt_subscribe.h>
williamr@2
    35
williamr@2
    36
williamr@2
    37
williamr@2
    38
_LIT(KRFCOMMDesC,"RFCOMM");	/*!< Descriptor name for RFCOMM */
williamr@2
    39
williamr@2
    40
_LIT(KL2CAPDesC,"L2CAP"); 	/*!< Descriptor name for L2CAP */
williamr@2
    41
williamr@2
    42
//
williamr@2
    43
// BT Protocol Family
williamr@2
    44
//
williamr@2
    45
williamr@2
    46
const TUint KBTAddrFamily = 0x101; 		/*!< BT Address Family */
williamr@2
    47
williamr@2
    48
const TUint KBTLinkManager = 0x0099; 	/*!< Protocol Number for Link Manager */
williamr@2
    49
const TUint KL2CAP = 0x0100;			/*!< Protocol Number for L2CAP */
williamr@2
    50
const TUint KRFCOMM = 0x0003;			/*!< Protocol Number for RFCOMM */
williamr@2
    51
const TUint KSDP = 0x0001;				/*!< Protocol Number for SDP */
williamr@2
    52
const TUint	KAVCTP = 0x0017;			/*!< Protocol Number for AVCTP */
williamr@2
    53
const TInt KTCIL2CAP = 0xF100;			/*!< Protocol Number for TCI L2CAP */
williamr@2
    54
williamr@2
    55
const TInt KBTMajor = 0;				/*!< BT version number for major version */
williamr@2
    56
const TInt KBTMinor = 1;				/*!< BT version number for minor version */
williamr@2
    57
const TInt KBTBuild = 1;				/*!< BT version number for build version */
williamr@2
    58
williamr@2
    59
// Socket Options
williamr@2
    60
const TUint	KSolBtBlog  =0x1000;		/*!< Logging socket option */
williamr@2
    61
const TUint KSolBtHCI   =0x1010;		/*!< HCI socket option */
williamr@2
    62
const TUint KSolBtLM    =0x1011;		/*!< Link Manager socket option */
williamr@2
    63
const TUint KSolBtL2CAP =0x1012;		/*!< L2CAP socket option */
williamr@2
    64
const TUint KSolBtRFCOMM=0x1013;		/*!< RFCOMM socket option */
williamr@2
    65
const TUint KSolBtAVCTP	=0x1014;		/*!< AVCTP socket option */
williamr@2
    66
const TUint KSolBtACL	=0x1015;		/*!< ACL socket option */
williamr@2
    67
/**
williamr@2
    68
Decimal Value: 4118.
williamr@2
    69
*/
williamr@2
    70
const TUint	KSolBtAVDTPSignalling	=0x1016;
williamr@2
    71
/**
williamr@2
    72
Decimal Value: 4119.
williamr@2
    73
*/
williamr@2
    74
const TUint	KSolBtAVDTPMedia		=0x1017;
williamr@2
    75
/**
williamr@2
    76
Decimal Value: 4120.
williamr@2
    77
*/
williamr@2
    78
const TUint	KSolBtAVDTPReporting	=0x1018;
williamr@2
    79
/**
williamr@2
    80
Decimal Value: 4121.
williamr@2
    81
*/
williamr@2
    82
const TUint	KSolBtAVDTPRecovery		=0x1019;
williamr@2
    83
/**
williamr@2
    84
Decimal Value: 4128.
williamr@2
    85
*/
williamr@2
    86
const TUint KSolBtAVDTPInternal		=0x1020;
williamr@2
    87
const TUint KSolBtLMProxy = 0x2011;		/*!< Link Manager Proxy socket option */
williamr@2
    88
const TUint KSolBtSAPBase  = 0x2020;	/*!< CBluetoothSAP handles SetOpt first */
williamr@2
    89
williamr@2
    90
const static TUint8 KSCOListenQueSize = 1; /*!< Length of SCO listening queue */
williamr@2
    91
williamr@2
    92
const static TUint16 KL2MinMTU = 48; 			/*!< BT Spec defined min. supported MTU size */
williamr@2
    93
williamr@2
    94
williamr@2
    95
// All PSM values must be ODD, that is, the least significant bit of the least significant
williamr@2
    96
// octet must be '1'. Also, all PSM values must be assigned such that the
williamr@2
    97
// least significant bit of the most significant octet equals '0'.
williamr@2
    98
const static TUint16 KMaxPSM = 0xFEFF;	/*!< Max L2CAP PSM value */
williamr@2
    99
williamr@2
   100
/**
williamr@2
   101
 * This is the minimum user PSM. Smaller PSM values are possible but are reserved for use by the 
williamr@2
   102
 * Bluetooth stack only.
williamr@2
   103
 */
williamr@2
   104
const static TUint16 KMinUserPSM = 0x1001;
williamr@2
   105
williamr@2
   106
/**
williamr@2
   107
 * This constant has been deprecated since its name is misleading becasue it doesn't represent the 
williamr@2
   108
 * absolute minimum PSM but the minimum user PSM instead. 
williamr@2
   109
 * Use KMinUserPSM instead of this constant.
williamr@2
   110
 * @deprecated
williamr@2
   111
 */
williamr@2
   112
const static TUint16 KMinPSM = 0x1001;
williamr@2
   113
williamr@2
   114
/**
williamr@2
   115
An enumeration to represent the possible levels of Man-in-the-Middle protection
williamr@2
   116
that a Bluetooth service may specify.
williamr@2
   117
*/
williamr@2
   118
enum TBluetoothMitmProtection
williamr@2
   119
	{
williamr@2
   120
	EMitmNotRequired	= 0x0, /*!< No Man-in-the-Middle protection is required. */
williamr@2
   121
	EMitmDesired		= 0x1, /*!< Man-in-the-Middle protection should be used where possible. */
williamr@2
   122
	EMitmRequired		= 0x2  /*!< Man-in-the-Middle protection is required. */
williamr@2
   123
	};
williamr@2
   124
williamr@2
   125
NONSHARABLE_CLASS(TBTAccessRequirements)
williamr@2
   126
/** The access requirements set up by a bluetooth service.
williamr@2
   127
williamr@2
   128
An incoming connection must satisfy these criteria before the connection may proceed.
williamr@2
   129
Not spectacularly useful for applications; mainly used by other Bluetooth libraries
williamr@2
   130
@publishedAll
williamr@2
   131
@released
williamr@2
   132
*/
williamr@2
   133
	{
williamr@2
   134
public:
williamr@2
   135
	IMPORT_C TBTAccessRequirements();
williamr@2
   136
	IMPORT_C void SetAuthentication(TBool aPreference);
williamr@2
   137
	IMPORT_C void SetAuthorisation(TBool aPreference);
williamr@2
   138
	IMPORT_C void SetEncryption(TBool aPreference);
williamr@2
   139
	IMPORT_C void SetDenied(TBool aPreference);
williamr@2
   140
	IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference);
williamr@2
   141
	IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);	
williamr@2
   142
	IMPORT_C TBool AuthenticationRequired() const;
williamr@2
   143
	IMPORT_C TBool AuthorisationRequired() const;
williamr@2
   144
	IMPORT_C TBool EncryptionRequired() const;
williamr@2
   145
	IMPORT_C TBool Denied() const;
williamr@2
   146
	IMPORT_C TUint PasskeyMinLength() const;
williamr@2
   147
	IMPORT_C TBool operator==(const TBTAccessRequirements& aRequirements) const;
williamr@2
   148
	IMPORT_C TBluetoothMitmProtection MitmProtection() const;
williamr@2
   149
	
williamr@2
   150
private:
williamr@2
   151
	TUint8 iRequirements;
williamr@2
   152
	TUint  iPasskeyMinLength;
williamr@2
   153
	
williamr@2
   154
private:
williamr@2
   155
	enum TBTServiceSecuritySettings
williamr@2
   156
		{
williamr@2
   157
		EAuthenticate = 0x01,
williamr@2
   158
		EAuthorise = 0x02,
williamr@2
   159
		EEncrypt = 0x04,
williamr@2
   160
		EDenied = 0x08,
williamr@2
   161
		EMitm = 0x30, // 2 bit field for MITM
williamr@2
   162
		};
williamr@2
   163
	
williamr@2
   164
	enum TBTAccessRequirementsMitmProtection
williamr@2
   165
		{
williamr@2
   166
		EAccessRequirementsMitmUndefined = 0x00,
williamr@2
   167
		EAccessRequirementsMitmNotRequired = 0x10,
williamr@2
   168
		EAccessRequirementsMitmDesired = 0x20,
williamr@2
   169
		EAccessRequirementsMitmRequired = 0x30
williamr@2
   170
		};
williamr@2
   171
	};
williamr@2
   172
williamr@2
   173
NONSHARABLE_CLASS(TBTServiceSecurity)
williamr@2
   174
/** The security settings of a bluetooth service.
williamr@2
   175
williamr@2
   176
Contains information regarding the service UID and the access requirements.
williamr@2
   177
@publishedAll
williamr@2
   178
@released
williamr@2
   179
*/
williamr@2
   180
	{
williamr@2
   181
public:
williamr@2
   182
	IMPORT_C TBTServiceSecurity(const TBTServiceSecurity& aService);
williamr@2
   183
	IMPORT_C TBTServiceSecurity();
williamr@2
   184
	IMPORT_C void SetUid(TUid aUid);
williamr@2
   185
	IMPORT_C void SetAuthentication(TBool aPreference);
williamr@2
   186
	IMPORT_C void SetAuthorisation(TBool aPreference);
williamr@2
   187
	IMPORT_C void SetEncryption(TBool aPreference);
williamr@2
   188
	IMPORT_C void SetDenied(TBool aPreference);
williamr@2
   189
	IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference);
williamr@2
   190
	IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);	
williamr@2
   191
	IMPORT_C TBool AuthorisationRequired() const;
williamr@2
   192
	IMPORT_C TBool EncryptionRequired() const;
williamr@2
   193
	IMPORT_C TBool AuthenticationRequired() const;
williamr@2
   194
	IMPORT_C TBool Denied() const;
williamr@2
   195
	IMPORT_C TUint PasskeyMinLength() const;
williamr@2
   196
	IMPORT_C TUid Uid() const;
williamr@2
   197
	IMPORT_C TBluetoothMitmProtection MitmProtection() const;
williamr@2
   198
	
williamr@2
   199
private:
williamr@2
   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.
williamr@2
   201
	TBTAccessRequirements iSecurityRequirements;	///<Whether the service requires authentication, authorisation, encryption or min passkey len.
williamr@2
   202
	};
williamr@2
   203
williamr@2
   204
typedef TPckgBuf<TBTServiceSecurity> TBTServiceSecurityPckg;	/*!< Package definition for securty settings */
williamr@2
   205
williamr@2
   206
NONSHARABLE_CLASS(TBTSockAddr) : public TSockAddr
williamr@2
   207
/** Bluetooth socket address
williamr@2
   208
williamr@2
   209
Stores bluetooth device address, and security - these are common to all Bluetooth addresses
williamr@2
   210
@publishedAll
williamr@2
   211
@released
williamr@2
   212
*/
williamr@2
   213
	{
williamr@2
   214
struct SBTAddrSecurity
williamr@2
   215
	{		
williamr@2
   216
	TBTDevAddr iAddress;
williamr@2
   217
	TBTServiceSecurity iSecurity;
williamr@2
   218
	};
williamr@2
   219
	
williamr@2
   220
public:
williamr@2
   221
	IMPORT_C TBTSockAddr();
williamr@2
   222
	IMPORT_C TBTSockAddr(const TSockAddr& aAddr);
williamr@2
   223
	IMPORT_C TBTDevAddr BTAddr() const;
williamr@2
   224
	IMPORT_C void SetBTAddr(const TBTDevAddr& aRemote);
williamr@2
   225
	IMPORT_C void SetSecurity(const TBTServiceSecurity& aSecurity);
williamr@2
   226
	IMPORT_C TBTServiceSecurity BTSecurity() const;
williamr@2
   227
	IMPORT_C static TBTSockAddr& Cast(const TSockAddr& aAddr);
williamr@2
   228
	
williamr@2
   229
protected:
williamr@2
   230
	IMPORT_C TAny* EndBTSockAddrPtr() const;
williamr@2
   231
	
williamr@2
   232
private:
williamr@2
   233
	SBTAddrSecurity& BTAddrSecStruct() const;
williamr@2
   234
	TPtr8 AddressPtr() const;
williamr@2
   235
	};
williamr@2
   236
williamr@2
   237
williamr@2
   238
const static TInt KErrBtEskError = -6999;	/*!< BT ESK error code */
williamr@2
   239
williamr@2
   240
williamr@2
   241
// Options available for all Bluetooth protocols
williamr@2
   242
williamr@2
   243
/** BT options. */
williamr@2
   244
enum TBTOptions
williamr@2
   245
	{
williamr@2
   246
	/** Override device security */
williamr@2
   247
	KBTRegisterCodService = 0x998,		/*!< Set a CoD Service bit(s) */
williamr@2
   248
	KBTSecurityDeviceOverride = 0x999,
williamr@2
   249
	};
williamr@2
   250
williamr@2
   251
typedef TPckgBuf<TBTServiceSecurityPerDevice> TBTServiceSecurityPerDeviceBuf;	/*!< Package definition for securty settings */
williamr@2
   252
williamr@2
   253
williamr@2
   254
// Link manager error codes.
williamr@2
   255
const static TInt KLinkManagerErrBase = -6450;								/*!< Link manager base error value */
williamr@2
   256
const static TInt KErrInsufficientBasebandResources = KLinkManagerErrBase;	/*!< Insufficient baseband resources error value */
williamr@2
   257
const static TInt KErrProxyWriteNotAvailable = KLinkManagerErrBase-1;		/*!< Proxy write not available error value */
williamr@2
   258
const static TInt KErrReflexiveBluetoothLink = KLinkManagerErrBase-2;		/*!< Reflexive BT link error value */
williamr@2
   259
const static TInt KErrPendingPhysicalLink = KLinkManagerErrBase-3;			/*!< Physical link connection already pending when trying to connect the physical link */
williamr@2
   260
const static TInt KErrRemoteDeviceIndicatedNoBonding = KLinkManagerErrBase-4; /*!< Dedicated bonding attempt failure when the remote device responds with No-Bonding */
williamr@2
   261
williamr@2
   262
//
williamr@2
   263
// L2CAP
williamr@2
   264
//
williamr@2
   265
williamr@2
   266
const static TInt KL2CAPErrBase = -6300;								/*!< Base error value for L2CAP error codes */
williamr@2
   267
const static TInt KErrBadAddress = KL2CAPErrBase;						/*!< L2CAP Bad address error code */
williamr@2
   268
const static TInt KErrSAPUnexpectedEvent = KL2CAPErrBase - 1;			/*!< L2CAP unexpected SAP event error code */
williamr@2
   269
const static TInt KErrBadPacketReceived = KL2CAPErrBase - 2;			/*!< L2CAP bad packet received error code */
williamr@2
   270
const static TInt KErrL2CAPBadResponse = KL2CAPErrBase - 3;				/*!< L2CAP bad response error code */
williamr@2
   271
const static TInt KErrHCIConnectFailed = KL2CAPErrBase - 4;				/*!< L2CAP HCI connection failed error code */
williamr@2
   272
const static TInt KErrHCILinkDisconnection = KL2CAPErrBase - 5;			/*!< L2CAP HCI link disconnection error code */
williamr@2
   273
const static TInt KErrSAPNotConnected = KL2CAPErrBase - 6;				/*!< L2CAP SAP not connected error code */
williamr@2
   274
const static TInt KErrConfigBadParams = KL2CAPErrBase - 7;				/*!< L2CAP bad configuration parameters error code */
williamr@2
   275
const static TInt KErrConfigRejected = KL2CAPErrBase - 8;				/*!< L2CAP configuration rejected error code */
williamr@2
   276
const static TInt KErrConfigUnknownOptions = KL2CAPErrBase - 9;			/*!< L2CAP unknown configuration options error code */
williamr@2
   277
const static TInt KErrL2PeerDisconnected = KL2CAPErrBase - 10;			/*!< L2CAP peer disconnected error code */
williamr@2
   278
const static TInt KErrL2CAPAccessRequestDenied = KL2CAPErrBase - 11;	/*!< L2CAP access request denied error code */
williamr@2
   279
const static TInt KErrL2CAPRequestTimeout = KL2CAPErrBase - 12;			/*!< L2CAP request timeout error code */
williamr@2
   280
const static TInt KErrL2PeerRejectedCommand = KL2CAPErrBase - 13;		/*!< L2CAP peer rejected command error code */
williamr@2
   281
const static TInt KErrHostResNameTooLong = KL2CAPErrBase - 14;			/*!< L2CAP host resolver name too long error code */
williamr@2
   282
const static TInt KErrL2CAPNoMorePSMs = KL2CAPErrBase - 15;				/*!< L2CAP no more PSMs error code */
williamr@2
   283
const static TInt KErrL2CAPMaxTransmitExceeded = KL2CAPErrBase - 16;	/*!< L2CAP in reliable mode: the maximum L2Cap retransmissions have been made and channel will disconnect error code*/
williamr@2
   284
const static TInt KErrL2CAPDataControllerDetached = KL2CAPErrBase - 17;	/*!< L2CAP problems (e.g. no memory) whilst sending data error code*/
williamr@2
   285
const static TInt KErrL2CAPConfigPending = KL2CAPErrBase - 18;			/*!< L2CAP configuration is in progress error code 
williamr@2
   286
																			 @internalComponent*/
williamr@2
   287
const static TInt KErrL2CAPConfigAlreadyInProgress = KL2CAPErrBase - 19;/*!< L2CAP attempt to alter config whilst configuration is in progress error code*/
williamr@2
   288
const static TInt KErrL2CAPNoFreeCID = KL2CAPErrBase - 21;				/*!< L2CAP no more channel IDs available error code*/
williamr@2
   289
williamr@2
   290
// Host Resolver
williamr@2
   291
const static TInt KErrHostResNoMoreResults = KErrEof;  					/*!< Host resolver has no more results error code */
williamr@2
   292
const static TUint KHostResInquiry = 1;			/*!< Host resolver inquiry option */ 
williamr@2
   293
const static TUint KHostResName = 2;			/*!< Host resolver name option. This is mutually exclusive with KHostResEir */ 
williamr@2
   294
const static TUint KHostResIgnoreCache = 16; 	/*!< A way of ignoring the cache */ 
williamr@2
   295
const static TUint KHostResCache = 32; 			/*!< A way to get CoD from cache */
williamr@2
   296
const static TUint KHostResEir = 64; 			/*!< Host resolver Eir option. This is mutually exclusive with KHostResName  */
williamr@2
   297
williamr@2
   298
// L2CAP Ioctls
williamr@2
   299
const static TInt KL2CAPEchoRequestIoctl	= 0;		/*!< Echo Request Ioctl name */
williamr@2
   300
const static TInt KL2CAPIncomingMTUIoctl	= 1;		/*!< Change incoming MTU Ioctl name */
williamr@2
   301
const static TInt KL2CAPOutgoingMTUIoctl    = 2;		/*!< Change outgoing MTU Ioctl name */
williamr@2
   302
const static TInt KL2CAPUpdateChannelConfigIoctl	= 3;/*!< Change conguration parameters Ioctl name */
williamr@2
   303
williamr@2
   304
williamr@2
   305
// Link Manager Ioctls
williamr@2
   306
williamr@2
   307
/** Link manager Ioctl codes.*/
williamr@2
   308
enum TBTLMIoctls
williamr@2
   309
	{
williamr@2
   310
	/** Disconnect ACL Ioctl code
williamr@2
   311
	@deprecated
williamr@2
   312
	*/
williamr@2
   313
	KLMDisconnectACLIoctl,
williamr@2
   314
	/** Set Packet type Ioctl code
williamr@2
   315
	@deprecated
williamr@2
   316
	*/
williamr@2
   317
	KLMSetPacketTypeIoctl,
williamr@2
   318
	/** Wait for SCO notification Ioctl code
williamr@2
   319
	@internalComponent
williamr@2
   320
	*/
williamr@2
   321
	KLMWaitForSCONotificationIoctl,
williamr@2
   322
	/** One-shot baseband notification Ioctl code
williamr@2
   323
	@internalComponent
williamr@2
   324
	*/	
williamr@2
   325
	KLMBasebandEventOneShotNotificationIoctl,
williamr@2
   326
	/** Baseband event notification Ioctl code
williamr@2
   327
	@internalComponent
williamr@2
   328
	*/	
williamr@2
   329
	KLMBasebandEventNotificationIoctl,
williamr@2
   330
	/** Read Failed Contact Counter Ioctl
williamr@2
   331
	@internalComponent
williamr@2
   332
	*/	
williamr@2
   333
	KLMReadFailedContactCounterIoctl,
williamr@2
   334
	/** Read Link Quality Ioctl
williamr@2
   335
	@internalComponent
williamr@2
   336
	*/	
williamr@2
   337
	KLMReadLinkQualityIoctl,
williamr@2
   338
	/** Read RSSI Ioctl
williamr@2
   339
	@internalComponent
williamr@2
   340
	*/	
williamr@2
   341
	KLMReadRssiIoctl,
williamr@2
   342
	/** Read Current Transmit Power Level Ioctl
williamr@2
   343
	@internalComponent
williamr@2
   344
	*/	
williamr@2
   345
	KLMReadCurrentTransmitPowerLevelIoctl,
williamr@2
   346
	};
williamr@2
   347
williamr@2
   348
williamr@2
   349
/** Paging policy for baseband.*/
williamr@2
   350
enum TBasebandPageTimePolicy
williamr@2
   351
    {
williamr@2
   352
	EPagingDontCare,	/*!< Don't care setting */
williamr@2
   353
    EPagingNormal,		/*!< Normal setting */
williamr@2
   354
    EPagingBestEffort,	/*!< Best effort setting */
williamr@2
   355
    EPagingQuick,		/*!< Quick paging setting */
williamr@2
   356
    };
williamr@2
   357
williamr@2
   358
struct TBasebandPolicyParams
williamr@2
   359
/** Baseband policy parameters.*/
williamr@2
   360
	{
williamr@2
   361
	TBasebandPageTimePolicy		iPageTimePolicy;	/*!< Page time policy */
williamr@2
   362
	};
williamr@2
   363
williamr@2
   364
struct TSetBasebandPolicy
williamr@2
   365
/** Set baseband policy.
williamr@2
   366
williamr@2
   367
@deprecated
williamr@2
   368
@see RBTBaseband, TPhysicalLinkQuickConnectionToken
williamr@2
   369
*/
williamr@2
   370
	{
williamr@2
   371
	TBTDevAddr				iDevAddr;	/*!< Device Address */
williamr@2
   372
	TBasebandPolicyParams	iPolicy;	/*!< Policy parameters */
williamr@2
   373
	};
williamr@2
   374
williamr@2
   375
/** Package for SetBasebandPolicy structure
williamr@2
   376
@deprecated
williamr@2
   377
*/
williamr@2
   378
typedef TPckgBuf<TSetBasebandPolicy> TSetBasebandPolicyBuf;	
williamr@2
   379
williamr@2
   380
struct TPhysicalLinkQuickConnectionToken
williamr@2
   381
/** Specifies details for faster connection.*/
williamr@2
   382
	{
williamr@2
   383
	TBTNamelessDevice		iDevice;	/*!< Nameless device */
williamr@2
   384
	TBasebandPolicyParams	iPolicy;	/*!< New policy */
williamr@2
   385
	};
williamr@2
   386
	
williamr@2
   387
typedef TPckgBuf<TPhysicalLinkQuickConnectionToken> TPhysicalLinkQuickConnectionTokenBuf;	/*!< Package for TPhysicalLinkQuickConnectionToken structure */
williamr@2
   388
williamr@2
   389
#define KBasebandSlotTime 0.000625	/*!< Baseband timeslot duration (0.000625 seconds) */
williamr@2
   390
static const TUint KDefaultBasebandConnectionTimeout = 10;  /*!< Default baseband connection timeout (10 seconds) */
williamr@2
   391
williamr@2
   392
williamr@2
   393
struct TLMDisconnectACLIoctl
williamr@2
   394
/**
williamr@2
   395
Structure to specify the remote ACL connection to disconnect.
williamr@2
   396
The reason passed in iReason will be sent to the remote device.
williamr@2
   397
williamr@2
   398
Use with KLMDisconnectACLIoctl.
williamr@2
   399
@deprecated
williamr@2
   400
*/
williamr@2
   401
	{
williamr@2
   402
	TBTDevAddr	iDevAddr;	/*!< Device address */
williamr@2
   403
	TUint8		iReason;	/*!< Reason code */
williamr@2
   404
	};
williamr@2
   405
williamr@2
   406
typedef TPckgBuf<TLMDisconnectACLIoctl> TLMDisconnectACLBuf;	/*!< Package for TLMDisconnectACLIoctl structure */
williamr@2
   407
williamr@2
   408
// private tokens for use by RBTBaseband facade and stack
williamr@2
   409
_LIT8(KDisconnectOnePhysicalLink, "1");		/*!< Specifes one physical link should be disconnected */
williamr@2
   410
_LIT8(KDisconnectAllPhysicalLinks, "A");	/*!< Specifes all physical links should be disconnected */
williamr@2
   411
williamr@2
   412
williamr@2
   413
/** Link manager options.
williamr@2
   414
@internalComponent
williamr@2
   415
*/
williamr@2
   416
enum TBTLMOptions
williamr@2
   417
	{
williamr@2
   418
	ELMOutboundACLSize,						/*!< Outbound ACL size option */
williamr@2
   419
	ELMInboundACLSize,						/*!< Inbound ACL size option */
williamr@2
   420
	KLMGetACLHandle,						/*!< Get ACL Handle option */
williamr@2
   421
	KLMGetACLLinkCount,						/*!< Get ACL link count option */
williamr@2
   422
	KLMGetACLLinkArray,						/*!< Get ACL link array option */
williamr@2
   423
	KLMSetBasebandConnectionPolicy,			/*!< Set baseband connection policy option */
williamr@2
   424
	KLMGetBasebandHandle,					/*!< Get baseband handle option */
williamr@2
   425
	EBBSubscribePhysicalLink,				/*!< Subscribe physical link option */
williamr@2
   426
	EBBBeginRaw,							/*!< Enable raw broadcast option */
williamr@2
   427
	EBBRequestRoleMaster,					/*!< Request switch to master option */
williamr@2
   428
	EBBRequestRoleSlave,					/*!< Request switch to slave option */
williamr@2
   429
	EBBCancelModeRequest,					/*!< Cancel mode request option */
williamr@2
   430
	EBBRequestSniff,						/*!< Request sniff mode option */
williamr@2
   431
	EBBRequestPark,							/*!< Request park mode option */
williamr@2
   432
	EBBRequestPreventRoleChange,			/*!< Request to prevent a role (master / slave) switch option */
williamr@2
   433
	EBBRequestAllowRoleChange,				/*!< Request to allow a role (master / slave) switchoption */
williamr@2
   434
	EBBRequestChangeSupportedPacketTypes,	/*!< Request to cange the current supported packet types option */
williamr@2
   435
	EBBEnumeratePhysicalLinks,				/*!< Enumerate physical links option */
williamr@2
   436
	EBBGetPhysicalLinkState,				/*!< Get the physical link state option */
williamr@2
   437
	EBBGetSniffInterval,					/*!< Get Sniff Interval option */
williamr@2
   438
	EBBRequestLinkAuthentication,			/*!< Request authentication on the link */
williamr@2
   439
	EBBRequestExplicitActiveMode,			/*!< Explicitly request the link to go into active mode */
williamr@2
   440
	
williamr@2
   441
	//Allow combination of options below...
williamr@2
   442
	EBBRequestPreventSniff = 0x100,			/*!< Request to prevent entering sniff mode option */
williamr@2
   443
	EBBRequestPreventHold = 0x200,			/*!< Request to prevent entering hold mode option */
williamr@2
   444
	EBBRequestPreventPark = 0x400,			/*!< Request to prevent entering park mode option */
williamr@2
   445
	EBBRequestPreventAllLowPowerModes = 
williamr@2
   446
		(EBBRequestPreventSniff | 
williamr@2
   447
		 EBBRequestPreventHold | 
williamr@2
   448
		 EBBRequestPreventPark),			/*!< Request to prevent entering all modes option */
williamr@2
   449
	EBBRequestAllowSniff = 0x800,			/*!< Request to allow entering sniff mode option */
williamr@2
   450
	EBBRequestAllowHold = 0x1000,			/*!< Request to allow entering hold mode option */
williamr@2
   451
	EBBRequestAllowPark = 0x2000,			/*!< Request to allow entering park mode option */
williamr@2
   452
	EBBRequestAllowAllLowPowerModes = 
williamr@2
   453
		(EBBRequestAllowSniff | 
williamr@2
   454
		 EBBRequestAllowHold | 
williamr@2
   455
		 EBBRequestAllowPark),				/*!< Request to allow entering-all-modes option. */
williamr@2
   456
	};
williamr@2
   457
williamr@2
   458
// HCI Ioctls
williamr@2
   459
/** Add SCO connnection Ioctl
williamr@2
   460
@deprecated
williamr@2
   461
*/
williamr@2
   462
static const TUint KLMAddSCOConnIoctl			=0;
williamr@2
   463
/** Remove SCO connection Ioctl
williamr@2
   464
@deprecated
williamr@2
   465
*/
williamr@2
   466
static const TUint KHCIRemoveSCOConnIoctl		=1;
williamr@2
   467
/** Change packet types allowed Ioctl
williamr@2
   468
@deprecated
williamr@2
   469
*/
williamr@2
   470
static const TUint KHCIChangePacketTypeIoctl	=2;
williamr@2
   471
/** Request authorisation Ioctl 
williamr@2
   472
@deprecated
williamr@2
   473
*/
williamr@2
   474
static const TUint KHCIAuthRequestIoctl			=3;
williamr@2
   475
/** Request encryption Ioctl
williamr@2
   476
@deprecated
williamr@2
   477
*/
williamr@2
   478
static const TUint KHCIEncryptIoctl				=4;
williamr@2
   479
/** Change link key Ioctl
williamr@2
   480
@deprecated
williamr@2
   481
*/
williamr@2
   482
static const TUint KHCIChangeLinkKeyIoctl		=5;
williamr@2
   483
/** Master link key Ioctl
williamr@2
   484
@deprecated
williamr@2
   485
*/
williamr@2
   486
static const TUint KHCIMasterLinkKeyIoctl		=6;
williamr@2
   487
/** Enable hold mode Ioctl
williamr@2
   488
@deprecated
williamr@2
   489
*/
williamr@2
   490
static const TUint KHCIHoldModeIoctl			=7;
williamr@2
   491
/** Enable sniff mode Ioctl
williamr@2
   492
@deprecated
williamr@2
   493
*/
williamr@2
   494
static const TUint KHCISniffModeIoctl			=8;
williamr@2
   495
/** Exit sniff mode Ioctl
williamr@2
   496
@deprecated
williamr@2
   497
*/
williamr@2
   498
static const TUint KHCIExitSniffModeIoctl		=9;
williamr@2
   499
/** Enable park mode Ioctl
williamr@2
   500
@deprecated
williamr@2
   501
*/
williamr@2
   502
static const TUint KHCIParkModeIoctl			=10;
williamr@2
   503
/** Exit park mode Ioctl
williamr@2
   504
@deprecated
williamr@2
   505
*/
williamr@2
   506
static const TUint KHCIExitParkModeIoctl		=11;
williamr@2
   507
williamr@2
   508
/** Read page timeout Ioctl
williamr@2
   509
@deprecated
williamr@2
   510
*/
williamr@2
   511
static const TUint KHCIReadPageTimeoutIoctl		=12;
williamr@2
   512
/** Write page timeout Ioctl
williamr@2
   513
@deprecated
williamr@2
   514
*/
williamr@2
   515
static const TUint KHCIWritePageTimeoutIoctl	=13;
williamr@2
   516
/** Read scan enable Ioctl
williamr@2
   517
@deprecated
williamr@2
   518
@see bt_subscribe.h
williamr@2
   519
*/
williamr@2
   520
static const TUint KHCIReadScanEnableIoctl		=14;
williamr@2
   521
/** Write scan enable Ioctl
williamr@2
   522
@deprecated
williamr@2
   523
@see bt_subscribe.h
williamr@2
   524
*/
williamr@2
   525
static const TUint KHCIWriteScanEnableIoctl		=15;
williamr@2
   526
/** Read device class Ioctl
williamr@2
   527
@deprecated
williamr@2
   528
@see bt_subscribe.h
williamr@2
   529
*/
williamr@2
   530
static const TUint KHCIReadDeviceClassIoctl		=16;
williamr@2
   531
/** Write device class Ioctl
williamr@2
   532
@deprecated
williamr@2
   533
@see bt_subscribe.h
williamr@2
   534
*/
williamr@2
   535
static const TUint KHCIWriteDeviceClassIoctl	=17;
williamr@2
   536
/** Read voice settings Ioctl
williamr@2
   537
@deprecated
williamr@2
   538
*/
williamr@2
   539
static const TUint KHCIReadVoiceSettingIoctl	=18;
williamr@2
   540
/** Write voice settings Ioctl
williamr@2
   541
@deprecated
williamr@2
   542
*/
williamr@2
   543
static const TUint KHCIWriteVoiceSettingIoctl	=19;
williamr@2
   544
/** Read hold mode activity Ioctl
williamr@2
   545
@deprecated
williamr@2
   546
*/
williamr@2
   547
static const TUint KHCIReadHoldModeActivityIoctl=20;
williamr@2
   548
/** Write hold mode activity Ioctl
williamr@2
   549
@deprecated
williamr@2
   550
*/
williamr@2
   551
static const TUint KHCIWriteHoldModeActivityIoctl=21;
williamr@2
   552
/** Local version Ioctl
williamr@2
   553
@deprecated
williamr@2
   554
*/
williamr@2
   555
static const TUint KHCILocalVersionIoctl		=22;
williamr@2
   556
/** Local features Ioctl
williamr@2
   557
@deprecated
williamr@2
   558
*/
williamr@2
   559
static const TUint KHCILocalFeaturesIoctl		=23;
williamr@2
   560
/** Country code Ioctl
williamr@2
   561
@deprecated
williamr@2
   562
*/
williamr@2
   563
static const TUint KHCICountryCodeIoctl			=24;
williamr@2
   564
/** Local address Ioctl
williamr@2
   565
@deprecated
williamr@2
   566
@see bt_subscribe.h
williamr@2
   567
*/
williamr@2
   568
static const TUint KHCILocalAddressIoctl		=25;
williamr@2
   569
/** Write discoverability Ioctl
williamr@2
   570
@deprecated
williamr@2
   571
@see bt_subscribe.h
williamr@2
   572
*/
williamr@2
   573
static const TUint KHCIWriteDiscoverabilityIoctl=26;
williamr@2
   574
/** Read discoverability Ioctl
williamr@2
   575
@deprecated
williamr@2
   576
@see bt_subscribe.h
williamr@2
   577
*/
williamr@2
   578
static const TUint KHCIReadDiscoverabilityIoctl	=27;
williamr@2
   579
/** Read authentification enabled Ioctl
williamr@2
   580
@deprecated
williamr@2
   581
*/
williamr@2
   582
static const TUint KHCIReadAuthenticationEnableIoctl=33;
williamr@2
   583
/** Write authentification enabled Ioctl
williamr@2
   584
@deprecated
williamr@2
   585
*/
williamr@2
   586
static const TUint KHCIWriteAuthenticationEnableIoctl=34;
williamr@2
   587
williamr@2
   588
williamr@2
   589
// Structs for ioctl parameters
williamr@2
   590
williamr@2
   591
/**
williamr@2
   592
Enumerations for the four possible scan enable modes.
williamr@2
   593
Use Inquiry scan for discoverability and Page scan for
williamr@2
   594
connectability.
williamr@2
   595
williamr@2
   596
Use with KHCIReadScanEnableIoctl and KHCIWriteScanEnableIoctl.
williamr@2
   597
@deprecated
williamr@2
   598
@see bt_subscribe.h
williamr@2
   599
*/
williamr@2
   600
enum THCIScanEnableIoctl 
williamr@2
   601
    {
williamr@2
   602
     EHCINoScansEnabled=0x00,          /*!< No scans enabled. */
williamr@2
   603
     EHCIInquiryScanOnly,              /*!< Inquiry scan only. */
williamr@2
   604
     EHCIPageScanOnly,                 /*!< Page scan only. */
williamr@2
   605
     EHCIInquiryAndPageScan            /*!< Both inquiry and page scan enabled. */
williamr@2
   606
    };
williamr@2
   607
/**
williamr@2
   608
Package for THCIScanEnableIoctl structure 
williamr@2
   609
@deprecated
williamr@2
   610
*/
williamr@2
   611
typedef TPckgBuf<THCIScanEnableIoctl> THCIScanEnableBuf;	
williamr@2
   612
williamr@2
   613
struct TLMAddSCOConnectionIoctl
williamr@2
   614
/**
williamr@2
   615
Structure for specifying SCO type to add to a connected socket.
williamr@2
   616
The connection handle for the SCO link is returned in iConnH when
williamr@2
   617
the Ioctl completes.
williamr@2
   618
williamr@2
   619
Use with KHCIAddSCOConnIoctl.
williamr@2
   620
@deprecated
williamr@2
   621
*/
williamr@2
   622
	{
williamr@2
   623
	TUint16        iPktType;	/*!< Packet type */
williamr@2
   624
	};
williamr@2
   625
/**
williamr@2
   626
Package for TLMAddSCOConnectionIoctl structure
williamr@2
   627
@deprecated
williamr@2
   628
*/
williamr@2
   629
typedef TPckgBuf<TLMAddSCOConnectionIoctl> TLMAddSCOConnectionBuf;	
williamr@2
   630
williamr@2
   631
struct THCISetEncryptionIoctl
williamr@2
   632
/**
williamr@2
   633
Request to change the encryption state of a connection.
williamr@2
   634
iEncrypt specifies whether to turn encryption on or off.
williamr@2
   635
williamr@2
   636
Use with KHCIEncryptIoctl.
williamr@2
   637
@deprecated
williamr@2
   638
*/
williamr@2
   639
	{
williamr@2
   640
	TBool             iEncrypt;		/*!< Encryption enabled / disabled */
williamr@2
   641
	};
williamr@2
   642
/**
williamr@2
   643
Package for THCISetEncryptionIoctl structure 
williamr@2
   644
@deprecated
williamr@2
   645
*/
williamr@2
   646
typedef TPckgBuf<THCISetEncryptionIoctl> THCISetEncryptionBuf;
williamr@2
   647
williamr@2
   648
struct THCIDeviceClassIoctl
williamr@2
   649
/**
williamr@2
   650
Structure to specify the class of device when getting or setting
williamr@2
   651
the local device class.
williamr@2
   652
williamr@2
   653
Use with KHCIReadDeviceClassIoctl and KHCIWriteDeviceClassIoctl.
williamr@2
   654
@deprecated
williamr@2
   655
@see bt_subscribe.h
williamr@2
   656
*/
williamr@2
   657
	{
williamr@2
   658
	TUint16    iMajorServiceClass;		/*!< Major Service class */
williamr@2
   659
	TUint8     iMajorDeviceClass;		/*!< Major Device class */
williamr@2
   660
	TUint8     iMinorDeviceClass;		/*!< Minor Device class */
williamr@2
   661
	};
williamr@2
   662
/**
williamr@2
   663
Package for THCIDeviceClassIoctl structure 
williamr@2
   664
@deprecated
williamr@2
   665
*/
williamr@2
   666
typedef TPckgBuf<THCIDeviceClassIoctl> THCIDeviceClassBuf;
williamr@2
   667
	
williamr@2
   668
struct THCILocalVersionIoctl
williamr@2
   669
/**
williamr@2
   670
Structure describing the local Bluetooth hardware version.
williamr@2
   671
williamr@2
   672
Use with KHCILocalVersionIoctl.
williamr@2
   673
@deprecated
williamr@2
   674
*/
williamr@2
   675
	{
williamr@2
   676
	TUint8   iHCIVersion;			/*!< HCI version */
williamr@2
   677
	TUint16  iHCIRevision;			/*!< HCI Revision */
williamr@2
   678
	TUint8   iLMPVersion;			/*!< LMP version */
williamr@2
   679
	TUint16  iLMPSubversion;		/*!< LMP subversion */
williamr@2
   680
	TUint16  iManufacturerName;		/*!< Manufacturer name */
williamr@2
   681
	};
williamr@2
   682
/**
williamr@2
   683
Package for THCILocalVersionIoctl structure 
williamr@2
   684
@deprecated
williamr@2
   685
*/
williamr@2
   686
typedef TPckgBuf<THCILocalVersionIoctl> THCILocalVersionBuf;	
williamr@2
   687
williamr@2
   688
/** L2CAP Get / Set Options. */
williamr@2
   689
enum TBTL2CAPOptions
williamr@2
   690
	{
williamr@2
   691
	/** 
williamr@2
   692
	Get the outbound MTU size taking into account both the negotiated MTU size 
williamr@2
   693
    and best use of underlying packet sizes.
williamr@2
   694
	For example: If the default outgoing MTU of 672 has been negotiated for a L2CAP channel
williamr@2
   695
	that is in Retransmission or Flow control mode then this GetOpt will return an
williamr@2
   696
	outgoing MTU of 668 bytes. This allows a maximally sized SDU 
williamr@2
   697
	(which due to this adjustment will be 668 bytes) to be sent in two DH5 packets.
williamr@2
   698
	KL2CAPOutboundMTUForBestPerformance may also be used to set the current negotiated 
williamr@2
   699
	(or to be negotiated) outbound MTU size.
williamr@2
   700
	Note that the outbound MTU size returned when using KL2CAPOutboundMTUForBestPerformance 
williamr@2
   701
	with a GetOpt may not be the same as the outbound MTU size previously set 
williamr@2
   702
	when using KL2CAPOutboundMTUForBestPerformance with a SetOpt.
williamr@2
   703
	*/ 
williamr@2
   704
	KL2CAPOutboundMTUForBestPerformance,	
williamr@2
   705
williamr@2
   706
	/** 
williamr@2
   707
	This is the legacy value for setting getting \ setting the outbound MTU size and behaves
williamr@2
   708
	in the same way as KL2CAPOutboundMTUForBestPerformance.
williamr@2
   709
	@see KL2CAPOutboundMTUForBestPerformance
williamr@2
   710
	*/ 
williamr@2
   711
	KL2CAPGetOutboundMTU = KL2CAPOutboundMTUForBestPerformance,
williamr@2
   712
williamr@2
   713
	KL2CAPGetDebug1,				/*!< Debug Command */
williamr@2
   714
	KL2CAPInboundMTU,				/*!< Get / Set the current inbound MTU size */
williamr@2
   715
	KL2CAPRTXTimer,					/*!< Change the extended L2CAP command retransmission timeout */
williamr@2
   716
	KL2CAPERTXTimer,				/*!< Change the L2CAP command retransmission timeout */
williamr@2
   717
	KL2CAPGetMaxOutboundMTU,		/*!< Get the max outbound MTU supported by the stack */
williamr@2
   718
	KL2CAPGetMaxInboundMTU,			/*!< Get the max inbound MTU supported by the stack */
williamr@2
   719
	KL2CAPUpdateChannelConfig,		/*!< Get and Set the current configuration parameters */
williamr@2
   720
williamr@2
   721
	/** Get / Set the current negotiated (or to be negotiated) outbound MTU size */
williamr@2
   722
	KL2CAPNegotiatedOutboundMTU,    
williamr@2
   723
williamr@2
   724
	KL2CAPTestConfigure,	
williamr@2
   725
	KL2CAPDebugFlush,
williamr@2
   726
	KL2CAPVersion1_2,
williamr@2
   727
	KL2CAPHeapAlloc,
williamr@2
   728
	KL2CAPDataPlaneConfig,
williamr@2
   729
	
williamr@2
   730
	/**
williamr@2
   731
	This is similar to KL2CAPOutboundMTUForBestPerformance except that the caller can specify
williamr@2
   732
	a restriction that the returned MTU shall not exceed. This is useful for layers above L2CAP
williamr@2
   733
	that still want an optimal MTU but have their own restrictions on packet size.
williamr@2
   734
	*/
williamr@2
   735
	KL2CAPOutboundMTUForBestPerformanceWithRestriction,
williamr@2
   736
	};
williamr@2
   737
williamr@2
   738
typedef TUint16 TL2CAPPort;			/*!< Definition of a L2CAP port number type */
williamr@2
   739
williamr@2
   740
const static TL2CAPPort KL2CAPPassiveAutoBind = KMaxTUint16;  /*!< PSM out of the valid range used for passive auto bind operation */
williamr@2
   741
williamr@2
   742
NONSHARABLE_CLASS(TL2CAPSockAddr) : public TBTSockAddr
williamr@2
   743
/** L2CAP Socket Address.
williamr@2
   744
williamr@2
   745
Use this class to specify a local or remote L2CAP connection end-point,
williamr@2
   746
that is Device Address and PSM/CID.
williamr@2
   747
When unconnected, the Port() specifies the PSM, once connected it refers to
williamr@2
   748
the CID.
williamr@2
   749
@see TBTSockAddr
williamr@2
   750
@publishedAll
williamr@2
   751
@released
williamr@2
   752
*/
williamr@2
   753
	{
williamr@2
   754
public:
williamr@2
   755
	IMPORT_C TL2CAPSockAddr();
williamr@2
   756
	IMPORT_C TL2CAPSockAddr(const TSockAddr& aSockAddr);
williamr@2
   757
	IMPORT_C static TL2CAPSockAddr& Cast(const TSockAddr& aSockAddr);
williamr@2
   758
williamr@2
   759
	IMPORT_C TL2CAPPort Port() const;
williamr@2
   760
	IMPORT_C void SetPort(const TL2CAPPort aHomePort);
williamr@2
   761
	};
williamr@2
   762
williamr@2
   763
NONSHARABLE_CLASS(TInquirySockAddr) : public TSockAddr
williamr@2
   764
/** Socket address class used for inquiries.
williamr@2
   765
williamr@2
   766
Used to specify the inquiry request, and then filled with information
williamr@2
   767
about remote devices discovered through the inquiry process.
williamr@2
   768
williamr@2
   769
Use the BTAddr() method to extract the device address to connect to.
williamr@2
   770
williamr@2
   771
williamr@2
   772
Note: Usage of RHostResolver class for Bluetooth protocol.
williamr@2
   773
williamr@2
   774
The RHostResolver class is a generic interface to host name 
williamr@2
   775
resolution services, such as DNS, that may be provided 
williamr@2
   776
by particular protocol modules.
williamr@2
   777
williamr@2
   778
The points to remember when using RHostResolver::GetByAddress(), 
williamr@2
   779
RHostResolver::GetByName(), or RHostResolver::Next() 
williamr@2
   780
with Bluetooth protocol are:
williamr@2
   781
williamr@2
   782
1)  If you operate on one instance of RHostResolver you can perform 
williamr@2
   783
	only one request by calling either RHostResolver::GetByAddress() 
williamr@2
   784
	or  RHostResolver::GetByName(). If these functions are called again 
williamr@2
   785
	and if there is more than one possible response	for a given host name
williamr@2
   786
	then that will be returned (The host resolving process will
williamr@2
   787
	not start from the beginning). It is exactly as if the RHostResolve::Next() 
williamr@2
   788
	method was called.
williamr@2
   789
williamr@2
   790
2)  In order to start resolving new hosts from the beginning using the same 
williamr@2
   791
	instance of RHostResolver, the instance must be closed and reopened again.
williamr@2
   792
	
williamr@2
   793
3)  In order to perform several RHostResolver requests they	should be issued on 
williamr@2
   794
	separate instances of RHostResolver (many RHostResolver instances might 
williamr@2
   795
	exist and perform requests at the same time).
williamr@2
   796
	
williamr@2
   797
4)  The KHostResIgnoreCache flag is only valid when issuing RHostResolver::GetByAddress() 
williamr@2
   798
	or RHostResolver::GetByName() request for the first time.
williamr@2
   799
williamr@2
   800
5)  As an RHostResolver is only intended to be used once, it is recommended that it 
williamr@2
   801
	be closed as soon as it is finished with as the semantics of Cancel merely
williamr@2
   802
	indicates that one client server request should be cancelled.
williamr@2
   803
	
williamr@2
   804
@publishedAll
williamr@2
   805
@released
williamr@2
   806
*/
williamr@2
   807
	{
williamr@2
   808
// Max size for this structure is 24 bytes (32 - 8, see TSockAddr). However, due to padding and to prevent BC breaks, 
williamr@2
   809
// only up to 3 TUint8(s) may be added after iFlags
williamr@2
   810
	struct SInquiryAddr
williamr@2
   811
		{
williamr@2
   812
		TBTDevAddr iAddress;
williamr@2
   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)
williamr@2
   814
		TUint16 iMajorServiceClass;
williamr@2
   815
		TUint8 iMajorDeviceClass;
williamr@2
   816
		TUint8 iMinorDeviceClass;
williamr@2
   817
		TUint iIAC;
williamr@2
   818
		TUint8 iActionFlags;
williamr@2
   819
		TUint8 iResultFlags;
williamr@2
   820
		TInt8 iRssi;
williamr@2
   821
		};
williamr@2
   822
	
williamr@2
   823
public:
williamr@2
   824
	// This defines all the bit masks for the inquiry result
williamr@2
   825
	enum TResolverResultFlags
williamr@2
   826
		{
williamr@2
   827
		ERssiValid = 0x1,
williamr@2
   828
		};
williamr@2
   829
williamr@2
   830
public:
williamr@2
   831
	IMPORT_C TInquirySockAddr();
williamr@2
   832
	IMPORT_C TInquirySockAddr(const TSockAddr& aSockAddr);
williamr@2
   833
	IMPORT_C TBTDevAddr BTAddr() const;
williamr@2
   834
	IMPORT_C void SetBTAddr(const TBTDevAddr& aRemote);
williamr@2
   835
williamr@2
   836
	IMPORT_C static TInquirySockAddr& Cast(const TSockAddr& aSockAddr);
williamr@2
   837
	IMPORT_C TUint16 MajorServiceClass() const;
williamr@2
   838
	IMPORT_C void SetMajorServiceClass(TUint16 aClass);
williamr@2
   839
	IMPORT_C TUint8 MajorClassOfDevice() const;
williamr@2
   840
	IMPORT_C void SetMajorClassOfDevice(TUint8 aMajorClassOfDevice);
williamr@2
   841
	IMPORT_C TUint8 MinorClassOfDevice() const;
williamr@2
   842
	IMPORT_C void SetMinorClassOfDevice(TUint8 aMinorClassOfDevice);
williamr@2
   843
	IMPORT_C TUint IAC() const;
williamr@2
   844
	IMPORT_C void SetIAC(const TUint aIAC);
williamr@2
   845
	IMPORT_C TUint8 Action() const;
williamr@2
   846
	IMPORT_C void SetAction(TUint8 aFlags);
williamr@2
   847
	IMPORT_C TVersion Version() const;	
williamr@2
   848
	IMPORT_C TInt8 Rssi() const;	
williamr@2
   849
	IMPORT_C void SetRssi(const TInt8 aRssi);
williamr@2
   850
	IMPORT_C TUint8 ResultFlags() const;
williamr@2
   851
	IMPORT_C void SetResultFlags(TUint8 aResultFlags);
williamr@2
   852
williamr@2
   853
protected:
williamr@2
   854
	void SetVersion(TVersion aVersion);
williamr@2
   855
	IMPORT_C TUint8 FormatTypeField() const;
williamr@2
   856
	void SetFormatTypeField(TUint8 aType);
williamr@2
   857
	
williamr@2
   858
private:
williamr@2
   859
	SInquiryAddr& InquiryAddrStruct() const;
williamr@2
   860
	TPtr8 AddressPtr() const;
williamr@2
   861
	};
williamr@2
   862
williamr@2
   863
williamr@2
   864
enum TACLPort
williamr@2
   865
/** ACL port types.
williamr@2
   866
@internalComponent
williamr@2
   867
*/
williamr@2
   868
	{
williamr@2
   869
	EACLPortRaw		= 0x00,		/*!< Raw port type */
williamr@2
   870
	EACLPortL2CAP	= 0x01,		/*!< L2CAP port type */
williamr@2
   871
	EACLPortUnset	= 0xFF,		/*!< Unspecified ACL port type */
williamr@2
   872
	};
williamr@2
   873
williamr@2
   874
williamr@2
   875
// SAP types for baseband
williamr@2
   876
/** ACL socket type
williamr@2
   877
@internalTechnology
williamr@2
   878
*/
williamr@2
   879
static const TUint KSockBluetoothTypeACL = KMaxTUint;
williamr@2
   880
/** Raw broadcast socket type
williamr@2
   881
@internalTechnology
williamr@2
   882
*/
williamr@2
   883
static const TUint KSockBluetoothTypeRawBroadcast = KMaxTUint-2;
williamr@2
   884
williamr@2
   885
NONSHARABLE_CLASS(TACLSockAddr) : public TBTSockAddr
williamr@2
   886
/** ACL Socket Address.
williamr@2
   887
williamr@2
   888
Use this class to specify a local or remote baseband connection end-point,
williamr@2
   889
This is tied to the flags field in ACL data packets
williamr@2
   890
@internalComponent
williamr@2
   891
*/
williamr@2
   892
	{
williamr@2
   893
public:
williamr@2
   894
	IMPORT_C TACLSockAddr();
williamr@2
   895
	IMPORT_C TACLSockAddr(const TSockAddr& aSockAddr);
williamr@2
   896
	IMPORT_C static TACLSockAddr& Cast(const TSockAddr& aSockAddr);
williamr@2
   897
	//
williamr@2
   898
	IMPORT_C TACLPort Port() const;
williamr@2
   899
	IMPORT_C void SetPort(TACLPort aPort);
williamr@2
   900
	};
williamr@2
   901
williamr@2
   902
williamr@2
   903
//
williamr@2
   904
// RFCOMM
williamr@2
   905
//
williamr@2
   906
williamr@2
   907
const static TInt KRFErrorBase = -6350;										/*!< RFCOMM base error code. */
williamr@2
   908
const static TInt KErrRfcommSAPUnexpectedEvent = KRFErrorBase;				/*!< RFCOMM unexpected event error code. */
williamr@2
   909
const static TInt KErrRfcommAlreadyBound = KRFErrorBase-1;					/*!< RFCOMM SAP already bound error code. */
williamr@2
   910
const static TInt KErrRfcommBadAddress = KRFErrorBase-2;					/*!< RFCOMM bad address error code. */
williamr@2
   911
const static TInt KErrRfcommMTUSize = KRFErrorBase-3;						/*!< RFCOMM MTU size exceeded error code. */
williamr@2
   912
const static TInt KErrRfcommFrameResponseTimeout = KRFErrorBase-4;			/*!< RFCOMM frame response timeout error code. */
williamr@2
   913
const static TInt KErrRfcommMuxRemoteDisconnect = KRFErrorBase-5;			/*!< RFCOMM remote end disconnected error code. */
williamr@2
   914
const static TInt KErrRfcommNotBound = KRFErrorBase-6;						/*!< RFCOMM SAP not bound error code. */
williamr@2
   915
const static TInt KErrRfcommParameterNegotiationFailure = KRFErrorBase-7;	/*!< RFCOMM parameter negotiation failure error code. */
williamr@2
   916
const static TInt KErrRfcommNotListening = KRFErrorBase-8;					/*!< RFCOMM not listening error code. */
williamr@2
   917
const static TInt KErrRfcommNoMoreServerChannels = KRFErrorBase-9;			/*!< RFCOMM no more server channels available error code. */
williamr@2
   918
williamr@2
   919
//RFCOMMIoctls
williamr@2
   920
williamr@2
   921
const static TInt KRFCOMMModemStatusCmdIoctl =0;		/*!< RFCOMM status command Ioctl */
williamr@2
   922
const static TInt KRFCOMMRemoteLineStatusCmdIoctl = 1;	/*!< RFCOMM remote line status command Ioctl */
williamr@2
   923
const static TInt KRFCOMMRemotePortNegCmdIoctl = 2;		/*!< RFCOMM remote port negotiation command Ioctl */
williamr@2
   924
const static TInt KRFCOMMRemotePortNegRequestIoctl = 3;	/*!< RFCOMM remote port negotiation request Ioctl */
williamr@2
   925
const static TInt KRFCOMMConfigChangeIndicationIoctl = 4;	/*!< RFCOMM MSC activity Ioctl */
williamr@2
   926
williamr@2
   927
// RFCOMM Options
williamr@2
   928
williamr@2
   929
const static TInt KRFCOMMLocalPortParameter = 0;	/*!< RFCOMM local port parameter option (Get + Set) */
williamr@2
   930
/** RFCOMM Get Available server channel option (Get only)
williamr@2
   931
@deprecated
williamr@2
   932
*/
williamr@2
   933
const static TInt KRFCOMMGetAvailableServerChannel = 1;
williamr@2
   934
williamr@2
   935
const static TInt KRFCOMMMaximumSupportedMTU = 2; 	/*!< RFCOMM maximum supported option (Get + Set) */
williamr@2
   936
const static TInt KRFCOMMGetDebug1 = 3;   			/*!< RFCOMM debug option (Get only) */
williamr@2
   937
const static TInt KRFCOMMGetRemoteModemStatus = 4; 	/*!< RFCOMM remote modem status option (Get + Set) */
williamr@2
   938
williamr@2
   939
const static TInt KRFCOMMGetTransmitCredit = 5;		/*!< RFCOMM get transmit credits option */
williamr@2
   940
const static TInt KRFCOMMGetReceiveCredit = 6;		/*!< RFCOMM get receive credits option */
williamr@2
   941
const static TInt KRFCOMMGetReUsedCount = 7;		/*!< RFCOMM get number of remote used credits option */
williamr@2
   942
const static TInt KRFCOMMFlowTypeCBFC = 8; 			/*!< RFCOMM Credit based flow control option (Get + Set) */
williamr@2
   943
const static TInt KRFCOMMErrOnMSC = 9;				/*!< RFCOMM set the value of MSC signals that will cause a disconnect error to be generated */
williamr@2
   944
const static TUint KRFCOMMLocalModemStatus = 10;   	/*!< RFCOMM local modem status option (Get + Set) */
williamr@2
   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) */
williamr@2
   946
williamr@2
   947
const static TInt KRFCOMMMaximumMTU = 12; 	/*!< RFCOMM maximum optimal MTU (Get only) */
williamr@2
   948
williamr@2
   949
// Masks for interpreting signalling commands
williamr@2
   950
const static TUint8 KModemSignalFC  = 0x01;			/*!< RFCOMM FC signalling command mask */
williamr@2
   951
const static TUint8 KModemSignalRTC = 0x02;			/*!< RFCOMM RTC signalling command mask */
williamr@2
   952
const static TUint8 KModemSignalRTR = 0x04;			/*!< RFCOMM RTR signalling command mask */
williamr@2
   953
const static TUint8 KModemSignalIC  = 0x20;			/*!< RFCOMM IC signalling command mask */
williamr@2
   954
const static TUint8 KModemSignalDV  = 0x40;			/*!< RFCOMM DV signalling command mask */
williamr@2
   955
williamr@2
   956
enum TRPNParameterMask
williamr@2
   957
/** Remote port negotiation parameter masks
williamr@2
   958
*/
williamr@2
   959
	{
williamr@2
   960
	EPMBitRate		= 0x0001,		/*!< Remote port negotiation parameter masks for bit rate */
williamr@2
   961
	EPMDataBits		= 0x0002,		/*!< Remote port negotiation parameter masks for data bits */
williamr@2
   962
	EPMStopBit		= 0x0004,		/*!< Remote port negotiation parameter masks for stop bit */
williamr@2
   963
	EPMParity		= 0x0008,		/*!< Remote port negotiation parameter masks for parity */
williamr@2
   964
	EPMParityType	= 0x0010,		/*!< Remote port negotiation parameter masks for parity type */
williamr@2
   965
	EPMXOnChar		= 0x0020,		/*!< Remote port negotiation parameter masks for on character */
williamr@2
   966
	EPMXOffChar		= 0x0040,		/*!< Remote port negotiation parameter masks for off character */
williamr@2
   967
	// RESERVED		= 0x0080		
williamr@2
   968
	EPMXOnOffInput	= 0x0100,		/*!< Remote port negotiation parameter masks for XOn/Off input */
williamr@2
   969
	EPMXOnOffOutput	= 0x0200,		/*!< Remote port negotiation parameter masks for XOn/Off output */
williamr@2
   970
	EPMRTRInput		= 0x0400,		/*!< Remote port negotiation parameter masks for read to receive input */
williamr@2
   971
	EPMRTROutput	= 0x0800,		/*!< Remote port negotiation parameter masks for read to receive output */
williamr@2
   972
	EPMRTCInput		= 0x1000,		/*!< Remote port negotiation parameter masks for RTC input */
williamr@2
   973
	EPMRTCOutput	= 0x2000		/*!< Remote port negotiation parameter masks for RTC output */
williamr@2
   974
	// RESERVED		= 0x4000
williamr@2
   975
	// RESERVED		= 0x8000
williamr@2
   976
	};
williamr@2
   977
williamr@2
   978
enum TRPNFlowCtrlMask
williamr@2
   979
/** Remote port negotiation flow control masks
williamr@2
   980
*/
williamr@2
   981
	{
williamr@2
   982
	EFCXOnOffInput	=0x01,	/*!< Remote port negotiation flow control masks for XOn/Off input */
williamr@2
   983
	EFCXOnOffOutput =0x02,	/*!< Remote port negotiation flow control masks for XOn/Off output */
williamr@2
   984
	EFCRTRInput		=0x04,	/*!< Remote port negotiation flow control masks for ready to receive input */
williamr@2
   985
	EFCRTROutput	=0x08,	/*!< Remote port negotiation flow control masks for ready to receive output */
williamr@2
   986
	EFCRTCInput		=0x10,	/*!< Remote port negotiation flow control masks for RTC input */
williamr@2
   987
	EFCRTCOutput	=0x20	/*!< Remote port negotiation flow control masks for RTC output */
williamr@2
   988
	};
williamr@2
   989
williamr@2
   990
enum TRPNValidityMask
williamr@2
   991
/** Remote port negotiation validity masks
williamr@2
   992
*/
williamr@2
   993
	{
williamr@2
   994
	EVMBitRate	= 0x01,	/*!< Remote port negotiation validity masks for bit rate */
williamr@2
   995
	EVMDataBits	= 0x02,	/*!< Remote port negotiation validity masks for data bits */
williamr@2
   996
	EVMStopBit	= 0x04,	/*!< Remote port negotiation validity masks for stop bit */
williamr@2
   997
	EVMParity	= 0x08,	/*!< Remote port negotiation validity masks for parity */
williamr@2
   998
	EVMFlowCtrl	= 0x10,	/*!< Remote port negotiation validity masks for flow control */
williamr@2
   999
	EVMXOnChar	= 0x20,	/*!< Remote port negotiation validity masks for XOn charater */
williamr@2
  1000
	EVMXOffChar	= 0x40	/*!< Remote port negotiation validity masks for XOff charater */
williamr@2
  1001
	};
williamr@2
  1002
williamr@2
  1003
// structs for RFCOMM Ioctls
williamr@2
  1004
williamr@2
  1005
class TRfcommRPNTransaction;
williamr@2
  1006
williamr@2
  1007
NONSHARABLE_CLASS(TRfcommRemotePortParams)
williamr@2
  1008
/** RF COMM remote port parameters. 
williamr@2
  1009
williamr@2
  1010
@publishedAll
williamr@2
  1011
@released
williamr@2
  1012
*/
williamr@2
  1013
	{
williamr@2
  1014
public:
williamr@2
  1015
	IMPORT_C TRfcommRemotePortParams();
williamr@2
  1016
	IMPORT_C TUint8	IsValid() const;
williamr@2
  1017
	IMPORT_C TBool  GetBitRate(TBps& aBitRate) const;
williamr@2
  1018
	IMPORT_C TInt   SetBitRate(TBps  aBitRate);
williamr@2
  1019
	IMPORT_C TBool  GetDataBits(TDataBits& aDataBits) const;
williamr@2
  1020
	IMPORT_C TInt   SetDataBits(TDataBits  aDataBits);
williamr@2
  1021
	IMPORT_C TBool  GetStopBit(TStopBits& aStopBit) const;
williamr@2
  1022
	IMPORT_C TInt   SetStopBit(TStopBits  aStopBit);
williamr@2
  1023
	IMPORT_C TBool  GetParity(TParity& aParity) const;
williamr@2
  1024
	IMPORT_C TInt   SetParity(TParity  aParity);
williamr@2
  1025
	IMPORT_C TBool  GetFlowCtrl(TUint8& aFlowCtrl) const;
williamr@2
  1026
	IMPORT_C TInt   SetFlowCtrl(TUint8  aFlowCtrl);
williamr@2
  1027
	IMPORT_C TBool  GetXOnChar(TUint8& aXOnChar) const;
williamr@2
  1028
	IMPORT_C TInt   SetXOnChar(TUint8  aXOnChar);
williamr@2
  1029
	IMPORT_C TBool  GetXOffChar(TUint8& aXOffChar) const;
williamr@2
  1030
	IMPORT_C TInt   SetXOffChar(TUint8  aXOffChar);
williamr@2
  1031
	IMPORT_C void   UpdateFlowCtrlBit(TUint8 aFlowCtrl, TRPNFlowCtrlMask aFCMask);
williamr@2
  1032
	IMPORT_C void   UpdateWholeFlowCtrl(TUint16 aParamMask, TUint8 aFlowCtrl);
williamr@2
  1033
	IMPORT_C void   UpdateFromRPNTransaction(const TRfcommRPNTransaction& 
williamr@2
  1034
											aRPNTransaction);	
williamr@2
  1035
private:	
williamr@2
  1036
	TBps iBitRate;
williamr@2
  1037
	TDataBits iDataBits;
williamr@2
  1038
	TStopBits iStopBit; //It's really only one bit - ignore what the type implies...
williamr@2
  1039
	TParity iParity;
williamr@2
  1040
	TUint8 iFlowCtrl;
williamr@2
  1041
	TUint8 iXOnChar;
williamr@2
  1042
	TUint8 iXOffChar;
williamr@2
  1043
	TUint8 iValidMask;
williamr@2
  1044
		
williamr@2
  1045
	// This data padding has been added to help prevent future binary compatibility breaks	
williamr@2
  1046
	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
williamr@2
  1047
	TUint32     iPadding1; 
williamr@2
  1048
	TUint32     iPadding2; 
williamr@2
  1049
	};
williamr@2
  1050
williamr@2
  1051
// structs for RFCOMM Ioctls
williamr@2
  1052
williamr@2
  1053
NONSHARABLE_CLASS(TRfcommRPNTransaction)
williamr@2
  1054
/** RF COMM IO control structs.
williamr@2
  1055
williamr@2
  1056
@publishedAll
williamr@2
  1057
@released
williamr@2
  1058
*/
williamr@2
  1059
	{
williamr@2
  1060
public: // Functions
williamr@2
  1061
	IMPORT_C TRfcommRPNTransaction();
williamr@2
  1062
public: // Variables
williamr@2
  1063
	TRfcommRemotePortParams iPortParams;	/*!< Remote port parameters */
williamr@2
  1064
	TUint16 iParamMask;						/*!< Parameter mask */
williamr@2
  1065
	};
williamr@2
  1066
williamr@2
  1067
// RFCOMM addresses
williamr@2
  1068
williamr@2
  1069
typedef TUint8 TRfcommChannel;	/*!< RFCOMM channel type definition */
williamr@2
  1070
williamr@2
  1071
const static TRfcommChannel KMinRfcommServerChannel = 1;	/*!< Minimum RFCOMM server channel value */
williamr@2
  1072
const static TRfcommChannel KMaxRfcommServerChannel = 30;	/*!< Maximum RFCOMM server channel value */
williamr@2
  1073
williamr@2
  1074
const static TRfcommChannel KRfcommPassiveAutoBind = KMaxTUint8;	/*!< Channel value out of the valid range used for passive auto bind. */
williamr@2
  1075
williamr@2
  1076
NONSHARABLE_CLASS(TRfcommSockAddr) : public TBTSockAddr
williamr@2
  1077
/** Defines the format of an Rfcomm address.
williamr@2
  1078
williamr@2
  1079
This class uses the TSockAddr data area to hold the address so that
williamr@2
  1080
it can be passed through the ESOCK boundary.
williamr@2
  1081
Assumes that the remote RFCOMM instance is always bound to PSM 3 on
williamr@2
  1082
L2CAP, so there is no way of specifying another remote PSM.
williamr@2
  1083
williamr@2
  1084
@see TBTSockAddr
williamr@2
  1085
@publishedAll   
williamr@2
  1086
@released
williamr@2
  1087
*/
williamr@2
  1088
	{
williamr@2
  1089
public:
williamr@2
  1090
	IMPORT_C TRfcommSockAddr();
williamr@2
  1091
	IMPORT_C TRfcommSockAddr(const TSockAddr& aSockAddr);
williamr@2
  1092
	IMPORT_C static TRfcommSockAddr& Cast(const TSockAddr& aSockAddr);
williamr@2
  1093
	};
williamr@2
  1094
williamr@2
  1095
/*****BASEBAND CLIENT*********/
williamr@2
  1096
williamr@2
  1097
class CBTBasebandSocketProxy;
williamr@2
  1098
class CBTBasebandPropertySubscriber;
williamr@2
  1099
williamr@2
  1100
class MBasebandObserver;
williamr@2
  1101
/** Array of device addresses
williamr@2
  1102
@see Enumerate method
williamr@2
  1103
*/
williamr@2
  1104
typedef RArray<TBTDevAddr> RBTDevAddrArray;		
williamr@2
  1105
williamr@2
  1106
NONSHARABLE_CLASS(RBTBaseband)
williamr@2
  1107
/** API useful for Bluetooth as seen from a single physical link perspective
williamr@2
  1108
@internalTechnology
williamr@2
  1109
@released
williamr@2
  1110
*/
williamr@2
  1111
	{
williamr@2
  1112
public:
williamr@2
  1113
	RBTBaseband();
williamr@2
  1114
	//API useful for Bluetooth as seen from a single physical link perspective
williamr@2
  1115
	TInt Open(RSocketServ& aSocketServ, RSocket& aSocket);
williamr@2
  1116
	TInt Open(RSocketServ& aSocketServ, const TBTDevAddr& aDevAddr);
williamr@2
  1117
	void Close();
williamr@2
  1118
	TInt PhysicalLinkState(TUint32& aState);
williamr@2
  1119
	TInt BasebandState(TUint32& aState); 
williamr@2
  1120
	TInt PreventRoleSwitch();
williamr@2
  1121
	TInt AllowRoleSwitch();
williamr@2
  1122
	TInt RequestMasterRole();
williamr@2
  1123
	TInt RequestSlaveRole();
williamr@2
  1124
	TInt PreventLowPowerModes(TUint32 aLowPowerModes);
williamr@2
  1125
	TInt AllowLowPowerModes(TUint32 aLowPowerModes);
williamr@2
  1126
	TInt ActivateSniffRequester();
williamr@2
  1127
	TInt ActivateParkRequester();
williamr@2
  1128
	TInt CancelLowPowerModeRequester();
williamr@2
  1129
	TInt RequestExplicitActiveMode(TBool aActive);
williamr@2
  1130
	TInt RequestChangeSupportedPacketTypes(TUint16 aPacketTypes);
williamr@2
  1131
	//THE TWO NOTIFY METHODS BELOW MUST NOT BE CALLED CONCURRENTLY
williamr@2
  1132
	//Method to be used if only the next event should be notified
williamr@2
  1133
	void ActivateNotifierForOneShot(TBTBasebandEvent& aEventNotification, 
williamr@2
  1134
		                            TRequestStatus& aStatus, 
williamr@2
  1135
									TUint32 aEventMask);
williamr@2
  1136
	//Method to be used if it is intended to call it again 
williamr@2
  1137
	//(or call CancelNextBasebandChangeEventNotifier) when it completes 
williamr@2
  1138
	// - this sets up a continuous monitoring of events on the server.
williamr@2
  1139
	//Each time ActivateNotifierForOneShot is called it will either return
williamr@2
  1140
	//the next event in the servers notification queue or if the
williamr@2
  1141
	//queue is empty it will await the next event. 
williamr@2
  1142
	void ActivateNotifierForRecall(TBTBasebandEvent& aEventNotification, 
williamr@2
  1143
		                           TRequestStatus& aStatus, 
williamr@2
  1144
								   TUint32 aEventMask);
williamr@2
  1145
	void ReadNewPhysicalLinkMetricValue(TRequestStatus& aStatus,
williamr@2
  1146
								TDes8& aData,
williamr@2
  1147
								TBTLMIoctls aIoctl);
williamr@2
  1148
	void CancelPhysicalLinkMetricUpdate();
williamr@2
  1149
	void CancelNextBasebandChangeEventNotifier();
williamr@2
  1150
	TInt Authenticate();
williamr@2
  1151
	
williamr@2
  1152
	//API useful for Bluetooth as seen from a device perspective
williamr@2
  1153
	TInt Open(RSocketServ& aSocketServ);
williamr@2
  1154
	void Connect(const TBTDevAddr& aDevAddr, TRequestStatus& aStatus);
williamr@2
  1155
	void Connect(const TPhysicalLinkQuickConnectionToken& aToken, TRequestStatus& aStatus);
williamr@2
  1156
	TInt Broadcast(const TDesC8& aData); // testing broadcast writes
williamr@2
  1157
	TInt ReadRaw(TDes8& aData);
williamr@2
  1158
	TInt Enumerate(RBTDevAddrArray& aBTDevAddrArray, TUint aMaxNumber);
williamr@2
  1159
	void TerminatePhysicalLink(TInt aReason);
williamr@2
  1160
	void TerminatePhysicalLink(TInt aReason, TRequestStatus& aStatus);
williamr@2
  1161
	void TerminatePhysicalLink(TInt aReason, const TBTDevAddr& aDevAddr, TRequestStatus& aStatus);
williamr@2
  1162
	void ShutdownPhysicalLink(TRequestStatus& aStatus);
williamr@2
  1163
	void TerminateAllPhysicalLinks(TInt aReason);
williamr@2
  1164
	void TerminateAllPhysicalLinks(TInt aReason, TRequestStatus& aStatus);
williamr@2
  1165
	TInt SubSessionHandle() const;
williamr@2
  1166
	
williamr@2
  1167
private:
williamr@2
  1168
	TInt RequestRole(TBTLMOptions aRole);
williamr@2
  1169
	TInt RequestEncrypt(THCIEncryptModeFlag aEnable);
williamr@2
  1170
	void LocalComplete(TRequestStatus& aStatus, TInt aErr);
williamr@2
  1171
	void SetClientPending(TRequestStatus& aStatus);
williamr@2
  1172
	void DoConnect(TRequestStatus& aStatus);
williamr@2
  1173
	TInt Enumerate(TDes8& aData);
williamr@2
  1174
	TInt Construct();
williamr@2
  1175
		
williamr@2
  1176
private:
williamr@2
  1177
	TAny*					iUnusedPointer;
williamr@2
  1178
	RSocket					iSocket;
williamr@2
  1179
williamr@2
  1180
	TRequestStatus*							iClientRequestStatus;
williamr@2
  1181
	TBTSockAddr								iSocketAddress;				
williamr@2
  1182
	TPhysicalLinkQuickConnectionTokenBuf	iConnectToken;
williamr@2
  1183
	TBuf8<1>								iConnectInData; // not used yet - needed tho!
williamr@2
  1184
	TBuf8<1>								iDummySCOShutdownDescriptor;
williamr@2
  1185
	
williamr@2
  1186
	// This data padding has been added to help prevent future binary compatibility breaks	
williamr@2
  1187
	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
williamr@2
  1188
	TUint32     iPadding1; 
williamr@2
  1189
	TUint32     iPadding2; 	
williamr@2
  1190
	};
williamr@2
  1191
williamr@2
  1192
NONSHARABLE_CLASS(RBTPhysicalLinkAdapter)
williamr@2
  1193
/** Class to enable modification of a physical link:
williamr@2
  1194
williamr@2
  1195
Modifications may be requested or prevented (blocked).
williamr@2
  1196
Whilst a modification is being prevented, any request to
williamr@2
  1197
perform that modification by this or any other
williamr@2
  1198
RBTPhysicalLinkAdapter client will be ignored.
williamr@2
  1199
If a low power mode is being used on the physical link, a
williamr@2
  1200
call to prevent that low power mode will, if possible, cause
williamr@2
  1201
the physical link to exit that low power mode. An
williamr@2
  1202
arbitration between all RBTPhysicalLinkAdapter clients will then occur
williamr@2
  1203
to decide whether the physical link should remain active or 
williamr@2
  1204
enter another low power mode. (If all low power modes are prevented
williamr@2
  1205
then that arbitration will result in the physical link remaining
williamr@2
  1206
active.)
williamr@2
  1207
williamr@2
  1208
Methods to prevent modifications begin 'Prevent...'
williamr@2
  1209
williamr@2
  1210
Methods to cancel the prevention of modification begin 'Allow...'
williamr@2
  1211
williamr@2
  1212
Requests for low power mode modifications, and notification of modifications
williamr@2
  1213
take the form of continuously repeated requests which can be switched on or 
williamr@2
  1214
switched off. 
williamr@2
  1215
williamr@2
  1216
Only one low power mode requester may active on a single RBTPhysicalLinkAdapter
williamr@2
  1217
client at a time. If several RBTPhysicalLinkAdapter clients have differing low
williamr@2
  1218
power mode requests active at a given moment then the priority will be:
williamr@2
  1219
	Hold
williamr@2
  1220
	Sniff
williamr@2
  1221
	Park
williamr@2
  1222
williamr@2
  1223
Methods to perform these requests start 'Activate...'
williamr@2
  1224
williamr@2
  1225
Methods to cancel these requests start 'Cancel...'
williamr@2
  1226
@publishedAll
williamr@2
  1227
@released
williamr@2
  1228
*/
williamr@2
  1229
	{
williamr@2
  1230
public:
williamr@2
  1231
	IMPORT_C RBTPhysicalLinkAdapter();
williamr@2
  1232
	IMPORT_C TInt Open(RSocketServ& aSocketServ, RSocket& aSocket);
williamr@2
  1233
	IMPORT_C TInt Open(RSocketServ& aSocketServ, const TBTDevAddr& aDevAddr);
williamr@2
  1234
	IMPORT_C TBool IsOpen() const;		
williamr@2
  1235
	IMPORT_C void Close();
williamr@2
  1236
	IMPORT_C TInt PhysicalLinkState(TUint32& aState);
williamr@2
  1237
	IMPORT_C TInt PreventRoleSwitch();
williamr@2
  1238
	IMPORT_C TInt AllowRoleSwitch();
williamr@2
  1239
	IMPORT_C TInt RequestMasterRole();
williamr@2
  1240
	IMPORT_C TInt RequestSlaveRole();
williamr@2
  1241
	IMPORT_C TInt PreventLowPowerModes(TUint32 aLowPowerModes);
williamr@2
  1242
	IMPORT_C TInt AllowLowPowerModes(TUint32 aLowPowerModes);
williamr@2
  1243
	IMPORT_C TInt ActivateSniffRequester();
williamr@2
  1244
	IMPORT_C TInt ActivateParkRequester();
williamr@2
  1245
	IMPORT_C TInt ActivateActiveRequester();
williamr@2
  1246
	IMPORT_C TInt CancelLowPowerModeRequester();
williamr@2
  1247
	IMPORT_C TInt RequestChangeSupportedPacketTypes(TUint16 aPacketTypes);
williamr@2
  1248
	IMPORT_C void NotifyNextBasebandChangeEvent(TBTBasebandEvent& aEventNotification, 
williamr@2
  1249
		                                        TRequestStatus& aStatus, 
williamr@2
  1250
						     		            TUint32 aEventMask = ENotifyAnyPhysicalLinkState);
williamr@2
  1251
williamr@2
  1252
	IMPORT_C void CancelNextBasebandChangeEventNotifier();
williamr@2
  1253
	IMPORT_C TInt Authenticate();
williamr@2
  1254
	
williamr@2
  1255
private:
williamr@2
  1256
	RBTBaseband iBTBaseband;
williamr@2
  1257
	
williamr@2
  1258
	// This data padding has been added to help prevent future binary compatibility breaks	
williamr@2
  1259
	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
williamr@2
  1260
	TUint32     iPadding1; 
williamr@2
  1261
	TUint32     iPadding2; 	
williamr@2
  1262
	};
williamr@2
  1263
williamr@2
  1264
/**
williamr@2
  1265
This allows for notification of events relating to a CBluetoothPhysicalLinkMetrics object.
williamr@2
  1266
williamr@2
  1267
These notifications will be called when the value of a physical link metric that has been
williamr@2
  1268
subscribed to in CBluetoothPhysicalLinkMetrics changes. If the notification is not called,
williamr@2
  1269
the value has not changed since the last notification
williamr@2
  1270
williamr@2
  1271
Mixin class to be used with CBluetoothPhysicalLinkMetrics
williamr@2
  1272
@publishedAll
williamr@2
  1273
@released
williamr@2
  1274
*/
williamr@2
  1275
class MBluetoothPhysicalLinkMetricsObserver
williamr@2
  1276
	{
williamr@2
  1277
public:
williamr@2
  1278
	/**
williamr@2
  1279
	Notification for the initial RSSI (received signal strengh indication) value
williamr@2
  1280
	and whenever the RSSI changes
williamr@2
  1281
	@param aRssi Current RSSI Value in dB
williamr@2
  1282
	*/
williamr@2
  1283
	virtual void MbplmoRssiChanged(TInt8 aRssi) = 0;
williamr@2
  1284
	
williamr@2
  1285
	/**
williamr@2
  1286
	Notification for the initial Link Quality value and whenever the Link Quality changes.
williamr@2
  1287
	@param aLinkQuality Link quality for this connection where the higher value represents a better quality link
williamr@2
  1288
	*/
williamr@2
  1289
	virtual void MbplmoLinkQualityChanged(TUint8 aLinkQuality) = 0;
williamr@2
  1290
	
williamr@2
  1291
	/**
williamr@2
  1292
	Notification for the initial failed contact counter value, and whenever the failed contact counter changes.
williamr@2
  1293
	@param aFailedContactCounter Number of consecutive failed contacts for this connection
williamr@2
  1294
	*/
williamr@2
  1295
	virtual void MbplmoFailedContactCounterChanged(TUint16 aFailedContactCounter) = 0;
williamr@2
  1296
	
williamr@2
  1297
	/**
williamr@2
  1298
	Notification for the initial transmit power level, and whenever the transmit power level changes.
williamr@2
  1299
	@param aTransmitPowerLevel Transmit power level in dBm
williamr@2
  1300
	*/
williamr@2
  1301
	virtual void MbplmoTransmitPowerLevelChanged(TInt8 aTransmitPowerLevel) = 0;
williamr@2
  1302
	
williamr@2
  1303
	/**
williamr@2
  1304
	Notification that an error has occured. When this is called, the current
williamr@2
  1305
	subscriptions will be cancelled.
williamr@2
  1306
	If a link disconnection occurs, the CBluetoothPhysicalLinkMetrics object will
williamr@2
  1307
	no longer be valid, so it is recommended to delete the object in this callback
williamr@2
  1308
	*/
williamr@2
  1309
	virtual void MbplmoError(TInt aError) = 0;
williamr@2
  1310
	
williamr@2
  1311
	/**
williamr@2
  1312
	Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
williamr@2
  1313
	@param aInterface UID of the interface to return
williamr@2
  1314
	@return The container for another interface as specified by aInterface
williamr@2
  1315
	*/
williamr@2
  1316
	IMPORT_C virtual TAny* MbplmoExtensionInterfaceL(TUid aInterface);
williamr@2
  1317
	};
williamr@2
  1318
williamr@2
  1319
class CBluetoothPhysicalLinkMetricSubscriber;
williamr@2
  1320
williamr@2
  1321
/**
williamr@2
  1322
Class to subscribe to physical link metrics
williamr@2
  1323
@publishedAll
williamr@2
  1324
@released
williamr@2
  1325
*/
williamr@2
  1326
NONSHARABLE_CLASS(CBluetoothPhysicalLinkMetrics): public CBase
williamr@2
  1327
	{
williamr@2
  1328
public:
williamr@2
  1329
	IMPORT_C static CBluetoothPhysicalLinkMetrics* NewL(
williamr@2
  1330
						MBluetoothPhysicalLinkMetricsObserver& aObserver,
williamr@2
  1331
						RSocketServ& aSockServ,
williamr@2
  1332
						RSocket& aConnectedSocket);
williamr@2
  1333
	
williamr@2
  1334
	IMPORT_C static CBluetoothPhysicalLinkMetrics* NewL(
williamr@2
  1335
						MBluetoothPhysicalLinkMetricsObserver& aObserver,
williamr@2
  1336
						RSocketServ& aSockServ,
williamr@2
  1337
						const TBTDevAddr& aAddr);
williamr@2
  1338
	
williamr@2
  1339
	IMPORT_C ~CBluetoothPhysicalLinkMetrics();
williamr@2
  1340
	IMPORT_C void SubscribeRssi();
williamr@2
  1341
	IMPORT_C void SubscribeLinkQuality();
williamr@2
  1342
	IMPORT_C void SubscribeFailedContactCounter();
williamr@2
  1343
	IMPORT_C void SubscribeTransmitPowerLevel();
williamr@2
  1344
	IMPORT_C void Cancel();
williamr@2
  1345
	
williamr@2
  1346
	void RssiChanged(TInt8 aRssi);
williamr@2
  1347
	void LinkQualityChanged(TUint8 aLinkQuality);
williamr@2
  1348
	void FailedContactCounterChanged(TUint16 aFailedContactCounter);
williamr@2
  1349
	void TransmitPowerLevelChanged(TInt8 aTransmitPowerLevel);
williamr@2
  1350
	void SubscribeError(TInt aError);
williamr@2
  1351
williamr@2
  1352
	
williamr@2
  1353
private:
williamr@2
  1354
	CBluetoothPhysicalLinkMetrics(MBluetoothPhysicalLinkMetricsObserver& aObserver);
williamr@2
  1355
	template<class T> void ConstructL(RSocketServ& aSockServ, T& aLinkIdentifier);	
williamr@2
  1356
	
williamr@2
  1357
private:
williamr@2
  1358
	MBluetoothPhysicalLinkMetricsObserver& iObserver;
williamr@2
  1359
	CBluetoothPhysicalLinkMetricSubscriber* iRssiBaseband;
williamr@2
  1360
	CBluetoothPhysicalLinkMetricSubscriber* iLinkQualityBaseband;
williamr@2
  1361
	CBluetoothPhysicalLinkMetricSubscriber* iFailedContactCounterBaseband;
williamr@2
  1362
	CBluetoothPhysicalLinkMetricSubscriber* iTransmitPowerLevelBaseband;
williamr@2
  1363
	};
williamr@2
  1364
williamr@2
  1365
williamr@2
  1366
class MBluetoothSocketNotifier
williamr@2
  1367
/** This allows for notification of events relating to a CBluetoothSocket object.
williamr@2
  1368
williamr@2
  1369
Such notification consists of notification of logical link events (for example receipt 
williamr@2
  1370
of a user packet) and physical link state events (for example change of power mode).
williamr@2
  1371
williamr@2
  1372
Mixin class to be used with CBluetoothSocket
williamr@2
  1373
@publishedAll
williamr@2
  1374
@released
williamr@2
  1375
*/
williamr@2
  1376
	{
williamr@2
  1377
public:
williamr@2
  1378
	/** Notification of a connection complete event.
williamr@2
  1379
	
williamr@2
  1380
	 If no error is reported, then the connection is ready for use.
williamr@2
  1381
	 @note If the implementation of this function needs to delete associated 
williamr@2
  1382
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
  1383
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
  1384
	 @param aErr the returned error
williamr@2
  1385
	*/
williamr@2
  1386
	virtual void HandleConnectCompleteL(TInt aErr) = 0;
williamr@2
  1387
williamr@2
  1388
	/** Notification of an accept complete event.
williamr@2
  1389
	
williamr@2
  1390
	 If no error is reported, then we have accepted a connection request 
williamr@2
  1391
	 and that connection is ready for use.
williamr@2
  1392
	 @note If the implementation of this function needs to delete associated 
williamr@2
  1393
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
  1394
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
  1395
	 @param aErr the returned error
williamr@2
  1396
	*/
williamr@2
  1397
	virtual void HandleAcceptCompleteL(TInt aErr) = 0;
williamr@2
  1398
williamr@2
  1399
	/** Notification of a shutdown complete event.
williamr@2
  1400
	
williamr@2
  1401
	 If no error is reported, then the connection has been closed.
williamr@2
  1402
	 @note If the implementation of this function needs to delete associated 
williamr@2
  1403
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
  1404
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
  1405
	 @param aErr the returned error
williamr@2
  1406
	*/
williamr@2
  1407
	virtual void HandleShutdownCompleteL(TInt aErr) = 0;
williamr@2
  1408
williamr@2
  1409
	/** Notification of a send complete event.
williamr@2
  1410
	
williamr@2
  1411
	 If no error is reported, then an attempt to send data over Bluetooth has succeeded.
williamr@2
  1412
	 @note If the implementation of this function needs to delete associated 
williamr@2
  1413
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
  1414
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
  1415
	 @param aErr the returned error
williamr@2
  1416
	*/
williamr@2
  1417
	virtual void HandleSendCompleteL(TInt aErr) = 0;
williamr@2
  1418
williamr@2
  1419
	/** Notification of a receive complete event.
williamr@2
  1420
	
williamr@2
  1421
	 If no error is reported, then then we have successfully received
williamr@2
  1422
	 a specified quantity of data.
williamr@2
  1423
	 @note If the implementation of this function needs to delete associated 
williamr@2
  1424
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
  1425
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
  1426
	 @param aErr the returned error
williamr@2
  1427
	*/
williamr@2
  1428
	virtual void HandleReceiveCompleteL(TInt aErr) = 0;
williamr@2
  1429
williamr@2
  1430
	/** Notification of a ioctl complete event.
williamr@2
  1431
	
williamr@2
  1432
	 An HCI request that has an associated command complete has completed.
williamr@2
  1433
	 @note If the implementation of this function needs to delete associated 
williamr@2
  1434
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
  1435
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
  1436
	 @param aErr the returned error
williamr@2
  1437
	*/
williamr@2
  1438
	virtual void HandleIoctlCompleteL(TInt aErr) = 0;
williamr@2
  1439
williamr@2
  1440
	/** Notification of a baseband event.
williamr@2
  1441
	
williamr@2
  1442
	 If no error is reported, then a baseband event has been retrieved successfully.
williamr@2
  1443
	 @note If the implementation of this function needs to delete associated 
williamr@2
  1444
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
  1445
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
  1446
	 @param aErr the returned error
williamr@2
  1447
	 @param TBTBasebandEventNotification Bit(s) set in TBTBasebandEventNotification bitmap indicate what event has taken place.
williamr@2
  1448
	 @see TBTPhysicalLinkStateNotifier
williamr@2
  1449
	*/
williamr@2
  1450
	virtual void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification& aEventNotification) = 0;
williamr@2
  1451
	
williamr@2
  1452
    /**
williamr@2
  1453
 	 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
williamr@2
  1454
	 @param aInterface UID of the interface to return
williamr@2
  1455
	 @param aObject the container for another interface as specified by aInterface
williamr@2
  1456
	 */
williamr@2
  1457
	IMPORT_C virtual void MBSN_ExtensionInterfaceL(TUid aInterface, void*& aObject);	
williamr@2
  1458
	};
williamr@2
  1459
williamr@2
  1460
williamr@2
  1461
class CBTConnecter;
williamr@2
  1462
class CBTAccepter;
williamr@2
  1463
class CBTShutdowner;
williamr@2
  1464
class CBTReceiver;
williamr@2
  1465
class CBTSender;
williamr@2
  1466
class CBTIoctler;
williamr@2
  1467
class CBTBasebandChangeEventNotifier;
williamr@2
  1468
class CAutoSniffDelayTimer;
williamr@2
  1469
class CBTBasebandManager;
williamr@2
  1470
class CBTBasebandChangeEventDelegate;
williamr@2
  1471
williamr@2
  1472
NONSHARABLE_CLASS(CBluetoothSocket): public CBase
williamr@2
  1473
    /** This allows Bluetooth ACL socket-based services to be run.
williamr@2
  1474
williamr@2
  1475
    It allows all user-plane data flow to occur, plus control-plane Bluetooth 
williamr@2
  1476
    baseband modification capabilities.
williamr@2
  1477
    
williamr@2
  1478
    For a more detailed description of RBTBaseband functionality see the class and function documentation for
williamr@2
  1479
    RBTPhysicalLinkAdapter.
williamr@2
  1480
    
williamr@2
  1481
	This class doesn't provide the functionality to directly activate Active mode
williamr@2
  1482
	(this is implementated in class RBTPhysicalLinkAdapter.)
williamr@2
  1483
	@see RBTPhysicalLinkAdapter::ActivateActiveRequester()
williamr@2
  1484
	Explicit Active mode requests are made automatically when using the Automatic Sniff Requester 
williamr@2
  1485
	utility provided by this class.
williamr@2
  1486
	@see CBluetoothSocket::SetAutomaticSniffMode	
williamr@2
  1487
williamr@2
  1488
    @see RBTPhysicalLinkAdapter
williamr@2
  1489
    @publishedAll
williamr@2
  1490
    @released
williamr@2
  1491
    */
williamr@2
  1492
	{
williamr@2
  1493
friend class CBTAccepter;		
williamr@2
  1494
public:
williamr@2
  1495
	IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1496
										   RSocketServ& aServer,TUint aSockType,
williamr@2
  1497
										   TUint aProtocol);
williamr@2
  1498
	IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1499
										   RSocketServ& aServer,TUint aSockType,
williamr@2
  1500
										   TUint aProtocol);
williamr@2
  1501
	IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1502
										   RSocketServ& aServer,TUint aSockType,
williamr@2
  1503
										   TUint aProtocol, 
williamr@2
  1504
										   RConnection& aConnection);
williamr@2
  1505
	IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1506
										   RSocketServ& aServer,
williamr@2
  1507
										   TUint aSockType,TUint aProtocol, 
williamr@2
  1508
										   RConnection& aConnection);
williamr@2
  1509
	IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1510
										   RSocketServ& aServer,
williamr@2
  1511
										   const TDesC& aName);
williamr@2
  1512
	IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1513
										   RSocketServ& aServer,
williamr@2
  1514
										   const TDesC& aName);
williamr@2
  1515
	IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1516
										   RSocketServ& aServer);
williamr@2
  1517
	IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1518
										   RSocketServ& aServer);
williamr@2
  1519
	IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1520
										   RSocketServ& aServer,
williamr@2
  1521
										   RSocket& aSocket);
williamr@2
  1522
	IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1523
										   RSocketServ& aServer,
williamr@2
  1524
										   RSocket& aSocket);								
williamr@2
  1525
	IMPORT_C ~CBluetoothSocket();
williamr@2
  1526
williamr@2
  1527
	//Forwarding functions to RSocket
williamr@2
  1528
	IMPORT_C TInt Send(const TDesC8& aDesc,TUint someFlags);
williamr@2
  1529
	IMPORT_C TInt Send(const TDesC8& aDesc,TUint someFlags,TSockXfrLength& aLen);
williamr@2
  1530
	IMPORT_C void CancelSend();
williamr@2
  1531
	IMPORT_C TInt Recv(TDes8& aDesc,TUint flags);
williamr@2
  1532
	IMPORT_C TInt Recv(TDes8& aDesc,TUint flags,TSockXfrLength& aLen);
williamr@2
  1533
	IMPORT_C TInt RecvOneOrMore(TDes8& aDesc,TUint flags,TSockXfrLength& aLen);
williamr@2
  1534
	IMPORT_C void CancelRecv();
williamr@2
  1535
	IMPORT_C TInt Read(TDes8& aDesc);
williamr@2
  1536
	IMPORT_C void CancelRead();
williamr@2
  1537
	IMPORT_C TInt Write(const TDesC8& aDesc);
williamr@2
  1538
	IMPORT_C void CancelWrite();
williamr@2
  1539
	IMPORT_C TInt SendTo(const TDesC8& aDesc,TSockAddr& aSockAddr,TUint flags);
williamr@2
  1540
	IMPORT_C TInt SendTo(const TDesC8& aDesc,TSockAddr& aSockAddr,TUint flags,TSockXfrLength& aLen);
williamr@2
  1541
	IMPORT_C TInt RecvFrom(TDes8& aDesc,TSockAddr& aSockAddr,TUint flags);
williamr@2
  1542
	IMPORT_C TInt RecvFrom(TDes8& aDesc,TSockAddr& aSockAddr,TUint flags,TSockXfrLength& aLen);
williamr@2
  1543
	IMPORT_C TInt Connect(TBTSockAddr& aSockAddr);
williamr@2
  1544
	IMPORT_C TInt Connect(TBTSockAddr& aSockAddr,const TDesC8& aConnectDataOut,TDes8& aConnectDataIn);
williamr@2
  1545
	IMPORT_C TInt Connect(TBTSockAddr& aAddr, TUint16 aServiceBits);
williamr@2
  1546
	IMPORT_C void CancelConnect();
williamr@2
  1547
	IMPORT_C TInt Bind(TSockAddr& aSockAddr);
williamr@2
  1548
	IMPORT_C TInt SetLocalPort(TInt aPort);
williamr@2
  1549
	IMPORT_C TInt Accept(CBluetoothSocket& aBlankSocket);
williamr@2
  1550
	IMPORT_C TInt Accept(CBluetoothSocket& aBlankSocket,TDes8& aConnectData);
williamr@2
  1551
	IMPORT_C void CancelAccept();
williamr@2
  1552
	IMPORT_C TInt Listen(TUint qSize);
williamr@2
  1553
	IMPORT_C TInt Listen(TUint qSize,const TDesC8& aConnectData);
williamr@2
  1554
	IMPORT_C TInt Listen(TUint qSize, TUint16 aServiceBits);
williamr@2
  1555
	IMPORT_C TInt SetOpt(TUint aOptionName,TUint aOptionLevel,TInt aOption);
williamr@2
  1556
	IMPORT_C TInt SetOption(TUint aOptionName,TUint aOptionLevel,const TDesC8& aOption);
williamr@2
  1557
	IMPORT_C TInt GetOpt(TUint aOptionName,TUint aOptionLevel,TDes8& aOption);
williamr@2
  1558
	IMPORT_C TInt GetOpt(TUint aOptionName,TUint aOptionLevel,TInt &aOption);
williamr@2
  1559
	IMPORT_C TInt Ioctl(TUint aLevel, TUint aCommand, TDes8* aDesc);
williamr@2
  1560
	IMPORT_C void CancelIoctl();
williamr@2
  1561
	IMPORT_C TInt GetDisconnectData(TDes8& aDesc);
williamr@2
  1562
	IMPORT_C void LocalName(TSockAddr& aSockAddr);
williamr@2
  1563
	IMPORT_C TUint LocalPort();
williamr@2
  1564
	IMPORT_C void RemoteName(TSockAddr& aSockAddr);
williamr@2
  1565
	IMPORT_C TInt Shutdown(RSocket::TShutdown aHow);
williamr@2
  1566
	IMPORT_C TInt Shutdown(RSocket::TShutdown aHow,const TDesC8& aDisconnectDataOut,TDes8& aDisconnectDataIn);
williamr@2
  1567
	IMPORT_C void CancelAll();
williamr@2
  1568
	IMPORT_C TInt Info(TProtocolDesc& aProtocol);
williamr@2
  1569
	IMPORT_C TInt Name(TName& aName);
williamr@2
  1570
	IMPORT_C TInt Transfer(RSocketServ& aServer, const TDesC& aName);
williamr@2
  1571
williamr@2
  1572
	
williamr@2
  1573
	//Forwarding functions to RBTBaseband
williamr@2
  1574
	IMPORT_C TInt PhysicalLinkState(TUint32& aState);
williamr@2
  1575
	IMPORT_C TInt PreventRoleSwitch();
williamr@2
  1576
	IMPORT_C TInt AllowRoleSwitch();
williamr@2
  1577
	IMPORT_C TInt RequestMasterRole();
williamr@2
  1578
	IMPORT_C TInt RequestSlaveRole();
williamr@2
  1579
	IMPORT_C TInt PreventLowPowerModes(TUint32 aLowPowerModes);
williamr@2
  1580
	IMPORT_C TInt AllowLowPowerModes(TUint32 aLowPowerModes);
williamr@2
  1581
	IMPORT_C TInt ActivateSniffRequester();
williamr@2
  1582
	IMPORT_C TInt ActivateParkRequester();
williamr@2
  1583
	IMPORT_C TInt CancelLowPowerModeRequester();
williamr@2
  1584
	IMPORT_C TInt RequestChangeSupportedPacketTypes(TUint16 aPacketTypes);
williamr@2
  1585
	IMPORT_C TInt ActivateBasebandEventNotifier(TUint32 aEventTypes);
williamr@2
  1586
	IMPORT_C void CancelBasebandEventNotifier();
williamr@2
  1587
	
williamr@2
  1588
	IMPORT_C void SetNotifier(MBluetoothSocketNotifier& aNewNotifier);
williamr@2
  1589
	IMPORT_C TInt SetAutomaticSniffMode(TBool aAutoSniffMode);
williamr@2
  1590
	IMPORT_C TInt SetAutomaticSniffMode(TBool aAutoSniffMode, TInt aIdleSecondsBeforeSniffRequest);
williamr@2
  1591
	IMPORT_C TBool AutomaticSniffMode() const;
williamr@2
  1592
	
williamr@2
  1593
	IMPORT_C void AsyncDelete();
williamr@2
  1594
	
williamr@2
  1595
	//Callback functions called by active object RunLs.
williamr@2
  1596
	// NB These functions kill the active objects that call them (cf mating spiders) 
williamr@2
  1597
	MBluetoothSocketNotifier& Notifier();
williamr@2
  1598
	void HandleConnectCompleteL(TInt aErr);
williamr@2
  1599
	void HandleAcceptCompleteL(TInt aErr);
williamr@2
  1600
	void HandleShutdownCompleteL(TInt aErr);
williamr@2
  1601
	void HandleSendCompleteL(TInt aErr);
williamr@2
  1602
	void HandleReceiveCompleteL(TInt aErr);
williamr@2
  1603
	void HandleIoctlCompleteL(TInt aErr);
williamr@2
  1604
	void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification aEventNotification);
williamr@2
  1605
williamr@2
  1606
	/**
williamr@2
  1607
	@deprecated
williamr@2
  1608
	*/
williamr@2
  1609
	IMPORT_C TInt Ioctl(TUint aCommand,TDes8* aDesc=NULL,TUint aLevel=KLevelUnspecified);
williamr@2
  1610
williamr@2
  1611
	/**
williamr@2
  1612
	@deprecated
williamr@2
  1613
	*/
williamr@2
  1614
	IMPORT_C TInt SetOpt(TUint aOptionName,TUint aOptionLevel,const TDesC8& aOption=TPtrC8(NULL,0));
williamr@2
  1615
public:
williamr@2
  1616
	RSocket& Socket();
williamr@2
  1617
	RSocketServ& SocketServer();
williamr@2
  1618
	RBTBaseband& BTBaseband();
williamr@2
  1619
	CBTBasebandManager& BTBasebandManager();
williamr@2
  1620
williamr@2
  1621
private:
williamr@2
  1622
	CBluetoothSocket(MBluetoothSocketNotifier& aNotifier, RSocketServ& aServer);
williamr@2
  1623
	void ConstructL(TUint aSockType,TUint aProtocol);
williamr@2
  1624
	void ConstructL(TUint aSockType,TUint aProtocol, RConnection& aConnection);
williamr@2
  1625
	void ConstructL(const TDesC& aName);
williamr@2
  1626
	void ConstructL();
williamr@2
  1627
	void ConstructL(RSocket& aSocket);
williamr@2
  1628
	void InitialiseL();
williamr@2
  1629
	static TInt AsyncDeleteCallBack(TAny *aThisPtr);
williamr@2
  1630
	void ConfigureSocket();
williamr@2
  1631
williamr@2
  1632
private:
williamr@2
  1633
	RSocket							iSocket;
williamr@2
  1634
	RSocketServ&					iSockServer;
williamr@2
  1635
	TBTSockAddr						iSockAddr;
williamr@2
  1636
williamr@2
  1637
	MBluetoothSocketNotifier*		iNotifier;
williamr@2
  1638
williamr@2
  1639
	CBTConnecter* 					iBTConnecter;
williamr@2
  1640
	CBTAccepter*					iBTAccepter;
williamr@2
  1641
	CBTShutdowner*					iBTShutdowner;
williamr@2
  1642
	CBTReceiver*					iBTReceiver;	//for read, recv etc
williamr@2
  1643
	CBTSender*						iBTSender;		//for send, write etc
williamr@2
  1644
	CBTIoctler*						iBTIoctler;
williamr@2
  1645
	CBTBasebandChangeEventNotifier* iBTBasebandChangeEventNotifier;
williamr@2
  1646
	TUint32							iNotifierEventMask;
williamr@2
  1647
	TBool							iSending;
williamr@2
  1648
	TBool							iReceiving;
williamr@2
  1649
williamr@2
  1650
	RBTBaseband 					iBTBaseband;
williamr@2
  1651
	CAutoSniffDelayTimer*			iAutoSniffDelayTimer;
williamr@2
  1652
	CBTBasebandManager*				iBTBasebandManager;
williamr@2
  1653
	CBTBasebandChangeEventDelegate*	iBTBasebandChangeEventDelegate;
williamr@2
  1654
	
williamr@2
  1655
	CAsyncCallBack*					iAsyncDestroyer;	//for async deletion
williamr@2
  1656
	};
williamr@2
  1657
williamr@2
  1658
williamr@2
  1659
class MBluetoothSynchronousLinkNotifier
williamr@2
  1660
/** SCO and eSCO link notification events.
williamr@2
  1661
williamr@2
  1662
This allows for notification of Connect, Disconnect, Send and
williamr@2
  1663
Receive events relating to SCO and eSCO links.
williamr@2
  1664
williamr@2
  1665
Mixin class to be used with CBluetoothSynchronousLink
williamr@2
  1666
Note that although the function signatures allow it, these functions should
williamr@2
  1667
not be allowed to leave as the error will be ignored.
williamr@2
  1668
williamr@2
  1669
@publishedAll
williamr@2
  1670
@released
williamr@2
  1671
*/
williamr@2
  1672
	{
williamr@2
  1673
public:
williamr@2
  1674
	/** Notification that a synchronous link (SCO) has been set up
williamr@2
  1675
	
williamr@2
  1676
	 If no error is reported, then the synchronous link is ready for use.
williamr@2
  1677
	 @note 1) Observe that although the function signature allows it, this function should
williamr@2
  1678
	 not be allowed to leave as the error will be ignored.
williamr@2
  1679
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1680
	 CBluetoothSynchronousLink object.
williamr@2
  1681
	 @param aErr the returned error
williamr@2
  1682
	*/
williamr@2
  1683
	virtual void HandleSetupConnectionCompleteL(TInt aErr) = 0;
williamr@2
  1684
williamr@2
  1685
	/** Notification that a synchronous link (SCO) has disconnected
williamr@2
  1686
	
williamr@2
  1687
	 If no error is reported, then the synchronous link has been closed.
williamr@2
  1688
	 @note 1) Observe that although the function signature allows it, this function should
williamr@2
  1689
	 not be allowed to leave as the error will be ignored.
williamr@2
  1690
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1691
	 CBluetoothSynchronousLink object.
williamr@2
  1692
	 @param aErr the returned error
williamr@2
  1693
	*/
williamr@2
  1694
	virtual void HandleDisconnectionCompleteL(TInt aErr) = 0;
williamr@2
  1695
williamr@2
  1696
	/** Notification that a synchronous link (SCO) has been accepted
williamr@2
  1697
	
williamr@2
  1698
	 If no error is reported, then we have accepted a request for a synchronous link.
williamr@2
  1699
	 That synchronous link is ready for use.
williamr@2
  1700
	 @note 1) Observe that although the function signature allows it, this function should
williamr@2
  1701
	 not be allowed to leave as the error will be ignored.
williamr@2
  1702
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1703
	 CBluetoothSynchronousLink object.
williamr@2
  1704
	 @param aErr the returned error
williamr@2
  1705
	*/
williamr@2
  1706
	virtual void HandleAcceptConnectionCompleteL(TInt aErr) = 0;
williamr@2
  1707
williamr@2
  1708
	/** Notification of a send complete event
williamr@2
  1709
	
williamr@2
  1710
	 If no error is reported, then an attempt to send synchronous (SCO) data 
williamr@2
  1711
	 (e.g. voice) over Bluetooth has succeeded.
williamr@2
  1712
	 @note 1) Observe that although the function signature allows it, this function should
williamr@2
  1713
	 not be allowed to leave as the error will be ignored.
williamr@2
  1714
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1715
	 CBluetoothSynchronousLink object.
williamr@2
  1716
	 @param aErr the returned error
williamr@2
  1717
	*/
williamr@2
  1718
	virtual void HandleSendCompleteL(TInt aErr) = 0;
williamr@2
  1719
williamr@2
  1720
	/** Notification of a receive complete event
williamr@2
  1721
	
williamr@2
  1722
	 If no error is reported, then then we have successfully received
williamr@2
  1723
	 a specified quantity of synchronous (SCO) data.
williamr@2
  1724
	 @note 1) Observe that although the function signature allows it, this function should
williamr@2
  1725
	 not be allowed to leave as the error will be ignored.
williamr@2
  1726
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1727
	 CBluetoothSynchronousLink object.
williamr@2
  1728
	 @param aErr the returned error
williamr@2
  1729
	*/
williamr@2
  1730
	virtual void HandleReceiveCompleteL(TInt aErr) = 0;
williamr@2
  1731
	
williamr@2
  1732
    /**
williamr@2
  1733
 	 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
williamr@2
  1734
	 @param aInterface UID of the interface to return
williamr@2
  1735
	 @param aObject the container for another interface as specified by aInterface
williamr@2
  1736
	 */
williamr@2
  1737
	IMPORT_C virtual void MBSLN_ExtensionInterfaceL(TUid aInterface, void*& aObject);	
williamr@2
  1738
	};
williamr@2
  1739
williamr@2
  1740
class CBTSynchronousLinkAttacher;
williamr@2
  1741
class CBTSynchronousLinkDetacher;
williamr@2
  1742
class CBTSynchronousLinkAccepter;
williamr@2
  1743
class CBTSynchronousLinkSender;
williamr@2
  1744
class CBTSynchronousLinkReceiver;
williamr@2
  1745
class CBTSynchronousLinkBaseband;
williamr@2
  1746
williamr@2
  1747
/**
williamr@2
  1748
@publishedAll
williamr@2
  1749
@released
williamr@2
  1750
williamr@2
  1751
A pair of transmit and receive bandwidths for use on synchronous Bluetooth links
williamr@2
  1752
*/
williamr@2
  1753
NONSHARABLE_CLASS(TBTSyncBandwidth)
williamr@2
  1754
	{
williamr@2
  1755
	public:
williamr@2
  1756
		IMPORT_C TBTSyncBandwidth();
williamr@2
  1757
		IMPORT_C TBTSyncBandwidth(TUint aBandwidth);
williamr@2
  1758
		
williamr@2
  1759
		TUint32 iTransmit;
williamr@2
  1760
		TUint32 iReceive;
williamr@2
  1761
	
williamr@2
  1762
	private:
williamr@2
  1763
		// This data padding has been added to help prevent future binary compatibility breaks	
williamr@2
  1764
		// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
williamr@2
  1765
		TUint32     iPadding1; 
williamr@2
  1766
		TUint32     iPadding2; 		
williamr@2
  1767
	};
williamr@2
  1768
williamr@2
  1769
/**
williamr@2
  1770
eSCO 64Kbit link utility constant.
williamr@2
  1771
*/
williamr@2
  1772
static const TUint KBTSync64KBit = (64000 / 8);
williamr@2
  1773
williamr@2
  1774
/**
williamr@2
  1775
@internalTechnology
williamr@2
  1776
Used internally to hold eSCO link parameters.  Not intended for use.
williamr@2
  1777
*/
williamr@2
  1778
NONSHARABLE_CLASS(TBTeSCOLinkParams)
williamr@2
  1779
	{
williamr@2
  1780
	public:
williamr@2
  1781
		TBTeSCOLinkParams() {};
williamr@2
  1782
		TBTeSCOLinkParams(TUint aBandwidth, TUint16 aCoding, TUint16 aLatency, TUint8 aRetransmission);
williamr@2
  1783
		
williamr@2
  1784
		TBTSyncBandwidth iBandwidth;
williamr@2
  1785
		TUint16 iCoding;
williamr@2
  1786
		TUint16 iLatency;
williamr@2
  1787
		TUint8 iRetransmissionEffort;	
williamr@2
  1788
	};
williamr@2
  1789
williamr@2
  1790
enum TSCOType
williamr@2
  1791
/** Bluetooth link SCO type
williamr@2
  1792
@internalTechnology
williamr@2
  1793
*/
williamr@2
  1794
	{
williamr@2
  1795
	ESCO=0x01,	/*!< Synchronous Connection Oriented link */
williamr@2
  1796
	EeSCO=0x02	/*!< eSCO link */
williamr@2
  1797
	};	
williamr@2
  1798
		
williamr@2
  1799
NONSHARABLE_CLASS(CBluetoothSynchronousLink): public CBase
williamr@2
  1800
/** Provides Bluetooth SCO functionality.
williamr@2
  1801
williamr@2
  1802
This allows Bluetooth SCO (synchronous) link Connect, Disconnect, Send and Receive.
williamr@2
  1803
@publishedAll
williamr@2
  1804
@released
williamr@2
  1805
*/
williamr@2
  1806
	{
williamr@2
  1807
public:
williamr@2
  1808
	IMPORT_C static CBluetoothSynchronousLink* NewL(MBluetoothSynchronousLinkNotifier& aNotifier, 
williamr@2
  1809
											  RSocketServ& aServer);
williamr@2
  1810
	IMPORT_C static CBluetoothSynchronousLink* NewLC(MBluetoothSynchronousLinkNotifier& aNotifier,
williamr@2
  1811
											   RSocketServ& aServer);
williamr@2
  1812
	IMPORT_C ~CBluetoothSynchronousLink();
williamr@2
  1813
williamr@2
  1814
	IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr);
williamr@2
  1815
	IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr, const TUint16 aPacketTypes);
williamr@2
  1816
	IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr, const TBTSyncPackets& aPacketTypes);
williamr@2
  1817
	IMPORT_C void CancelSetup();
williamr@2
  1818
	IMPORT_C TInt Disconnect();
williamr@2
  1819
	IMPORT_C TInt Send(const TDesC8& aData);
williamr@2
  1820
	IMPORT_C void CancelSend();
williamr@2
  1821
	IMPORT_C TInt Receive(TDes8& aData);
williamr@2
  1822
	IMPORT_C void CancelReceive();
williamr@2
  1823
	IMPORT_C TInt AcceptConnection();
williamr@2
  1824
	IMPORT_C TInt AcceptConnection(const TBTSyncPackets& aPacketTypes);
williamr@2
  1825
	IMPORT_C void CancelAccept();
williamr@2
  1826
	
williamr@2
  1827
	IMPORT_C void SetCoding(TUint16 aVoiceSetting);
williamr@2
  1828
	IMPORT_C void SetMaxBandwidth(TBTSyncBandwidth aMaximum);
williamr@2
  1829
	IMPORT_C void SetMaxLatency(TUint16 aLatency);
williamr@2
  1830
	IMPORT_C void SetRetransmissionEffort(TBTeSCORetransmissionTypes aRetransmissionEffort);
williamr@2
  1831
	
williamr@2
  1832
	IMPORT_C TUint16 Coding();
williamr@2
  1833
	IMPORT_C TBTSyncBandwidth Bandwidth();
williamr@2
  1834
	IMPORT_C TUint16 Latency();
williamr@2
  1835
	IMPORT_C TUint8 RetransmissionEffort();
williamr@2
  1836
	
williamr@2
  1837
	IMPORT_C void RemoteName(TSockAddr& aAddr);
williamr@2
  1838
	
williamr@2
  1839
	IMPORT_C void SetNotifier(MBluetoothSynchronousLinkNotifier& aNotifier);
williamr@2
  1840
williamr@2
  1841
	MBluetoothSynchronousLinkNotifier& Notifier();
williamr@2
  1842
    RSocket& SCOSocket();
williamr@2
  1843
	RSocket& ESCOSocket();
williamr@2
  1844
	RSocket& ListeningSCOSocket();
williamr@2
  1845
	RSocket& ListeningESCOSocket();
williamr@2
  1846
	RSocketServ& SocketServer();
williamr@2
  1847
	RBTBaseband& Baseband();
williamr@2
  1848
williamr@2
  1849
	
williamr@2
  1850
	//Callback methods called by active object RunLs.
williamr@2
  1851
	void HandleSetupConnectionCompleteL(TInt aErr, TSCOType aSCOType);
williamr@2
  1852
	void HandleAcceptConnectionCompleteL(TInt aErr, TSCOType aSCOType);
williamr@2
  1853
	void HandleDisconnectionCompleteL(TInt aErr);
williamr@2
  1854
	void HandleSendCompleteL(TInt aErr);
williamr@2
  1855
	void HandleReceiveCompleteL(TInt aErr);
williamr@2
  1856
williamr@2
  1857
private:
williamr@2
  1858
	CBluetoothSynchronousLink(MBluetoothSynchronousLinkNotifier& aNotifier, RSocketServ& aServer);
williamr@2
  1859
	void ConstructL();
williamr@2
  1860
	void UpdateLinkParams(TSCOType aSCOType);
williamr@2
  1861
	TInt LinkUp(TBTDevAddr aAddr);
williamr@2
  1862
	void LinkDown();
williamr@2
  1863
williamr@2
  1864
private:
williamr@2
  1865
	CBTSynchronousLinkSender*			iBTSynchronousLinkSenderSCO;
williamr@2
  1866
	CBTSynchronousLinkSender*			iBTSynchronousLinkSenderESCO;
williamr@2
  1867
	CBTSynchronousLinkReceiver*			iBTSynchronousLinkReceiverSCO;
williamr@2
  1868
	CBTSynchronousLinkReceiver*			iBTSynchronousLinkReceiverESCO;
williamr@2
  1869
	CBTSynchronousLinkAccepter*			iBTSynchronousLinkAccepterSCO;
williamr@2
  1870
	CBTSynchronousLinkAccepter*			iBTSynchronousLinkAccepterESCO;
williamr@2
  1871
	CBTSynchronousLinkAttacher* 		iBTSynchronousLinkAttacherSCO;
williamr@2
  1872
	CBTSynchronousLinkAttacher* 		iBTSynchronousLinkAttacherESCO;
williamr@2
  1873
	CBTSynchronousLinkDetacher* 		iBTSynchronousLinkDetacherSCO;
williamr@2
  1874
	CBTSynchronousLinkDetacher* 		iBTSynchronousLinkDetacherESCO;
williamr@2
  1875
	CBTSynchronousLinkBaseband*			iBTSynchronousLinkBaseband;
williamr@2
  1876
	MBluetoothSynchronousLinkNotifier*	iNotifier;
williamr@2
  1877
	RSocket								iSCOSocket;
williamr@2
  1878
	RSocket								iESCOSocket;
williamr@2
  1879
	RSocket 							iListeningSCOSocket;
williamr@2
  1880
	RSocket 							iListeningESCOSocket;
williamr@2
  1881
	RBTBaseband							iBaseband;
williamr@2
  1882
	RSocketServ& 						iSockServer;
williamr@2
  1883
	TBTSockAddr 						iSockAddr;
williamr@2
  1884
	TBuf8<1> 							iDummySCOShutdownDescriptor;
williamr@2
  1885
	
williamr@2
  1886
	TBTeSCOLinkParams					iRequestedLink;
williamr@2
  1887
	TBTeSCOLinkParams					iNegotiatedLink;
williamr@2
  1888
	
williamr@2
  1889
	TUint8		 						iSCOTypes;
williamr@2
  1890
	
williamr@2
  1891
	TBool								iOpeningSCO;
williamr@2
  1892
	TBool								iOpeningESCO;
williamr@2
  1893
	TBool								iOpenedSCO;
williamr@2
  1894
	};
williamr@2
  1895
williamr@2
  1896
williamr@2
  1897
class MBluetoothPhysicalLinksNotifier
williamr@2
  1898
/** This allows for notifications of Physical link connections & disconnections
williamr@2
  1899
williamr@2
  1900
Mixin class to be used with CBluetoothPhysicalLinks
williamr@2
  1901
williamr@2
  1902
williamr@2
  1903
@publishedAll
williamr@2
  1904
@released
williamr@2
  1905
*/
williamr@2
  1906
	{
williamr@2
  1907
public:
williamr@2
  1908
	/** Notification of a requested connection coming up
williamr@2
  1909
	
williamr@2
  1910
	 If no error is reported, then that connection is ready for use.
williamr@2
  1911
	 @note 1) While this function may leave, any errors are ignored.  Implementers are
williamr@2
  1912
	 responsible for performing their own cleanup prior to exiting the function.	 
williamr@2
  1913
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1914
	 CBluetoothPhysicalLinks object.
williamr@2
  1915
	 
williamr@2
  1916
	 @param aErr the returned error
williamr@2
  1917
	*/
williamr@2
  1918
	virtual void HandleCreateConnectionCompleteL(TInt aErr) = 0;
williamr@2
  1919
williamr@2
  1920
	/** Notification of a requested disconnection having taken place
williamr@2
  1921
	
williamr@2
  1922
	 If no error is reported, then that connection has been closed.
williamr@2
  1923
	 @note 1) While this function may leave, any errors are ignored.  Implementers are
williamr@2
  1924
	 responsible for performing their own cleanup prior to exiting the function.
williamr@2
  1925
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1926
	 CBluetoothPhysicalLinks object.
williamr@2
  1927
	 @param aErr the returned error
williamr@2
  1928
	*/
williamr@2
  1929
	virtual void HandleDisconnectCompleteL(TInt aErr) = 0;
williamr@2
  1930
williamr@2
  1931
	/** Notification that all existing connections have been torn down
williamr@2
  1932
	
williamr@2
  1933
	 If no error is reported, then there are no Bluetooth connections existing.
williamr@2
  1934
	 @note 1) While this function may leave, any errors are ignored.  Implementers are
williamr@2
  1935
	 responsible for performing their own cleanup prior to exiting the function.
williamr@2
  1936
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1937
	 CBluetoothPhysicalLinks object.
williamr@2
  1938
	 @param aErr the returned error
williamr@2
  1939
	*/
williamr@2
  1940
	virtual void HandleDisconnectAllCompleteL(TInt aErr) = 0;
williamr@2
  1941
williamr@2
  1942
    /**
williamr@2
  1943
 	 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
williamr@2
  1944
	 @param aInterface UID of the interface to return
williamr@2
  1945
	 @param aObject the container for another interface as specified by aInterface
williamr@2
  1946
	 */
williamr@2
  1947
	IMPORT_C virtual void MBPLN_ExtensionInterfaceL(TUid aInterface, void*& aObject);	
williamr@2
  1948
	};
williamr@2
  1949
williamr@2
  1950
williamr@2
  1951
class CBTBasebandConnecter;
williamr@2
  1952
class CBTBasebandShutdowner;
williamr@2
  1953
class CBTDisconnector;
williamr@2
  1954
williamr@2
  1955
NONSHARABLE_CLASS(CBluetoothPhysicalLinks): public CBase
williamr@2
  1956
/** This is used to enumerate members of piconet, and attach and remove members thereof
williamr@2
  1957
williamr@2
  1958
It may also be used for non-service dependent reads and writes.
williamr@2
  1959
@publishedAll
williamr@2
  1960
@released
williamr@2
  1961
*/
williamr@2
  1962
	{
williamr@2
  1963
public:
williamr@2
  1964
	IMPORT_C static CBluetoothPhysicalLinks* NewL(MBluetoothPhysicalLinksNotifier& aNotifier,
williamr@2
  1965
											      RSocketServ& aServer);
williamr@2
  1966
	IMPORT_C static CBluetoothPhysicalLinks* NewLC(MBluetoothPhysicalLinksNotifier& aNotifier,
williamr@2
  1967
											      RSocketServ& aServer);
williamr@2
  1968
	IMPORT_C ~CBluetoothPhysicalLinks();
williamr@2
  1969
williamr@2
  1970
	IMPORT_C TInt CreateConnection(const TBTDevAddr& aDevAddr);
williamr@2
  1971
	IMPORT_C void CancelCreateConnection();
williamr@2
  1972
	IMPORT_C TInt Disconnect(const TBTDevAddr& aDevAddr);
williamr@2
  1973
	IMPORT_C TInt DisconnectAll();
williamr@2
  1974
	
williamr@2
  1975
	IMPORT_C TInt Broadcast(const TDesC8& aData);
williamr@2
  1976
	IMPORT_C TInt ReadRaw(TDes8& aData);
williamr@2
  1977
	IMPORT_C TInt Enumerate(RBTDevAddrArray& aBTDevAddrArray, TUint aMaxNumber);
williamr@2
  1978
williamr@2
  1979
	
williamr@2
  1980
	//Callback methods called by active object RunLs.
williamr@2
  1981
	//NB These methods kill the active objects that call them
williamr@2
  1982
	/**
williamr@2
  1983
	@internalTechnology
williamr@2
  1984
	*/
williamr@2
  1985
	void HandleCreateConnectionCompleteL(TInt aErr);
williamr@2
  1986
	/**
williamr@2
  1987
	@internalTechnology
williamr@2
  1988
	*/
williamr@2
  1989
	void HandleDisconnectCompleteL(TInt aErr);
williamr@2
  1990
	/**
williamr@2
  1991
	@internalTechnology
williamr@2
  1992
	*/
williamr@2
  1993
	void HandleDisconnectAllCompleteL(TInt aErr);
williamr@2
  1994
williamr@2
  1995
	/**
williamr@2
  1996
	@internalTechnology
williamr@2
  1997
	*/
williamr@2
  1998
	RSocketServ& SockServer();
williamr@2
  1999
	/**
williamr@2
  2000
	@internalTechnology
williamr@2
  2001
	*/
williamr@2
  2002
	RBTBaseband& BTBaseband();
williamr@2
  2003
	/**
williamr@2
  2004
	@internalTechnology
williamr@2
  2005
	*/
williamr@2
  2006
	MBluetoothPhysicalLinksNotifier& Notifier();
williamr@2
  2007
williamr@2
  2008
williamr@2
  2009
private:
williamr@2
  2010
	CBluetoothPhysicalLinks(MBluetoothPhysicalLinksNotifier& aNotifier, 
williamr@2
  2011
							RSocketServ& aServer);
williamr@2
  2012
	void ConstructL();
williamr@2
  2013
williamr@2
  2014
private:
williamr@2
  2015
	CBTBasebandConnecter* iBTBasebandConnecter;
williamr@2
  2016
	CBTDisconnector* iBTDisconnector;
williamr@2
  2017
	MBluetoothPhysicalLinksNotifier& iNotifier;
williamr@2
  2018
	RSocketServ& iSockServer;
williamr@2
  2019
	RBTBaseband iBTBaseband;
williamr@2
  2020
	};
williamr@2
  2021
williamr@2
  2022
williamr@2
  2023
williamr@2
  2024
williamr@2
  2025
NONSHARABLE_CLASS(RBluetoothPowerSwitch)
williamr@2
  2026
/** This is intended for controlling whether the Bluetooth hardware is switched on or not.
williamr@2
  2027
williamr@2
  2028
@publishedPartner
williamr@2
  2029
@deprecated
williamr@2
  2030
@see HCI_v2 documentation
williamr@2
  2031
*/
williamr@2
  2032
	{
williamr@2
  2033
	public:
williamr@2
  2034
williamr@2
  2035
	IMPORT_C RBluetoothPowerSwitch();
williamr@2
  2036
	IMPORT_C void RequestSwitchOn();
williamr@2
  2037
	IMPORT_C void RequestSwitchOff();
williamr@2
  2038
	};
williamr@2
  2039
williamr@2
  2040
williamr@2
  2041
williamr@2
  2042
class RHCIServerSession;
williamr@2
  2043
class RSocketBasedHciDirectAccess;
williamr@2
  2044
williamr@2
  2045
NONSHARABLE_CLASS(RHCIDirectAccess)
williamr@2
  2046
/**
williamr@2
  2047
API used for licensee-specific direct HCI access
williamr@2
  2048
williamr@2
  2049
This class allows vendor-specific messages to be passed through to the HCI for
williamr@2
  2050
customised (licensee-specific) HCI functionality.
williamr@2
  2051
williamr@2
  2052
Note: No use of this class should be required by default. It is provided to
williamr@2
  2053
assist with hardware workarounds, or link policy not implemented by the
williamr@2
  2054
Bluetooth stack.
williamr@2
  2055
williamr@2
  2056
Do not use unless entirely familar with this API and the specific HCI in use!!!!
williamr@2
  2057
williamr@2
  2058
@publishedPartner
williamr@2
  2059
@released
williamr@2
  2060
*/
williamr@2
  2061
	{
williamr@2
  2062
public:
williamr@2
  2063
	IMPORT_C RHCIDirectAccess();
williamr@2
  2064
	//API used for licensee-specific direct HCI access
williamr@2
  2065
	IMPORT_C TInt Open();
williamr@2
  2066
	IMPORT_C TInt Open(RSocketServ& aSocketServ);
williamr@2
  2067
	IMPORT_C void Close();
williamr@2
  2068
williamr@2
  2069
	IMPORT_C void Ioctl(TUint aCommand, TRequestStatus &aStatus, TDes8* aDesc=NULL,TUint aLevel = KSolBtHCI); 
williamr@2
  2070
	IMPORT_C void CancelIoctl();
williamr@2
  2071
williamr@2
  2072
	IMPORT_C void AsyncMessage(TUint aCommand, TRequestStatus &aStatus, TDes8* aDesc); 
williamr@2
  2073
	IMPORT_C void CancelAsyncMessage();
williamr@2
  2074
williamr@2
  2075
	IMPORT_C TInt SubSessionHandle();
williamr@2
  2076
private:
williamr@2
  2077
	RHCIServerSession* iHCIServerSession;
williamr@2
  2078
	RSocketBasedHciDirectAccess* iSocketAccess;
williamr@2
  2079
	TUint32 iReserved; // Padding for possible future "per-copy" state.
williamr@2
  2080
	};
williamr@2
  2081
williamr@2
  2082
#endif