epoc32/include/bt_sock.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
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@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@2
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.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
 @file
williamr@2
    20
 @publishedAll
williamr@2
    21
 @released
williamr@2
    22
*/
williamr@2
    23
williamr@2
    24
#ifndef BT_SOCK_H
williamr@2
    25
#define BT_SOCK_H
williamr@2
    26
williamr@4
    27
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
williamr@4
    28
#include <bthci.h>
williamr@4
    29
#include <bluetooth/lmoptions.h>
williamr@4
    30
#endif
williamr@4
    31
williamr@4
    32
#include <bluetooth/btscoparams.h>
williamr@4
    33
#include <bluetooth/btbaseband.h>
williamr@4
    34
#include <btsocketoptionlevels.h>
williamr@4
    35
#include <btdevice.h>
williamr@4
    36
williamr@2
    37
#include <es_sock.h>
williamr@2
    38
#include <bttypes.h>
williamr@2
    39
#include <d32comm.h>	// for RS232 signal names for RFCOMM
williamr@2
    40
#include <bluetooth/hci/hcierrors.h>
williamr@4
    41
#include <btmanclient.h>
williamr@2
    42
#include <bt_subscribe.h>
williamr@4
    43
#include <btsockaddr.h>
williamr@4
    44
#include <btsecurity.h>
williamr@4
    45
#include <btbasebandpolicy.h>
williamr@4
    46
#include <btsyncbandwidth.h>
williamr@2
    47
williamr@2
    48
williamr@2
    49
williamr@2
    50
_LIT(KRFCOMMDesC,"RFCOMM");	/*!< Descriptor name for RFCOMM */
williamr@2
    51
williamr@2
    52
_LIT(KL2CAPDesC,"L2CAP"); 	/*!< Descriptor name for L2CAP */
williamr@2
    53
williamr@2
    54
//
williamr@2
    55
// BT Protocol Family
williamr@2
    56
//
williamr@2
    57
williamr@2
    58
const TUint KBTAddrFamily = 0x101; 		/*!< BT Address Family */
williamr@2
    59
williamr@2
    60
const TUint KBTLinkManager = 0x0099; 	/*!< Protocol Number for Link Manager */
williamr@2
    61
const TUint KL2CAP = 0x0100;			/*!< Protocol Number for L2CAP */
williamr@2
    62
const TUint KRFCOMM = 0x0003;			/*!< Protocol Number for RFCOMM */
williamr@2
    63
const TUint KSDP = 0x0001;				/*!< Protocol Number for SDP */
williamr@2
    64
const TUint	KAVCTP = 0x0017;			/*!< Protocol Number for AVCTP */
williamr@2
    65
const TInt KTCIL2CAP = 0xF100;			/*!< Protocol Number for TCI L2CAP */
williamr@2
    66
williamr@2
    67
const TInt KBTMajor = 0;				/*!< BT version number for major version */
williamr@2
    68
const TInt KBTMinor = 1;				/*!< BT version number for minor version */
williamr@2
    69
const TInt KBTBuild = 1;				/*!< BT version number for build version */
williamr@2
    70
williamr@4
    71
// The Socket Options are now in btsocketoptionlevels.h
williamr@2
    72
williamr@2
    73
const static TUint8 KSCOListenQueSize = 1; /*!< Length of SCO listening queue */
williamr@2
    74
williamr@2
    75
const static TUint16 KL2MinMTU = 48; 			/*!< BT Spec defined min. supported MTU size */
williamr@2
    76
williamr@2
    77
williamr@2
    78
// All PSM values must be ODD, that is, the least significant bit of the least significant
williamr@2
    79
// octet must be '1'. Also, all PSM values must be assigned such that the
williamr@2
    80
// least significant bit of the most significant octet equals '0'.
williamr@2
    81
const static TUint16 KMaxPSM = 0xFEFF;	/*!< Max L2CAP PSM value */
williamr@2
    82
williamr@2
    83
/**
williamr@2
    84
 * This is the minimum user PSM. Smaller PSM values are possible but are reserved for use by the 
williamr@2
    85
 * Bluetooth stack only.
williamr@2
    86
 */
williamr@2
    87
const static TUint16 KMinUserPSM = 0x1001;
williamr@2
    88
williamr@2
    89
/**
williamr@2
    90
 * This constant has been deprecated since its name is misleading becasue it doesn't represent the 
williamr@2
    91
 * absolute minimum PSM but the minimum user PSM instead. 
williamr@2
    92
 * Use KMinUserPSM instead of this constant.
williamr@2
    93
 * @deprecated
williamr@2
    94
 */
williamr@2
    95
const static TUint16 KMinPSM = 0x1001;
williamr@2
    96
williamr@2
    97
const static TInt KErrBtEskError = -6999;	/*!< BT ESK error code */
williamr@2
    98
williamr@2
    99
williamr@2
   100
// Options available for all Bluetooth protocols
williamr@2
   101
williamr@2
   102
/** BT options. */
williamr@2
   103
enum TBTOptions
williamr@2
   104
	{
williamr@2
   105
	/** Override device security */
williamr@2
   106
	KBTRegisterCodService = 0x998,		/*!< Set a CoD Service bit(s) */
williamr@2
   107
	KBTSecurityDeviceOverride = 0x999,
williamr@2
   108
	};
williamr@2
   109
williamr@2
   110
typedef TPckgBuf<TBTServiceSecurityPerDevice> TBTServiceSecurityPerDeviceBuf;	/*!< Package definition for securty settings */
williamr@2
   111
williamr@2
   112
williamr@2
   113
// Link manager error codes.
williamr@2
   114
const static TInt KLinkManagerErrBase = -6450;								/*!< Link manager base error value */
williamr@2
   115
const static TInt KErrInsufficientBasebandResources = KLinkManagerErrBase;	/*!< Insufficient baseband resources error value */
williamr@2
   116
const static TInt KErrProxyWriteNotAvailable = KLinkManagerErrBase-1;		/*!< Proxy write not available error value */
williamr@2
   117
const static TInt KErrReflexiveBluetoothLink = KLinkManagerErrBase-2;		/*!< Reflexive BT link error value */
williamr@2
   118
const static TInt KErrPendingPhysicalLink = KLinkManagerErrBase-3;			/*!< Physical link connection already pending when trying to connect the physical link */
williamr@2
   119
const static TInt KErrRemoteDeviceIndicatedNoBonding = KLinkManagerErrBase-4; /*!< Dedicated bonding attempt failure when the remote device responds with No-Bonding */
williamr@2
   120
williamr@2
   121
//
williamr@2
   122
// L2CAP
williamr@2
   123
//
williamr@2
   124
williamr@2
   125
const static TInt KL2CAPErrBase = -6300;								/*!< Base error value for L2CAP error codes */
williamr@2
   126
const static TInt KErrBadAddress = KL2CAPErrBase;						/*!< L2CAP Bad address error code */
williamr@2
   127
const static TInt KErrSAPUnexpectedEvent = KL2CAPErrBase - 1;			/*!< L2CAP unexpected SAP event error code */
williamr@2
   128
const static TInt KErrBadPacketReceived = KL2CAPErrBase - 2;			/*!< L2CAP bad packet received error code */
williamr@2
   129
const static TInt KErrL2CAPBadResponse = KL2CAPErrBase - 3;				/*!< L2CAP bad response error code */
williamr@2
   130
const static TInt KErrHCIConnectFailed = KL2CAPErrBase - 4;				/*!< L2CAP HCI connection failed error code */
williamr@2
   131
const static TInt KErrHCILinkDisconnection = KL2CAPErrBase - 5;			/*!< L2CAP HCI link disconnection error code */
williamr@2
   132
const static TInt KErrSAPNotConnected = KL2CAPErrBase - 6;				/*!< L2CAP SAP not connected error code */
williamr@2
   133
const static TInt KErrConfigBadParams = KL2CAPErrBase - 7;				/*!< L2CAP bad configuration parameters error code */
williamr@2
   134
const static TInt KErrConfigRejected = KL2CAPErrBase - 8;				/*!< L2CAP configuration rejected error code */
williamr@2
   135
const static TInt KErrConfigUnknownOptions = KL2CAPErrBase - 9;			/*!< L2CAP unknown configuration options error code */
williamr@2
   136
const static TInt KErrL2PeerDisconnected = KL2CAPErrBase - 10;			/*!< L2CAP peer disconnected error code */
williamr@2
   137
const static TInt KErrL2CAPAccessRequestDenied = KL2CAPErrBase - 11;	/*!< L2CAP access request denied error code */
williamr@2
   138
const static TInt KErrL2CAPRequestTimeout = KL2CAPErrBase - 12;			/*!< L2CAP request timeout error code */
williamr@2
   139
const static TInt KErrL2PeerRejectedCommand = KL2CAPErrBase - 13;		/*!< L2CAP peer rejected command error code */
williamr@2
   140
const static TInt KErrHostResNameTooLong = KL2CAPErrBase - 14;			/*!< L2CAP host resolver name too long error code */
williamr@2
   141
const static TInt KErrL2CAPNoMorePSMs = KL2CAPErrBase - 15;				/*!< L2CAP no more PSMs error code */
williamr@2
   142
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
   143
const static TInt KErrL2CAPDataControllerDetached = KL2CAPErrBase - 17;	/*!< L2CAP problems (e.g. no memory) whilst sending data error code*/
williamr@2
   144
const static TInt KErrL2CAPConfigPending = KL2CAPErrBase - 18;			/*!< L2CAP configuration is in progress error code 
williamr@2
   145
																			 @internalComponent*/
williamr@2
   146
const static TInt KErrL2CAPConfigAlreadyInProgress = KL2CAPErrBase - 19;/*!< L2CAP attempt to alter config whilst configuration is in progress error code*/
williamr@2
   147
const static TInt KErrL2CAPNoFreeCID = KL2CAPErrBase - 21;				/*!< L2CAP no more channel IDs available error code*/
williamr@4
   148
const static TInt KErrL2CAPPeerDoesNotSupportRequestedChannelMode = KL2CAPErrBase - 22; /*!< L2CAP peer doesn't support channel modes satisfying requested channel configuration. */
williamr@4
   149
const static TInt KErrL2CAPInvalidPacketSequenceNumber = KL2CAPErrBase - 23;	/*!< L2CAP packet with an invalid sequence number was received */
williamr@4
   150
const static TInt KErrL2CAPInvalidAcknowledgementNumber = KL2CAPErrBase - 24;	/*!< L2CAP invalid acknowledgment number was received */
williamr@4
   151
const static TInt KErrL2CAPIllegalRemoteBehavior = KL2CAPErrBase - 25;			/*!< L2CAP remote broke the L2CAP specification */
williamr@4
   152
const static TInt KErrL2CAPNegotiatedDifferentModesForEachDirection = KL2CAPErrBase - 26; /*!< L2CAP different channel modes were negotiated for incoming and outgoing direction */
williamr@4
   153
const static TInt KErrL2CAPIncomingSduSegmentationError = KL2CAPErrBase - 27;	/*!< L2CAP received I-Frame does not match the sequence of start, continuation, end of SDU */
williamr@4
   154
const static TInt KErrL2CAPIncomingSduTooBig = KL2CAPErrBase - 28;		/*!< L2CAP received SDU size is larger than the negotiated MTU */
williamr@4
   155
const static TInt KErrL2CAPIncomingIFrameTooSmall = KL2CAPErrBase - 29;	/*!< L2CAP Incoming I-Frame size is too small */
williamr@4
   156
const static TInt KErrL2CAPIncomingIFrameTooBig = KL2CAPErrBase - 30;	/*!< L2CAP Incoming I-Frame information payload is larger than the negotiated MPS */
williamr@4
   157
const static TInt KErrL2CAPInvalidIncomingSFrameSize = KL2CAPErrBase - 31; /*!< L2CAP Incoming S-Frame size is incorrect */
williamr@4
   158
const static TInt KErrL2CAPAttemptToSetMinMtuGreaterThanMtu = KL2CAPErrBase - 32; /*!< L2CAP An attempt to configure minimal acceptable MTU that's larger than the preferred MTU was made */
williamr@4
   159
const static TInt KErrL2CAPAttemptToSetMinMruGreaterThanMru = KL2CAPErrBase - 33; /*!< L2CAP An attempt to configure minimal acceptable MRU that's larger than the preferred MRU was made */
williamr@2
   160
williamr@2
   161
// Host Resolver
williamr@2
   162
const static TInt KErrHostResNoMoreResults = KErrEof;  					/*!< Host resolver has no more results error code */
williamr@2
   163
const static TUint KHostResInquiry = 1;			/*!< Host resolver inquiry option */ 
williamr@2
   164
const static TUint KHostResName = 2;			/*!< Host resolver name option. This is mutually exclusive with KHostResEir */ 
williamr@2
   165
const static TUint KHostResIgnoreCache = 16; 	/*!< A way of ignoring the cache */ 
williamr@2
   166
const static TUint KHostResCache = 32; 			/*!< A way to get CoD from cache */
williamr@2
   167
const static TUint KHostResEir = 64; 			/*!< Host resolver Eir option. This is mutually exclusive with KHostResName  */
williamr@2
   168
