1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // BT socket interface types
27 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
29 #include <bluetooth/lmoptions.h>
32 #include <bluetooth/btscoparams.h>
33 #include <bluetooth/btbaseband.h>
34 #include <btsocketoptionlevels.h>
39 #include <d32comm.h> // for RS232 signal names for RFCOMM
40 #include <bluetooth/hci/hcierrors.h>
41 #include <btmanclient.h>
42 #include <bt_subscribe.h>
43 #include <btsockaddr.h>
44 #include <btsecurity.h>
45 #include <btbasebandpolicy.h>
46 #include <btsyncbandwidth.h>
50 _LIT(KRFCOMMDesC,"RFCOMM"); /*!< Descriptor name for RFCOMM */
52 _LIT(KL2CAPDesC,"L2CAP"); /*!< Descriptor name for L2CAP */
58 const TUint KBTAddrFamily = 0x101; /*!< BT Address Family */
60 const TUint KBTLinkManager = 0x0099; /*!< Protocol Number for Link Manager */
61 const TUint KL2CAP = 0x0100; /*!< Protocol Number for L2CAP */
62 const TUint KRFCOMM = 0x0003; /*!< Protocol Number for RFCOMM */
63 const TUint KSDP = 0x0001; /*!< Protocol Number for SDP */
64 const TUint KAVCTP = 0x0017; /*!< Protocol Number for AVCTP */
65 const TInt KTCIL2CAP = 0xF100; /*!< Protocol Number for TCI L2CAP */
67 const TInt KBTMajor = 0; /*!< BT version number for major version */
68 const TInt KBTMinor = 1; /*!< BT version number for minor version */
69 const TInt KBTBuild = 1; /*!< BT version number for build version */
71 // The Socket Options are now in btsocketoptionlevels.h
73 const static TUint8 KSCOListenQueSize = 1; /*!< Length of SCO listening queue */
75 const static TUint16 KL2MinMTU = 48; /*!< BT Spec defined min. supported MTU size */
78 // All PSM values must be ODD, that is, the least significant bit of the least significant
79 // octet must be '1'. Also, all PSM values must be assigned such that the
80 // least significant bit of the most significant octet equals '0'.
81 const static TUint16 KMaxPSM = 0xFEFF; /*!< Max L2CAP PSM value */
84 * This is the minimum user PSM. Smaller PSM values are possible but are reserved for use by the
85 * Bluetooth stack only.
87 const static TUint16 KMinUserPSM = 0x1001;
90 * This constant has been deprecated since its name is misleading becasue it doesn't represent the
91 * absolute minimum PSM but the minimum user PSM instead.
92 * Use KMinUserPSM instead of this constant.
95 const static TUint16 KMinPSM = 0x1001;
97 const static TInt KErrBtEskError = -6999; /*!< BT ESK error code */
100 // Options available for all Bluetooth protocols
105 /** Override device security */
106 KBTRegisterCodService = 0x998, /*!< Set a CoD Service bit(s) */
107 KBTSecurityDeviceOverride = 0x999,
110 typedef TPckgBuf<TBTServiceSecurityPerDevice> TBTServiceSecurityPerDeviceBuf; /*!< Package definition for securty settings */
113 // Link manager error codes.
114 const static TInt KLinkManagerErrBase = -6450; /*!< Link manager base error value */
115 const static TInt KErrInsufficientBasebandResources = KLinkManagerErrBase; /*!< Insufficient baseband resources error value */
116 const static TInt KErrProxyWriteNotAvailable = KLinkManagerErrBase-1; /*!< Proxy write not available error value */
117 const static TInt KErrReflexiveBluetoothLink = KLinkManagerErrBase-2; /*!< Reflexive BT link error value */
118 const static TInt KErrPendingPhysicalLink = KLinkManagerErrBase-3; /*!< Physical link connection already pending when trying to connect the physical link */
119 const static TInt KErrRemoteDeviceIndicatedNoBonding = KLinkManagerErrBase-4; /*!< Dedicated bonding attempt failure when the remote device responds with No-Bonding */
125 const static TInt KL2CAPErrBase = -6300; /*!< Base error value for L2CAP error codes */
126 const static TInt KErrBadAddress = KL2CAPErrBase; /*!< L2CAP Bad address error code */
127 const static TInt KErrSAPUnexpectedEvent = KL2CAPErrBase - 1; /*!< L2CAP unexpected SAP event error code */
128 const static TInt KErrBadPacketReceived = KL2CAPErrBase - 2; /*!< L2CAP bad packet received error code */
129 const static TInt KErrL2CAPBadResponse = KL2CAPErrBase - 3; /*!< L2CAP bad response error code */
130 const static TInt KErrHCIConnectFailed = KL2CAPErrBase - 4; /*!< L2CAP HCI connection failed error code */
131 const static TInt KErrHCILinkDisconnection = KL2CAPErrBase - 5; /*!< L2CAP HCI link disconnection error code */
132 const static TInt KErrSAPNotConnected = KL2CAPErrBase - 6; /*!< L2CAP SAP not connected error code */
133 const static TInt KErrConfigBadParams = KL2CAPErrBase - 7; /*!< L2CAP bad configuration parameters error code */
134 const static TInt KErrConfigRejected = KL2CAPErrBase - 8; /*!< L2CAP configuration rejected error code */
135 const static TInt KErrConfigUnknownOptions = KL2CAPErrBase - 9; /*!< L2CAP unknown configuration options error code */
136 const static TInt KErrL2PeerDisconnected = KL2CAPErrBase - 10; /*!< L2CAP peer disconnected error code */
137 const static TInt KErrL2CAPAccessRequestDenied = KL2CAPErrBase - 11; /*!< L2CAP access request denied error code */
138 const static TInt KErrL2CAPRequestTimeout = KL2CAPErrBase - 12; /*!< L2CAP request timeout error code */
139 const static TInt KErrL2PeerRejectedCommand = KL2CAPErrBase - 13; /*!< L2CAP peer rejected command error code */
140 const static TInt KErrHostResNameTooLong = KL2CAPErrBase - 14; /*!< L2CAP host resolver name too long error code */
141 const static TInt KErrL2CAPNoMorePSMs = KL2CAPErrBase - 15; /*!< L2CAP no more PSMs error code */
142 const static TInt KErrL2CAPMaxTransmitExceeded = KL2CAPErrBase - 16; /*!< L2CAP in reliable mode: the maximum L2Cap retransmissions have been made and channel will disconnect error code*/
143 const static TInt KErrL2CAPDataControllerDetached = KL2CAPErrBase - 17; /*!< L2CAP problems (e.g. no memory) whilst sending data error code*/
144 const static TInt KErrL2CAPConfigPending = KL2CAPErrBase - 18; /*!< L2CAP configuration is in progress error code
146 const static TInt KErrL2CAPConfigAlreadyInProgress = KL2CAPErrBase - 19;/*!< L2CAP attempt to alter config whilst configuration is in progress error code*/
147 const static TInt KErrL2CAPNoFreeCID = KL2CAPErrBase - 21; /*!< L2CAP no more channel IDs available error code*/
148 const static TInt KErrL2CAPPeerDoesNotSupportRequestedChannelMode = KL2CAPErrBase - 22; /*!< L2CAP peer doesn't support channel modes satisfying requested channel configuration. */
149 const static TInt KErrL2CAPInvalidPacketSequenceNumber = KL2CAPErrBase - 23; /*!< L2CAP packet with an invalid sequence number was received */
150 const static TInt KErrL2CAPInvalidAcknowledgementNumber = KL2CAPErrBase - 24; /*!< L2CAP invalid acknowledgment number was received */
151 const static TInt KErrL2CAPIllegalRemoteBehavior = KL2CAPErrBase - 25; /*!< L2CAP remote broke the L2CAP specification */
152 const static TInt KErrL2CAPNegotiatedDifferentModesForEachDirection = KL2CAPErrBase - 26; /*!< L2CAP different channel modes were negotiated for incoming and outgoing direction */
153 const static TInt KErrL2CAPIncomingSduSegmentationError = KL2CAPErrBase - 27; /*!< L2CAP received I-Frame does not match the sequence of start, continuation, end of SDU */
154 const static TInt KErrL2CAPIncomingSduTooBig = KL2CAPErrBase - 28; /*!< L2CAP received SDU size is larger than the negotiated MTU */
155 const static TInt KErrL2CAPIncomingIFrameTooSmall = KL2CAPErrBase - 29; /*!< L2CAP Incoming I-Frame size is too small */
156 const static TInt KErrL2CAPIncomingIFrameTooBig = KL2CAPErrBase - 30; /*!< L2CAP Incoming I-Frame information payload is larger than the negotiated MPS */
157 const static TInt KErrL2CAPInvalidIncomingSFrameSize = KL2CAPErrBase - 31; /*!< L2CAP Incoming S-Frame size is incorrect */
158 const static TInt KErrL2CAPAttemptToSetMinMtuGreaterThanMtu = KL2CAPErrBase - 32; /*!< L2CAP An attempt to configure minimal acceptable MTU that's larger than the preferred MTU was made */
159 const static TInt KErrL2CAPAttemptToSetMinMruGreaterThanMru = KL2CAPErrBase - 33; /*!< L2CAP An attempt to configure minimal acceptable MRU that's larger than the preferred MRU was made */
162 const static TInt KErrHostResNoMoreResults = KErrEof; /*!< Host resolver has no more results error code */
163 const static TUint KHostResInquiry = 1; /*!< Host resolver inquiry option */
164 const static TUint KHostResName = 2; /*!< Host resolver name option. This is mutually exclusive with KHostResEir */
165 const static TUint KHostResIgnoreCache = 16; /*!< A way of ignoring the cache */
166 const static TUint KHostResCache = 32; /*!< A way to get CoD from cache */
167 const static TUint KHostResEir = 64; /*!< Host resolver Eir option. This is mutually exclusive with KHostResName */
170 const static TInt KL2CAPEchoRequestIoctl = 0; /*!< Echo Request Ioctl name */
171 const static TInt KL2CAPIncomingMTUIoctl = 1; /*!< Change incoming MTU Ioctl name */
172 const static TInt KL2CAPOutgoingMTUIoctl = 2; /*!< Change outgoing MTU Ioctl name */
173 const static TInt KL2CAPUpdateChannelConfigIoctl = 3; /*!< Change configuration parameters Ioctl name */
174 const static TInt KL2CAPPretendIncomingSduQFull = 4; /*!< Pretend incoming SDU Queue is full - internal testing only @internalComponent */
176 struct TLMDisconnectACLIoctl
178 Structure to specify the remote ACL connection to disconnect.
179 The reason passed in iReason will be sent to the remote device.
181 Use with KLMDisconnectACLIoctl.
185 TBTDevAddr iDevAddr; /*!< Device address */
186 TUint8 iReason; /*!< Reason code */
189 typedef TPckgBuf<TLMDisconnectACLIoctl> TLMDisconnectACLBuf; /*!< Package for TLMDisconnectACLIoctl structure */
191 // private tokens for use by RBTBaseband facade and stack
192 _LIT8(KDisconnectOnePhysicalLink, "1"); /*!< Specifes one physical link should be disconnected */
193 _LIT8(KDisconnectAllPhysicalLinks, "A"); /*!< Specifes all physical links should be disconnected */
196 /** Add SCO connnection Ioctl
199 static const TUint KLMAddSCOConnIoctl =0;
200 /** Remove SCO connection Ioctl
203 static const TUint KHCIRemoveSCOConnIoctl =1;
204 /** Change packet types allowed Ioctl
207 static const TUint KHCIChangePacketTypeIoctl =2;
208 /** Request authorisation Ioctl
211 static const TUint KHCIAuthRequestIoctl =3;
212 /** Request encryption Ioctl
215 static const TUint KHCIEncryptIoctl =4;
216 /** Change link key Ioctl
219 static const TUint KHCIChangeLinkKeyIoctl =5;
220 /** Master link key Ioctl
223 static const TUint KHCIMasterLinkKeyIoctl =6;
224 /** Enable hold mode Ioctl
227 static const TUint KHCIHoldModeIoctl =7;
228 /** Enable sniff mode Ioctl
231 static const TUint KHCISniffModeIoctl =8;
232 /** Exit sniff mode Ioctl
235 static const TUint KHCIExitSniffModeIoctl =9;
236 /** Enable park mode Ioctl
239 static const TUint KHCIParkModeIoctl =10;
240 /** Exit park mode Ioctl
243 static const TUint KHCIExitParkModeIoctl =11;
245 /** Read page timeout Ioctl
248 static const TUint KHCIReadPageTimeoutIoctl =12;
249 /** Write page timeout Ioctl
252 static const TUint KHCIWritePageTimeoutIoctl =13;
253 /** Read scan enable Ioctl
257 static const TUint KHCIReadScanEnableIoctl =14;
258 /** Write scan enable Ioctl
262 static const TUint KHCIWriteScanEnableIoctl =15;
263 /** Read device class Ioctl
267 static const TUint KHCIReadDeviceClassIoctl =16;
268 /** Write device class Ioctl
272 static const TUint KHCIWriteDeviceClassIoctl =17;
273 /** Read voice settings Ioctl
276 static const TUint KHCIReadVoiceSettingIoctl =18;
277 /** Write voice settings Ioctl
280 static const TUint KHCIWriteVoiceSettingIoctl =19;
281 /** Read hold mode activity Ioctl
284 static const TUint KHCIReadHoldModeActivityIoctl=20;
285 /** Write hold mode activity Ioctl
288 static const TUint KHCIWriteHoldModeActivityIoctl=21;
289 /** Local version Ioctl
292 static const TUint KHCILocalVersionIoctl =22;
293 /** Local features Ioctl
296 static const TUint KHCILocalFeaturesIoctl =23;
297 /** Country code Ioctl
300 static const TUint KHCICountryCodeIoctl =24;
301 /** Local address Ioctl
305 static const TUint KHCILocalAddressIoctl =25;
306 /** Write discoverability Ioctl
310 static const TUint KHCIWriteDiscoverabilityIoctl=26;
311 /** Read discoverability Ioctl
315 static const TUint KHCIReadDiscoverabilityIoctl =27;
316 /** Read authentification enabled Ioctl
319 static const TUint KHCIReadAuthenticationEnableIoctl=33;
320 /** Write authentification enabled Ioctl
323 static const TUint KHCIWriteAuthenticationEnableIoctl=34;
326 // Structs for ioctl parameters
329 Enumerations for the four possible scan enable modes.
330 Use Inquiry scan for discoverability and Page scan for
333 Use with KHCIReadScanEnableIoctl and KHCIWriteScanEnableIoctl.
337 enum THCIScanEnableIoctl
339 EHCINoScansEnabled=0x00, /*!< No scans enabled. */
340 EHCIInquiryScanOnly, /*!< Inquiry scan only. */
341 EHCIPageScanOnly, /*!< Page scan only. */
342 EHCIInquiryAndPageScan /*!< Both inquiry and page scan enabled. */
345 Package for THCIScanEnableIoctl structure
348 typedef TPckgBuf<THCIScanEnableIoctl> THCIScanEnableBuf;
350 struct TLMAddSCOConnectionIoctl
352 Structure for specifying SCO type to add to a connected socket.
353 The connection handle for the SCO link is returned in iConnH when
356 Use with KHCIAddSCOConnIoctl.
360 TUint16 iPktType; /*!< Packet type */
363 Package for TLMAddSCOConnectionIoctl structure
366 typedef TPckgBuf<TLMAddSCOConnectionIoctl> TLMAddSCOConnectionBuf;
368 struct THCISetEncryptionIoctl
370 Request to change the encryption state of a connection.
371 iEncrypt specifies whether to turn encryption on or off.
373 Use with KHCIEncryptIoctl.
377 TBool iEncrypt; /*!< Encryption enabled / disabled */
380 Package for THCISetEncryptionIoctl structure
383 typedef TPckgBuf<THCISetEncryptionIoctl> THCISetEncryptionBuf;
385 struct THCIDeviceClassIoctl
387 Structure to specify the class of device when getting or setting
388 the local device class.
390 Use with KHCIReadDeviceClassIoctl and KHCIWriteDeviceClassIoctl.
395 TUint16 iMajorServiceClass; /*!< Major Service class */
396 TUint8 iMajorDeviceClass; /*!< Major Device class */
397 TUint8 iMinorDeviceClass; /*!< Minor Device class */
400 Package for THCIDeviceClassIoctl structure
403 typedef TPckgBuf<THCIDeviceClassIoctl> THCIDeviceClassBuf;
405 struct THCILocalVersionIoctl
407 Structure describing the local Bluetooth hardware version.
409 Use with KHCILocalVersionIoctl.
413 TUint8 iHCIVersion; /*!< HCI version */
414 TUint16 iHCIRevision; /*!< HCI Revision */
415 TUint8 iLMPVersion; /*!< LMP version */
416 TUint16 iLMPSubversion; /*!< LMP subversion */
417 TUint16 iManufacturerName; /*!< Manufacturer name */
420 Package for THCILocalVersionIoctl structure
423 typedef TPckgBuf<THCILocalVersionIoctl> THCILocalVersionBuf;
425 /** L2CAP Get / Set Options. */
429 Get the outbound MTU size taking into account both the negotiated MTU size
430 and best use of underlying packet sizes.
431 For example: If the default outgoing MTU of 672 has been negotiated for a L2CAP channel
432 that is in Retransmission or Flow control mode then this GetOpt will return an
433 outgoing MTU of 668 bytes. This allows a maximally sized SDU
434 (which due to this adjustment will be 668 bytes) to be sent in two DH5 packets.
435 KL2CAPOutboundMTUForBestPerformance may also be used to set the current negotiated
436 (or to be negotiated) outbound MTU size.
437 Note that the outbound MTU size returned when using KL2CAPOutboundMTUForBestPerformance
438 with a GetOpt may not be the same as the outbound MTU size previously set
439 when using KL2CAPOutboundMTUForBestPerformance with a SetOpt.
441 KL2CAPOutboundMTUForBestPerformance,
444 This is the legacy value for setting getting \ setting the outbound MTU size and behaves
445 in the same way as KL2CAPOutboundMTUForBestPerformance.
446 @see KL2CAPOutboundMTUForBestPerformance
448 KL2CAPGetOutboundMTU = KL2CAPOutboundMTUForBestPerformance,
450 KL2CAPGetDebug1, /*!< Debug Command */
451 KL2CAPInboundMTU, /*!< Get / Set the current inbound MTU size */
452 KL2CAPRTXTimer, /*!< Change the extended L2CAP command retransmission timeout */
453 KL2CAPERTXTimer, /*!< Change the L2CAP command retransmission timeout */
454 KL2CAPGetMaxOutboundMTU, /*!< Get the max outbound MTU supported by the stack */
455 KL2CAPGetMaxInboundMTU, /*!< Get the max inbound MTU supported by the stack */
456 KL2CAPUpdateChannelConfig, /*!< Get and Set the current configuration parameters */
458 /** Get / Set the current negotiated (or to be negotiated) outbound MTU size */
459 KL2CAPNegotiatedOutboundMTU,
462 KL2CAPDebugFlush, // not implemented anymore, just a placeholder for BC
465 KL2CAPDataPlaneConfig,
468 This is similar to KL2CAPOutboundMTUForBestPerformance except that the caller can specify
469 a restriction that the returned MTU shall not exceed. This is useful for layers above L2CAP
470 that still want an optimal MTU but have their own restrictions on packet size.
472 KL2CAPOutboundMTUForBestPerformanceWithRestriction,
473 KL2CAPLocalPSM, /*!< Return local PSM of the socket (only works before the socket is accepted, stack internal use only) @internalTechnology */
474 KL2CAPNegotiatedChannelMode /*!< Get the negotiated L2CAP channel mode */
477 typedef TUint16 TL2CAPPort; /*!< Definition of a L2CAP port number type */
479 const static TL2CAPPort KL2CAPPassiveAutoBind = KMaxTUint16; /*!< PSM out of the valid range used for passive auto bind operation */
481 NONSHARABLE_CLASS(TL2CAPSockAddr) : public TBTSockAddr
482 /** L2CAP Socket Address.
484 Use this class to specify a local or remote L2CAP connection end-point,
485 that is Device Address and PSM/CID.
486 When unconnected, the Port() specifies the PSM, once connected it refers to
494 IMPORT_C TL2CAPSockAddr();
495 IMPORT_C TL2CAPSockAddr(const TSockAddr& aSockAddr);
496 IMPORT_C static TL2CAPSockAddr& Cast(const TSockAddr& aSockAddr);
498 IMPORT_C TL2CAPPort Port() const;
499 IMPORT_C void SetPort(const TL2CAPPort aHomePort);
502 NONSHARABLE_CLASS(TInquirySockAddr) : public TSockAddr
503 /** Socket address class used for inquiries.
505 Used to specify the inquiry request, and then filled with information
506 about remote devices discovered through the inquiry process.
508 Use the BTAddr() method to extract the device address to connect to.
511 Note: Usage of RHostResolver class for Bluetooth protocol.
513 The RHostResolver class is a generic interface to host name
514 resolution services, such as DNS, that may be provided
515 by particular protocol modules.
517 The points to remember when using RHostResolver::GetByAddress(),
518 RHostResolver::GetByName(), or RHostResolver::Next()
519 with Bluetooth protocol are:
521 1) If you operate on one instance of RHostResolver you can perform
522 only one request by calling either RHostResolver::GetByAddress()
523 or RHostResolver::GetByName(). If these functions are called again
524 and if there is more than one possible response for a given host name
525 then that will be returned (The host resolving process will
526 not start from the beginning). It is exactly as if the RHostResolve::Next()
529 2) In order to start resolving new hosts from the beginning using the same
530 instance of RHostResolver, the instance must be closed and reopened again.
532 3) In order to perform several RHostResolver requests they should be issued on
533 separate instances of RHostResolver (many RHostResolver instances might
534 exist and perform requests at the same time).
536 4) The KHostResIgnoreCache flag is only valid when issuing RHostResolver::GetByAddress()
537 or RHostResolver::GetByName() request for the first time.
539 5) As an RHostResolver is only intended to be used once, it is recommended that it
540 be closed as soon as it is finished with as the semantics of Cancel merely
541 indicates that one client server request should be cancelled.
547 // Max size for this structure is 24 bytes (32 - 8, see TSockAddr). However, due to padding and to prevent BC breaks,
548 // only up to 3 TUint8(s) may be added after iFlags
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)
553 TUint16 iMajorServiceClass;
554 TUint8 iMajorDeviceClass;
555 TUint8 iMinorDeviceClass;
563 // This defines all the bit masks for the inquiry result
564 enum TResolverResultFlags
570 IMPORT_C TInquirySockAddr();
571 IMPORT_C TInquirySockAddr(const TSockAddr& aSockAddr);
572 IMPORT_C TBTDevAddr BTAddr() const;
573 IMPORT_C void SetBTAddr(const TBTDevAddr& aRemote);
575 IMPORT_C static TInquirySockAddr& Cast(const TSockAddr& aSockAddr);
576 IMPORT_C TUint16 MajorServiceClass() const;
577 IMPORT_C void SetMajorServiceClass(TUint16 aClass);
578 IMPORT_C TUint8 MajorClassOfDevice() const;
579 IMPORT_C void SetMajorClassOfDevice(TUint8 aMajorClassOfDevice);
580 IMPORT_C TUint8 MinorClassOfDevice() const;
581 IMPORT_C void SetMinorClassOfDevice(TUint8 aMinorClassOfDevice);
582 IMPORT_C TUint IAC() const;
583 IMPORT_C void SetIAC(const TUint aIAC);
584 IMPORT_C TUint8 Action() const;
585 IMPORT_C void SetAction(TUint8 aFlags);
586 IMPORT_C TVersion Version() const;
587 IMPORT_C TInt8 Rssi() const;
588 IMPORT_C void SetRssi(const TInt8 aRssi);
589 IMPORT_C TUint8 ResultFlags() const;
590 IMPORT_C void SetResultFlags(TUint8 aResultFlags);
593 void SetVersion(TVersion aVersion);
594 IMPORT_C TUint8 FormatTypeField() const;
595 void SetFormatTypeField(TUint8 aType);
598 SInquiryAddr& InquiryAddrStruct() const;
599 TPtr8 AddressPtr() const;
606 const static TInt KRFErrorBase = -6350; /*!< RFCOMM base error code. */
607 const static TInt KErrRfcommSAPUnexpectedEvent = KRFErrorBase; /*!< RFCOMM unexpected event error code. */
608 const static TInt KErrRfcommAlreadyBound = KRFErrorBase-1; /*!< RFCOMM SAP already bound error code. */
609 const static TInt KErrRfcommBadAddress = KRFErrorBase-2; /*!< RFCOMM bad address error code. */
610 const static TInt KErrRfcommMTUSize = KRFErrorBase-3; /*!< RFCOMM MTU size exceeded error code. */
611 const static TInt KErrRfcommFrameResponseTimeout = KRFErrorBase-4; /*!< RFCOMM frame response timeout error code. */
612 const static TInt KErrRfcommMuxRemoteDisconnect = KRFErrorBase-5; /*!< RFCOMM remote end disconnected error code. */
613 const static TInt KErrRfcommNotBound = KRFErrorBase-6; /*!< RFCOMM SAP not bound error code. */
614 const static TInt KErrRfcommParameterNegotiationFailure = KRFErrorBase-7; /*!< RFCOMM parameter negotiation failure error code. */
615 const static TInt KErrRfcommNotListening = KRFErrorBase-8; /*!< RFCOMM not listening error code. */
616 const static TInt KErrRfcommNoMoreServerChannels = KRFErrorBase-9; /*!< RFCOMM no more server channels available error code. */
620 const static TInt KRFCOMMModemStatusCmdIoctl =0; /*!< RFCOMM status command Ioctl */
621 const static TInt KRFCOMMRemoteLineStatusCmdIoctl = 1; /*!< RFCOMM remote line status command Ioctl */
622 const static TInt KRFCOMMRemotePortNegCmdIoctl = 2; /*!< RFCOMM remote port negotiation command Ioctl */
623 const static TInt KRFCOMMRemotePortNegRequestIoctl = 3; /*!< RFCOMM remote port negotiation request Ioctl */
624 const static TInt KRFCOMMConfigChangeIndicationIoctl = 4; /*!< RFCOMM MSC activity Ioctl */
628 const static TInt KRFCOMMLocalPortParameter = 0; /*!< RFCOMM local port parameter option (Get + Set) */
629 /** RFCOMM Get Available server channel option (Get only)
632 const static TInt KRFCOMMGetAvailableServerChannel = 1;
634 const static TInt KRFCOMMMaximumSupportedMTU = 2; /*!< RFCOMM maximum supported option (Get + Set) */
635 const static TInt KRFCOMMGetDebug1 = 3; /*!< RFCOMM debug option (Get only) */
636 const static TInt KRFCOMMGetRemoteModemStatus = 4; /*!< RFCOMM remote modem status option (Get + Set) */
638 const static TInt KRFCOMMGetTransmitCredit = 5; /*!< RFCOMM get transmit credits option */
639 const static TInt KRFCOMMGetReceiveCredit = 6; /*!< RFCOMM get receive credits option */
640 const static TInt KRFCOMMGetReUsedCount = 7; /*!< RFCOMM get number of remote used credits option */
641 const static TInt KRFCOMMFlowTypeCBFC = 8; /*!< RFCOMM Credit based flow control option (Get + Set) */
642 const static TInt KRFCOMMErrOnMSC = 9; /*!< RFCOMM set the value of MSC signals that will cause a disconnect error to be generated */
643 const static TUint KRFCOMMLocalModemStatus = 10; /*!< RFCOMM local modem status option (Get + Set) */
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) */
646 const static TInt KRFCOMMMaximumMTU = 12; /*!< RFCOMM maximum optimal MTU (Get only) */
648 // Masks for interpreting signalling commands
649 const static TUint8 KModemSignalFC = 0x01; /*!< RFCOMM FC signalling command mask */
650 const static TUint8 KModemSignalRTC = 0x02; /*!< RFCOMM RTC signalling command mask */
651 const static TUint8 KModemSignalRTR = 0x04; /*!< RFCOMM RTR signalling command mask */
652 const static TUint8 KModemSignalIC = 0x20; /*!< RFCOMM IC signalling command mask */
653 const static TUint8 KModemSignalDV = 0x40; /*!< RFCOMM DV signalling command mask */
655 enum TRPNParameterMask
656 /** Remote port negotiation parameter masks
659 EPMBitRate = 0x0001, /*!< Remote port negotiation parameter masks for bit rate */
660 EPMDataBits = 0x0002, /*!< Remote port negotiation parameter masks for data bits */
661 EPMStopBit = 0x0004, /*!< Remote port negotiation parameter masks for stop bit */
662 EPMParity = 0x0008, /*!< Remote port negotiation parameter masks for parity */
663 EPMParityType = 0x0010, /*!< Remote port negotiation parameter masks for parity type */
664 EPMXOnChar = 0x0020, /*!< Remote port negotiation parameter masks for on character */
665 EPMXOffChar = 0x0040, /*!< Remote port negotiation parameter masks for off character */
667 EPMXOnOffInput = 0x0100, /*!< Remote port negotiation parameter masks for XOn/Off input */
668 EPMXOnOffOutput = 0x0200, /*!< Remote port negotiation parameter masks for XOn/Off output */
669 EPMRTRInput = 0x0400, /*!< Remote port negotiation parameter masks for read to receive input */
670 EPMRTROutput = 0x0800, /*!< Remote port negotiation parameter masks for read to receive output */
671 EPMRTCInput = 0x1000, /*!< Remote port negotiation parameter masks for RTC input */
672 EPMRTCOutput = 0x2000 /*!< Remote port negotiation parameter masks for RTC output */
677 enum TRPNFlowCtrlMask
678 /** Remote port negotiation flow control masks
681 EFCXOnOffInput =0x01, /*!< Remote port negotiation flow control masks for XOn/Off input */
682 EFCXOnOffOutput =0x02, /*!< Remote port negotiation flow control masks for XOn/Off output */
683 EFCRTRInput =0x04, /*!< Remote port negotiation flow control masks for ready to receive input */
684 EFCRTROutput =0x08, /*!< Remote port negotiation flow control masks for ready to receive output */
685 EFCRTCInput =0x10, /*!< Remote port negotiation flow control masks for RTC input */
686 EFCRTCOutput =0x20 /*!< Remote port negotiation flow control masks for RTC output */
689 enum TRPNValidityMask
690 /** Remote port negotiation validity masks
693 EVMBitRate = 0x01, /*!< Remote port negotiation validity masks for bit rate */
694 EVMDataBits = 0x02, /*!< Remote port negotiation validity masks for data bits */
695 EVMStopBit = 0x04, /*!< Remote port negotiation validity masks for stop bit */
696 EVMParity = 0x08, /*!< Remote port negotiation validity masks for parity */
697 EVMFlowCtrl = 0x10, /*!< Remote port negotiation validity masks for flow control */
698 EVMXOnChar = 0x20, /*!< Remote port negotiation validity masks for XOn charater */
699 EVMXOffChar = 0x40 /*!< Remote port negotiation validity masks for XOff charater */
702 // structs for RFCOMM Ioctls
704 class TRfcommRPNTransaction;
706 NONSHARABLE_CLASS(TRfcommRemotePortParams)
707 /** RF COMM remote port parameters.
714 IMPORT_C TRfcommRemotePortParams();
715 IMPORT_C TUint8 IsValid() const;
716 IMPORT_C TBool GetBitRate(TBps& aBitRate) const;
717 IMPORT_C TInt SetBitRate(TBps aBitRate);
718 IMPORT_C TBool GetDataBits(TDataBits& aDataBits) const;
719 IMPORT_C TInt SetDataBits(TDataBits aDataBits);
720 IMPORT_C TBool GetStopBit(TStopBits& aStopBit) const;
721 IMPORT_C TInt SetStopBit(TStopBits aStopBit);
722 IMPORT_C TBool GetParity(TParity& aParity) const;
723 IMPORT_C TInt SetParity(TParity aParity);
724 IMPORT_C TBool GetFlowCtrl(TUint8& aFlowCtrl) const;
725 IMPORT_C TInt SetFlowCtrl(TUint8 aFlowCtrl);
726 IMPORT_C TBool GetXOnChar(TUint8& aXOnChar) const;
727 IMPORT_C TInt SetXOnChar(TUint8 aXOnChar);
728 IMPORT_C TBool GetXOffChar(TUint8& aXOffChar) const;
729 IMPORT_C TInt SetXOffChar(TUint8 aXOffChar);
730 IMPORT_C void UpdateFlowCtrlBit(TUint8 aFlowCtrl, TRPNFlowCtrlMask aFCMask);
731 IMPORT_C void UpdateWholeFlowCtrl(TUint16 aParamMask, TUint8 aFlowCtrl);
732 IMPORT_C void UpdateFromRPNTransaction(const TRfcommRPNTransaction&
737 TStopBits iStopBit; //It's really only one bit - ignore what the type implies...
744 // This data padding has been added to help prevent future binary compatibility breaks
745 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
750 // structs for RFCOMM Ioctls
752 NONSHARABLE_CLASS(TRfcommRPNTransaction)
753 /** RF COMM IO control structs.
760 IMPORT_C TRfcommRPNTransaction();
762 TRfcommRemotePortParams iPortParams; /*!< Remote port parameters */
763 TUint16 iParamMask; /*!< Parameter mask */
768 typedef TUint8 TRfcommChannel; /*!< RFCOMM channel type definition */
770 const static TRfcommChannel KMinRfcommServerChannel = 1; /*!< Minimum RFCOMM server channel value */
771 const static TRfcommChannel KMaxRfcommServerChannel = 30; /*!< Maximum RFCOMM server channel value */
773 const static TRfcommChannel KRfcommPassiveAutoBind = KMaxTUint8; /*!< Channel value out of the valid range used for passive auto bind. */
775 NONSHARABLE_CLASS(TRfcommSockAddr) : public TBTSockAddr
776 /** Defines the format of an Rfcomm address.
778 This class uses the TSockAddr data area to hold the address so that
779 it can be passed through the ESOCK boundary.
780 Assumes that the remote RFCOMM instance is always bound to PSM 3 on
781 L2CAP, so there is no way of specifying another remote PSM.
789 IMPORT_C TRfcommSockAddr();
790 IMPORT_C TRfcommSockAddr(const TSockAddr& aSockAddr);
791 IMPORT_C static TRfcommSockAddr& Cast(const TSockAddr& aSockAddr);
794 /*****BASEBAND CLIENT*********/
796 class CBTBasebandSocketProxy;
797 class CBTBasebandPropertySubscriber;
799 class MBasebandObserver;
801 NONSHARABLE_CLASS(RBTPhysicalLinkAdapter)
802 /** Class to enable modification of a physical link:
804 Modifications may be requested or prevented (blocked).
805 Whilst a modification is being prevented, any request to
806 perform that modification by this or any other
807 RBTPhysicalLinkAdapter client will be ignored.
808 If a low power mode is being used on the physical link, a
809 call to prevent that low power mode will, if possible, cause
810 the physical link to exit that low power mode. An
811 arbitration between all RBTPhysicalLinkAdapter clients will then occur
812 to decide whether the physical link should remain active or
813 enter another low power mode. (If all low power modes are prevented
814 then that arbitration will result in the physical link remaining
817 Methods to prevent modifications begin 'Prevent...'
819 Methods to cancel the prevention of modification begin 'Allow...'
821 Requests for low power mode modifications, and notification of modifications
822 take the form of continuously repeated requests which can be switched on or
825 Only one low power mode requester may active on a single RBTPhysicalLinkAdapter
826 client at a time. If several RBTPhysicalLinkAdapter clients have differing low
827 power mode requests active at a given moment then the priority will be:
832 Methods to perform these requests start 'Activate...'
834 Methods to cancel these requests start 'Cancel...'
840 IMPORT_C RBTPhysicalLinkAdapter();
841 IMPORT_C TInt Open(RSocketServ& aSocketServ, RSocket& aSocket);
842 IMPORT_C TInt Open(RSocketServ& aSocketServ, const TBTDevAddr& aDevAddr);
843 IMPORT_C TBool IsOpen() const;
844 IMPORT_C void Close();
845 IMPORT_C TInt PhysicalLinkState(TUint32& aState);
846 IMPORT_C TInt PreventRoleSwitch();
847 IMPORT_C TInt AllowRoleSwitch();
848 IMPORT_C TInt RequestMasterRole();
849 IMPORT_C TInt RequestSlaveRole();
850 IMPORT_C TInt PreventLowPowerModes(TUint32 aLowPowerModes);
851 IMPORT_C TInt AllowLowPowerModes(TUint32 aLowPowerModes);
852 IMPORT_C TInt ActivateSniffRequester();
853 IMPORT_C TInt ActivateParkRequester();
854 IMPORT_C TInt ActivateActiveRequester();
855 IMPORT_C TInt CancelLowPowerModeRequester();
856 IMPORT_C TInt RequestChangeSupportedPacketTypes(TUint16 aPacketTypes);
857 IMPORT_C void NotifyNextBasebandChangeEvent(TBTBasebandEvent& aEventNotification,
858 TRequestStatus& aStatus,
859 TUint32 aEventMask = ENotifyAnyPhysicalLinkState);
861 IMPORT_C void CancelNextBasebandChangeEventNotifier();
862 IMPORT_C TInt Authenticate();
865 RBTBaseband iBTBaseband;
867 // This data padding has been added to help prevent future binary compatibility breaks
868 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
874 This allows for notification of events relating to a CBluetoothPhysicalLinkMetrics object.
876 These notifications will be called when the value of a physical link metric that has been
877 subscribed to in CBluetoothPhysicalLinkMetrics changes. If the notification is not called,
878 the value has not changed since the last notification
880 Mixin class to be used with CBluetoothPhysicalLinkMetrics
884 class MBluetoothPhysicalLinkMetricsObserver
888 Notification for the initial RSSI (received signal strengh indication) value
889 and whenever the RSSI changes
890 @param aRssi Current RSSI Value in dB
892 virtual void MbplmoRssiChanged(TInt8 aRssi) = 0;
895 Notification for the initial Link Quality value and whenever the Link Quality changes.
896 @param aLinkQuality Link quality for this connection where the higher value represents a better quality link
898 virtual void MbplmoLinkQualityChanged(TUint8 aLinkQuality) = 0;
901 Notification for the initial failed contact counter value, and whenever the failed contact counter changes.
902 @param aFailedContactCounter Number of consecutive failed contacts for this connection
904 virtual void MbplmoFailedContactCounterChanged(TUint16 aFailedContactCounter) = 0;
907 Notification for the initial transmit power level, and whenever the transmit power level changes.
908 @param aTransmitPowerLevel Transmit power level in dBm
910 virtual void MbplmoTransmitPowerLevelChanged(TInt8 aTransmitPowerLevel) = 0;
913 Notification that an error has occured. When this is called, the current
914 subscriptions will be cancelled.
915 If a link disconnection occurs, the CBluetoothPhysicalLinkMetrics object will
916 no longer be valid, so it is recommended to delete the object in this callback
918 virtual void MbplmoError(TInt aError) = 0;
921 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
922 @param aInterface UID of the interface to return
923 @return The container for another interface as specified by aInterface
925 IMPORT_C virtual TAny* MbplmoExtensionInterfaceL(TUid aInterface);
928 class CBluetoothPhysicalLinkMetricSubscriber;
931 Class to subscribe to physical link metrics
935 NONSHARABLE_CLASS(CBluetoothPhysicalLinkMetrics): public CBase
938 IMPORT_C static CBluetoothPhysicalLinkMetrics* NewL(
939 MBluetoothPhysicalLinkMetricsObserver& aObserver,
940 RSocketServ& aSockServ,
941 RSocket& aConnectedSocket);
943 IMPORT_C static CBluetoothPhysicalLinkMetrics* NewL(
944 MBluetoothPhysicalLinkMetricsObserver& aObserver,
945 RSocketServ& aSockServ,
946 const TBTDevAddr& aAddr);
948 IMPORT_C ~CBluetoothPhysicalLinkMetrics();
949 IMPORT_C void SubscribeRssi();
950 IMPORT_C void SubscribeLinkQuality();
951 IMPORT_C void SubscribeFailedContactCounter();
952 IMPORT_C void SubscribeTransmitPowerLevel();
953 IMPORT_C void Cancel();
955 void RssiChanged(TInt8 aRssi);
956 void LinkQualityChanged(TUint8 aLinkQuality);
957 void FailedContactCounterChanged(TUint16 aFailedContactCounter);
958 void TransmitPowerLevelChanged(TInt8 aTransmitPowerLevel);
959 void SubscribeError(TInt aError);
963 CBluetoothPhysicalLinkMetrics(MBluetoothPhysicalLinkMetricsObserver& aObserver);
964 template<class T> void ConstructL(RSocketServ& aSockServ, T& aLinkIdentifier);
967 MBluetoothPhysicalLinkMetricsObserver& iObserver;
968 CBluetoothPhysicalLinkMetricSubscriber* iRssiBaseband;
969 CBluetoothPhysicalLinkMetricSubscriber* iLinkQualityBaseband;
970 CBluetoothPhysicalLinkMetricSubscriber* iFailedContactCounterBaseband;
971 CBluetoothPhysicalLinkMetricSubscriber* iTransmitPowerLevelBaseband;
975 class MBluetoothSocketNotifier
976 /** This allows for notification of events relating to a CBluetoothSocket object.
978 Such notification consists of notification of logical link events (for example receipt
979 of a user packet) and physical link state events (for example change of power mode).
981 Mixin class to be used with CBluetoothSocket
987 /** Notification of a connection complete event.
989 If no error is reported, then the connection is ready for use.
990 @note If the implementation of this function needs to delete associated
991 CBluetoothSocket object, it should NOT use delete operator. The implementation
992 should call CBluetoothSocket::AsyncDelete() method instead.
993 @param aErr the returned error
995 virtual void HandleConnectCompleteL(TInt aErr) = 0;
997 /** Notification of an accept complete event.
999 If no error is reported, then we have accepted a connection request
1000 and that connection is ready for use.
1001 @note If the implementation of this function needs to delete associated
1002 CBluetoothSocket object, it should NOT use delete operator. The implementation
1003 should call CBluetoothSocket::AsyncDelete() method instead.
1004 @param aErr the returned error
1006 virtual void HandleAcceptCompleteL(TInt aErr) = 0;
1008 /** Notification of a shutdown complete event.
1010 If no error is reported, then the connection has been closed.
1011 @note If the implementation of this function needs to delete associated
1012 CBluetoothSocket object, it should NOT use delete operator. The implementation
1013 should call CBluetoothSocket::AsyncDelete() method instead.
1014 @param aErr the returned error
1016 virtual void HandleShutdownCompleteL(TInt aErr) = 0;
1018 /** Notification of a send complete event.
1020 If no error is reported, then an attempt to send data over Bluetooth has succeeded.
1021 @note If the implementation of this function needs to delete associated
1022 CBluetoothSocket object, it should NOT use delete operator. The implementation
1023 should call CBluetoothSocket::AsyncDelete() method instead.
1024 @param aErr the returned error
1026 virtual void HandleSendCompleteL(TInt aErr) = 0;
1028 /** Notification of a receive complete event.
1030 If no error is reported, then then we have successfully received
1031 a specified quantity of data.
1032 @note If the implementation of this function needs to delete associated
1033 CBluetoothSocket object, it should NOT use delete operator. The implementation
1034 should call CBluetoothSocket::AsyncDelete() method instead.
1035 @param aErr the returned error
1037 virtual void HandleReceiveCompleteL(TInt aErr) = 0;
1039 /** Notification of a ioctl complete event.
1041 An HCI request that has an associated command complete has completed.
1042 @note If the implementation of this function needs to delete associated
1043 CBluetoothSocket object, it should NOT use delete operator. The implementation
1044 should call CBluetoothSocket::AsyncDelete() method instead.
1045 @param aErr the returned error
1047 virtual void HandleIoctlCompleteL(TInt aErr) = 0;
1049 /** Notification of a baseband event.
1051 If no error is reported, then a baseband event has been retrieved successfully.
1052 @note If the implementation of this function needs to delete associated
1053 CBluetoothSocket object, it should NOT use delete operator. The implementation
1054 should call CBluetoothSocket::AsyncDelete() method instead.
1055 @param aErr the returned error
1056 @param TBTBasebandEventNotification Bit(s) set in TBTBasebandEventNotification bitmap indicate what event has taken place.
1057 @see TBTPhysicalLinkStateNotifier
1059 virtual void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification& aEventNotification) = 0;
1062 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
1063 @param aInterface UID of the interface to return
1064 @param aObject the container for another interface as specified by aInterface
1066 IMPORT_C virtual void MBSN_ExtensionInterfaceL(TUid aInterface, void*& aObject);
1072 class CBTShutdowner;
1076 class CBTBasebandChangeEventNotifier;
1077 class CAutoSniffDelayTimer;
1078 class CBTBasebandManager;
1079 class CBTBasebandChangeEventDelegate;
1081 NONSHARABLE_CLASS(CBluetoothSocket): public CBase
1082 /** This allows Bluetooth ACL socket-based services to be run.
1084 It allows all user-plane data flow to occur, plus control-plane Bluetooth
1085 baseband modification capabilities.
1087 For a more detailed description of RBTBaseband functionality see the class and function documentation for
1088 RBTPhysicalLinkAdapter.
1090 This class doesn't provide the functionality to directly activate Active mode
1091 (this is implementated in class RBTPhysicalLinkAdapter.)
1092 @see RBTPhysicalLinkAdapter::ActivateActiveRequester()
1093 Explicit Active mode requests are made automatically when using the Automatic Sniff Requester
1094 utility provided by this class.
1095 @see CBluetoothSocket::SetAutomaticSniffMode
1097 @see RBTPhysicalLinkAdapter
1102 friend class CBTAccepter;
1104 IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier,
1105 RSocketServ& aServer,TUint aSockType,
1107 IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier,
1108 RSocketServ& aServer,TUint aSockType,
1110 IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier,
1111 RSocketServ& aServer,TUint aSockType,
1113 RConnection& aConnection);
1114 IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier,
1115 RSocketServ& aServer,
1116 TUint aSockType,TUint aProtocol,
1117 RConnection& aConnection);
1118 IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier,
1119 RSocketServ& aServer,
1120 const TDesC& aName);
1121 IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier,
1122 RSocketServ& aServer,
1123 const TDesC& aName);
1124 IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier,
1125 RSocketServ& aServer);
1126 IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier,
1127 RSocketServ& aServer);
1128 IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier,
1129 RSocketServ& aServer,
1131 IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier,
1132 RSocketServ& aServer,
1134 IMPORT_C ~CBluetoothSocket();
1136 //Forwarding functions to RSocket
1137 IMPORT_C TInt Send(const TDesC8& aDesc,TUint someFlags);
1138 IMPORT_C TInt Send(const TDesC8& aDesc,TUint someFlags,TSockXfrLength& aLen);
1139 IMPORT_C void CancelSend();
1140 IMPORT_C TInt Recv(TDes8& aDesc,TUint flags);
1141 IMPORT_C TInt Recv(TDes8& aDesc,TUint flags,TSockXfrLength& aLen);
1142 IMPORT_C TInt RecvOneOrMore(TDes8& aDesc,TUint flags,TSockXfrLength& aLen);
1143 IMPORT_C void CancelRecv();
1144 IMPORT_C TInt Read(TDes8& aDesc);
1145 IMPORT_C void CancelRead();
1146 IMPORT_C TInt Write(const TDesC8& aDesc);
1147 IMPORT_C void CancelWrite();
1148 IMPORT_C TInt SendTo(const TDesC8& aDesc,TSockAddr& aSockAddr,TUint flags);
1149 IMPORT_C TInt SendTo(const TDesC8& aDesc,TSockAddr& aSockAddr,TUint flags,TSockXfrLength& aLen);
1150 IMPORT_C TInt RecvFrom(TDes8& aDesc,TSockAddr& aSockAddr,TUint flags);
1151 IMPORT_C TInt RecvFrom(TDes8& aDesc,TSockAddr& aSockAddr,TUint flags,TSockXfrLength& aLen);
1152 IMPORT_C TInt Connect(TBTSockAddr& aSockAddr);
1153 IMPORT_C TInt Connect(TBTSockAddr& aSockAddr,const TDesC8& aConnectDataOut,TDes8& aConnectDataIn);
1154 IMPORT_C TInt Connect(TBTSockAddr& aAddr, TUint16 aServiceBits);
1155 IMPORT_C void CancelConnect();
1156 IMPORT_C TInt Bind(TSockAddr& aSockAddr);
1157 IMPORT_C TInt SetLocalPort(TInt aPort);
1158 IMPORT_C TInt Accept(CBluetoothSocket& aBlankSocket);
1159 IMPORT_C TInt Accept(CBluetoothSocket& aBlankSocket,TDes8& aConnectData);
1160 IMPORT_C void CancelAccept();
1161 IMPORT_C TInt Listen(TUint qSize);
1162 IMPORT_C TInt Listen(TUint qSize,const TDesC8& aConnectData);
1163 IMPORT_C TInt Listen(TUint qSize, TUint16 aServiceBits);
1164 IMPORT_C TInt SetOpt(TUint aOptionName,TUint aOptionLevel,TInt aOption);
1165 IMPORT_C TInt SetOption(TUint aOptionName,TUint aOptionLevel,const TDesC8& aOption);
1166 IMPORT_C TInt GetOpt(TUint aOptionName,TUint aOptionLevel,TDes8& aOption);
1167 IMPORT_C TInt GetOpt(TUint aOptionName,TUint aOptionLevel,TInt &aOption);
1168 IMPORT_C TInt Ioctl(TUint aLevel, TUint aCommand, TDes8* aDesc);
1169 IMPORT_C void CancelIoctl();
1170 IMPORT_C TInt GetDisconnectData(TDes8& aDesc);
1171 IMPORT_C void LocalName(TSockAddr& aSockAddr);
1172 IMPORT_C TUint LocalPort();
1173 IMPORT_C void RemoteName(TSockAddr& aSockAddr);
1174 IMPORT_C TInt Shutdown(RSocket::TShutdown aHow);
1175 IMPORT_C TInt Shutdown(RSocket::TShutdown aHow,const TDesC8& aDisconnectDataOut,TDes8& aDisconnectDataIn);
1176 IMPORT_C void CancelAll();
1177 IMPORT_C TInt Info(TProtocolDesc& aProtocol);
1178 IMPORT_C TInt Name(TName& aName);
1179 IMPORT_C TInt Transfer(RSocketServ& aServer, const TDesC& aName);
1182 //Forwarding functions to RBTBaseband
1183 IMPORT_C TInt PhysicalLinkState(TUint32& aState);
1184 IMPORT_C TInt PreventRoleSwitch();
1185 IMPORT_C TInt AllowRoleSwitch();
1186 IMPORT_C TInt RequestMasterRole();
1187 IMPORT_C TInt RequestSlaveRole();
1188 IMPORT_C TInt PreventLowPowerModes(TUint32 aLowPowerModes);
1189 IMPORT_C TInt AllowLowPowerModes(TUint32 aLowPowerModes);
1190 IMPORT_C TInt ActivateSniffRequester();
1191 IMPORT_C TInt ActivateParkRequester();
1192 IMPORT_C TInt CancelLowPowerModeRequester();
1193 IMPORT_C TInt RequestChangeSupportedPacketTypes(TUint16 aPacketTypes);
1194 IMPORT_C TInt ActivateBasebandEventNotifier(TUint32 aEventTypes);
1195 IMPORT_C void CancelBasebandEventNotifier();
1197 IMPORT_C void SetNotifier(MBluetoothSocketNotifier& aNewNotifier);
1198 IMPORT_C TInt SetAutomaticSniffMode(TBool aAutoSniffMode);
1199 IMPORT_C TInt SetAutomaticSniffMode(TBool aAutoSniffMode, TInt aIdleSecondsBeforeSniffRequest);
1200 IMPORT_C TBool AutomaticSniffMode() const;
1202 IMPORT_C void AsyncDelete();
1204 //Callback functions called by active object RunLs.
1205 // NB These functions kill the active objects that call them (cf mating spiders)
1206 MBluetoothSocketNotifier& Notifier();
1207 void HandleConnectCompleteL(TInt aErr);
1208 void HandleAcceptCompleteL(TInt aErr);
1209 void HandleShutdownCompleteL(TInt aErr);
1210 void HandleSendCompleteL(TInt aErr);
1211 void HandleReceiveCompleteL(TInt aErr);
1212 void HandleIoctlCompleteL(TInt aErr);
1213 void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification aEventNotification);
1218 IMPORT_C TInt Ioctl(TUint aCommand,TDes8* aDesc=NULL,TUint aLevel=KLevelUnspecified);
1223 IMPORT_C TInt SetOpt(TUint aOptionName,TUint aOptionLevel,const TDesC8& aOption=TPtrC8(NULL,0));
1226 RSocketServ& SocketServer();
1227 RBTBaseband& BTBaseband();
1228 CBTBasebandManager& BTBasebandManager();
1231 CBluetoothSocket(MBluetoothSocketNotifier& aNotifier, RSocketServ& aServer);
1232 void ConstructL(TUint aSockType,TUint aProtocol);
1233 void ConstructL(TUint aSockType,TUint aProtocol, RConnection& aConnection);
1234 void ConstructL(const TDesC& aName);
1236 void ConstructL(RSocket& aSocket);
1238 static TInt AsyncDeleteCallBack(TAny *aThisPtr);
1239 void ConfigureSocket();
1243 RSocketServ& iSockServer;
1244 TBTSockAddr iSockAddr;
1246 MBluetoothSocketNotifier* iNotifier;
1248 CBTConnecter* iBTConnecter;
1249 CBTAccepter* iBTAccepter;
1250 CBTShutdowner* iBTShutdowner;
1251 CBTReceiver* iBTReceiver; //for read, recv etc
1252 CBTSender* iBTSender; //for send, write etc
1253 CBTIoctler* iBTIoctler;
1254 CBTBasebandChangeEventNotifier* iBTBasebandChangeEventNotifier;
1255 TUint32 iNotifierEventMask;
1259 RBTBaseband iBTBaseband;
1260 CAutoSniffDelayTimer* iAutoSniffDelayTimer;
1261 CBTBasebandManager* iBTBasebandManager;
1262 CBTBasebandChangeEventDelegate* iBTBasebandChangeEventDelegate;
1264 CAsyncCallBack* iAsyncDestroyer; //for async deletion
1268 class MBluetoothSynchronousLinkNotifier
1269 /** SCO and eSCO link notification events.
1271 This allows for notification of Connect, Disconnect, Send and
1272 Receive events relating to SCO and eSCO links.
1274 Mixin class to be used with CBluetoothSynchronousLink
1275 Note that although the function signatures allow it, these functions should
1276 not be allowed to leave as the error will be ignored.
1283 /** Notification that a synchronous link (SCO) has been set up
1285 If no error is reported, then the synchronous link is ready for use.
1286 @note 1) Observe that although the function signature allows it, this function should
1287 not be allowed to leave as the error will be ignored.
1288 @note 2) The implementation of this function should NOT be used to delete the associated
1289 CBluetoothSynchronousLink object.
1290 @param aErr the returned error
1292 virtual void HandleSetupConnectionCompleteL(TInt aErr) = 0;
1294 /** Notification that a synchronous link (SCO) has disconnected
1296 If no error is reported, then the synchronous link has been closed.
1297 @note 1) Observe that although the function signature allows it, this function should
1298 not be allowed to leave as the error will be ignored.
1299 @note 2) The implementation of this function should NOT be used to delete the associated
1300 CBluetoothSynchronousLink object.
1301 @param aErr the returned error
1303 virtual void HandleDisconnectionCompleteL(TInt aErr) = 0;
1305 /** Notification that a synchronous link (SCO) has been accepted
1307 If no error is reported, then we have accepted a request for a synchronous link.
1308 That synchronous link is ready for use.
1309 @note 1) Observe that although the function signature allows it, this function should
1310 not be allowed to leave as the error will be ignored.
1311 @note 2) The implementation of this function should NOT be used to delete the associated
1312 CBluetoothSynchronousLink object.
1313 @param aErr the returned error
1315 virtual void HandleAcceptConnectionCompleteL(TInt aErr) = 0;
1317 /** Notification of a send complete event
1319 If no error is reported, then an attempt to send synchronous (SCO) data
1320 (e.g. voice) over Bluetooth has succeeded.
1321 @note 1) Observe that although the function signature allows it, this function should
1322 not be allowed to leave as the error will be ignored.
1323 @note 2) The implementation of this function should NOT be used to delete the associated
1324 CBluetoothSynchronousLink object.
1325 @param aErr the returned error
1327 virtual void HandleSendCompleteL(TInt aErr) = 0;
1329 /** Notification of a receive complete event
1331 If no error is reported, then then we have successfully received
1332 a specified quantity of synchronous (SCO) data.
1333 @note 1) Observe that although the function signature allows it, this function should
1334 not be allowed to leave as the error will be ignored.
1335 @note 2) The implementation of this function should NOT be used to delete the associated
1336 CBluetoothSynchronousLink object.
1337 @param aErr the returned error
1339 virtual void HandleReceiveCompleteL(TInt aErr) = 0;
1342 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
1343 @param aInterface UID of the interface to return
1344 @param aObject the container for another interface as specified by aInterface
1346 IMPORT_C virtual void MBSLN_ExtensionInterfaceL(TUid aInterface, void*& aObject);
1349 class CBTSynchronousLinkAttacher;
1350 class CBTSynchronousLinkDetacher;
1351 class CBTSynchronousLinkAccepter;
1352 class CBTSynchronousLinkSender;
1353 class CBTSynchronousLinkReceiver;
1354 class CBTSynchronousLinkBaseband;
1357 eSCO 64Kbit link utility constant.
1359 static const TUint KBTSync64KBit = (64000 / 8);
1361 NONSHARABLE_CLASS(CBluetoothSynchronousLink): public CBase
1362 /** Provides Bluetooth SCO functionality.
1364 This allows Bluetooth SCO (synchronous) link Connect, Disconnect, Send and Receive.
1370 IMPORT_C static CBluetoothSynchronousLink* NewL(MBluetoothSynchronousLinkNotifier& aNotifier,
1371 RSocketServ& aServer);
1372 IMPORT_C static CBluetoothSynchronousLink* NewLC(MBluetoothSynchronousLinkNotifier& aNotifier,
1373 RSocketServ& aServer);
1374 IMPORT_C ~CBluetoothSynchronousLink();
1376 IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr);
1377 IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr, const TUint16 aPacketTypes);
1378 IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr, const TBTSyncPackets& aPacketTypes);
1379 IMPORT_C void CancelSetup();
1380 IMPORT_C TInt Disconnect();
1381 IMPORT_C TInt Send(const TDesC8& aData);
1382 IMPORT_C void CancelSend();
1383 IMPORT_C TInt Receive(TDes8& aData);
1384 IMPORT_C void CancelReceive();
1385 IMPORT_C TInt AcceptConnection();
1386 IMPORT_C TInt AcceptConnection(const TBTSyncPackets& aPacketTypes);
1387 IMPORT_C void CancelAccept();
1389 IMPORT_C void SetCoding(TUint16 aVoiceSetting);
1390 IMPORT_C void SetMaxBandwidth(TBTSyncBandwidth aMaximum);
1391 IMPORT_C void SetMaxLatency(TUint16 aLatency);
1392 IMPORT_C void SetRetransmissionEffort(TBTeSCORetransmissionTypes aRetransmissionEffort);
1394 IMPORT_C TUint16 Coding();
1395 IMPORT_C TBTSyncBandwidth Bandwidth();
1396 IMPORT_C TUint16 Latency();
1397 IMPORT_C TUint8 RetransmissionEffort();
1399 IMPORT_C void RemoteName(TSockAddr& aAddr);
1401 IMPORT_C void SetNotifier(MBluetoothSynchronousLinkNotifier& aNotifier);
1403 MBluetoothSynchronousLinkNotifier& Notifier();
1404 RSocket& SCOSocket();
1405 RSocket& ESCOSocket();
1406 RSocket& ListeningSCOSocket();
1407 RSocket& ListeningESCOSocket();
1408 RSocketServ& SocketServer();
1409 RBTBaseband& Baseband();
1412 //Callback methods called by active object RunLs.
1413 void HandleSetupConnectionCompleteL(TInt aErr, TSCOType aSCOType);
1414 void HandleAcceptConnectionCompleteL(TInt aErr, TSCOType aSCOType);
1415 void HandleDisconnectionCompleteL(TInt aErr);
1416 void HandleSendCompleteL(TInt aErr);
1417 void HandleReceiveCompleteL(TInt aErr);
1420 CBluetoothSynchronousLink(MBluetoothSynchronousLinkNotifier& aNotifier, RSocketServ& aServer);
1422 void UpdateLinkParams(TSCOType aSCOType);
1423 TInt LinkUp(TBTDevAddr aAddr);
1427 CBTSynchronousLinkSender* iBTSynchronousLinkSenderSCO;
1428 CBTSynchronousLinkSender* iBTSynchronousLinkSenderESCO;
1429 CBTSynchronousLinkReceiver* iBTSynchronousLinkReceiverSCO;
1430 CBTSynchronousLinkReceiver* iBTSynchronousLinkReceiverESCO;
1431 CBTSynchronousLinkAccepter* iBTSynchronousLinkAccepterSCO;
1432 CBTSynchronousLinkAccepter* iBTSynchronousLinkAccepterESCO;
1433 CBTSynchronousLinkAttacher* iBTSynchronousLinkAttacherSCO;
1434 CBTSynchronousLinkAttacher* iBTSynchronousLinkAttacherESCO;
1435 CBTSynchronousLinkDetacher* iBTSynchronousLinkDetacherSCO;
1436 CBTSynchronousLinkDetacher* iBTSynchronousLinkDetacherESCO;
1437 CBTSynchronousLinkBaseband* iBTSynchronousLinkBaseband;
1438 MBluetoothSynchronousLinkNotifier* iNotifier;
1440 RSocket iESCOSocket;
1441 RSocket iListeningSCOSocket;
1442 RSocket iListeningESCOSocket;
1443 RBTBaseband iBaseband;
1444 RSocketServ& iSockServer;
1445 TBTSockAddr iSockAddr;
1446 TBuf8<1> iDummySCOShutdownDescriptor;
1448 TBTeSCOLinkParams iRequestedLink;
1449 TBTeSCOLinkParams iNegotiatedLink;
1459 class MBluetoothPhysicalLinksNotifier
1460 /** This allows for notifications of Physical link connections & disconnections
1462 Mixin class to be used with CBluetoothPhysicalLinks
1470 /** Notification of a requested connection coming up
1472 If no error is reported, then that connection is ready for use.
1473 @note 1) While this function may leave, any errors are ignored. Implementers are
1474 responsible for performing their own cleanup prior to exiting the function.
1475 @note 2) The implementation of this function should NOT be used to delete the associated
1476 CBluetoothPhysicalLinks object.
1478 @param aErr the returned error
1480 virtual void HandleCreateConnectionCompleteL(TInt aErr) = 0;
1482 /** Notification of a requested disconnection having taken place
1484 If no error is reported, then that connection has been closed.
1485 @note 1) While this function may leave, any errors are ignored. Implementers are
1486 responsible for performing their own cleanup prior to exiting the function.
1487 @note 2) The implementation of this function should NOT be used to delete the associated
1488 CBluetoothPhysicalLinks object.
1489 @param aErr the returned error
1491 virtual void HandleDisconnectCompleteL(TInt aErr) = 0;
1493 /** Notification that all existing connections have been torn down
1495 If no error is reported, then there are no Bluetooth connections existing.
1496 @note 1) While this function may leave, any errors are ignored. Implementers are
1497 responsible for performing their own cleanup prior to exiting the function.
1498 @note 2) The implementation of this function should NOT be used to delete the associated
1499 CBluetoothPhysicalLinks object.
1500 @param aErr the returned error
1502 virtual void HandleDisconnectAllCompleteL(TInt aErr) = 0;
1505 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
1506 @param aInterface UID of the interface to return
1507 @param aObject the container for another interface as specified by aInterface
1509 IMPORT_C virtual void MBPLN_ExtensionInterfaceL(TUid aInterface, void*& aObject);
1513 class CBTBasebandConnecter;
1514 class CBTBasebandShutdowner;
1515 class CBTDisconnector;
1517 NONSHARABLE_CLASS(CBluetoothPhysicalLinks): public CBase
1518 /** This is used to enumerate members of piconet, and attach and remove members thereof
1520 It may also be used for non-service dependent reads and writes.
1526 IMPORT_C static CBluetoothPhysicalLinks* NewL(MBluetoothPhysicalLinksNotifier& aNotifier,
1527 RSocketServ& aServer);
1528 IMPORT_C static CBluetoothPhysicalLinks* NewLC(MBluetoothPhysicalLinksNotifier& aNotifier,
1529 RSocketServ& aServer);
1530 IMPORT_C ~CBluetoothPhysicalLinks();
1532 IMPORT_C TInt CreateConnection(const TBTDevAddr& aDevAddr);
1533 IMPORT_C void CancelCreateConnection();
1534 IMPORT_C TInt Disconnect(const TBTDevAddr& aDevAddr);
1535 IMPORT_C TInt DisconnectAll();
1537 IMPORT_C TInt Broadcast(const TDesC8& aData);
1538 IMPORT_C TInt ReadRaw(TDes8& aData);
1539 IMPORT_C TInt Enumerate(RBTDevAddrArray& aBTDevAddrArray, TUint aMaxNumber);
1542 //Callback methods called by active object RunLs.
1543 //NB These methods kill the active objects that call them
1545 This method is for internal sub-system use only and should be not be used otherwise.
1548 void HandleCreateConnectionCompleteL(TInt aErr);
1550 This method is for internal sub-system use only and should be not be used otherwise.
1553 void HandleDisconnectCompleteL(TInt aErr);
1555 This method is for internal sub-system use only and should be not be used otherwise.
1558 void HandleDisconnectAllCompleteL(TInt aErr);
1561 This method is for internal sub-system use only and should be not be used otherwise.
1564 RSocketServ& SockServer();
1566 This method is for internal sub-system use only and should be not be used otherwise.
1569 RBTBaseband& BTBaseband();
1571 This method is for internal sub-system use only and should be not be used otherwise.
1574 MBluetoothPhysicalLinksNotifier& Notifier();
1578 CBluetoothPhysicalLinks(MBluetoothPhysicalLinksNotifier& aNotifier,
1579 RSocketServ& aServer);
1583 CBTBasebandConnecter* iBTBasebandConnecter;
1584 CBTDisconnector* iBTDisconnector;
1585 MBluetoothPhysicalLinksNotifier& iNotifier;
1586 RSocketServ& iSockServer;
1587 RBTBaseband iBTBaseband;