williamr@2
   169
// L2CAP Ioctls
williamr@4
   170
const static TInt KL2CAPEchoRequestIoctl			= 0;	/*!< Echo Request Ioctl name */
williamr@4
   171
const static TInt KL2CAPIncomingMTUIoctl			= 1;	/*!< Change incoming MTU Ioctl name */
williamr@4
   172
const static TInt KL2CAPOutgoingMTUIoctl			= 2;	/*!< Change outgoing MTU Ioctl name */
williamr@4
   173
const static TInt KL2CAPUpdateChannelConfigIoctl	= 3;	/*!< Change configuration parameters Ioctl name */
williamr@4
   174
const static TInt KL2CAPPretendIncomingSduQFull		= 4;	/*!< Pretend incoming SDU Queue is full - internal testing only @internalComponent */
williamr@2
   175
williamr@2
   176
struct TLMDisconnectACLIoctl
williamr@2
   177
/**
williamr@2
   178
Structure to specify the remote ACL connection to disconnect.
williamr@2
   179
The reason passed in iReason will be sent to the remote device.
williamr@2
   180
williamr@2
   181
Use with KLMDisconnectACLIoctl.
williamr@2
   182
@deprecated
williamr@2
   183
*/
williamr@2
   184
	{
williamr@2
   185
	TBTDevAddr	iDevAddr;	/*!< Device address */
williamr@2
   186
	TUint8		iReason;	/*!< Reason code */
williamr@2
   187
	};
williamr@2
   188
williamr@2
   189
typedef TPckgBuf<TLMDisconnectACLIoctl> TLMDisconnectACLBuf;	/*!< Package for TLMDisconnectACLIoctl structure */
williamr@2
   190
williamr@2
   191
// private tokens for use by RBTBaseband facade and stack
williamr@2
   192
_LIT8(KDisconnectOnePhysicalLink, "1");		/*!< Specifes one physical link should be disconnected */
williamr@2
   193
_LIT8(KDisconnectAllPhysicalLinks, "A");	/*!< Specifes all physical links should be disconnected */
williamr@2
   194
williamr@2
   195
// HCI Ioctls
williamr@2
   196
/** Add SCO connnection Ioctl
williamr@2
   197
@deprecated
williamr@2
   198
*/
williamr@2
   199
static const TUint KLMAddSCOConnIoctl			=0;
williamr@2
   200
/** Remove SCO connection Ioctl
williamr@2
   201
@deprecated
williamr@2
   202
*/
williamr@2
   203
static const TUint KHCIRemoveSCOConnIoctl		=1;
williamr@2
   204
/** Change packet types allowed Ioctl
williamr@2
   205
@deprecated
williamr@2
   206
*/
williamr@2
   207
static const TUint KHCIChangePacketTypeIoctl	=2;
williamr@2
   208
/** Request authorisation Ioctl 
williamr@2
   209
@deprecated
williamr@2
   210
*/
williamr@2
   211
static const TUint KHCIAuthRequestIoctl			=3;
williamr@2
   212
/** Request encryption Ioctl
williamr@2
   213
@deprecated
williamr@2
   214
*/
williamr@2
   215
static const TUint KHCIEncryptIoctl				=4;
williamr@2
   216
/** Change link key Ioctl
williamr@2
   217
@deprecated
williamr@2
   218
*/
williamr@2
   219
static const TUint KHCIChangeLinkKeyIoctl		=5;
williamr@2
   220
/** Master link key Ioctl
williamr@2
   221
@deprecated
williamr@2
   222
*/
williamr@2
   223
static const TUint KHCIMasterLinkKeyIoctl		=6;
williamr@2
   224
/** Enable hold mode Ioctl
williamr@2
   225
@deprecated
williamr@2
   226
*/
williamr@2
   227
static const TUint KHCIHoldModeIoctl			=7;
williamr@2
   228
/** Enable sniff mode Ioctl
williamr@2
   229
@deprecated
williamr@2
   230
*/
williamr@2
   231
static const TUint KHCISniffModeIoctl			=8;
williamr@2
   232
/** Exit sniff mode Ioctl
williamr@2
   233
@deprecated
williamr@2
   234
*/
williamr@2
   235
static const TUint KHCIExitSniffModeIoctl		=9;
williamr@2
   236
/** Enable park mode Ioctl
williamr@2
   237
@deprecated
williamr@2
   238
*/
williamr@2
   239
static const TUint KHCIParkModeIoctl			=10;
williamr@2
   240
/** Exit park mode Ioctl
williamr@2
   241
@deprecated
williamr@2
   242
*/
williamr@2
   243
static const TUint KHCIExitParkModeIoctl		=11;
williamr@2
   244
williamr@2
   245
/** Read page timeout Ioctl
williamr@2
   246
@deprecated
williamr@2
   247
*/
williamr@2
   248
static const TUint KHCIReadPageTimeoutIoctl		=12;
williamr@2
   249
/** Write page timeout Ioctl
williamr@2
   250
@deprecated
williamr@2
   251
*/
williamr@2
   252
static const TUint KHCIWritePageTimeoutIoctl	=13;
williamr@2
   253
/** Read scan enable Ioctl
williamr@2
   254
@deprecated
williamr@2
   255
@see bt_subscribe.h
williamr@2
   256
*/
williamr@2
   257
static const TUint KHCIReadScanEnableIoctl		=14;
williamr@2
   258
/** Write scan enable Ioctl
williamr@2
   259
@deprecated
williamr@2
   260
@see bt_subscribe.h
williamr@2
   261
*/
williamr@2
   262
static const TUint KHCIWriteScanEnableIoctl		=15;
williamr@2
   263
/** Read device class Ioctl
williamr@2
   264
@deprecated
williamr@2
   265
@see bt_subscribe.h
williamr@2
   266
*/
williamr@2
   267
static const TUint KHCIReadDeviceClassIoctl		=16;
williamr@2
   268
/** Write device class Ioctl
williamr@2
   269
@deprecated
williamr@2
   270
@see bt_subscribe.h
williamr@2
   271
*/
williamr@2
   272
static const TUint KHCIWriteDeviceClassIoctl	=17;
williamr@2
   273
/** Read voice settings Ioctl
williamr@2
   274
@deprecated
williamr@2
   275
*/
williamr@2
   276
static const TUint KHCIReadVoiceSettingIoctl	=18;
williamr@2
   277
/** Write voice settings Ioctl
williamr@2
   278
@deprecated
williamr@2
   279
*/
williamr@2
   280
static const TUint KHCIWriteVoiceSettingIoctl	=19;
williamr@2
   281
/** Read hold mode activity Ioctl
williamr@2
   282
@deprecated
williamr@2
   283
*/
williamr@2
   284
static const TUint KHCIReadHoldModeActivityIoctl=20;
williamr@2
   285
/** Write hold mode activity Ioctl
williamr@2
   286
@deprecated
williamr@2
   287
*/
williamr@2
   288
static const TUint KHCIWriteHoldModeActivityIoctl=21;
williamr@2
   289
/** Local version Ioctl
williamr@2
   290
@deprecated
williamr@2
   291
*/
williamr@2
   292
static const TUint KHCILocalVersionIoctl		=22;
williamr@2
   293
/** Local features Ioctl
williamr@2
   294
@deprecated
williamr@2
   295
*/
williamr@2
   296
static const TUint KHCILocalFeaturesIoctl		=23;
williamr@2
   297
/** Country code Ioctl
williamr@2
   298
@deprecated
williamr@2
   299
*/
williamr@2
   300
static const TUint KHCICountryCodeIoctl			=24;
williamr@2
   301
/** Local address Ioctl
williamr@2
   302
@deprecated
williamr@2
   303
@see bt_subscribe.h
williamr@2
   304
*/
williamr@2
   305
static const TUint KHCILocalAddressIoctl		=25;
williamr@2
   306
/** Write discoverability Ioctl
williamr@2
   307
@deprecated
williamr@2
   308
@see bt_subscribe.h
williamr@2
   309
*/
williamr@2
   310
static const TUint KHCIWriteDiscoverabilityIoctl=26;
williamr@2
   311
/** Read discoverability Ioctl
williamr@2
   312
@deprecated
williamr@2
   313
@see bt_subscribe.h
williamr@2
   314
*/
williamr@2
   315
static const TUint KHCIReadDiscoverabilityIoctl	=27;
williamr@2
   316
/** Read authentification enabled Ioctl
williamr@2
   317
@deprecated
williamr@2
   318
*/
williamr@2
   319
static const TUint KHCIReadAuthenticationEnableIoctl=33;
williamr@2
   320
/** Write authentification enabled Ioctl
williamr@2
   321
@deprecated
williamr@2
   322
*/
williamr@2
   323
static const TUint KHCIWriteAuthenticationEnableIoctl=34;
williamr@2
   324
williamr@2
   325
williamr@2
   326
// Structs for ioctl parameters
williamr@2
   327
williamr@2
   328
/**
williamr@2
   329
Enumerations for the four possible scan enable modes.
williamr@2
   330
Use Inquiry scan for discoverability and Page scan for
williamr@2
   331
connectability.
williamr@2
   332
williamr@2
   333
Use with KHCIReadScanEnableIoctl and KHCIWriteScanEnableIoctl.
williamr@2
   334
@deprecated
williamr@2
   335
@see bt_subscribe.h
williamr@2
   336
*/
williamr@2
   337
enum THCIScanEnableIoctl 
williamr@2
   338
    {
williamr@2
   339
     EHCINoScansEnabled=0x00,          /*!< No scans enabled. */
williamr@2
   340
     EHCIInquiryScanOnly,              /*!< Inquiry scan only. */
williamr@2
   341
     EHCIPageScanOnly,                 /*!< Page scan only. */
williamr@2
   342
     EHCIInquiryAndPageScan            /*!< Both inquiry and page scan enabled. */
williamr@2
   343
    };
williamr@2
   344
/**
williamr@2
   345
Package for THCIScanEnableIoctl structure 
williamr@2
   346
@deprecated
williamr@2
   347
*/
williamr@2
   348
typedef TPckgBuf<THCIScanEnableIoctl> THCIScanEnableBuf;	
williamr@2
   349
williamr@2
   350
struct TLMAddSCOConnectionIoctl
williamr@2
   351
/**
williamr@2
   352
Structure for specifying SCO type to add to a connected socket.
williamr@2
   353
The connection handle for the SCO link is returned in iConnH when
williamr@2
   354
the Ioctl completes.
williamr@2
   355
williamr@2
   356
Use with KHCIAddSCOConnIoctl.
williamr@2
   357
@deprecated
williamr@2
   358
*/
williamr@2
   359
	{
williamr@2
   360
	TUint16        iPktType;	/*!< Packet type */
williamr@2
   361
	};
williamr@2
   362
/**
williamr@2
   363
Package for TLMAddSCOConnectionIoctl structure
williamr@2
   364
@deprecated
williamr@2
   365
*/
williamr@2
   366
typedef TPckgBuf<TLMAddSCOConnectionIoctl> TLMAddSCOConnectionBuf;	
williamr@2
   367
williamr@2
   368
struct THCISetEncryptionIoctl
williamr@2
   369
/**
williamr@2
   370
Request to change the encryption state of a connection.
williamr@2
   371
iEncrypt specifies whether to turn encryption on or off.
williamr@2
   372
williamr@2
   373
Use with KHCIEncryptIoctl.
williamr@2
   374
@deprecated
williamr@2
   375
*/
williamr@2
   376
	{
williamr@2
   377
	TBool             iEncrypt;		/*!< Encryption enabled / disabled */
williamr@2
   378
	};
williamr@2
   379
/**
williamr@2
   380
Package for THCISetEncryptionIoctl structure 
williamr@2
   381
@deprecated
williamr@2
   382
*/
williamr@2
   383
typedef TPckgBuf<THCISetEncryptionIoctl> THCISetEncryptionBuf;
williamr@2
   384
williamr@2
   385
struct THCIDeviceClassIoctl
williamr@2
   386
/**
williamr@2
   387
Structure to specify the class of device when getting or setting
williamr@2
   388
the local device class.
williamr@2
   389
williamr@2
   390
Use with KHCIReadDeviceClassIoctl and KHCIWriteDeviceClassIoctl.
williamr@2
   391
@deprecated
williamr@2
   392
@see bt_subscribe.h
williamr@2
   393
*/
williamr@2
   394
	{
williamr@2
   395
	TUint16    iMajorServiceClass;		/*!< Major Service class */
williamr@2
   396
	TUint8     iMajorDeviceClass;		/*!< Major Device class */
williamr@2
   397
	TUint8     iMinorDeviceClass;		/*!< Minor Device class */
williamr@2
   398
	};
williamr@2
   399
/**
williamr@2
   400
Package for THCIDeviceClassIoctl structure 
williamr@2
   401
@deprecated
williamr@2
   402
*/
williamr@2
   403
typedef TPckgBuf<THCIDeviceClassIoctl> THCIDeviceClassBuf;
williamr@2
   404
	
williamr@2
   405
struct THCILocalVersionIoctl
williamr@2
   406
/**
williamr@2
   407
Structure describing the local Bluetooth hardware version.
williamr@2
   408
williamr@2
   409
Use with KHCILocalVersionIoctl.
williamr@2
   410
@deprecated
williamr@2
   411
*/
williamr@2
   412
	{
williamr@2
   413
	TUint8   iHCIVersion;			/*!< HCI version */
williamr@2
   414
	TUint16  iHCIRevision;			/*!< HCI Revision */
williamr@2
   415
	TUint8   iLMPVersion;			/*!< LMP version */
williamr@2
   416
	TUint16  iLMPSubversion;		/*!< LMP subversion */
williamr@2
   417
	TUint16  iManufacturerName;		/*!< Manufacturer name */
williamr@2
   418
	};
williamr@2
   419
/**
williamr@2
   420
Package for THCILocalVersionIoctl structure 
williamr@2
   421
@deprecated
williamr@2
   422
*/
williamr@2
   423
typedef TPckgBuf<THCILocalVersionIoctl> THCILocalVersionBuf;	
williamr@2
   424
williamr@2
   425
/** L2CAP Get / Set Options. */
williamr@2
   426
enum TBTL2CAPOptions
williamr@2
   427
	{
williamr@2
   428
	/** 
williamr@2
   429
	Get the outbound MTU size taking into account both the negotiated MTU size 
williamr@2
   430
    and best use of underlying packet sizes.
williamr@2
   431
	For example: If the default outgoing MTU of 672 has been negotiated for a L2CAP channel
williamr@2
   432
	that is in Retransmission or Flow control mode then this GetOpt will return an
williamr@2
   433
	outgoing MTU of 668 bytes. This allows a maximally sized SDU 
williamr@2
   434
	(which due to this adjustment will be 668 bytes) to be sent in two DH5 packets.
williamr@2
   435
	KL2CAPOutboundMTUForBestPerformance may also be used to set the current negotiated 
williamr@2
   436
	(or to be negotiated) outbound MTU size.
williamr@2
   437
	Note that the outbound MTU size returned when using KL2CAPOutboundMTUForBestPerformance 
williamr@2
   438
	with a GetOpt may not be the same as the outbound MTU size previously set 
williamr@2
   439
	when using KL2CAPOutboundMTUForBestPerformance with a SetOpt.
williamr@2
   440
	*/ 
williamr@2
   441
	KL2CAPOutboundMTUForBestPerformance,	
williamr@2
   442
williamr@2
   443
	/** 
williamr@2
   444
	This is the legacy value for setting getting \ setting the outbound MTU size and behaves
williamr@2
   445
	in the same way as KL2CAPOutboundMTUForBestPerformance.
williamr@2
   446
	@see KL2CAPOutboundMTUForBestPerformance
williamr@2
   447
	*/ 
williamr@2
   448
	KL2CAPGetOutboundMTU = KL2CAPOutboundMTUForBestPerformance,
williamr@2
   449
williamr@2
   450
	KL2CAPGetDebug1,				/*!< Debug Command */
williamr@2
   451
	KL2CAPInboundMTU,				/*!< Get / Set the current inbound MTU size */
williamr@2
   452
	KL2CAPRTXTimer,					/*!< Change the extended L2CAP command retransmission timeout */
williamr@2
   453
	KL2CAPERTXTimer,				/*!< Change the L2CAP command retransmission timeout */
williamr@2
   454
	KL2CAPGetMaxOutboundMTU,		/*!< Get the max outbound MTU supported by the stack */
williamr@2
   455
	KL2CAPGetMaxInboundMTU,			/*!< Get the max inbound MTU supported by the stack */
williamr@2
   456
	KL2CAPUpdateChannelConfig,		/*!< Get and Set the current configuration parameters */
williamr@2
   457
williamr@2
   458
	/** Get / Set the current negotiated (or to be negotiated) outbound MTU size */
williamr@2
   459
	KL2CAPNegotiatedOutboundMTU,    
williamr@2
   460
williamr@2
   461
	KL2CAPTestConfigure,	
williamr@4
   462
	KL2CAPDebugFlush,				// not implemented anymore, just a placeholder for BC
williamr@2
   463
	KL2CAPVersion1_2,
williamr@2
   464
	KL2CAPHeapAlloc,
williamr@2
   465
	KL2CAPDataPlaneConfig,
williamr@2
   466
	
williamr@2
   467
	/**
williamr@2
   468
	This is similar to KL2CAPOutboundMTUForBestPerformance except that the caller can specify
williamr@2
   469
	a restriction that the returned MTU shall not exceed. This is useful for layers above L2CAP
williamr@2
   470
	that still want an optimal MTU but have their own restrictions on packet size.
williamr@2
   471
	*/
williamr@2
   472
	KL2CAPOutboundMTUForBestPerformanceWithRestriction,
williamr@4
   473
	KL2CAPLocalPSM,					/*!< Return local PSM of the socket (only works before the socket is accepted, stack internal use only) @internalTechnology */
williamr@4
   474
	KL2CAPNegotiatedChannelMode		/*!< Get the negotiated L2CAP channel mode */
williamr@2
   475
	};
williamr@2
   476
williamr@2
   477
typedef TUint16 TL2CAPPort;			/*!< Definition of a L2CAP port number type */
williamr@2
   478
williamr@2
   479
const static TL2CAPPort KL2CAPPassiveAutoBind = KMaxTUint16;  /*!< PSM out of the valid range used for passive auto bind operation */
williamr@2
   480
williamr@2
   481
NONSHARABLE_CLASS(TL2CAPSockAddr) : public TBTSockAddr
williamr@2
   482
/** L2CAP Socket Address.
williamr@2
   483
williamr@2
   484
Use this class to specify a local or remote L2CAP connection end-point,
williamr@2
   485
that is Device Address and PSM/CID.
williamr@2
   486
When unconnected, the Port() specifies the PSM, once connected it refers to
williamr@2
   487
the CID.
williamr@2
   488
@see TBTSockAddr
williamr@2
   489
@publishedAll
williamr@2
   490
@released
williamr@2
   491
*/
williamr@2
   492
	{
williamr@2
   493
public:
williamr@2
   494
	IMPORT_C TL2CAPSockAddr();
williamr@2
   495
	IMPORT_C TL2CAPSockAddr(const TSockAddr& aSockAddr);
williamr@2
   496
	IMPORT_C static TL2CAPSockAddr& Cast(const TSockAddr& aSockAddr);
williamr@2
   497
williamr@2
   498
	IMPORT_C TL2CAPPort Port() const;
williamr@2
   499
	IMPORT_C void SetPort(const TL2CAPPort aHomePort);
williamr@2
   500
	};
williamr@2
   501
williamr@2
   502
NONSHARABLE_CLASS(TInquirySockAddr) : public TSockAddr
williamr@2
   503
/** Socket address class used for inquiries.
williamr@2
   504
williamr@2
   505
Used to specify the inquiry request, and then filled with information
williamr@2
   506
about remote devices discovered through the inquiry process.
williamr@2
   507
williamr@2
   508
Use the BTAddr() method to extract the device address to connect to.
williamr@2
   509
williamr@2
   510
williamr@2
   511
Note: Usage of RHostResolver class for Bluetooth protocol.
williamr@2
   512
williamr@2
   513
The RHostResolver class is a generic interface to host name 
williamr@2
   514
resolution services, such as DNS, that may be provided 
williamr@2
   515
by particular protocol modules.
williamr@2
   516
williamr@2
   517
The points to remember when using RHostResolver::GetByAddress(), 
williamr@2
   518
RHostResolver::GetByName(), or RHostResolver::Next() 
williamr@2
   519
with Bluetooth protocol are:
williamr@2
   520
williamr@2
   521
1)  If you operate on one instance of RHostResolver you can perform 
williamr@2
   522
	only one request by calling either RHostResolver::GetByAddress() 
williamr@2
   523
	or  RHostResolver::GetByName(). If these functions are called again 
williamr@2
   524
	and if there is more than one possible response	for a given host name
williamr@2
   525
	then that will be returned (The host resolving process will
williamr@2
   526
	not start from the beginning). It is exactly as if the RHostResolve::Next() 
williamr@2
   527
	method was called.
williamr@2
   528
williamr@2
   529
2)  In order to start resolving new hosts from the beginning using the same 
williamr@2
   530
	instance of RHostResolver, the instance must be closed and reopened again.
williamr@2
   531
	
williamr@2
   532
3)  In order to perform several RHostResolver requests they	should be issued on 
williamr@2
   533
	separate instances of RHostResolver (many RHostResolver instances might 
williamr@2
   534
	exist and perform requests at the same time).
williamr@2
   535
	
williamr@2
   536
4)  The KHostResIgnoreCache flag is only valid when issuing RHostResolver::GetByAddress() 
williamr@2
   537
	or RHostResolver::GetByName() request for the first time.
williamr@2
   538
williamr@2
   539
5)  As an RHostResolver is only intended to be used once, it is recommended that it 
williamr@2
   540
	be closed as soon as it is finished with as the semantics of Cancel merely
williamr@2
   541
	indicates that one client server request should be cancelled.
williamr@2
   542
	
williamr@2
   543
@publishedAll
williamr@2
   544
@released
williamr@2
   545
*/
williamr@2
   546
	{
williamr@2
   547
// Max size for this structure is 24 bytes (32 - 8, see TSockAddr). However, due to padding and to prevent BC breaks, 
williamr@2
   548
// only up to 3 TUint8(s) may be added after iFlags
williamr@2
   549
	struct SInquiryAddr
williamr@2
   550
		{
williamr@2
   551
		TBTDevAddr iAddress;
williamr@2
   552
		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
   553
		TUint16 iMajorServiceClass;
williamr@2
   554
		TUint8 iMajorDeviceClass;
williamr@2
   555
		TUint8 iMinorDeviceClass;
williamr@2
   556
		TUint iIAC;
williamr@2
   557
		TUint8 iActionFlags;
williamr@2
   558
		TUint8 iResultFlags;
williamr@2
   559
		TInt8 iRssi;
williamr@2
   560
		};
williamr@2
   561
	
williamr@2
   562
public:
williamr@2
   563
	// This defines all the bit masks for the inquiry result
williamr@2
   564
	enum TResolverResultFlags
williamr@2
   565
		{
williamr@2
   566
		ERssiValid = 0x1,
williamr@2
   567
		};
williamr@2
   568
williamr@2
   569
public:
williamr@2
   570
	IMPORT_C TInquirySockAddr();
williamr@2
   571
	IMPORT_C TInquirySockAddr(const TSockAddr& aSockAddr);
williamr@2
   572
	IMPORT_C TBTDevAddr BTAddr() const;
williamr@2
   573
	IMPORT_C void SetBTAddr(const TBTDevAddr& aRemote);
williamr@2
   574
williamr@2
   575
	IMPORT_C static TInquirySockAddr& Cast(const TSockAddr& aSockAddr);
williamr@2
   576
	IMPORT_C TUint16 MajorServiceClass() const;
williamr@2
   577
	IMPORT_C void SetMajorServiceClass(TUint16 aClass);
williamr@2
   578
	IMPORT_C TUint8 MajorClassOfDevice() const;
williamr@2
   579
	IMPORT_C void SetMajorClassOfDevice(TUint8 aMajorClassOfDevice);
williamr@2
   580
	IMPORT_C TUint8 MinorClassOfDevice() const;
williamr@2
   581
	IMPORT_C void SetMinorClassOfDevice(TUint8 aMinorClassOfDevice);
williamr@2
   582
	IMPORT_C TUint IAC() const;
williamr@2
   583
	IMPORT_C void SetIAC(const TUint aIAC);
williamr@2
   584
	IMPORT_C TUint8 Action() const;
williamr@2
   585
	IMPORT_C void SetAction(TUint8 aFlags);
williamr@2
   586
	IMPORT_C TVersion Version() const;	
williamr@2
   587
	IMPORT_C TInt8 Rssi() const;	
williamr@2
   588
	IMPORT_C void SetRssi(const TInt8 aRssi);
williamr@2
   589
	IMPORT_C TUint8 ResultFlags() const;
williamr@2
   590
	IMPORT_C void SetResultFlags(TUint8 aResultFlags);
williamr@2
   591
williamr@2
   592
protected:
williamr@2
   593
	void SetVersion(TVersion aVersion);
williamr@2
   594
	IMPORT_C TUint8 FormatTypeField() const;
williamr@2
   595
	void SetFormatTypeField(TUint8 aType);
williamr@2
   596
	
williamr@2
   597
private:
williamr@2
   598
	SInquiryAddr& InquiryAddrStruct() const;
williamr@2
   599
	TPtr8 AddressPtr() const;
williamr@2
   600
	};
williamr@2
   601
williamr@2
   602
//
williamr@2
   603
// RFCOMM
williamr@2
   604
//
williamr@2
   605
williamr@2
   606
const static TInt KRFErrorBase = -6350;										/*!< RFCOMM base error code. */
williamr@2
   607
const static TInt KErrRfcommSAPUnexpectedEvent = KRFErrorBase;				/*!< RFCOMM unexpected event error code. */
williamr@2
   608
const static TInt KErrRfcommAlreadyBound = KRFErrorBase-1;					/*!< RFCOMM SAP already bound error code. */
williamr@2
   609
const static TInt KErrRfcommBadAddress = KRFErrorBase-2;					/*!< RFCOMM bad address error code. */
williamr@2
   610
const static TInt KErrRfcommMTUSize = KRFErrorBase-3;						/*!< RFCOMM MTU size exceeded error code. */
williamr@2
   611
const static TInt KErrRfcommFrameResponseTimeout = KRFErrorBase-4;			/*!< RFCOMM frame response timeout error code. */
williamr@2
   612
const static TInt KErrRfcommMuxRemoteDisconnect = KRFErrorBase-5;			/*!< RFCOMM remote end disconnected error code. */
williamr@2
   613
const static TInt KErrRfcommNotBound = KRFErrorBase-6;						/*!< RFCOMM SAP not bound error code. */
williamr@2
   614
const static TInt KErrRfcommParameterNegotiationFailure = KRFErrorBase-7;	/*!< RFCOMM parameter negotiation failure error code. */
williamr@2
   615
const static TInt KErrRfcommNotListening = KRFErrorBase-8;					/*!< RFCOMM not listening error code. */
williamr@2
   616
const static TInt KErrRfcommNoMoreServerChannels = KRFErrorBase-9;			/*!< RFCOMM no more server channels available error code. */
williamr@2
   617
williamr@2
   618
//RFCOMMIoctls
williamr@2
   619
williamr@2
   620
const static TInt KRFCOMMModemStatusCmdIoctl =0;		/*!< RFCOMM status command Ioctl */
williamr@2
   621
const static TInt KRFCOMMRemoteLineStatusCmdIoctl = 1;	/*!< RFCOMM remote line status command Ioctl */
williamr@2
   622
const static TInt KRFCOMMRemotePortNegCmdIoctl = 2;		/*!< RFCOMM remote port negotiation command Ioctl */
williamr@2
   623
const static TInt KRFCOMMRemotePortNegRequestIoctl = 3;	/*!< RFCOMM remote port negotiation request Ioctl */
williamr@2
   624
const static TInt KRFCOMMConfigChangeIndicationIoctl = 4;	/*!< RFCOMM MSC activity Ioctl */
williamr@2
   625
williamr@2
   626
// RFCOMM Options
williamr@2
   627
williamr@2
   628
const static TInt KRFCOMMLocalPortParameter = 0;	/*!< RFCOMM local port parameter option (Get + Set) */
williamr@2
   629
/** RFCOMM Get Available server channel option (Get only)
williamr@2
   630
@deprecated
williamr@2
   631
*/
williamr@2
   632
const static TInt KRFCOMMGetAvailableServerChannel = 1;
williamr@2
   633
williamr@2
   634
const static TInt KRFCOMMMaximumSupportedMTU = 2; 	/*!< RFCOMM maximum supported option (Get + Set) */
williamr@2
   635
const static TInt KRFCOMMGetDebug1 = 3;   			/*!< RFCOMM debug option (Get only) */
williamr@2
   636
const static TInt KRFCOMMGetRemoteModemStatus = 4; 	/*!< RFCOMM remote modem status option (Get + Set) */
williamr@2
   637
williamr@2
   638
const static TInt KRFCOMMGetTransmitCredit = 5;		/*!< RFCOMM get transmit credits option */
williamr@2
   639
const static TInt KRFCOMMGetReceiveCredit = 6;		/*!< RFCOMM get receive credits option */
williamr@2
   640
const static TInt KRFCOMMGetReUsedCount = 7;		/*!< RFCOMM get number of remote used credits option */
williamr@2
   641
const static TInt KRFCOMMFlowTypeCBFC = 8; 			/*!< RFCOMM Credit based flow control option (Get + Set) */
williamr@2
   642
const static TInt KRFCOMMErrOnMSC = 9;				/*!< RFCOMM set the value of MSC signals that will cause a disconnect error to be generated */
williamr@2
   643
const static TUint KRFCOMMLocalModemStatus = 10;   	/*!< RFCOMM local modem status option (Get + Set) */
williamr@2
   644
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
   645
williamr@2
   646
const static TInt KRFCOMMMaximumMTU = 12; 	/*!< RFCOMM maximum optimal MTU (Get only) */
williamr@2
   647
williamr@2
   648
// Masks for interpreting signalling commands
williamr@2
   649
const static TUint8 KModemSignalFC  = 0x01;			/*!< RFCOMM FC signalling command mask */
williamr@2
   650
const static TUint8 KModemSignalRTC = 0x02;			/*!< RFCOMM RTC signalling command mask */
williamr@2
   651
const static TUint8 KModemSignalRTR = 0x04;			/*!< RFCOMM RTR signalling command mask */
williamr@2
   652
const static TUint8 KModemSignalIC  = 0x20;			/*!< RFCOMM IC signalling command mask */
williamr@2
   653
const static TUint8 KModemSignalDV  = 0x40;			/*!< RFCOMM DV signalling command mask */
williamr@2
   654
williamr@2
   655
enum TRPNParameterMask
williamr@2
   656
/** Remote port negotiation parameter masks
williamr@2
   657
*/
williamr@2
   658
	{
williamr@2
   659
	EPMBitRate		= 0x0001,		/*!< Remote port negotiation parameter masks for bit rate */
williamr@2
   660
	EPMDataBits		= 0x0002,		/*!< Remote port negotiation parameter masks for data bits */
williamr@2
   661
	EPMStopBit		= 0x0004,		/*!< Remote port negotiation parameter masks for stop bit */
williamr@2
   662
	EPMParity		= 0x0008,		/*!< Remote port negotiation parameter masks for parity */
williamr@2
   663
	EPMParityType	= 0x0010,		/*!< Remote port negotiation parameter masks for parity type */
williamr@2
   664
	EPMXOnChar		= 0x0020,		/*!< Remote port negotiation parameter masks for on character */
williamr@2
   665
	EPMXOffChar		= 0x0040,		/*!< Remote port negotiation parameter masks for off character */
williamr@2
   666
	// RESERVED		= 0x0080		
williamr@2
   667
	EPMXOnOffInput	= 0x0100,		/*!< Remote port negotiation parameter masks for XOn/Off input */
williamr@2
   668
	EPMXOnOffOutput	= 0x0200,		/*!< Remote port negotiation parameter masks for XOn/Off output */
williamr@2
   669
	EPMRTRInput		= 0x0400,		/*!< Remote port negotiation parameter masks for read to receive input */
williamr@2
   670
	EPMRTROutput	= 0x0800,		/*!< Remote port negotiation parameter masks for read to receive output */
williamr@2
   671
	EPMRTCInput		= 0x1000,		/*!< Remote port negotiation parameter masks for RTC input */
williamr@2
   672
	EPMRTCOutput	= 0x2000		/*!< Remote port negotiation parameter masks for RTC output */
williamr@2
   673
	// RESERVED		= 0x4000
williamr@2
   674
	// RESERVED		= 0x8000
williamr@2
   675
	};
williamr@2
   676
williamr@2
   677
enum TRPNFlowCtrlMask
williamr@2
   678
/** Remote port negotiation flow control masks
williamr@2
   679
*/
williamr@2
   680
	{
williamr@2
   681
	EFCXOnOffInput	=0x01,	/*!< Remote port negotiation flow control masks for XOn/Off input */
williamr@2
   682
	EFCXOnOffOutput =0x02,	/*!< Remote port negotiation flow control masks for XOn/Off output */
williamr@2
   683
	EFCRTRInput		=0x04,	/*!< Remote port negotiation flow control masks for ready to receive input */
williamr@2
   684
	EFCRTROutput	=0x08,	/*!< Remote port negotiation flow control masks for ready to receive output */
williamr@2
   685
	EFCRTCInput		=0x10,	/*!< Remote port negotiation flow control masks for RTC input */
williamr@2
   686
	EFCRTCOutput	=0x20	/*!< Remote port negotiation flow control masks for RTC output */
williamr@2
   687
	};
williamr@2
   688
williamr@2
   689
enum TRPNValidityMask
williamr@2
   690
/** Remote port negotiation validity masks
williamr@2
   691
*/
williamr@2
   692
	{
williamr@2
   693
	EVMBitRate	= 0x01,	/*!< Remote port negotiation validity masks for bit rate */
williamr@2
   694
	EVMDataBits	= 0x02,	/*!< Remote port negotiation validity masks for data bits */
williamr@2
   695
	EVMStopBit	= 0x04,	/*!< Remote port negotiation validity masks for stop bit */
williamr@2
   696
	EVMParity	= 0x08,	/*!< Remote port negotiation validity masks for parity */
williamr@2
   697
	EVMFlowCtrl	= 0x10,	/*!< Remote port negotiation validity masks for flow control */
williamr@2
   698
	EVMXOnChar	= 0x20,	/*!< Remote port negotiation validity masks for XOn charater */
williamr@2
   699
	EVMXOffChar	= 0x40	/*!< Remote port negotiation validity masks for XOff charater */
williamr@2
   700
	};
williamr@2
   701
williamr@2
   702
// structs for RFCOMM Ioctls
williamr@2
   703
williamr@2
   704
class TRfcommRPNTransaction;
williamr@2
   705
williamr@2
   706
NONSHARABLE_CLASS(TRfcommRemotePortParams)
williamr@2
   707
/** RF COMM remote port parameters. 
williamr@2
   708
williamr@2
   709
@publishedAll
williamr@2
   710
@released
williamr@2
   711
*/
williamr@2
   712
	{
williamr@2
   713
public:
williamr@2
   714
	IMPORT_C TRfcommRemotePortParams();
williamr@2
   715
	IMPORT_C TUint8	IsValid() const;
williamr@2
   716
	IMPORT_C TBool  GetBitRate(TBps& aBitRate) const;
williamr@2
   717
	IMPORT_C TInt   SetBitRate(TBps  aBitRate);
williamr@2
   718
	IMPORT_C TBool  GetDataBits(TDataBits& aDataBits) const;
williamr@2
   719
	IMPORT_C TInt   SetDataBits(TDataBits  aDataBits);
williamr@2
   720
	IMPORT_C TBool  GetStopBit(TStopBits& aStopBit) const;
williamr@2
   721
	IMPORT_C TInt   SetStopBit(TStopBits  aStopBit);
williamr@2
   722
	IMPORT_C TBool  GetParity(TParity& aParity) const;
williamr@2
   723
	IMPORT_C TInt   SetParity(TParity  aParity);
williamr@2
   724
	IMPORT_C TBool  GetFlowCtrl(TUint8& aFlowCtrl) const;
williamr@2
   725
	IMPORT_C TInt   SetFlowCtrl(TUint8  aFlowCtrl);
williamr@2
   726
	IMPORT_C TBool  GetXOnChar(TUint8& aXOnChar) const;
williamr@2
   727
	IMPORT_C TInt   SetXOnChar(TUint8  aXOnChar);
williamr@2
   728
	IMPORT_C TBool  GetXOffChar(TUint8& aXOffChar) const;
williamr@2
   729
	IMPORT_C TInt   SetXOffChar(TUint8  aXOffChar);
williamr@2
   730
	IMPORT_C void   UpdateFlowCtrlBit(TUint8 aFlowCtrl, TRPNFlowCtrlMask aFCMask);
williamr@2
   731
	IMPORT_C void   UpdateWholeFlowCtrl(TUint16 aParamMask, TUint8 aFlowCtrl);
williamr@2
   732
	IMPORT_C void   UpdateFromRPNTransaction(const TRfcommRPNTransaction& 
williamr@2
   733
											aRPNTransaction);	
williamr@2
   734
private:	
williamr@2
   735
	TBps iBitRate;
williamr@2
   736
	TDataBits iDataBits;
williamr@2
   737
	TStopBits iStopBit; //It's really only one bit - ignore what the type implies...
williamr@2
   738
	TParity iParity;
williamr@2
   739
	TUint8 iFlowCtrl;
williamr@2
   740
	TUint8 iXOnChar;
williamr@2
   741
	TUint8 iXOffChar;
williamr@2
   742
	TUint8 iValidMask;
williamr@2
   743
		
williamr@2
   744
	// This data padding has been added to help prevent future binary compatibility breaks	
williamr@2
   745
	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
williamr@2
   746
	TUint32     iPadding1; 
williamr@2
   747
	TUint32     iPadding2; 
williamr@2
   748
	};
williamr@2
   749
williamr@2
   750
// structs for RFCOMM Ioctls
williamr@2
   751
williamr@2
   752
NONSHARABLE_CLASS(TRfcommRPNTransaction)
williamr@2
   753
/** RF COMM IO control structs.
williamr@2
   754
williamr@2
   755
@publishedAll
williamr@2
   756
@released
williamr@2
   757
*/
williamr@2
   758
	{
williamr@2
   759
public: // Functions
williamr@2
   760
	IMPORT_C TRfcommRPNTransaction();
williamr@2
   761
public: // Variables
williamr@2
   762
	TRfcommRemotePortParams iPortParams;	/*!< Remote port parameters */
williamr@2
   763
	TUint16 iParamMask;						/*!< Parameter mask */
williamr@2
   764
	};
williamr@2
   765
williamr@2
   766
// RFCOMM addresses
williamr@2
   767
williamr@2
   768
typedef TUint8 TRfcommChannel;	/*!< RFCOMM channel type definition */
williamr@2
   769
williamr@2
   770
const static TRfcommChannel KMinRfcommServerChannel = 1;	/*!< Minimum RFCOMM server channel value */
williamr@2
   771
const static TRfcommChannel KMaxRfcommServerChannel = 30;	/*!< Maximum RFCOMM server channel value */
williamr@2
   772
williamr@2
   773
const static TRfcommChannel KRfcommPassiveAutoBind = KMaxTUint8;	/*!< Channel value out of the valid range used for passive auto bind. */
williamr@2
   774
williamr@2
   775
NONSHARABLE_CLASS(TRfcommSockAddr) : public TBTSockAddr
williamr@2
   776
/** Defines the format of an Rfcomm address.
williamr@2
   777
williamr@2
   778
This class uses the TSockAddr data area to hold the address so that
williamr@2
   779
it can be passed through the ESOCK boundary.
williamr@2
   780
Assumes that the remote RFCOMM instance is always bound to PSM 3 on
williamr@2
   781
L2CAP, so there is no way of specifying another remote PSM.
williamr@2
   782
williamr@2
   783
@see TBTSockAddr
williamr@2
   784
@publishedAll   
williamr@2
   785
@released
williamr@2
   786
*/
williamr@2
   787
	{
williamr@2
   788
public:
williamr@2
   789
	IMPORT_C TRfcommSockAddr();
williamr@2
   790
	IMPORT_C TRfcommSockAddr(const TSockAddr& aSockAddr);
williamr@2
   791
	IMPORT_C static TRfcommSockAddr& Cast(const TSockAddr& aSockAddr);
williamr@2
   792
	};
williamr@2
   793
williamr@2
   794
/*****BASEBAND CLIENT*********/
williamr@2
   795
williamr@2
   796
class CBTBasebandSocketProxy;
williamr@2
   797
class CBTBasebandPropertySubscriber;
williamr@2
   798
williamr@2
   799
class MBasebandObserver;
williamr@2
   800
		
williamr@2
   801
NONSHARABLE_CLASS(RBTPhysicalLinkAdapter)
williamr@2
   802
/** Class to enable modification of a physical link:
williamr@2
   803
williamr@2
   804
Modifications may be requested or prevented (blocked).
williamr@2
   805
Whilst a modification is being prevented, any request to
williamr@2
   806
perform that modification by this or any other
williamr@2
   807
RBTPhysicalLinkAdapter client will be ignored.
williamr@2
   808
If a low power mode is being used on the physical link, a
williamr@2
   809
call to prevent that low power mode will, if possible, cause
williamr@2
   810
the physical link to exit that low power mode. An
williamr@2
   811
arbitration between all RBTPhysicalLinkAdapter clients will then occur
williamr@2
   812
to decide whether the physical link should remain active or 
williamr@2
   813
enter another low power mode. (If all low power modes are prevented
williamr@2
   814
then that arbitration will result in the physical link remaining
williamr@2
   815
active.)
williamr@2
   816
williamr@2
   817
Methods to prevent modifications begin 'Prevent...'
williamr@2
   818
williamr@2
   819
Methods to cancel the prevention of modification begin 'Allow...'
williamr@2
   820
williamr@2
   821
Requests for low power mode modifications, and notification of modifications
williamr@2
   822
take the form of continuously repeated requests which can be switched on or 
williamr@2
   823
switched off. 
williamr@2
   824
williamr@2
   825
Only one low power mode requester may active on a single RBTPhysicalLinkAdapter
williamr@2
   826
client at a time. If several RBTPhysicalLinkAdapter clients have differing low
williamr@2
   827
power mode requests active at a given moment then the priority will be:
williamr@2
   828
	Hold
williamr@2
   829
	Sniff
williamr@2
   830
	Park
williamr@2
   831
williamr@2
   832
Methods to perform these requests start 'Activate...'
williamr@2
   833
williamr@2
   834
Methods to cancel these requests start 'Cancel...'
williamr@2
   835
@publishedAll
williamr@2
   836
@released
williamr@2
   837
*/
williamr@2
   838
	{
williamr@2
   839
public:
williamr@2
   840
	IMPORT_C RBTPhysicalLinkAdapter();
williamr@2
   841
	IMPORT_C TInt Open(RSocketServ& aSocketServ, RSocket& aSocket);
williamr@2
   842
	IMPORT_C TInt Open(RSocketServ& aSocketServ, const TBTDevAddr& aDevAddr);
williamr@2
   843
	IMPORT_C TBool IsOpen() const;		
williamr@2
   844
	IMPORT_C void Close();
williamr@2
   845
	IMPORT_C TInt PhysicalLinkState(TUint32& aState);
williamr@2
   846
	IMPORT_C TInt PreventRoleSwitch();
williamr@2
   847
	IMPORT_C TInt AllowRoleSwitch();
williamr@2
   848
	IMPORT_C TInt RequestMasterRole();
williamr@2
   849
	IMPORT_C TInt RequestSlaveRole();
williamr@2
   850
	IMPORT_C TInt PreventLowPowerModes(TUint32 aLowPowerModes);
williamr@2
   851
	IMPORT_C TInt AllowLowPowerModes(TUint32 aLowPowerModes);
williamr@2
   852
	IMPORT_C TInt ActivateSniffRequester();
williamr@2
   853
	IMPORT_C TInt ActivateParkRequester();
williamr@2
   854
	IMPORT_C TInt ActivateActiveRequester();
williamr@2
   855
	IMPORT_C TInt CancelLowPowerModeRequester();
williamr@2
   856
	IMPORT_C TInt RequestChangeSupportedPacketTypes(TUint16 aPacketTypes);
williamr@2
   857
	IMPORT_C void NotifyNextBasebandChangeEvent(TBTBasebandEvent& aEventNotification, 
williamr@2
   858
		                                        TRequestStatus& aStatus, 
williamr@2
   859
						     		            TUint32 aEventMask = ENotifyAnyPhysicalLinkState);
williamr@2
   860
williamr@2
   861
	IMPORT_C void CancelNextBasebandChangeEventNotifier();
williamr@2
   862
	IMPORT_C TInt Authenticate();
williamr@2
   863
	
williamr@2
   864
private:
williamr@2
   865
	RBTBaseband iBTBaseband;
williamr@2
   866
	
williamr@2
   867
	// This data padding has been added to help prevent future binary compatibility breaks	
williamr@2
   868
	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
williamr@2
   869
	TUint32     iPadding1; 
williamr@2
   870
	TUint32     iPadding2; 	
williamr@2
   871
	};
williamr@2
   872
williamr@2
   873
/**
williamr@2
   874
This allows for notification of events relating to a CBluetoothPhysicalLinkMetrics object.
williamr@2
   875
williamr@2
   876
These notifications will be called when the value of a physical link metric that has been
williamr@2
   877
subscribed to in CBluetoothPhysicalLinkMetrics changes. If the notification is not called,
williamr@2
   878
the value has not changed since the last notification
williamr@2
   879
williamr@2
   880
Mixin class to be used with CBluetoothPhysicalLinkMetrics
williamr@2
   881
@publishedAll
williamr@2
   882
@released
williamr@2
   883
*/
williamr@2
   884
class MBluetoothPhysicalLinkMetricsObserver
williamr@2
   885
	{
williamr@2
   886
public:
williamr@2
   887
	/**
williamr@2
   888
	Notification for the initial RSSI (received signal strengh indication) value
williamr@2
   889
	and whenever the RSSI changes
williamr@2
   890
	@param aRssi Current RSSI Value in dB
williamr@2
   891
	*/
williamr@2
   892
	virtual void MbplmoRssiChanged(TInt8 aRssi) = 0;
williamr@2
   893
	
williamr@2
   894
	/**
williamr@2
   895
	Notification for the initial Link Quality value and whenever the Link Quality changes.
williamr@2
   896
	@param aLinkQuality Link quality for this connection where the higher value represents a better quality link
williamr@2
   897
	*/
williamr@2
   898
	virtual void MbplmoLinkQualityChanged(TUint8 aLinkQuality) = 0;
williamr@2
   899
	
williamr@2
   900
	/**
williamr@2
   901
	Notification for the initial failed contact counter value, and whenever the failed contact counter changes.
williamr@2
   902
	@param aFailedContactCounter Number of consecutive failed contacts for this connection
williamr@2
   903
	*/
williamr@2
   904
	virtual void MbplmoFailedContactCounterChanged(TUint16 aFailedContactCounter) = 0;
williamr@2
   905
	
williamr@2
   906
	/**
williamr@2
   907
	Notification for the initial transmit power level, and whenever the transmit power level changes.
williamr@2
   908
	@param aTransmitPowerLevel Transmit power level in dBm
williamr@2
   909
	*/
williamr@2
   910
	virtual void MbplmoTransmitPowerLevelChanged(TInt8 aTransmitPowerLevel) = 0;
williamr@2
   911
	
williamr@2
   912
	/**
williamr@2
   913
	Notification that an error has occured. When this is called, the current
williamr@2
   914
	subscriptions will be cancelled.
williamr@2
   915
	If a link disconnection occurs, the CBluetoothPhysicalLinkMetrics object will
williamr@2
   916
	no longer be valid, so it is recommended to delete the object in this callback
williamr@2
   917
	*/
williamr@2
   918
	virtual void MbplmoError(TInt aError) = 0;
williamr@2
   919
	
williamr@2
   920
	/**
williamr@2
   921
	Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
williamr@2
   922
	@param aInterface UID of the interface to return
williamr@2
   923
	@return The container for another interface as specified by aInterface
williamr@2
   924
	*/
williamr@2
   925
	IMPORT_C virtual TAny* MbplmoExtensionInterfaceL(TUid aInterface);
williamr@2
   926
	};
williamr@2
   927
williamr@2
   928
class CBluetoothPhysicalLinkMetricSubscriber;
williamr@2
   929
williamr@2
   930
/**
williamr@2
   931
Class to subscribe to physical link metrics
williamr@2
   932
@publishedAll
williamr@2
   933
@released
williamr@2
   934
*/
williamr@2
   935
NONSHARABLE_CLASS(CBluetoothPhysicalLinkMetrics): public CBase
williamr@2
   936
	{
williamr@2
   937
public:
williamr@2
   938
	IMPORT_C static CBluetoothPhysicalLinkMetrics* NewL(
williamr@2
   939
						MBluetoothPhysicalLinkMetricsObserver& aObserver,
williamr@2
   940
						RSocketServ& aSockServ,
williamr@2
   941
						RSocket& aConnectedSocket);
williamr@2
   942
	
williamr@2
   943
	IMPORT_C static CBluetoothPhysicalLinkMetrics* NewL(
williamr@2
   944
						MBluetoothPhysicalLinkMetricsObserver& aObserver,
williamr@2
   945
						RSocketServ& aSockServ,
williamr@2
   946
						const TBTDevAddr& aAddr);
williamr@2
   947
	
williamr@2
   948
	IMPORT_C ~CBluetoothPhysicalLinkMetrics();
williamr@2
   949
	IMPORT_C void SubscribeRssi();
williamr@2
   950
	IMPORT_C void SubscribeLinkQuality();
williamr@2
   951
	IMPORT_C void SubscribeFailedContactCounter();
williamr@2
   952
	IMPORT_C void SubscribeTransmitPowerLevel();
williamr@2
   953
	IMPORT_C void Cancel();
williamr@2
   954
	
williamr@2
   955
	void RssiChanged(TInt8 aRssi);
williamr@2
   956
	void LinkQualityChanged(TUint8 aLinkQuality);
williamr@2
   957
	void FailedContactCounterChanged(TUint16 aFailedContactCounter);
williamr@2
   958
	void TransmitPowerLevelChanged(TInt8 aTransmitPowerLevel);
williamr@2
   959
	void SubscribeError(TInt aError);
williamr@2
   960
williamr@2
   961
	
williamr@2
   962
private:
williamr@2
   963
	CBluetoothPhysicalLinkMetrics(MBluetoothPhysicalLinkMetricsObserver& aObserver);
williamr@2
   964
	template<class T> void ConstructL(RSocketServ& aSockServ, T& aLinkIdentifier);	
williamr@2
   965
	
williamr@2
   966
private:
williamr@2
   967
	MBluetoothPhysicalLinkMetricsObserver& iObserver;
williamr@2
   968
	CBluetoothPhysicalLinkMetricSubscriber* iRssiBaseband;
williamr@2
   969
	CBluetoothPhysicalLinkMetricSubscriber* iLinkQualityBaseband;
williamr@2
   970
	CBluetoothPhysicalLinkMetricSubscriber* iFailedContactCounterBaseband;
williamr@2
   971
	CBluetoothPhysicalLinkMetricSubscriber* iTransmitPowerLevelBaseband;
williamr@2
   972
	};
williamr@2
   973
williamr@2
   974
williamr@2
   975
class MBluetoothSocketNotifier
williamr@2
   976
/** This allows for notification of events relating to a CBluetoothSocket object.
williamr@2
   977
williamr@2
   978
Such notification consists of notification of logical link events (for example receipt 
williamr@2
   979
of a user packet) and physical link state events (for example change of power mode).
williamr@2
   980
williamr@2
   981
Mixin class to be used with CBluetoothSocket
williamr@2
   982
@publishedAll
williamr@2
   983
@released
williamr@2
   984
*/
williamr@2
   985
	{
williamr@2
   986
public:
williamr@2
   987
	/** Notification of a connection complete event.
williamr@2
   988
	
williamr@2
   989
	 If no error is reported, then the connection is ready for use.
williamr@2
   990
	 @note If the implementation of this function needs to delete associated 
williamr@2
   991
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
   992
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
   993
	 @param aErr the returned error
williamr@2
   994
	*/
williamr@2
   995
	virtual void HandleConnectCompleteL(TInt aErr) = 0;
williamr@2
   996
williamr@2
   997
	/** Notification of an accept complete event.
williamr@2
   998
	
williamr@2
   999
	 If no error is reported, then we have accepted a connection request 
williamr@2
  1000
	 and that connection is ready for use.
williamr@2
  1001
	 @note If the implementation of this function needs to delete associated 
williamr@2
  1002
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
  1003
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
  1004
	 @param aErr the returned error
williamr@2
  1005
	*/
williamr@2
  1006
	virtual void HandleAcceptCompleteL(TInt aErr) = 0;
williamr@2
  1007
williamr@2
  1008
	/** Notification of a shutdown complete event.
williamr@2
  1009
	
williamr@2
  1010
	 If no error is reported, then the connection has been closed.
williamr@2
  1011
	 @note If the implementation of this function needs to delete associated 
williamr@2
  1012
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
  1013
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
  1014
	 @param aErr the returned error
williamr@2
  1015
	*/
williamr@2
  1016
	virtual void HandleShutdownCompleteL(TInt aErr) = 0;
williamr@2
  1017
williamr@2
  1018
	/** Notification of a send complete event.
williamr@2
  1019
	
williamr@2
  1020
	 If no error is reported, then an attempt to send data over Bluetooth has succeeded.
williamr@2
  1021
	 @note If the implementation of this function needs to delete associated 
williamr@2
  1022
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
  1023
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
  1024
	 @param aErr the returned error
williamr@2
  1025
	*/
williamr@2
  1026
	virtual void HandleSendCompleteL(TInt aErr) = 0;
williamr@2
  1027
williamr@2
  1028
	/** Notification of a receive complete event.
williamr@2
  1029
	
williamr@2
  1030
	 If no error is reported, then then we have successfully received
williamr@2
  1031
	 a specified quantity of data.
williamr@2
  1032
	 @note If the implementation of this function needs to delete associated 
williamr@2
  1033
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
  1034
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
  1035
	 @param aErr the returned error
williamr@2
  1036
	*/
williamr@2
  1037
	virtual void HandleReceiveCompleteL(TInt aErr) = 0;
williamr@2
  1038
williamr@2
  1039
	/** Notification of a ioctl complete event.
williamr@2
  1040
	
williamr@2
  1041
	 An HCI request that has an associated command complete has completed.
williamr@2
  1042
	 @note If the implementation of this function needs to delete associated 
williamr@2
  1043
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
  1044
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
  1045
	 @param aErr the returned error
williamr@2
  1046
	*/
williamr@2
  1047
	virtual void HandleIoctlCompleteL(TInt aErr) = 0;
williamr@2
  1048
williamr@2
  1049
	/** Notification of a baseband event.
williamr@2
  1050
	
williamr@2
  1051
	 If no error is reported, then a baseband event has been retrieved successfully.
williamr@2
  1052
	 @note If the implementation of this function needs to delete associated 
williamr@2
  1053
	 CBluetoothSocket object, it should NOT use delete operator. The implementation 
williamr@2
  1054
	 should call CBluetoothSocket::AsyncDelete() method instead.
williamr@2
  1055
	 @param aErr the returned error
williamr@2
  1056
	 @param TBTBasebandEventNotification Bit(s) set in TBTBasebandEventNotification bitmap indicate what event has taken place.
williamr@2
  1057
	 @see TBTPhysicalLinkStateNotifier
williamr@2
  1058
	*/
williamr@2
  1059
	virtual void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification& aEventNotification) = 0;
williamr@2
  1060
	
williamr@2
  1061
    /**
williamr@2
  1062
 	 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
williamr@2
  1063
	 @param aInterface UID of the interface to return
williamr@2
  1064
	 @param aObject the container for another interface as specified by aInterface
williamr@2
  1065
	 */
williamr@2
  1066
	IMPORT_C virtual void MBSN_ExtensionInterfaceL(TUid aInterface, void*& aObject);	
williamr@2
  1067
	};
williamr@2
  1068
williamr@2
  1069
williamr@2
  1070
class CBTConnecter;
williamr@2
  1071
class CBTAccepter;
williamr@2
  1072
class CBTShutdowner;
williamr@2
  1073
class CBTReceiver;
williamr@2
  1074
class CBTSender;
williamr@2
  1075
class CBTIoctler;
williamr@2
  1076
class CBTBasebandChangeEventNotifier;
williamr@2
  1077
class CAutoSniffDelayTimer;
williamr@2
  1078
class CBTBasebandManager;
williamr@2
  1079
class CBTBasebandChangeEventDelegate;
williamr@2
  1080
williamr@2
  1081
NONSHARABLE_CLASS(CBluetoothSocket): public CBase
williamr@2
  1082
    /** This allows Bluetooth ACL socket-based services to be run.
williamr@2
  1083
williamr@2
  1084
    It allows all user-plane data flow to occur, plus control-plane Bluetooth 
williamr@2
  1085
    baseband modification capabilities.
williamr@2
  1086
    
williamr@2
  1087
    For a more detailed description of RBTBaseband functionality see the class and function documentation for
williamr@2
  1088
    RBTPhysicalLinkAdapter.
williamr@2
  1089
    
williamr@2
  1090
	This class doesn't provide the functionality to directly activate Active mode
williamr@2
  1091
	(this is implementated in class RBTPhysicalLinkAdapter.)
williamr@2
  1092
	@see RBTPhysicalLinkAdapter::ActivateActiveRequester()
williamr@2
  1093
	Explicit Active mode requests are made automatically when using the Automatic Sniff Requester 
williamr@2
  1094
	utility provided by this class.
williamr@2
  1095
	@see CBluetoothSocket::SetAutomaticSniffMode	
williamr@2
  1096
williamr@2
  1097
    @see RBTPhysicalLinkAdapter
williamr@2
  1098
    @publishedAll
williamr@2
  1099
    @released
williamr@2
  1100
    */
williamr@2
  1101
	{
williamr@2
  1102
friend class CBTAccepter;		
williamr@2
  1103
public:
williamr@2
  1104
	IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1105
										   RSocketServ& aServer,TUint aSockType,
williamr@2
  1106
										   TUint aProtocol);
williamr@2
  1107
	IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1108
										   RSocketServ& aServer,TUint aSockType,
williamr@2
  1109
										   TUint aProtocol);
williamr@2
  1110
	IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1111
										   RSocketServ& aServer,TUint aSockType,
williamr@2
  1112
										   TUint aProtocol, 
williamr@2
  1113
										   RConnection& aConnection);
williamr@2
  1114
	IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1115
										   RSocketServ& aServer,
williamr@2
  1116
										   TUint aSockType,TUint aProtocol, 
williamr@2
  1117
										   RConnection& aConnection);
williamr@2
  1118
	IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1119
										   RSocketServ& aServer,
williamr@2
  1120
										   const TDesC& aName);
williamr@2
  1121
	IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1122
										   RSocketServ& aServer,
williamr@2
  1123
										   const TDesC& aName);
williamr@2
  1124
	IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1125
										   RSocketServ& aServer);
williamr@2
  1126
	IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1127
										   RSocketServ& aServer);
williamr@2
  1128
	IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1129
										   RSocketServ& aServer,
williamr@2
  1130
										   RSocket& aSocket);
williamr@2
  1131
	IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, 
williamr@2
  1132
										   RSocketServ& aServer,
williamr@2
  1133
										   RSocket& aSocket);								
williamr@2
  1134
	IMPORT_C ~CBluetoothSocket();
williamr@2
  1135
williamr@2
  1136
	//Forwarding functions to RSocket
williamr@2
  1137
	IMPORT_C TInt Send(const TDesC8& aDesc,TUint someFlags);
williamr@2
  1138
	IMPORT_C TInt Send(const TDesC8& aDesc,TUint someFlags,TSockXfrLength& aLen);
williamr@2
  1139
	IMPORT_C void CancelSend();
williamr@2
  1140
	IMPORT_C TInt Recv(TDes8& aDesc,TUint flags);
williamr@2
  1141
	IMPORT_C TInt Recv(TDes8& aDesc,TUint flags,TSockXfrLength& aLen);
williamr@2
  1142
	IMPORT_C TInt RecvOneOrMore(TDes8& aDesc,TUint flags,TSockXfrLength& aLen);
williamr@2
  1143
	IMPORT_C void CancelRecv();
williamr@2
  1144
	IMPORT_C TInt Read(TDes8& aDesc);
williamr@2
  1145
	IMPORT_C void CancelRead();
williamr@2
  1146
	IMPORT_C TInt Write(const TDesC8& aDesc);
williamr@2
  1147
	IMPORT_C void CancelWrite();
williamr@2
  1148
	IMPORT_C TInt SendTo(const TDesC8& aDesc,TSockAddr& aSockAddr,TUint flags);
williamr@2
  1149
	IMPORT_C TInt SendTo(const TDesC8& aDesc,TSockAddr& aSockAddr,TUint flags,TSockXfrLength& aLen);
williamr@2
  1150
	IMPORT_C TInt RecvFrom(TDes8& aDesc,TSockAddr& aSockAddr,TUint flags);
williamr@2
  1151
	IMPORT_C TInt RecvFrom(TDes8& aDesc,TSockAddr& aSockAddr,TUint flags,TSockXfrLength& aLen);
williamr@2
  1152
	IMPORT_C TInt Connect(TBTSockAddr& aSockAddr);
williamr@2
  1153
	IMPORT_C TInt Connect(TBTSockAddr& aSockAddr,const TDesC8& aConnectDataOut,TDes8& aConnectDataIn);
williamr@2
  1154
	IMPORT_C TInt Connect(TBTSockAddr& aAddr, TUint16 aServiceBits);
williamr@2
  1155
	IMPORT_C void CancelConnect();
williamr@2
  1156
	IMPORT_C TInt Bind(TSockAddr& aSockAddr);
williamr@2
  1157
	IMPORT_C TInt SetLocalPort(TInt aPort);
williamr@2
  1158
	IMPORT_C TInt Accept(CBluetoothSocket& aBlankSocket);
williamr@2
  1159
	IMPORT_C TInt Accept(CBluetoothSocket& aBlankSocket,TDes8& aConnectData);
williamr@2
  1160
	IMPORT_C void CancelAccept();
williamr@2
  1161
	IMPORT_C TInt Listen(TUint qSize);
williamr@2
  1162
	IMPORT_C TInt Listen(TUint qSize,const TDesC8& aConnectData);
williamr@2
  1163
	IMPORT_C TInt Listen(TUint qSize, TUint16 aServiceBits);
williamr@2
  1164
	IMPORT_C TInt SetOpt(TUint aOptionName,TUint aOptionLevel,TInt aOption);
williamr@2
  1165
	IMPORT_C TInt SetOption(TUint aOptionName,TUint aOptionLevel,const TDesC8& aOption);
williamr@2
  1166
	IMPORT_C TInt GetOpt(TUint aOptionName,TUint aOptionLevel,TDes8& aOption);
williamr@2
  1167
	IMPORT_C TInt GetOpt(TUint aOptionName,TUint aOptionLevel,TInt &aOption);
williamr@2
  1168
	IMPORT_C TInt Ioctl(TUint aLevel, TUint aCommand, TDes8* aDesc);
williamr@2
  1169
	IMPORT_C void CancelIoctl();
williamr@2
  1170
	IMPORT_C TInt GetDisconnectData(TDes8& aDesc);
williamr@2
  1171
	IMPORT_C void LocalName(TSockAddr& aSockAddr);
williamr@2
  1172
	IMPORT_C TUint LocalPort();
williamr@2
  1173
	IMPORT_C void RemoteName(TSockAddr& aSockAddr);
williamr@2
  1174
	IMPORT_C TInt Shutdown(RSocket::TShutdown aHow);
williamr@2
  1175
	IMPORT_C TInt Shutdown(RSocket::TShutdown aHow,const TDesC8& aDisconnectDataOut,TDes8& aDisconnectDataIn);
williamr@2
  1176
	IMPORT_C void CancelAll();
williamr@2
  1177
	IMPORT_C TInt Info(TProtocolDesc& aProtocol);
williamr@2
  1178
	IMPORT_C TInt Name(TName& aName);
williamr@2
  1179
	IMPORT_C TInt Transfer(RSocketServ& aServer, const TDesC& aName);
williamr@2
  1180
williamr@2
  1181
	
williamr@2
  1182
	//Forwarding functions to RBTBaseband
williamr@2
  1183
	IMPORT_C TInt PhysicalLinkState(TUint32& aState);
williamr@2
  1184
	IMPORT_C TInt PreventRoleSwitch();
williamr@2
  1185
	IMPORT_C TInt AllowRoleSwitch();
williamr@2
  1186
	IMPORT_C TInt RequestMasterRole();
williamr@2
  1187
	IMPORT_C TInt RequestSlaveRole();
williamr@2
  1188
	IMPORT_C TInt PreventLowPowerModes(TUint32 aLowPowerModes);
williamr@2
  1189
	IMPORT_C TInt AllowLowPowerModes(TUint32 aLowPowerModes);
williamr@2
  1190
	IMPORT_C TInt ActivateSniffRequester();
williamr@2
  1191
	IMPORT_C TInt ActivateParkRequester();
williamr@2
  1192
	IMPORT_C TInt CancelLowPowerModeRequester();
williamr@2
  1193
	IMPORT_C TInt RequestChangeSupportedPacketTypes(TUint16 aPacketTypes);
williamr@2
  1194
	IMPORT_C TInt ActivateBasebandEventNotifier(TUint32 aEventTypes);
williamr@2
  1195
	IMPORT_C void CancelBasebandEventNotifier();
williamr@2
  1196
	
williamr@2
  1197
	IMPORT_C void SetNotifier(MBluetoothSocketNotifier& aNewNotifier);
williamr@2
  1198
	IMPORT_C TInt SetAutomaticSniffMode(TBool aAutoSniffMode);
williamr@2
  1199
	IMPORT_C TInt SetAutomaticSniffMode(TBool aAutoSniffMode, TInt aIdleSecondsBeforeSniffRequest);
williamr@2
  1200
	IMPORT_C TBool AutomaticSniffMode() const;
williamr@2
  1201
	
williamr@2
  1202
	IMPORT_C void AsyncDelete();
williamr@2
  1203
	
williamr@2
  1204
	//Callback functions called by active object RunLs.
williamr@2
  1205
	// NB These functions kill the active objects that call them (cf mating spiders) 
williamr@2
  1206
	MBluetoothSocketNotifier& Notifier();
williamr@2
  1207
	void HandleConnectCompleteL(TInt aErr);
williamr@2
  1208
	void HandleAcceptCompleteL(TInt aErr);
williamr@2
  1209
	void HandleShutdownCompleteL(TInt aErr);
williamr@2
  1210
	void HandleSendCompleteL(TInt aErr);
williamr@2
  1211
	void HandleReceiveCompleteL(TInt aErr);
williamr@2
  1212
	void HandleIoctlCompleteL(TInt aErr);
williamr@2
  1213
	void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification aEventNotification);
williamr@2
  1214
williamr@2
  1215
	/**
williamr@2
  1216
	@deprecated
williamr@2
  1217
	*/
williamr@2
  1218
	IMPORT_C TInt Ioctl(TUint aCommand,TDes8* aDesc=NULL,TUint aLevel=KLevelUnspecified);
williamr@2
  1219
williamr@2
  1220
	/**
williamr@2
  1221
	@deprecated
williamr@2
  1222
	*/
williamr@2
  1223
	IMPORT_C TInt SetOpt(TUint aOptionName,TUint aOptionLevel,const TDesC8& aOption=TPtrC8(NULL,0));
williamr@2
  1224
public:
williamr@2
  1225
	RSocket& Socket();
williamr@2
  1226
	RSocketServ& SocketServer();
williamr@2
  1227
	RBTBaseband& BTBaseband();
williamr@2
  1228
	CBTBasebandManager& BTBasebandManager();
williamr@2
  1229
williamr@2
  1230
private:
williamr@2
  1231
	CBluetoothSocket(MBluetoothSocketNotifier& aNotifier, RSocketServ& aServer);
williamr@2
  1232
	void ConstructL(TUint aSockType,TUint aProtocol);
williamr@2
  1233
	void ConstructL(TUint aSockType,TUint aProtocol, RConnection& aConnection);
williamr@2
  1234
	void ConstructL(const TDesC& aName);
williamr@2
  1235
	void ConstructL();
williamr@2
  1236
	void ConstructL(RSocket& aSocket);
williamr@2
  1237
	void InitialiseL();
williamr@2
  1238
	static TInt AsyncDeleteCallBack(TAny *aThisPtr);
williamr@2
  1239
	void ConfigureSocket();
williamr@2
  1240
williamr@2
  1241
private:
williamr@2
  1242
	RSocket							iSocket;
williamr@2
  1243
	RSocketServ&					iSockServer;
williamr@2
  1244
	TBTSockAddr						iSockAddr;
williamr@2
  1245
williamr@2
  1246
	MBluetoothSocketNotifier*		iNotifier;
williamr@2
  1247
williamr@2
  1248
	CBTConnecter* 					iBTConnecter;
williamr@2
  1249
	CBTAccepter*					iBTAccepter;
williamr@2
  1250
	CBTShutdowner*					iBTShutdowner;
williamr@2
  1251
	CBTReceiver*					iBTReceiver;	//for read, recv etc
williamr@2
  1252
	CBTSender*						iBTSender;		//for send, write etc
williamr@2
  1253
	CBTIoctler*						iBTIoctler;
williamr@2
  1254
	CBTBasebandChangeEventNotifier* iBTBasebandChangeEventNotifier;
williamr@2
  1255
	TUint32							iNotifierEventMask;
williamr@2
  1256
	TBool							iSending;
williamr@2
  1257
	TBool							iReceiving;
williamr@2
  1258
williamr@2
  1259
	RBTBaseband 					iBTBaseband;
williamr@2
  1260
	CAutoSniffDelayTimer*			iAutoSniffDelayTimer;
williamr@2
  1261
	CBTBasebandManager*				iBTBasebandManager;
williamr@2
  1262
	CBTBasebandChangeEventDelegate*	iBTBasebandChangeEventDelegate;
williamr@2
  1263
	
williamr@2
  1264
	CAsyncCallBack*					iAsyncDestroyer;	//for async deletion
williamr@2
  1265
	};
williamr@2
  1266
williamr@2
  1267
williamr@2
  1268
class MBluetoothSynchronousLinkNotifier
williamr@2
  1269
/** SCO and eSCO link notification events.
williamr@2
  1270
williamr@2
  1271
This allows for notification of Connect, Disconnect, Send and
williamr@2
  1272
Receive events relating to SCO and eSCO links.
williamr@2
  1273
williamr@2
  1274
Mixin class to be used with CBluetoothSynchronousLink
williamr@2
  1275
Note that although the function signatures allow it, these functions should
williamr@2
  1276
not be allowed to leave as the error will be ignored.
williamr@2
  1277
williamr@2
  1278
@publishedAll
williamr@2
  1279
@released
williamr@2
  1280
*/
williamr@2
  1281
	{
williamr@2
  1282
public:
williamr@2
  1283
	/** Notification that a synchronous link (SCO) has been set up
williamr@2
  1284
	
williamr@2
  1285
	 If no error is reported, then the synchronous link is ready for use.
williamr@2
  1286
	 @note 1) Observe that although the function signature allows it, this function should
williamr@2
  1287
	 not be allowed to leave as the error will be ignored.
williamr@2
  1288
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1289
	 CBluetoothSynchronousLink object.
williamr@2
  1290
	 @param aErr the returned error
williamr@2
  1291
	*/
williamr@2
  1292
	virtual void HandleSetupConnectionCompleteL(TInt aErr) = 0;
williamr@2
  1293
williamr@2
  1294
	/** Notification that a synchronous link (SCO) has disconnected
williamr@2
  1295
	
williamr@2
  1296
	 If no error is reported, then the synchronous link has been closed.
williamr@2
  1297
	 @note 1) Observe that although the function signature allows it, this function should
williamr@2
  1298
	 not be allowed to leave as the error will be ignored.
williamr@2
  1299
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1300
	 CBluetoothSynchronousLink object.
williamr@2
  1301
	 @param aErr the returned error
williamr@2
  1302
	*/
williamr@2
  1303
	virtual void HandleDisconnectionCompleteL(TInt aErr) = 0;
williamr@2
  1304
williamr@2
  1305
	/** Notification that a synchronous link (SCO) has been accepted
williamr@2
  1306
	
williamr@2
  1307
	 If no error is reported, then we have accepted a request for a synchronous link.
williamr@2
  1308
	 That synchronous link is ready for use.
williamr@2
  1309
	 @note 1) Observe that although the function signature allows it, this function should
williamr@2
  1310
	 not be allowed to leave as the error will be ignored.
williamr@2
  1311
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1312
	 CBluetoothSynchronousLink object.
williamr@2
  1313
	 @param aErr the returned error
williamr@2
  1314
	*/
williamr@2
  1315
	virtual void HandleAcceptConnectionCompleteL(TInt aErr) = 0;
williamr@2
  1316
williamr@2
  1317
	/** Notification of a send complete event
williamr@2
  1318
	
williamr@2
  1319
	 If no error is reported, then an attempt to send synchronous (SCO) data 
williamr@2
  1320
	 (e.g. voice) over Bluetooth has succeeded.
williamr@2
  1321
	 @note 1) Observe that although the function signature allows it, this function should
williamr@2
  1322
	 not be allowed to leave as the error will be ignored.
williamr@2
  1323
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1324
	 CBluetoothSynchronousLink object.
williamr@2
  1325
	 @param aErr the returned error
williamr@2
  1326
	*/
williamr@2
  1327
	virtual void HandleSendCompleteL(TInt aErr) = 0;
williamr@2
  1328
williamr@2
  1329
	/** Notification of a receive complete event
williamr@2
  1330
	
williamr@2
  1331
	 If no error is reported, then then we have successfully received
williamr@2
  1332
	 a specified quantity of synchronous (SCO) data.
williamr@2
  1333
	 @note 1) Observe that although the function signature allows it, this function should
williamr@2
  1334
	 not be allowed to leave as the error will be ignored.
williamr@2
  1335
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1336
	 CBluetoothSynchronousLink object.
williamr@2
  1337
	 @param aErr the returned error
williamr@2
  1338
	*/
williamr@2
  1339
	virtual void HandleReceiveCompleteL(TInt aErr) = 0;
williamr@2
  1340
	
williamr@2
  1341
    /**
williamr@2
  1342
 	 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
williamr@2
  1343
	 @param aInterface UID of the interface to return
williamr@2
  1344
	 @param aObject the container for another interface as specified by aInterface
williamr@2
  1345
	 */
williamr@2
  1346
	IMPORT_C virtual void MBSLN_ExtensionInterfaceL(TUid aInterface, void*& aObject);	
williamr@2
  1347
	};
williamr@2
  1348
williamr@2
  1349
class CBTSynchronousLinkAttacher;
williamr@2
  1350
class CBTSynchronousLinkDetacher;
williamr@2
  1351
class CBTSynchronousLinkAccepter;
williamr@2
  1352
class CBTSynchronousLinkSender;
williamr@2
  1353
class CBTSynchronousLinkReceiver;
williamr@2
  1354
class CBTSynchronousLinkBaseband;
williamr@2
  1355
williamr@2
  1356
/**
williamr@2
  1357
eSCO 64Kbit link utility constant.
williamr@2
  1358
*/
williamr@2
  1359
static const TUint KBTSync64KBit = (64000 / 8);
williamr@2
  1360
williamr@2
  1361
NONSHARABLE_CLASS(CBluetoothSynchronousLink): public CBase
williamr@2
  1362
/** Provides Bluetooth SCO functionality.
williamr@2
  1363
williamr@2
  1364
This allows Bluetooth SCO (synchronous) link Connect, Disconnect, Send and Receive.
williamr@2
  1365
@publishedAll
williamr@2
  1366
@released
williamr@2
  1367
*/
williamr@2
  1368
	{
williamr@2
  1369
public:
williamr@2
  1370
	IMPORT_C static CBluetoothSynchronousLink* NewL(MBluetoothSynchronousLinkNotifier& aNotifier, 
williamr@2
  1371
											  RSocketServ& aServer);
williamr@2
  1372
	IMPORT_C static CBluetoothSynchronousLink* NewLC(MBluetoothSynchronousLinkNotifier& aNotifier,
williamr@2
  1373
											   RSocketServ& aServer);
williamr@2
  1374
	IMPORT_C ~CBluetoothSynchronousLink();
williamr@2
  1375
williamr@2
  1376
	IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr);
williamr@2
  1377
	IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr, const TUint16 aPacketTypes);
williamr@2
  1378
	IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr, const TBTSyncPackets& aPacketTypes);
williamr@2
  1379
	IMPORT_C void CancelSetup();
williamr@2
  1380
	IMPORT_C TInt Disconnect();
williamr@2
  1381
	IMPORT_C TInt Send(const TDesC8& aData);
williamr@2
  1382
	IMPORT_C void CancelSend();
williamr@2
  1383
	IMPORT_C TInt Receive(TDes8& aData);
williamr@2
  1384
	IMPORT_C void CancelReceive();
williamr@2
  1385
	IMPORT_C TInt AcceptConnection();
williamr@2
  1386
	IMPORT_C TInt AcceptConnection(const TBTSyncPackets& aPacketTypes);
williamr@2
  1387
	IMPORT_C void CancelAccept();
williamr@2
  1388
	
williamr@2
  1389
	IMPORT_C void SetCoding(TUint16 aVoiceSetting);
williamr@2
  1390
	IMPORT_C void SetMaxBandwidth(TBTSyncBandwidth aMaximum);
williamr@2
  1391
	IMPORT_C void SetMaxLatency(TUint16 aLatency);
williamr@2
  1392
	IMPORT_C void SetRetransmissionEffort(TBTeSCORetransmissionTypes aRetransmissionEffort);
williamr@2
  1393
	
williamr@2
  1394
	IMPORT_C TUint16 Coding();
williamr@2
  1395
	IMPORT_C TBTSyncBandwidth Bandwidth();
williamr@2
  1396
	IMPORT_C TUint16 Latency();
williamr@2
  1397
	IMPORT_C TUint8 RetransmissionEffort();
williamr@2
  1398
	
williamr@2
  1399
	IMPORT_C void RemoteName(TSockAddr& aAddr);
williamr@2
  1400
	
williamr@2
  1401
	IMPORT_C void SetNotifier(MBluetoothSynchronousLinkNotifier& aNotifier);
williamr@2
  1402
williamr@2
  1403
	MBluetoothSynchronousLinkNotifier& Notifier();
williamr@2
  1404
    RSocket& SCOSocket();
williamr@2
  1405
	RSocket& ESCOSocket();
williamr@2
  1406
	RSocket& ListeningSCOSocket();
williamr@2
  1407
	RSocket& ListeningESCOSocket();
williamr@2
  1408
	RSocketServ& SocketServer();
williamr@2
  1409
	RBTBaseband& Baseband();
williamr@2
  1410
williamr@2
  1411
	
williamr@2
  1412
	//Callback methods called by active object RunLs.
williamr@2
  1413
	void HandleSetupConnectionCompleteL(TInt aErr, TSCOType aSCOType);
williamr@2
  1414
	void HandleAcceptConnectionCompleteL(TInt aErr, TSCOType aSCOType);
williamr@2
  1415
	void HandleDisconnectionCompleteL(TInt aErr);
williamr@2
  1416
	void HandleSendCompleteL(TInt aErr);
williamr@2
  1417
	void HandleReceiveCompleteL(TInt aErr);
williamr@2
  1418
williamr@2
  1419
private:
williamr@2
  1420
	CBluetoothSynchronousLink(MBluetoothSynchronousLinkNotifier& aNotifier, RSocketServ& aServer);
williamr@2
  1421
	void ConstructL();
williamr@2
  1422
	void UpdateLinkParams(TSCOType aSCOType);
williamr@2
  1423
	TInt LinkUp(TBTDevAddr aAddr);
williamr@2
  1424
	void LinkDown();
williamr@2
  1425
williamr@2
  1426
private:
williamr@2
  1427
	CBTSynchronousLinkSender*			iBTSynchronousLinkSenderSCO;
williamr@2
  1428
	CBTSynchronousLinkSender*			iBTSynchronousLinkSenderESCO;
williamr@2
  1429
	CBTSynchronousLinkReceiver*			iBTSynchronousLinkReceiverSCO;
williamr@2
  1430
	CBTSynchronousLinkReceiver*			iBTSynchronousLinkReceiverESCO;
williamr@2
  1431
	CBTSynchronousLinkAccepter*			iBTSynchronousLinkAccepterSCO;
williamr@2
  1432
	CBTSynchronousLinkAccepter*			iBTSynchronousLinkAccepterESCO;
williamr@2
  1433
	CBTSynchronousLinkAttacher* 		iBTSynchronousLinkAttacherSCO;
williamr@2
  1434
	CBTSynchronousLinkAttacher* 		iBTSynchronousLinkAttacherESCO;
williamr@2
  1435
	CBTSynchronousLinkDetacher* 		iBTSynchronousLinkDetacherSCO;
williamr@2
  1436
	CBTSynchronousLinkDetacher* 		iBTSynchronousLinkDetacherESCO;
williamr@2
  1437
	CBTSynchronousLinkBaseband*			iBTSynchronousLinkBaseband;
williamr@2
  1438
	MBluetoothSynchronousLinkNotifier*	iNotifier;
williamr@2
  1439
	RSocket								iSCOSocket;
williamr@2
  1440
	RSocket								iESCOSocket;
williamr@2
  1441
	RSocket 							iListeningSCOSocket;
williamr@2
  1442
	RSocket 							iListeningESCOSocket;
williamr@2
  1443
	RBTBaseband							iBaseband;
williamr@2
  1444
	RSocketServ& 						iSockServer;
williamr@2
  1445
	TBTSockAddr 						iSockAddr;
williamr@2
  1446
	TBuf8<1> 							iDummySCOShutdownDescriptor;
williamr@2
  1447
	
williamr@2
  1448
	TBTeSCOLinkParams					iRequestedLink;
williamr@2
  1449
	TBTeSCOLinkParams					iNegotiatedLink;
williamr@2
  1450
	
williamr@2
  1451
	TUint8		 						iSCOTypes;
williamr@2
  1452
	
williamr@2
  1453
	TBool								iOpeningSCO;
williamr@2
  1454
	TBool								iOpeningESCO;
williamr@2
  1455
	TBool								iOpenedSCO;
williamr@2
  1456
	};
williamr@2
  1457
williamr@2
  1458
williamr@2
  1459
class MBluetoothPhysicalLinksNotifier
williamr@2
  1460
/** This allows for notifications of Physical link connections & disconnections
williamr@2
  1461
williamr@2
  1462
Mixin class to be used with CBluetoothPhysicalLinks
williamr@2
  1463
williamr@2
  1464
williamr@2
  1465
@publishedAll
williamr@2
  1466
@released
williamr@2
  1467
*/
williamr@2
  1468
	{
williamr@2
  1469
public:
williamr@2
  1470
	/** Notification of a requested connection coming up
williamr@2
  1471
	
williamr@2
  1472
	 If no error is reported, then that connection is ready for use.
williamr@2
  1473
	 @note 1) While this function may leave, any errors are ignored.  Implementers are
williamr@2
  1474
	 responsible for performing their own cleanup prior to exiting the function.	 
williamr@2
  1475
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1476
	 CBluetoothPhysicalLinks object.
williamr@2
  1477
	 
williamr@2
  1478
	 @param aErr the returned error
williamr@2
  1479
	*/
williamr@2
  1480
	virtual void HandleCreateConnectionCompleteL(TInt aErr) = 0;
williamr@2
  1481
williamr@2
  1482
	/** Notification of a requested disconnection having taken place
williamr@2
  1483
	
williamr@2
  1484
	 If no error is reported, then that connection has been closed.
williamr@2
  1485
	 @note 1) While this function may leave, any errors are ignored.  Implementers are
williamr@2
  1486
	 responsible for performing their own cleanup prior to exiting the function.
williamr@2
  1487
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1488
	 CBluetoothPhysicalLinks object.
williamr@2
  1489
	 @param aErr the returned error
williamr@2
  1490
	*/
williamr@2
  1491
	virtual void HandleDisconnectCompleteL(TInt aErr) = 0;
williamr@2
  1492
williamr@2
  1493
	/** Notification that all existing connections have been torn down
williamr@2
  1494
	
williamr@2
  1495
	 If no error is reported, then there are no Bluetooth connections existing.
williamr@2
  1496
	 @note 1) While this function may leave, any errors are ignored.  Implementers are
williamr@2
  1497
	 responsible for performing their own cleanup prior to exiting the function.
williamr@2
  1498
	 @note 2) The implementation of this function should NOT be used to delete the associated 
williamr@2
  1499
	 CBluetoothPhysicalLinks object.
williamr@2
  1500
	 @param aErr the returned error
williamr@2
  1501
	*/
williamr@2
  1502
	virtual void HandleDisconnectAllCompleteL(TInt aErr) = 0;
williamr@2
  1503
williamr@2
  1504
    /**
williamr@2
  1505
 	 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
williamr@2
  1506
	 @param aInterface UID of the interface to return
williamr@2
  1507
	 @param aObject the container for another interface as specified by aInterface
williamr@2
  1508
	 */
williamr@2
  1509
	IMPORT_C virtual void MBPLN_ExtensionInterfaceL(TUid aInterface, void*& aObject);	
williamr@2
  1510
	};
williamr@2
  1511
williamr@2
  1512
williamr@2
  1513
class CBTBasebandConnecter;
williamr@2
  1514
class CBTBasebandShutdowner;
williamr@2
  1515
class CBTDisconnector;
williamr@2
  1516
williamr@2
  1517
NONSHARABLE_CLASS(CBluetoothPhysicalLinks): public CBase
williamr@2
  1518
/** This is used to enumerate members of piconet, and attach and remove members thereof
williamr@2
  1519
williamr@2
  1520
It may also be used for non-service dependent reads and writes.
williamr@2
  1521
@publishedAll
williamr@2
  1522
@released
williamr@2
  1523
*/
williamr@2
  1524
	{
williamr@2
  1525
public:
williamr@2
  1526
	IMPORT_C static CBluetoothPhysicalLinks* NewL(MBluetoothPhysicalLinksNotifier& aNotifier,
williamr@2
  1527
											      RSocketServ& aServer);
williamr@2
  1528
	IMPORT_C static CBluetoothPhysicalLinks* NewLC(MBluetoothPhysicalLinksNotifier& aNotifier,
williamr@2
  1529
											      RSocketServ& aServer);
williamr@2
  1530
	IMPORT_C ~CBluetoothPhysicalLinks();
williamr@2
  1531
williamr@2
  1532
	IMPORT_C TInt CreateConnection(const TBTDevAddr& aDevAddr);
williamr@2
  1533
	IMPORT_C void CancelCreateConnection();
williamr@2
  1534
	IMPORT_C TInt Disconnect(const TBTDevAddr& aDevAddr);
williamr@2
  1535
	IMPORT_C TInt DisconnectAll();
williamr@2
  1536
	
williamr@2
  1537
	IMPORT_C TInt Broadcast(const TDesC8& aData);
williamr@2
  1538
	IMPORT_C TInt ReadRaw(TDes8& aData);
williamr@2
  1539
	IMPORT_C TInt Enumerate(RBTDevAddrArray& aBTDevAddrArray, TUint aMaxNumber);
williamr@2
  1540
williamr@2
  1541
	
williamr@2
  1542
	//Callback methods called by active object RunLs.
williamr@2
  1543
	//NB These methods kill the active objects that call them
williamr@2
  1544
	/**
williamr@4
  1545
	This method is for internal sub-system use only and should be not be used otherwise.
williamr@2
  1546
	@internalTechnology
williamr@2
  1547
	*/
williamr@2
  1548
	void HandleCreateConnectionCompleteL(TInt aErr);
williamr@2
  1549
	/**
williamr@4
  1550
	This method is for internal sub-system use only and should be not be used otherwise.
williamr@2
  1551
	@internalTechnology
williamr@2
  1552
	*/
williamr@2
  1553
	void HandleDisconnectCompleteL(TInt aErr);
williamr@2
  1554
	/**
williamr@4
  1555
	This method is for internal sub-system use only and should be not be used otherwise.
williamr@2
  1556
	@internalTechnology
williamr@2
  1557
	*/
williamr@2
  1558
	void HandleDisconnectAllCompleteL(TInt aErr);
williamr@2
  1559
williamr@2
  1560
	/**
williamr@4
  1561
	This method is for internal sub-system use only and should be not be used otherwise.
williamr@2
  1562
	@internalTechnology
williamr@2
  1563
	*/
williamr@2
  1564
	RSocketServ& SockServer();
williamr@2
  1565
	/**
williamr@4
  1566
	This method is for internal sub-system use only and should be not be used otherwise.
williamr@2
  1567
	@internalTechnology
williamr@2
  1568
	*/
williamr@2
  1569
	RBTBaseband& BTBaseband();
williamr@2
  1570
	/**
williamr@4
  1571
	This method is for internal sub-system use only and should be not be used otherwise.
williamr@2
  1572
	@internalTechnology
williamr@2
  1573
	*/
williamr@2
  1574
	MBluetoothPhysicalLinksNotifier& Notifier();
williamr@2
  1575
williamr@2
  1576
williamr@2
  1577
private:
williamr@2
  1578
	CBluetoothPhysicalLinks(MBluetoothPhysicalLinksNotifier& aNotifier, 
williamr@2
  1579
							RSocketServ& aServer);
williamr@2
  1580
	void ConstructL();
williamr@2
  1581
williamr@2
  1582
private:
williamr@2
  1583
	CBTBasebandConnecter* iBTBasebandConnecter;
williamr@2
  1584
	CBTDisconnector* iBTDisconnector;
williamr@2
  1585
	MBluetoothPhysicalLinksNotifier& iNotifier;
williamr@2
  1586
	RSocketServ& iSockServer;
williamr@2
  1587
	RBTBaseband iBTBaseband;
williamr@2
  1588
	};
williamr@2
  1589
williamr@2
  1590
#endif