williamr@2: // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // BT socket interface types williamr@2: // williamr@2: // williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @file williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: williamr@2: #ifndef BT_SOCK_H williamr@2: #define BT_SOCK_H williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include // for RS232 signal names for RFCOMM williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: williamr@2: williamr@2: _LIT(KRFCOMMDesC,"RFCOMM"); /*!< Descriptor name for RFCOMM */ williamr@2: williamr@2: _LIT(KL2CAPDesC,"L2CAP"); /*!< Descriptor name for L2CAP */ williamr@2: williamr@2: // williamr@2: // BT Protocol Family williamr@2: // williamr@2: williamr@2: const TUint KBTAddrFamily = 0x101; /*!< BT Address Family */ williamr@2: williamr@2: const TUint KBTLinkManager = 0x0099; /*!< Protocol Number for Link Manager */ williamr@2: const TUint KL2CAP = 0x0100; /*!< Protocol Number for L2CAP */ williamr@2: const TUint KRFCOMM = 0x0003; /*!< Protocol Number for RFCOMM */ williamr@2: const TUint KSDP = 0x0001; /*!< Protocol Number for SDP */ williamr@2: const TUint KAVCTP = 0x0017; /*!< Protocol Number for AVCTP */ williamr@2: const TInt KTCIL2CAP = 0xF100; /*!< Protocol Number for TCI L2CAP */ williamr@2: williamr@2: const TInt KBTMajor = 0; /*!< BT version number for major version */ williamr@2: const TInt KBTMinor = 1; /*!< BT version number for minor version */ williamr@2: const TInt KBTBuild = 1; /*!< BT version number for build version */ williamr@2: williamr@2: // Socket Options williamr@2: const TUint KSolBtBlog =0x1000; /*!< Logging socket option */ williamr@2: const TUint KSolBtHCI =0x1010; /*!< HCI socket option */ williamr@2: const TUint KSolBtLM =0x1011; /*!< Link Manager socket option */ williamr@2: const TUint KSolBtL2CAP =0x1012; /*!< L2CAP socket option */ williamr@2: const TUint KSolBtRFCOMM=0x1013; /*!< RFCOMM socket option */ williamr@2: const TUint KSolBtAVCTP =0x1014; /*!< AVCTP socket option */ williamr@2: const TUint KSolBtACL =0x1015; /*!< ACL socket option */ williamr@2: /** williamr@2: Decimal Value: 4118. williamr@2: */ williamr@2: const TUint KSolBtAVDTPSignalling =0x1016; williamr@2: /** williamr@2: Decimal Value: 4119. williamr@2: */ williamr@2: const TUint KSolBtAVDTPMedia =0x1017; williamr@2: /** williamr@2: Decimal Value: 4120. williamr@2: */ williamr@2: const TUint KSolBtAVDTPReporting =0x1018; williamr@2: /** williamr@2: Decimal Value: 4121. williamr@2: */ williamr@2: const TUint KSolBtAVDTPRecovery =0x1019; williamr@2: /** williamr@2: Decimal Value: 4128. williamr@2: */ williamr@2: const TUint KSolBtAVDTPInternal =0x1020; williamr@2: const TUint KSolBtLMProxy = 0x2011; /*!< Link Manager Proxy socket option */ williamr@2: const TUint KSolBtSAPBase = 0x2020; /*!< CBluetoothSAP handles SetOpt first */ williamr@2: williamr@2: const static TUint8 KSCOListenQueSize = 1; /*!< Length of SCO listening queue */ williamr@2: williamr@2: const static TUint16 KL2MinMTU = 48; /*!< BT Spec defined min. supported MTU size */ williamr@2: williamr@2: williamr@2: // All PSM values must be ODD, that is, the least significant bit of the least significant williamr@2: // octet must be '1'. Also, all PSM values must be assigned such that the williamr@2: // least significant bit of the most significant octet equals '0'. williamr@2: const static TUint16 KMaxPSM = 0xFEFF; /*!< Max L2CAP PSM value */ williamr@2: williamr@2: /** williamr@2: * This is the minimum user PSM. Smaller PSM values are possible but are reserved for use by the williamr@2: * Bluetooth stack only. williamr@2: */ williamr@2: const static TUint16 KMinUserPSM = 0x1001; williamr@2: williamr@2: /** williamr@2: * This constant has been deprecated since its name is misleading becasue it doesn't represent the williamr@2: * absolute minimum PSM but the minimum user PSM instead. williamr@2: * Use KMinUserPSM instead of this constant. williamr@2: * @deprecated williamr@2: */ williamr@2: const static TUint16 KMinPSM = 0x1001; williamr@2: williamr@2: /** williamr@2: An enumeration to represent the possible levels of Man-in-the-Middle protection williamr@2: that a Bluetooth service may specify. williamr@2: */ williamr@2: enum TBluetoothMitmProtection williamr@2: { williamr@2: EMitmNotRequired = 0x0, /*!< No Man-in-the-Middle protection is required. */ williamr@2: EMitmDesired = 0x1, /*!< Man-in-the-Middle protection should be used where possible. */ williamr@2: EMitmRequired = 0x2 /*!< Man-in-the-Middle protection is required. */ williamr@2: }; williamr@2: williamr@2: NONSHARABLE_CLASS(TBTAccessRequirements) williamr@2: /** The access requirements set up by a bluetooth service. williamr@2: williamr@2: An incoming connection must satisfy these criteria before the connection may proceed. williamr@2: Not spectacularly useful for applications; mainly used by other Bluetooth libraries williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TBTAccessRequirements(); williamr@2: IMPORT_C void SetAuthentication(TBool aPreference); williamr@2: IMPORT_C void SetAuthorisation(TBool aPreference); williamr@2: IMPORT_C void SetEncryption(TBool aPreference); williamr@2: IMPORT_C void SetDenied(TBool aPreference); williamr@2: IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference); williamr@2: IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength); williamr@2: IMPORT_C TBool AuthenticationRequired() const; williamr@2: IMPORT_C TBool AuthorisationRequired() const; williamr@2: IMPORT_C TBool EncryptionRequired() const; williamr@2: IMPORT_C TBool Denied() const; williamr@2: IMPORT_C TUint PasskeyMinLength() const; williamr@2: IMPORT_C TBool operator==(const TBTAccessRequirements& aRequirements) const; williamr@2: IMPORT_C TBluetoothMitmProtection MitmProtection() const; williamr@2: williamr@2: private: williamr@2: TUint8 iRequirements; williamr@2: TUint iPasskeyMinLength; williamr@2: williamr@2: private: williamr@2: enum TBTServiceSecuritySettings williamr@2: { williamr@2: EAuthenticate = 0x01, williamr@2: EAuthorise = 0x02, williamr@2: EEncrypt = 0x04, williamr@2: EDenied = 0x08, williamr@2: EMitm = 0x30, // 2 bit field for MITM williamr@2: }; williamr@2: williamr@2: enum TBTAccessRequirementsMitmProtection williamr@2: { williamr@2: EAccessRequirementsMitmUndefined = 0x00, williamr@2: EAccessRequirementsMitmNotRequired = 0x10, williamr@2: EAccessRequirementsMitmDesired = 0x20, williamr@2: EAccessRequirementsMitmRequired = 0x30 williamr@2: }; williamr@2: }; williamr@2: williamr@2: NONSHARABLE_CLASS(TBTServiceSecurity) williamr@2: /** The security settings of a bluetooth service. williamr@2: williamr@2: Contains information regarding the service UID and the access requirements. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TBTServiceSecurity(const TBTServiceSecurity& aService); williamr@2: IMPORT_C TBTServiceSecurity(); williamr@2: IMPORT_C void SetUid(TUid aUid); williamr@2: IMPORT_C void SetAuthentication(TBool aPreference); williamr@2: IMPORT_C void SetAuthorisation(TBool aPreference); williamr@2: IMPORT_C void SetEncryption(TBool aPreference); williamr@2: IMPORT_C void SetDenied(TBool aPreference); williamr@2: IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference); williamr@2: IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength); williamr@2: IMPORT_C TBool AuthorisationRequired() const; williamr@2: IMPORT_C TBool EncryptionRequired() const; williamr@2: IMPORT_C TBool AuthenticationRequired() const; williamr@2: IMPORT_C TBool Denied() const; williamr@2: IMPORT_C TUint PasskeyMinLength() const; williamr@2: IMPORT_C TUid Uid() const; williamr@2: IMPORT_C TBluetoothMitmProtection MitmProtection() const; williamr@2: williamr@2: private: williamr@2: TUid iUid; /// TBTServiceSecurityPckg; /*!< Package definition for securty settings */ williamr@2: williamr@2: NONSHARABLE_CLASS(TBTSockAddr) : public TSockAddr williamr@2: /** Bluetooth socket address williamr@2: williamr@2: Stores bluetooth device address, and security - these are common to all Bluetooth addresses williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: struct SBTAddrSecurity williamr@2: { williamr@2: TBTDevAddr iAddress; williamr@2: TBTServiceSecurity iSecurity; williamr@2: }; williamr@2: williamr@2: public: williamr@2: IMPORT_C TBTSockAddr(); williamr@2: IMPORT_C TBTSockAddr(const TSockAddr& aAddr); williamr@2: IMPORT_C TBTDevAddr BTAddr() const; williamr@2: IMPORT_C void SetBTAddr(const TBTDevAddr& aRemote); williamr@2: IMPORT_C void SetSecurity(const TBTServiceSecurity& aSecurity); williamr@2: IMPORT_C TBTServiceSecurity BTSecurity() const; williamr@2: IMPORT_C static TBTSockAddr& Cast(const TSockAddr& aAddr); williamr@2: williamr@2: protected: williamr@2: IMPORT_C TAny* EndBTSockAddrPtr() const; williamr@2: williamr@2: private: williamr@2: SBTAddrSecurity& BTAddrSecStruct() const; williamr@2: TPtr8 AddressPtr() const; williamr@2: }; williamr@2: williamr@2: williamr@2: const static TInt KErrBtEskError = -6999; /*!< BT ESK error code */ williamr@2: williamr@2: williamr@2: // Options available for all Bluetooth protocols williamr@2: williamr@2: /** BT options. */ williamr@2: enum TBTOptions williamr@2: { williamr@2: /** Override device security */ williamr@2: KBTRegisterCodService = 0x998, /*!< Set a CoD Service bit(s) */ williamr@2: KBTSecurityDeviceOverride = 0x999, williamr@2: }; williamr@2: williamr@2: typedef TPckgBuf TBTServiceSecurityPerDeviceBuf; /*!< Package definition for securty settings */ williamr@2: williamr@2: williamr@2: // Link manager error codes. williamr@2: const static TInt KLinkManagerErrBase = -6450; /*!< Link manager base error value */ williamr@2: const static TInt KErrInsufficientBasebandResources = KLinkManagerErrBase; /*!< Insufficient baseband resources error value */ williamr@2: const static TInt KErrProxyWriteNotAvailable = KLinkManagerErrBase-1; /*!< Proxy write not available error value */ williamr@2: const static TInt KErrReflexiveBluetoothLink = KLinkManagerErrBase-2; /*!< Reflexive BT link error value */ williamr@2: const static TInt KErrPendingPhysicalLink = KLinkManagerErrBase-3; /*!< Physical link connection already pending when trying to connect the physical link */ williamr@2: const static TInt KErrRemoteDeviceIndicatedNoBonding = KLinkManagerErrBase-4; /*!< Dedicated bonding attempt failure when the remote device responds with No-Bonding */ williamr@2: williamr@2: // williamr@2: // L2CAP williamr@2: // williamr@2: williamr@2: const static TInt KL2CAPErrBase = -6300; /*!< Base error value for L2CAP error codes */ williamr@2: const static TInt KErrBadAddress = KL2CAPErrBase; /*!< L2CAP Bad address error code */ williamr@2: const static TInt KErrSAPUnexpectedEvent = KL2CAPErrBase - 1; /*!< L2CAP unexpected SAP event error code */ williamr@2: const static TInt KErrBadPacketReceived = KL2CAPErrBase - 2; /*!< L2CAP bad packet received error code */ williamr@2: const static TInt KErrL2CAPBadResponse = KL2CAPErrBase - 3; /*!< L2CAP bad response error code */ williamr@2: const static TInt KErrHCIConnectFailed = KL2CAPErrBase - 4; /*!< L2CAP HCI connection failed error code */ williamr@2: const static TInt KErrHCILinkDisconnection = KL2CAPErrBase - 5; /*!< L2CAP HCI link disconnection error code */ williamr@2: const static TInt KErrSAPNotConnected = KL2CAPErrBase - 6; /*!< L2CAP SAP not connected error code */ williamr@2: const static TInt KErrConfigBadParams = KL2CAPErrBase - 7; /*!< L2CAP bad configuration parameters error code */ williamr@2: const static TInt KErrConfigRejected = KL2CAPErrBase - 8; /*!< L2CAP configuration rejected error code */ williamr@2: const static TInt KErrConfigUnknownOptions = KL2CAPErrBase - 9; /*!< L2CAP unknown configuration options error code */ williamr@2: const static TInt KErrL2PeerDisconnected = KL2CAPErrBase - 10; /*!< L2CAP peer disconnected error code */ williamr@2: const static TInt KErrL2CAPAccessRequestDenied = KL2CAPErrBase - 11; /*!< L2CAP access request denied error code */ williamr@2: const static TInt KErrL2CAPRequestTimeout = KL2CAPErrBase - 12; /*!< L2CAP request timeout error code */ williamr@2: const static TInt KErrL2PeerRejectedCommand = KL2CAPErrBase - 13; /*!< L2CAP peer rejected command error code */ williamr@2: const static TInt KErrHostResNameTooLong = KL2CAPErrBase - 14; /*!< L2CAP host resolver name too long error code */ williamr@2: const static TInt KErrL2CAPNoMorePSMs = KL2CAPErrBase - 15; /*!< L2CAP no more PSMs error code */ williamr@2: 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: const static TInt KErrL2CAPDataControllerDetached = KL2CAPErrBase - 17; /*!< L2CAP problems (e.g. no memory) whilst sending data error code*/ williamr@2: const static TInt KErrL2CAPConfigPending = KL2CAPErrBase - 18; /*!< L2CAP configuration is in progress error code williamr@2: @internalComponent*/ williamr@2: const static TInt KErrL2CAPConfigAlreadyInProgress = KL2CAPErrBase - 19;/*!< L2CAP attempt to alter config whilst configuration is in progress error code*/ williamr@2: const static TInt KErrL2CAPNoFreeCID = KL2CAPErrBase - 21; /*!< L2CAP no more channel IDs available error code*/ williamr@2: williamr@2: // Host Resolver williamr@2: const static TInt KErrHostResNoMoreResults = KErrEof; /*!< Host resolver has no more results error code */ williamr@2: const static TUint KHostResInquiry = 1; /*!< Host resolver inquiry option */ williamr@2: const static TUint KHostResName = 2; /*!< Host resolver name option. This is mutually exclusive with KHostResEir */ williamr@2: const static TUint KHostResIgnoreCache = 16; /*!< A way of ignoring the cache */ williamr@2: const static TUint KHostResCache = 32; /*!< A way to get CoD from cache */ williamr@2: const static TUint KHostResEir = 64; /*!< Host resolver Eir option. This is mutually exclusive with KHostResName */ williamr@2: williamr@2: // L2CAP Ioctls williamr@2: const static TInt KL2CAPEchoRequestIoctl = 0; /*!< Echo Request Ioctl name */ williamr@2: const static TInt KL2CAPIncomingMTUIoctl = 1; /*!< Change incoming MTU Ioctl name */ williamr@2: const static TInt KL2CAPOutgoingMTUIoctl = 2; /*!< Change outgoing MTU Ioctl name */ williamr@2: const static TInt KL2CAPUpdateChannelConfigIoctl = 3;/*!< Change conguration parameters Ioctl name */ williamr@2: williamr@2: williamr@2: // Link Manager Ioctls williamr@2: williamr@2: /** Link manager Ioctl codes.*/ williamr@2: enum TBTLMIoctls williamr@2: { williamr@2: /** Disconnect ACL Ioctl code williamr@2: @deprecated williamr@2: */ williamr@2: KLMDisconnectACLIoctl, williamr@2: /** Set Packet type Ioctl code williamr@2: @deprecated williamr@2: */ williamr@2: KLMSetPacketTypeIoctl, williamr@2: /** Wait for SCO notification Ioctl code williamr@2: @internalComponent williamr@2: */ williamr@2: KLMWaitForSCONotificationIoctl, williamr@2: /** One-shot baseband notification Ioctl code williamr@2: @internalComponent williamr@2: */ williamr@2: KLMBasebandEventOneShotNotificationIoctl, williamr@2: /** Baseband event notification Ioctl code williamr@2: @internalComponent williamr@2: */ williamr@2: KLMBasebandEventNotificationIoctl, williamr@2: /** Read Failed Contact Counter Ioctl williamr@2: @internalComponent williamr@2: */ williamr@2: KLMReadFailedContactCounterIoctl, williamr@2: /** Read Link Quality Ioctl williamr@2: @internalComponent williamr@2: */ williamr@2: KLMReadLinkQualityIoctl, williamr@2: /** Read RSSI Ioctl williamr@2: @internalComponent williamr@2: */ williamr@2: KLMReadRssiIoctl, williamr@2: /** Read Current Transmit Power Level Ioctl williamr@2: @internalComponent williamr@2: */ williamr@2: KLMReadCurrentTransmitPowerLevelIoctl, williamr@2: }; williamr@2: williamr@2: williamr@2: /** Paging policy for baseband.*/ williamr@2: enum TBasebandPageTimePolicy williamr@2: { williamr@2: EPagingDontCare, /*!< Don't care setting */ williamr@2: EPagingNormal, /*!< Normal setting */ williamr@2: EPagingBestEffort, /*!< Best effort setting */ williamr@2: EPagingQuick, /*!< Quick paging setting */ williamr@2: }; williamr@2: williamr@2: struct TBasebandPolicyParams williamr@2: /** Baseband policy parameters.*/ williamr@2: { williamr@2: TBasebandPageTimePolicy iPageTimePolicy; /*!< Page time policy */ williamr@2: }; williamr@2: williamr@2: struct TSetBasebandPolicy williamr@2: /** Set baseband policy. williamr@2: williamr@2: @deprecated williamr@2: @see RBTBaseband, TPhysicalLinkQuickConnectionToken williamr@2: */ williamr@2: { williamr@2: TBTDevAddr iDevAddr; /*!< Device Address */ williamr@2: TBasebandPolicyParams iPolicy; /*!< Policy parameters */ williamr@2: }; williamr@2: williamr@2: /** Package for SetBasebandPolicy structure williamr@2: @deprecated williamr@2: */ williamr@2: typedef TPckgBuf TSetBasebandPolicyBuf; williamr@2: williamr@2: struct TPhysicalLinkQuickConnectionToken williamr@2: /** Specifies details for faster connection.*/ williamr@2: { williamr@2: TBTNamelessDevice iDevice; /*!< Nameless device */ williamr@2: TBasebandPolicyParams iPolicy; /*!< New policy */ williamr@2: }; williamr@2: williamr@2: typedef TPckgBuf TPhysicalLinkQuickConnectionTokenBuf; /*!< Package for TPhysicalLinkQuickConnectionToken structure */ williamr@2: williamr@2: #define KBasebandSlotTime 0.000625 /*!< Baseband timeslot duration (0.000625 seconds) */ williamr@2: static const TUint KDefaultBasebandConnectionTimeout = 10; /*!< Default baseband connection timeout (10 seconds) */ williamr@2: williamr@2: williamr@2: struct TLMDisconnectACLIoctl williamr@2: /** williamr@2: Structure to specify the remote ACL connection to disconnect. williamr@2: The reason passed in iReason will be sent to the remote device. williamr@2: williamr@2: Use with KLMDisconnectACLIoctl. williamr@2: @deprecated williamr@2: */ williamr@2: { williamr@2: TBTDevAddr iDevAddr; /*!< Device address */ williamr@2: TUint8 iReason; /*!< Reason code */ williamr@2: }; williamr@2: williamr@2: typedef TPckgBuf TLMDisconnectACLBuf; /*!< Package for TLMDisconnectACLIoctl structure */ williamr@2: williamr@2: // private tokens for use by RBTBaseband facade and stack williamr@2: _LIT8(KDisconnectOnePhysicalLink, "1"); /*!< Specifes one physical link should be disconnected */ williamr@2: _LIT8(KDisconnectAllPhysicalLinks, "A"); /*!< Specifes all physical links should be disconnected */ williamr@2: williamr@2: williamr@2: /** Link manager options. williamr@2: @internalComponent williamr@2: */ williamr@2: enum TBTLMOptions williamr@2: { williamr@2: ELMOutboundACLSize, /*!< Outbound ACL size option */ williamr@2: ELMInboundACLSize, /*!< Inbound ACL size option */ williamr@2: KLMGetACLHandle, /*!< Get ACL Handle option */ williamr@2: KLMGetACLLinkCount, /*!< Get ACL link count option */ williamr@2: KLMGetACLLinkArray, /*!< Get ACL link array option */ williamr@2: KLMSetBasebandConnectionPolicy, /*!< Set baseband connection policy option */ williamr@2: KLMGetBasebandHandle, /*!< Get baseband handle option */ williamr@2: EBBSubscribePhysicalLink, /*!< Subscribe physical link option */ williamr@2: EBBBeginRaw, /*!< Enable raw broadcast option */ williamr@2: EBBRequestRoleMaster, /*!< Request switch to master option */ williamr@2: EBBRequestRoleSlave, /*!< Request switch to slave option */ williamr@2: EBBCancelModeRequest, /*!< Cancel mode request option */ williamr@2: EBBRequestSniff, /*!< Request sniff mode option */ williamr@2: EBBRequestPark, /*!< Request park mode option */ williamr@2: EBBRequestPreventRoleChange, /*!< Request to prevent a role (master / slave) switch option */ williamr@2: EBBRequestAllowRoleChange, /*!< Request to allow a role (master / slave) switchoption */ williamr@2: EBBRequestChangeSupportedPacketTypes, /*!< Request to cange the current supported packet types option */ williamr@2: EBBEnumeratePhysicalLinks, /*!< Enumerate physical links option */ williamr@2: EBBGetPhysicalLinkState, /*!< Get the physical link state option */ williamr@2: EBBGetSniffInterval, /*!< Get Sniff Interval option */ williamr@2: EBBRequestLinkAuthentication, /*!< Request authentication on the link */ williamr@2: EBBRequestExplicitActiveMode, /*!< Explicitly request the link to go into active mode */ williamr@2: williamr@2: //Allow combination of options below... williamr@2: EBBRequestPreventSniff = 0x100, /*!< Request to prevent entering sniff mode option */ williamr@2: EBBRequestPreventHold = 0x200, /*!< Request to prevent entering hold mode option */ williamr@2: EBBRequestPreventPark = 0x400, /*!< Request to prevent entering park mode option */ williamr@2: EBBRequestPreventAllLowPowerModes = williamr@2: (EBBRequestPreventSniff | williamr@2: EBBRequestPreventHold | williamr@2: EBBRequestPreventPark), /*!< Request to prevent entering all modes option */ williamr@2: EBBRequestAllowSniff = 0x800, /*!< Request to allow entering sniff mode option */ williamr@2: EBBRequestAllowHold = 0x1000, /*!< Request to allow entering hold mode option */ williamr@2: EBBRequestAllowPark = 0x2000, /*!< Request to allow entering park mode option */ williamr@2: EBBRequestAllowAllLowPowerModes = williamr@2: (EBBRequestAllowSniff | williamr@2: EBBRequestAllowHold | williamr@2: EBBRequestAllowPark), /*!< Request to allow entering-all-modes option. */ williamr@2: }; williamr@2: williamr@2: // HCI Ioctls williamr@2: /** Add SCO connnection Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KLMAddSCOConnIoctl =0; williamr@2: /** Remove SCO connection Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIRemoveSCOConnIoctl =1; williamr@2: /** Change packet types allowed Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIChangePacketTypeIoctl =2; williamr@2: /** Request authorisation Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIAuthRequestIoctl =3; williamr@2: /** Request encryption Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIEncryptIoctl =4; williamr@2: /** Change link key Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIChangeLinkKeyIoctl =5; williamr@2: /** Master link key Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIMasterLinkKeyIoctl =6; williamr@2: /** Enable hold mode Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIHoldModeIoctl =7; williamr@2: /** Enable sniff mode Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCISniffModeIoctl =8; williamr@2: /** Exit sniff mode Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIExitSniffModeIoctl =9; williamr@2: /** Enable park mode Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIParkModeIoctl =10; williamr@2: /** Exit park mode Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIExitParkModeIoctl =11; williamr@2: williamr@2: /** Read page timeout Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIReadPageTimeoutIoctl =12; williamr@2: /** Write page timeout Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIWritePageTimeoutIoctl =13; williamr@2: /** Read scan enable Ioctl williamr@2: @deprecated williamr@2: @see bt_subscribe.h williamr@2: */ williamr@2: static const TUint KHCIReadScanEnableIoctl =14; williamr@2: /** Write scan enable Ioctl williamr@2: @deprecated williamr@2: @see bt_subscribe.h williamr@2: */ williamr@2: static const TUint KHCIWriteScanEnableIoctl =15; williamr@2: /** Read device class Ioctl williamr@2: @deprecated williamr@2: @see bt_subscribe.h williamr@2: */ williamr@2: static const TUint KHCIReadDeviceClassIoctl =16; williamr@2: /** Write device class Ioctl williamr@2: @deprecated williamr@2: @see bt_subscribe.h williamr@2: */ williamr@2: static const TUint KHCIWriteDeviceClassIoctl =17; williamr@2: /** Read voice settings Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIReadVoiceSettingIoctl =18; williamr@2: /** Write voice settings Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIWriteVoiceSettingIoctl =19; williamr@2: /** Read hold mode activity Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIReadHoldModeActivityIoctl=20; williamr@2: /** Write hold mode activity Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIWriteHoldModeActivityIoctl=21; williamr@2: /** Local version Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCILocalVersionIoctl =22; williamr@2: /** Local features Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCILocalFeaturesIoctl =23; williamr@2: /** Country code Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCICountryCodeIoctl =24; williamr@2: /** Local address Ioctl williamr@2: @deprecated williamr@2: @see bt_subscribe.h williamr@2: */ williamr@2: static const TUint KHCILocalAddressIoctl =25; williamr@2: /** Write discoverability Ioctl williamr@2: @deprecated williamr@2: @see bt_subscribe.h williamr@2: */ williamr@2: static const TUint KHCIWriteDiscoverabilityIoctl=26; williamr@2: /** Read discoverability Ioctl williamr@2: @deprecated williamr@2: @see bt_subscribe.h williamr@2: */ williamr@2: static const TUint KHCIReadDiscoverabilityIoctl =27; williamr@2: /** Read authentification enabled Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIReadAuthenticationEnableIoctl=33; williamr@2: /** Write authentification enabled Ioctl williamr@2: @deprecated williamr@2: */ williamr@2: static const TUint KHCIWriteAuthenticationEnableIoctl=34; williamr@2: williamr@2: williamr@2: // Structs for ioctl parameters williamr@2: williamr@2: /** williamr@2: Enumerations for the four possible scan enable modes. williamr@2: Use Inquiry scan for discoverability and Page scan for williamr@2: connectability. williamr@2: williamr@2: Use with KHCIReadScanEnableIoctl and KHCIWriteScanEnableIoctl. williamr@2: @deprecated williamr@2: @see bt_subscribe.h williamr@2: */ williamr@2: enum THCIScanEnableIoctl williamr@2: { williamr@2: EHCINoScansEnabled=0x00, /*!< No scans enabled. */ williamr@2: EHCIInquiryScanOnly, /*!< Inquiry scan only. */ williamr@2: EHCIPageScanOnly, /*!< Page scan only. */ williamr@2: EHCIInquiryAndPageScan /*!< Both inquiry and page scan enabled. */ williamr@2: }; williamr@2: /** williamr@2: Package for THCIScanEnableIoctl structure williamr@2: @deprecated williamr@2: */ williamr@2: typedef TPckgBuf THCIScanEnableBuf; williamr@2: williamr@2: struct TLMAddSCOConnectionIoctl williamr@2: /** williamr@2: Structure for specifying SCO type to add to a connected socket. williamr@2: The connection handle for the SCO link is returned in iConnH when williamr@2: the Ioctl completes. williamr@2: williamr@2: Use with KHCIAddSCOConnIoctl. williamr@2: @deprecated williamr@2: */ williamr@2: { williamr@2: TUint16 iPktType; /*!< Packet type */ williamr@2: }; williamr@2: /** williamr@2: Package for TLMAddSCOConnectionIoctl structure williamr@2: @deprecated williamr@2: */ williamr@2: typedef TPckgBuf TLMAddSCOConnectionBuf; williamr@2: williamr@2: struct THCISetEncryptionIoctl williamr@2: /** williamr@2: Request to change the encryption state of a connection. williamr@2: iEncrypt specifies whether to turn encryption on or off. williamr@2: williamr@2: Use with KHCIEncryptIoctl. williamr@2: @deprecated williamr@2: */ williamr@2: { williamr@2: TBool iEncrypt; /*!< Encryption enabled / disabled */ williamr@2: }; williamr@2: /** williamr@2: Package for THCISetEncryptionIoctl structure williamr@2: @deprecated williamr@2: */ williamr@2: typedef TPckgBuf THCISetEncryptionBuf; williamr@2: williamr@2: struct THCIDeviceClassIoctl williamr@2: /** williamr@2: Structure to specify the class of device when getting or setting williamr@2: the local device class. williamr@2: williamr@2: Use with KHCIReadDeviceClassIoctl and KHCIWriteDeviceClassIoctl. williamr@2: @deprecated williamr@2: @see bt_subscribe.h williamr@2: */ williamr@2: { williamr@2: TUint16 iMajorServiceClass; /*!< Major Service class */ williamr@2: TUint8 iMajorDeviceClass; /*!< Major Device class */ williamr@2: TUint8 iMinorDeviceClass; /*!< Minor Device class */ williamr@2: }; williamr@2: /** williamr@2: Package for THCIDeviceClassIoctl structure williamr@2: @deprecated williamr@2: */ williamr@2: typedef TPckgBuf THCIDeviceClassBuf; williamr@2: williamr@2: struct THCILocalVersionIoctl williamr@2: /** williamr@2: Structure describing the local Bluetooth hardware version. williamr@2: williamr@2: Use with KHCILocalVersionIoctl. williamr@2: @deprecated williamr@2: */ williamr@2: { williamr@2: TUint8 iHCIVersion; /*!< HCI version */ williamr@2: TUint16 iHCIRevision; /*!< HCI Revision */ williamr@2: TUint8 iLMPVersion; /*!< LMP version */ williamr@2: TUint16 iLMPSubversion; /*!< LMP subversion */ williamr@2: TUint16 iManufacturerName; /*!< Manufacturer name */ williamr@2: }; williamr@2: /** williamr@2: Package for THCILocalVersionIoctl structure williamr@2: @deprecated williamr@2: */ williamr@2: typedef TPckgBuf THCILocalVersionBuf; williamr@2: williamr@2: /** L2CAP Get / Set Options. */ williamr@2: enum TBTL2CAPOptions williamr@2: { williamr@2: /** williamr@2: Get the outbound MTU size taking into account both the negotiated MTU size williamr@2: and best use of underlying packet sizes. williamr@2: For example: If the default outgoing MTU of 672 has been negotiated for a L2CAP channel williamr@2: that is in Retransmission or Flow control mode then this GetOpt will return an williamr@2: outgoing MTU of 668 bytes. This allows a maximally sized SDU williamr@2: (which due to this adjustment will be 668 bytes) to be sent in two DH5 packets. williamr@2: KL2CAPOutboundMTUForBestPerformance may also be used to set the current negotiated williamr@2: (or to be negotiated) outbound MTU size. williamr@2: Note that the outbound MTU size returned when using KL2CAPOutboundMTUForBestPerformance williamr@2: with a GetOpt may not be the same as the outbound MTU size previously set williamr@2: when using KL2CAPOutboundMTUForBestPerformance with a SetOpt. williamr@2: */ williamr@2: KL2CAPOutboundMTUForBestPerformance, williamr@2: williamr@2: /** williamr@2: This is the legacy value for setting getting \ setting the outbound MTU size and behaves williamr@2: in the same way as KL2CAPOutboundMTUForBestPerformance. williamr@2: @see KL2CAPOutboundMTUForBestPerformance williamr@2: */ williamr@2: KL2CAPGetOutboundMTU = KL2CAPOutboundMTUForBestPerformance, williamr@2: williamr@2: KL2CAPGetDebug1, /*!< Debug Command */ williamr@2: KL2CAPInboundMTU, /*!< Get / Set the current inbound MTU size */ williamr@2: KL2CAPRTXTimer, /*!< Change the extended L2CAP command retransmission timeout */ williamr@2: KL2CAPERTXTimer, /*!< Change the L2CAP command retransmission timeout */ williamr@2: KL2CAPGetMaxOutboundMTU, /*!< Get the max outbound MTU supported by the stack */ williamr@2: KL2CAPGetMaxInboundMTU, /*!< Get the max inbound MTU supported by the stack */ williamr@2: KL2CAPUpdateChannelConfig, /*!< Get and Set the current configuration parameters */ williamr@2: williamr@2: /** Get / Set the current negotiated (or to be negotiated) outbound MTU size */ williamr@2: KL2CAPNegotiatedOutboundMTU, williamr@2: williamr@2: KL2CAPTestConfigure, williamr@2: KL2CAPDebugFlush, williamr@2: KL2CAPVersion1_2, williamr@2: KL2CAPHeapAlloc, williamr@2: KL2CAPDataPlaneConfig, williamr@2: williamr@2: /** williamr@2: This is similar to KL2CAPOutboundMTUForBestPerformance except that the caller can specify williamr@2: a restriction that the returned MTU shall not exceed. This is useful for layers above L2CAP williamr@2: that still want an optimal MTU but have their own restrictions on packet size. williamr@2: */ williamr@2: KL2CAPOutboundMTUForBestPerformanceWithRestriction, williamr@2: }; williamr@2: williamr@2: typedef TUint16 TL2CAPPort; /*!< Definition of a L2CAP port number type */ williamr@2: williamr@2: const static TL2CAPPort KL2CAPPassiveAutoBind = KMaxTUint16; /*!< PSM out of the valid range used for passive auto bind operation */ williamr@2: williamr@2: NONSHARABLE_CLASS(TL2CAPSockAddr) : public TBTSockAddr williamr@2: /** L2CAP Socket Address. williamr@2: williamr@2: Use this class to specify a local or remote L2CAP connection end-point, williamr@2: that is Device Address and PSM/CID. williamr@2: When unconnected, the Port() specifies the PSM, once connected it refers to williamr@2: the CID. williamr@2: @see TBTSockAddr williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TL2CAPSockAddr(); williamr@2: IMPORT_C TL2CAPSockAddr(const TSockAddr& aSockAddr); williamr@2: IMPORT_C static TL2CAPSockAddr& Cast(const TSockAddr& aSockAddr); williamr@2: williamr@2: IMPORT_C TL2CAPPort Port() const; williamr@2: IMPORT_C void SetPort(const TL2CAPPort aHomePort); williamr@2: }; williamr@2: williamr@2: NONSHARABLE_CLASS(TInquirySockAddr) : public TSockAddr williamr@2: /** Socket address class used for inquiries. williamr@2: williamr@2: Used to specify the inquiry request, and then filled with information williamr@2: about remote devices discovered through the inquiry process. williamr@2: williamr@2: Use the BTAddr() method to extract the device address to connect to. williamr@2: williamr@2: williamr@2: Note: Usage of RHostResolver class for Bluetooth protocol. williamr@2: williamr@2: The RHostResolver class is a generic interface to host name williamr@2: resolution services, such as DNS, that may be provided williamr@2: by particular protocol modules. williamr@2: williamr@2: The points to remember when using RHostResolver::GetByAddress(), williamr@2: RHostResolver::GetByName(), or RHostResolver::Next() williamr@2: with Bluetooth protocol are: williamr@2: williamr@2: 1) If you operate on one instance of RHostResolver you can perform williamr@2: only one request by calling either RHostResolver::GetByAddress() williamr@2: or RHostResolver::GetByName(). If these functions are called again williamr@2: and if there is more than one possible response for a given host name williamr@2: then that will be returned (The host resolving process will williamr@2: not start from the beginning). It is exactly as if the RHostResolve::Next() williamr@2: method was called. williamr@2: williamr@2: 2) In order to start resolving new hosts from the beginning using the same williamr@2: instance of RHostResolver, the instance must be closed and reopened again. williamr@2: williamr@2: 3) In order to perform several RHostResolver requests they should be issued on williamr@2: separate instances of RHostResolver (many RHostResolver instances might williamr@2: exist and perform requests at the same time). williamr@2: williamr@2: 4) The KHostResIgnoreCache flag is only valid when issuing RHostResolver::GetByAddress() williamr@2: or RHostResolver::GetByName() request for the first time. williamr@2: williamr@2: 5) As an RHostResolver is only intended to be used once, it is recommended that it williamr@2: be closed as soon as it is finished with as the semantics of Cancel merely williamr@2: indicates that one client server request should be cancelled. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: // Max size for this structure is 24 bytes (32 - 8, see TSockAddr). However, due to padding and to prevent BC breaks, williamr@2: // only up to 3 TUint8(s) may be added after iFlags williamr@2: struct SInquiryAddr williamr@2: { williamr@2: TBTDevAddr iAddress; williamr@2: 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: TUint16 iMajorServiceClass; williamr@2: TUint8 iMajorDeviceClass; williamr@2: TUint8 iMinorDeviceClass; williamr@2: TUint iIAC; williamr@2: TUint8 iActionFlags; williamr@2: TUint8 iResultFlags; williamr@2: TInt8 iRssi; williamr@2: }; williamr@2: williamr@2: public: williamr@2: // This defines all the bit masks for the inquiry result williamr@2: enum TResolverResultFlags williamr@2: { williamr@2: ERssiValid = 0x1, williamr@2: }; williamr@2: williamr@2: public: williamr@2: IMPORT_C TInquirySockAddr(); williamr@2: IMPORT_C TInquirySockAddr(const TSockAddr& aSockAddr); williamr@2: IMPORT_C TBTDevAddr BTAddr() const; williamr@2: IMPORT_C void SetBTAddr(const TBTDevAddr& aRemote); williamr@2: williamr@2: IMPORT_C static TInquirySockAddr& Cast(const TSockAddr& aSockAddr); williamr@2: IMPORT_C TUint16 MajorServiceClass() const; williamr@2: IMPORT_C void SetMajorServiceClass(TUint16 aClass); williamr@2: IMPORT_C TUint8 MajorClassOfDevice() const; williamr@2: IMPORT_C void SetMajorClassOfDevice(TUint8 aMajorClassOfDevice); williamr@2: IMPORT_C TUint8 MinorClassOfDevice() const; williamr@2: IMPORT_C void SetMinorClassOfDevice(TUint8 aMinorClassOfDevice); williamr@2: IMPORT_C TUint IAC() const; williamr@2: IMPORT_C void SetIAC(const TUint aIAC); williamr@2: IMPORT_C TUint8 Action() const; williamr@2: IMPORT_C void SetAction(TUint8 aFlags); williamr@2: IMPORT_C TVersion Version() const; williamr@2: IMPORT_C TInt8 Rssi() const; williamr@2: IMPORT_C void SetRssi(const TInt8 aRssi); williamr@2: IMPORT_C TUint8 ResultFlags() const; williamr@2: IMPORT_C void SetResultFlags(TUint8 aResultFlags); williamr@2: williamr@2: protected: williamr@2: void SetVersion(TVersion aVersion); williamr@2: IMPORT_C TUint8 FormatTypeField() const; williamr@2: void SetFormatTypeField(TUint8 aType); williamr@2: williamr@2: private: williamr@2: SInquiryAddr& InquiryAddrStruct() const; williamr@2: TPtr8 AddressPtr() const; williamr@2: }; williamr@2: williamr@2: williamr@2: enum TACLPort williamr@2: /** ACL port types. williamr@2: @internalComponent williamr@2: */ williamr@2: { williamr@2: EACLPortRaw = 0x00, /*!< Raw port type */ williamr@2: EACLPortL2CAP = 0x01, /*!< L2CAP port type */ williamr@2: EACLPortUnset = 0xFF, /*!< Unspecified ACL port type */ williamr@2: }; williamr@2: williamr@2: williamr@2: // SAP types for baseband williamr@2: /** ACL socket type williamr@2: @internalTechnology williamr@2: */ williamr@2: static const TUint KSockBluetoothTypeACL = KMaxTUint; williamr@2: /** Raw broadcast socket type williamr@2: @internalTechnology williamr@2: */ williamr@2: static const TUint KSockBluetoothTypeRawBroadcast = KMaxTUint-2; williamr@2: williamr@2: NONSHARABLE_CLASS(TACLSockAddr) : public TBTSockAddr williamr@2: /** ACL Socket Address. williamr@2: williamr@2: Use this class to specify a local or remote baseband connection end-point, williamr@2: This is tied to the flags field in ACL data packets williamr@2: @internalComponent williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TACLSockAddr(); williamr@2: IMPORT_C TACLSockAddr(const TSockAddr& aSockAddr); williamr@2: IMPORT_C static TACLSockAddr& Cast(const TSockAddr& aSockAddr); williamr@2: // williamr@2: IMPORT_C TACLPort Port() const; williamr@2: IMPORT_C void SetPort(TACLPort aPort); williamr@2: }; williamr@2: williamr@2: williamr@2: // williamr@2: // RFCOMM williamr@2: // williamr@2: williamr@2: const static TInt KRFErrorBase = -6350; /*!< RFCOMM base error code. */ williamr@2: const static TInt KErrRfcommSAPUnexpectedEvent = KRFErrorBase; /*!< RFCOMM unexpected event error code. */ williamr@2: const static TInt KErrRfcommAlreadyBound = KRFErrorBase-1; /*!< RFCOMM SAP already bound error code. */ williamr@2: const static TInt KErrRfcommBadAddress = KRFErrorBase-2; /*!< RFCOMM bad address error code. */ williamr@2: const static TInt KErrRfcommMTUSize = KRFErrorBase-3; /*!< RFCOMM MTU size exceeded error code. */ williamr@2: const static TInt KErrRfcommFrameResponseTimeout = KRFErrorBase-4; /*!< RFCOMM frame response timeout error code. */ williamr@2: const static TInt KErrRfcommMuxRemoteDisconnect = KRFErrorBase-5; /*!< RFCOMM remote end disconnected error code. */ williamr@2: const static TInt KErrRfcommNotBound = KRFErrorBase-6; /*!< RFCOMM SAP not bound error code. */ williamr@2: const static TInt KErrRfcommParameterNegotiationFailure = KRFErrorBase-7; /*!< RFCOMM parameter negotiation failure error code. */ williamr@2: const static TInt KErrRfcommNotListening = KRFErrorBase-8; /*!< RFCOMM not listening error code. */ williamr@2: const static TInt KErrRfcommNoMoreServerChannels = KRFErrorBase-9; /*!< RFCOMM no more server channels available error code. */ williamr@2: williamr@2: //RFCOMMIoctls williamr@2: williamr@2: const static TInt KRFCOMMModemStatusCmdIoctl =0; /*!< RFCOMM status command Ioctl */ williamr@2: const static TInt KRFCOMMRemoteLineStatusCmdIoctl = 1; /*!< RFCOMM remote line status command Ioctl */ williamr@2: const static TInt KRFCOMMRemotePortNegCmdIoctl = 2; /*!< RFCOMM remote port negotiation command Ioctl */ williamr@2: const static TInt KRFCOMMRemotePortNegRequestIoctl = 3; /*!< RFCOMM remote port negotiation request Ioctl */ williamr@2: const static TInt KRFCOMMConfigChangeIndicationIoctl = 4; /*!< RFCOMM MSC activity Ioctl */ williamr@2: williamr@2: // RFCOMM Options williamr@2: williamr@2: const static TInt KRFCOMMLocalPortParameter = 0; /*!< RFCOMM local port parameter option (Get + Set) */ williamr@2: /** RFCOMM Get Available server channel option (Get only) williamr@2: @deprecated williamr@2: */ williamr@2: const static TInt KRFCOMMGetAvailableServerChannel = 1; williamr@2: williamr@2: const static TInt KRFCOMMMaximumSupportedMTU = 2; /*!< RFCOMM maximum supported option (Get + Set) */ williamr@2: const static TInt KRFCOMMGetDebug1 = 3; /*!< RFCOMM debug option (Get only) */ williamr@2: const static TInt KRFCOMMGetRemoteModemStatus = 4; /*!< RFCOMM remote modem status option (Get + Set) */ williamr@2: williamr@2: const static TInt KRFCOMMGetTransmitCredit = 5; /*!< RFCOMM get transmit credits option */ williamr@2: const static TInt KRFCOMMGetReceiveCredit = 6; /*!< RFCOMM get receive credits option */ williamr@2: const static TInt KRFCOMMGetReUsedCount = 7; /*!< RFCOMM get number of remote used credits option */ williamr@2: const static TInt KRFCOMMFlowTypeCBFC = 8; /*!< RFCOMM Credit based flow control option (Get + Set) */ williamr@2: const static TInt KRFCOMMErrOnMSC = 9; /*!< RFCOMM set the value of MSC signals that will cause a disconnect error to be generated */ williamr@2: const static TUint KRFCOMMLocalModemStatus = 10; /*!< RFCOMM local modem status option (Get + Set) */ williamr@2: 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: williamr@2: const static TInt KRFCOMMMaximumMTU = 12; /*!< RFCOMM maximum optimal MTU (Get only) */ williamr@2: williamr@2: // Masks for interpreting signalling commands williamr@2: const static TUint8 KModemSignalFC = 0x01; /*!< RFCOMM FC signalling command mask */ williamr@2: const static TUint8 KModemSignalRTC = 0x02; /*!< RFCOMM RTC signalling command mask */ williamr@2: const static TUint8 KModemSignalRTR = 0x04; /*!< RFCOMM RTR signalling command mask */ williamr@2: const static TUint8 KModemSignalIC = 0x20; /*!< RFCOMM IC signalling command mask */ williamr@2: const static TUint8 KModemSignalDV = 0x40; /*!< RFCOMM DV signalling command mask */ williamr@2: williamr@2: enum TRPNParameterMask williamr@2: /** Remote port negotiation parameter masks williamr@2: */ williamr@2: { williamr@2: EPMBitRate = 0x0001, /*!< Remote port negotiation parameter masks for bit rate */ williamr@2: EPMDataBits = 0x0002, /*!< Remote port negotiation parameter masks for data bits */ williamr@2: EPMStopBit = 0x0004, /*!< Remote port negotiation parameter masks for stop bit */ williamr@2: EPMParity = 0x0008, /*!< Remote port negotiation parameter masks for parity */ williamr@2: EPMParityType = 0x0010, /*!< Remote port negotiation parameter masks for parity type */ williamr@2: EPMXOnChar = 0x0020, /*!< Remote port negotiation parameter masks for on character */ williamr@2: EPMXOffChar = 0x0040, /*!< Remote port negotiation parameter masks for off character */ williamr@2: // RESERVED = 0x0080 williamr@2: EPMXOnOffInput = 0x0100, /*!< Remote port negotiation parameter masks for XOn/Off input */ williamr@2: EPMXOnOffOutput = 0x0200, /*!< Remote port negotiation parameter masks for XOn/Off output */ williamr@2: EPMRTRInput = 0x0400, /*!< Remote port negotiation parameter masks for read to receive input */ williamr@2: EPMRTROutput = 0x0800, /*!< Remote port negotiation parameter masks for read to receive output */ williamr@2: EPMRTCInput = 0x1000, /*!< Remote port negotiation parameter masks for RTC input */ williamr@2: EPMRTCOutput = 0x2000 /*!< Remote port negotiation parameter masks for RTC output */ williamr@2: // RESERVED = 0x4000 williamr@2: // RESERVED = 0x8000 williamr@2: }; williamr@2: williamr@2: enum TRPNFlowCtrlMask williamr@2: /** Remote port negotiation flow control masks williamr@2: */ williamr@2: { williamr@2: EFCXOnOffInput =0x01, /*!< Remote port negotiation flow control masks for XOn/Off input */ williamr@2: EFCXOnOffOutput =0x02, /*!< Remote port negotiation flow control masks for XOn/Off output */ williamr@2: EFCRTRInput =0x04, /*!< Remote port negotiation flow control masks for ready to receive input */ williamr@2: EFCRTROutput =0x08, /*!< Remote port negotiation flow control masks for ready to receive output */ williamr@2: EFCRTCInput =0x10, /*!< Remote port negotiation flow control masks for RTC input */ williamr@2: EFCRTCOutput =0x20 /*!< Remote port negotiation flow control masks for RTC output */ williamr@2: }; williamr@2: williamr@2: enum TRPNValidityMask williamr@2: /** Remote port negotiation validity masks williamr@2: */ williamr@2: { williamr@2: EVMBitRate = 0x01, /*!< Remote port negotiation validity masks for bit rate */ williamr@2: EVMDataBits = 0x02, /*!< Remote port negotiation validity masks for data bits */ williamr@2: EVMStopBit = 0x04, /*!< Remote port negotiation validity masks for stop bit */ williamr@2: EVMParity = 0x08, /*!< Remote port negotiation validity masks for parity */ williamr@2: EVMFlowCtrl = 0x10, /*!< Remote port negotiation validity masks for flow control */ williamr@2: EVMXOnChar = 0x20, /*!< Remote port negotiation validity masks for XOn charater */ williamr@2: EVMXOffChar = 0x40 /*!< Remote port negotiation validity masks for XOff charater */ williamr@2: }; williamr@2: williamr@2: // structs for RFCOMM Ioctls williamr@2: williamr@2: class TRfcommRPNTransaction; williamr@2: williamr@2: NONSHARABLE_CLASS(TRfcommRemotePortParams) williamr@2: /** RF COMM remote port parameters. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TRfcommRemotePortParams(); williamr@2: IMPORT_C TUint8 IsValid() const; williamr@2: IMPORT_C TBool GetBitRate(TBps& aBitRate) const; williamr@2: IMPORT_C TInt SetBitRate(TBps aBitRate); williamr@2: IMPORT_C TBool GetDataBits(TDataBits& aDataBits) const; williamr@2: IMPORT_C TInt SetDataBits(TDataBits aDataBits); williamr@2: IMPORT_C TBool GetStopBit(TStopBits& aStopBit) const; williamr@2: IMPORT_C TInt SetStopBit(TStopBits aStopBit); williamr@2: IMPORT_C TBool GetParity(TParity& aParity) const; williamr@2: IMPORT_C TInt SetParity(TParity aParity); williamr@2: IMPORT_C TBool GetFlowCtrl(TUint8& aFlowCtrl) const; williamr@2: IMPORT_C TInt SetFlowCtrl(TUint8 aFlowCtrl); williamr@2: IMPORT_C TBool GetXOnChar(TUint8& aXOnChar) const; williamr@2: IMPORT_C TInt SetXOnChar(TUint8 aXOnChar); williamr@2: IMPORT_C TBool GetXOffChar(TUint8& aXOffChar) const; williamr@2: IMPORT_C TInt SetXOffChar(TUint8 aXOffChar); williamr@2: IMPORT_C void UpdateFlowCtrlBit(TUint8 aFlowCtrl, TRPNFlowCtrlMask aFCMask); williamr@2: IMPORT_C void UpdateWholeFlowCtrl(TUint16 aParamMask, TUint8 aFlowCtrl); williamr@2: IMPORT_C void UpdateFromRPNTransaction(const TRfcommRPNTransaction& williamr@2: aRPNTransaction); williamr@2: private: williamr@2: TBps iBitRate; williamr@2: TDataBits iDataBits; williamr@2: TStopBits iStopBit; //It's really only one bit - ignore what the type implies... williamr@2: TParity iParity; williamr@2: TUint8 iFlowCtrl; williamr@2: TUint8 iXOnChar; williamr@2: TUint8 iXOffChar; williamr@2: TUint8 iValidMask; williamr@2: williamr@2: // This data padding has been added to help prevent future binary compatibility breaks williamr@2: // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used williamr@2: TUint32 iPadding1; williamr@2: TUint32 iPadding2; williamr@2: }; williamr@2: williamr@2: // structs for RFCOMM Ioctls williamr@2: williamr@2: NONSHARABLE_CLASS(TRfcommRPNTransaction) williamr@2: /** RF COMM IO control structs. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: // Functions williamr@2: IMPORT_C TRfcommRPNTransaction(); williamr@2: public: // Variables williamr@2: TRfcommRemotePortParams iPortParams; /*!< Remote port parameters */ williamr@2: TUint16 iParamMask; /*!< Parameter mask */ williamr@2: }; williamr@2: williamr@2: // RFCOMM addresses williamr@2: williamr@2: typedef TUint8 TRfcommChannel; /*!< RFCOMM channel type definition */ williamr@2: williamr@2: const static TRfcommChannel KMinRfcommServerChannel = 1; /*!< Minimum RFCOMM server channel value */ williamr@2: const static TRfcommChannel KMaxRfcommServerChannel = 30; /*!< Maximum RFCOMM server channel value */ williamr@2: williamr@2: const static TRfcommChannel KRfcommPassiveAutoBind = KMaxTUint8; /*!< Channel value out of the valid range used for passive auto bind. */ williamr@2: williamr@2: NONSHARABLE_CLASS(TRfcommSockAddr) : public TBTSockAddr williamr@2: /** Defines the format of an Rfcomm address. williamr@2: williamr@2: This class uses the TSockAddr data area to hold the address so that williamr@2: it can be passed through the ESOCK boundary. williamr@2: Assumes that the remote RFCOMM instance is always bound to PSM 3 on williamr@2: L2CAP, so there is no way of specifying another remote PSM. williamr@2: williamr@2: @see TBTSockAddr williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TRfcommSockAddr(); williamr@2: IMPORT_C TRfcommSockAddr(const TSockAddr& aSockAddr); williamr@2: IMPORT_C static TRfcommSockAddr& Cast(const TSockAddr& aSockAddr); williamr@2: }; williamr@2: williamr@2: /*****BASEBAND CLIENT*********/ williamr@2: williamr@2: class CBTBasebandSocketProxy; williamr@2: class CBTBasebandPropertySubscriber; williamr@2: williamr@2: class MBasebandObserver; williamr@2: /** Array of device addresses williamr@2: @see Enumerate method williamr@2: */ williamr@2: typedef RArray RBTDevAddrArray; williamr@2: williamr@2: NONSHARABLE_CLASS(RBTBaseband) williamr@2: /** API useful for Bluetooth as seen from a single physical link perspective williamr@2: @internalTechnology williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: RBTBaseband(); williamr@2: //API useful for Bluetooth as seen from a single physical link perspective williamr@2: TInt Open(RSocketServ& aSocketServ, RSocket& aSocket); williamr@2: TInt Open(RSocketServ& aSocketServ, const TBTDevAddr& aDevAddr); williamr@2: void Close(); williamr@2: TInt PhysicalLinkState(TUint32& aState); williamr@2: TInt BasebandState(TUint32& aState); williamr@2: TInt PreventRoleSwitch(); williamr@2: TInt AllowRoleSwitch(); williamr@2: TInt RequestMasterRole(); williamr@2: TInt RequestSlaveRole(); williamr@2: TInt PreventLowPowerModes(TUint32 aLowPowerModes); williamr@2: TInt AllowLowPowerModes(TUint32 aLowPowerModes); williamr@2: TInt ActivateSniffRequester(); williamr@2: TInt ActivateParkRequester(); williamr@2: TInt CancelLowPowerModeRequester(); williamr@2: TInt RequestExplicitActiveMode(TBool aActive); williamr@2: TInt RequestChangeSupportedPacketTypes(TUint16 aPacketTypes); williamr@2: //THE TWO NOTIFY METHODS BELOW MUST NOT BE CALLED CONCURRENTLY williamr@2: //Method to be used if only the next event should be notified williamr@2: void ActivateNotifierForOneShot(TBTBasebandEvent& aEventNotification, williamr@2: TRequestStatus& aStatus, williamr@2: TUint32 aEventMask); williamr@2: //Method to be used if it is intended to call it again williamr@2: //(or call CancelNextBasebandChangeEventNotifier) when it completes williamr@2: // - this sets up a continuous monitoring of events on the server. williamr@2: //Each time ActivateNotifierForOneShot is called it will either return williamr@2: //the next event in the servers notification queue or if the williamr@2: //queue is empty it will await the next event. williamr@2: void ActivateNotifierForRecall(TBTBasebandEvent& aEventNotification, williamr@2: TRequestStatus& aStatus, williamr@2: TUint32 aEventMask); williamr@2: void ReadNewPhysicalLinkMetricValue(TRequestStatus& aStatus, williamr@2: TDes8& aData, williamr@2: TBTLMIoctls aIoctl); williamr@2: void CancelPhysicalLinkMetricUpdate(); williamr@2: void CancelNextBasebandChangeEventNotifier(); williamr@2: TInt Authenticate(); williamr@2: williamr@2: //API useful for Bluetooth as seen from a device perspective williamr@2: TInt Open(RSocketServ& aSocketServ); williamr@2: void Connect(const TBTDevAddr& aDevAddr, TRequestStatus& aStatus); williamr@2: void Connect(const TPhysicalLinkQuickConnectionToken& aToken, TRequestStatus& aStatus); williamr@2: TInt Broadcast(const TDesC8& aData); // testing broadcast writes williamr@2: TInt ReadRaw(TDes8& aData); williamr@2: TInt Enumerate(RBTDevAddrArray& aBTDevAddrArray, TUint aMaxNumber); williamr@2: void TerminatePhysicalLink(TInt aReason); williamr@2: void TerminatePhysicalLink(TInt aReason, TRequestStatus& aStatus); williamr@2: void TerminatePhysicalLink(TInt aReason, const TBTDevAddr& aDevAddr, TRequestStatus& aStatus); williamr@2: void ShutdownPhysicalLink(TRequestStatus& aStatus); williamr@2: void TerminateAllPhysicalLinks(TInt aReason); williamr@2: void TerminateAllPhysicalLinks(TInt aReason, TRequestStatus& aStatus); williamr@2: TInt SubSessionHandle() const; williamr@2: williamr@2: private: williamr@2: TInt RequestRole(TBTLMOptions aRole); williamr@2: TInt RequestEncrypt(THCIEncryptModeFlag aEnable); williamr@2: void LocalComplete(TRequestStatus& aStatus, TInt aErr); williamr@2: void SetClientPending(TRequestStatus& aStatus); williamr@2: void DoConnect(TRequestStatus& aStatus); williamr@2: TInt Enumerate(TDes8& aData); williamr@2: TInt Construct(); williamr@2: williamr@2: private: williamr@2: TAny* iUnusedPointer; williamr@2: RSocket iSocket; williamr@2: williamr@2: TRequestStatus* iClientRequestStatus; williamr@2: TBTSockAddr iSocketAddress; williamr@2: TPhysicalLinkQuickConnectionTokenBuf iConnectToken; williamr@2: TBuf8<1> iConnectInData; // not used yet - needed tho! williamr@2: TBuf8<1> iDummySCOShutdownDescriptor; williamr@2: williamr@2: // This data padding has been added to help prevent future binary compatibility breaks williamr@2: // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used williamr@2: TUint32 iPadding1; williamr@2: TUint32 iPadding2; williamr@2: }; williamr@2: williamr@2: NONSHARABLE_CLASS(RBTPhysicalLinkAdapter) williamr@2: /** Class to enable modification of a physical link: williamr@2: williamr@2: Modifications may be requested or prevented (blocked). williamr@2: Whilst a modification is being prevented, any request to williamr@2: perform that modification by this or any other williamr@2: RBTPhysicalLinkAdapter client will be ignored. williamr@2: If a low power mode is being used on the physical link, a williamr@2: call to prevent that low power mode will, if possible, cause williamr@2: the physical link to exit that low power mode. An williamr@2: arbitration between all RBTPhysicalLinkAdapter clients will then occur williamr@2: to decide whether the physical link should remain active or williamr@2: enter another low power mode. (If all low power modes are prevented williamr@2: then that arbitration will result in the physical link remaining williamr@2: active.) williamr@2: williamr@2: Methods to prevent modifications begin 'Prevent...' williamr@2: williamr@2: Methods to cancel the prevention of modification begin 'Allow...' williamr@2: williamr@2: Requests for low power mode modifications, and notification of modifications williamr@2: take the form of continuously repeated requests which can be switched on or williamr@2: switched off. williamr@2: williamr@2: Only one low power mode requester may active on a single RBTPhysicalLinkAdapter williamr@2: client at a time. If several RBTPhysicalLinkAdapter clients have differing low williamr@2: power mode requests active at a given moment then the priority will be: williamr@2: Hold williamr@2: Sniff williamr@2: Park williamr@2: williamr@2: Methods to perform these requests start 'Activate...' williamr@2: williamr@2: Methods to cancel these requests start 'Cancel...' williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C RBTPhysicalLinkAdapter(); williamr@2: IMPORT_C TInt Open(RSocketServ& aSocketServ, RSocket& aSocket); williamr@2: IMPORT_C TInt Open(RSocketServ& aSocketServ, const TBTDevAddr& aDevAddr); williamr@2: IMPORT_C TBool IsOpen() const; williamr@2: IMPORT_C void Close(); williamr@2: IMPORT_C TInt PhysicalLinkState(TUint32& aState); williamr@2: IMPORT_C TInt PreventRoleSwitch(); williamr@2: IMPORT_C TInt AllowRoleSwitch(); williamr@2: IMPORT_C TInt RequestMasterRole(); williamr@2: IMPORT_C TInt RequestSlaveRole(); williamr@2: IMPORT_C TInt PreventLowPowerModes(TUint32 aLowPowerModes); williamr@2: IMPORT_C TInt AllowLowPowerModes(TUint32 aLowPowerModes); williamr@2: IMPORT_C TInt ActivateSniffRequester(); williamr@2: IMPORT_C TInt ActivateParkRequester(); williamr@2: IMPORT_C TInt ActivateActiveRequester(); williamr@2: IMPORT_C TInt CancelLowPowerModeRequester(); williamr@2: IMPORT_C TInt RequestChangeSupportedPacketTypes(TUint16 aPacketTypes); williamr@2: IMPORT_C void NotifyNextBasebandChangeEvent(TBTBasebandEvent& aEventNotification, williamr@2: TRequestStatus& aStatus, williamr@2: TUint32 aEventMask = ENotifyAnyPhysicalLinkState); williamr@2: williamr@2: IMPORT_C void CancelNextBasebandChangeEventNotifier(); williamr@2: IMPORT_C TInt Authenticate(); williamr@2: williamr@2: private: williamr@2: RBTBaseband iBTBaseband; williamr@2: williamr@2: // This data padding has been added to help prevent future binary compatibility breaks williamr@2: // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used williamr@2: TUint32 iPadding1; williamr@2: TUint32 iPadding2; williamr@2: }; williamr@2: williamr@2: /** williamr@2: This allows for notification of events relating to a CBluetoothPhysicalLinkMetrics object. williamr@2: williamr@2: These notifications will be called when the value of a physical link metric that has been williamr@2: subscribed to in CBluetoothPhysicalLinkMetrics changes. If the notification is not called, williamr@2: the value has not changed since the last notification williamr@2: williamr@2: Mixin class to be used with CBluetoothPhysicalLinkMetrics williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class MBluetoothPhysicalLinkMetricsObserver williamr@2: { williamr@2: public: williamr@2: /** williamr@2: Notification for the initial RSSI (received signal strengh indication) value williamr@2: and whenever the RSSI changes williamr@2: @param aRssi Current RSSI Value in dB williamr@2: */ williamr@2: virtual void MbplmoRssiChanged(TInt8 aRssi) = 0; williamr@2: williamr@2: /** williamr@2: Notification for the initial Link Quality value and whenever the Link Quality changes. williamr@2: @param aLinkQuality Link quality for this connection where the higher value represents a better quality link williamr@2: */ williamr@2: virtual void MbplmoLinkQualityChanged(TUint8 aLinkQuality) = 0; williamr@2: williamr@2: /** williamr@2: Notification for the initial failed contact counter value, and whenever the failed contact counter changes. williamr@2: @param aFailedContactCounter Number of consecutive failed contacts for this connection williamr@2: */ williamr@2: virtual void MbplmoFailedContactCounterChanged(TUint16 aFailedContactCounter) = 0; williamr@2: williamr@2: /** williamr@2: Notification for the initial transmit power level, and whenever the transmit power level changes. williamr@2: @param aTransmitPowerLevel Transmit power level in dBm williamr@2: */ williamr@2: virtual void MbplmoTransmitPowerLevelChanged(TInt8 aTransmitPowerLevel) = 0; williamr@2: williamr@2: /** williamr@2: Notification that an error has occured. When this is called, the current williamr@2: subscriptions will be cancelled. williamr@2: If a link disconnection occurs, the CBluetoothPhysicalLinkMetrics object will williamr@2: no longer be valid, so it is recommended to delete the object in this callback williamr@2: */ williamr@2: virtual void MbplmoError(TInt aError) = 0; williamr@2: williamr@2: /** williamr@2: Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is. williamr@2: @param aInterface UID of the interface to return williamr@2: @return The container for another interface as specified by aInterface williamr@2: */ williamr@2: IMPORT_C virtual TAny* MbplmoExtensionInterfaceL(TUid aInterface); williamr@2: }; williamr@2: williamr@2: class CBluetoothPhysicalLinkMetricSubscriber; williamr@2: williamr@2: /** williamr@2: Class to subscribe to physical link metrics williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: NONSHARABLE_CLASS(CBluetoothPhysicalLinkMetrics): public CBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CBluetoothPhysicalLinkMetrics* NewL( williamr@2: MBluetoothPhysicalLinkMetricsObserver& aObserver, williamr@2: RSocketServ& aSockServ, williamr@2: RSocket& aConnectedSocket); williamr@2: williamr@2: IMPORT_C static CBluetoothPhysicalLinkMetrics* NewL( williamr@2: MBluetoothPhysicalLinkMetricsObserver& aObserver, williamr@2: RSocketServ& aSockServ, williamr@2: const TBTDevAddr& aAddr); williamr@2: williamr@2: IMPORT_C ~CBluetoothPhysicalLinkMetrics(); williamr@2: IMPORT_C void SubscribeRssi(); williamr@2: IMPORT_C void SubscribeLinkQuality(); williamr@2: IMPORT_C void SubscribeFailedContactCounter(); williamr@2: IMPORT_C void SubscribeTransmitPowerLevel(); williamr@2: IMPORT_C void Cancel(); williamr@2: williamr@2: void RssiChanged(TInt8 aRssi); williamr@2: void LinkQualityChanged(TUint8 aLinkQuality); williamr@2: void FailedContactCounterChanged(TUint16 aFailedContactCounter); williamr@2: void TransmitPowerLevelChanged(TInt8 aTransmitPowerLevel); williamr@2: void SubscribeError(TInt aError); williamr@2: williamr@2: williamr@2: private: williamr@2: CBluetoothPhysicalLinkMetrics(MBluetoothPhysicalLinkMetricsObserver& aObserver); williamr@2: template void ConstructL(RSocketServ& aSockServ, T& aLinkIdentifier); williamr@2: williamr@2: private: williamr@2: MBluetoothPhysicalLinkMetricsObserver& iObserver; williamr@2: CBluetoothPhysicalLinkMetricSubscriber* iRssiBaseband; williamr@2: CBluetoothPhysicalLinkMetricSubscriber* iLinkQualityBaseband; williamr@2: CBluetoothPhysicalLinkMetricSubscriber* iFailedContactCounterBaseband; williamr@2: CBluetoothPhysicalLinkMetricSubscriber* iTransmitPowerLevelBaseband; williamr@2: }; williamr@2: williamr@2: williamr@2: class MBluetoothSocketNotifier williamr@2: /** This allows for notification of events relating to a CBluetoothSocket object. williamr@2: williamr@2: Such notification consists of notification of logical link events (for example receipt williamr@2: of a user packet) and physical link state events (for example change of power mode). williamr@2: williamr@2: Mixin class to be used with CBluetoothSocket williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** Notification of a connection complete event. williamr@2: williamr@2: If no error is reported, then the connection is ready for use. williamr@2: @note If the implementation of this function needs to delete associated williamr@2: CBluetoothSocket object, it should NOT use delete operator. The implementation williamr@2: should call CBluetoothSocket::AsyncDelete() method instead. williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleConnectCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** Notification of an accept complete event. williamr@2: williamr@2: If no error is reported, then we have accepted a connection request williamr@2: and that connection is ready for use. williamr@2: @note If the implementation of this function needs to delete associated williamr@2: CBluetoothSocket object, it should NOT use delete operator. The implementation williamr@2: should call CBluetoothSocket::AsyncDelete() method instead. williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleAcceptCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** Notification of a shutdown complete event. williamr@2: williamr@2: If no error is reported, then the connection has been closed. williamr@2: @note If the implementation of this function needs to delete associated williamr@2: CBluetoothSocket object, it should NOT use delete operator. The implementation williamr@2: should call CBluetoothSocket::AsyncDelete() method instead. williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleShutdownCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** Notification of a send complete event. williamr@2: williamr@2: If no error is reported, then an attempt to send data over Bluetooth has succeeded. williamr@2: @note If the implementation of this function needs to delete associated williamr@2: CBluetoothSocket object, it should NOT use delete operator. The implementation williamr@2: should call CBluetoothSocket::AsyncDelete() method instead. williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleSendCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** Notification of a receive complete event. williamr@2: williamr@2: If no error is reported, then then we have successfully received williamr@2: a specified quantity of data. williamr@2: @note If the implementation of this function needs to delete associated williamr@2: CBluetoothSocket object, it should NOT use delete operator. The implementation williamr@2: should call CBluetoothSocket::AsyncDelete() method instead. williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleReceiveCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** Notification of a ioctl complete event. williamr@2: williamr@2: An HCI request that has an associated command complete has completed. williamr@2: @note If the implementation of this function needs to delete associated williamr@2: CBluetoothSocket object, it should NOT use delete operator. The implementation williamr@2: should call CBluetoothSocket::AsyncDelete() method instead. williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleIoctlCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** Notification of a baseband event. williamr@2: williamr@2: If no error is reported, then a baseband event has been retrieved successfully. williamr@2: @note If the implementation of this function needs to delete associated williamr@2: CBluetoothSocket object, it should NOT use delete operator. The implementation williamr@2: should call CBluetoothSocket::AsyncDelete() method instead. williamr@2: @param aErr the returned error williamr@2: @param TBTBasebandEventNotification Bit(s) set in TBTBasebandEventNotification bitmap indicate what event has taken place. williamr@2: @see TBTPhysicalLinkStateNotifier williamr@2: */ williamr@2: virtual void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification& aEventNotification) = 0; williamr@2: williamr@2: /** williamr@2: Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is. williamr@2: @param aInterface UID of the interface to return williamr@2: @param aObject the container for another interface as specified by aInterface williamr@2: */ williamr@2: IMPORT_C virtual void MBSN_ExtensionInterfaceL(TUid aInterface, void*& aObject); williamr@2: }; williamr@2: williamr@2: williamr@2: class CBTConnecter; williamr@2: class CBTAccepter; williamr@2: class CBTShutdowner; williamr@2: class CBTReceiver; williamr@2: class CBTSender; williamr@2: class CBTIoctler; williamr@2: class CBTBasebandChangeEventNotifier; williamr@2: class CAutoSniffDelayTimer; williamr@2: class CBTBasebandManager; williamr@2: class CBTBasebandChangeEventDelegate; williamr@2: williamr@2: NONSHARABLE_CLASS(CBluetoothSocket): public CBase williamr@2: /** This allows Bluetooth ACL socket-based services to be run. williamr@2: williamr@2: It allows all user-plane data flow to occur, plus control-plane Bluetooth williamr@2: baseband modification capabilities. williamr@2: williamr@2: For a more detailed description of RBTBaseband functionality see the class and function documentation for williamr@2: RBTPhysicalLinkAdapter. williamr@2: williamr@2: This class doesn't provide the functionality to directly activate Active mode williamr@2: (this is implementated in class RBTPhysicalLinkAdapter.) williamr@2: @see RBTPhysicalLinkAdapter::ActivateActiveRequester() williamr@2: Explicit Active mode requests are made automatically when using the Automatic Sniff Requester williamr@2: utility provided by this class. williamr@2: @see CBluetoothSocket::SetAutomaticSniffMode williamr@2: williamr@2: @see RBTPhysicalLinkAdapter williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: friend class CBTAccepter; williamr@2: public: williamr@2: IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, williamr@2: RSocketServ& aServer,TUint aSockType, williamr@2: TUint aProtocol); williamr@2: IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, williamr@2: RSocketServ& aServer,TUint aSockType, williamr@2: TUint aProtocol); williamr@2: IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, williamr@2: RSocketServ& aServer,TUint aSockType, williamr@2: TUint aProtocol, williamr@2: RConnection& aConnection); williamr@2: IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, williamr@2: RSocketServ& aServer, williamr@2: TUint aSockType,TUint aProtocol, williamr@2: RConnection& aConnection); williamr@2: IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, williamr@2: RSocketServ& aServer, williamr@2: const TDesC& aName); williamr@2: IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, williamr@2: RSocketServ& aServer, williamr@2: const TDesC& aName); williamr@2: IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, williamr@2: RSocketServ& aServer); williamr@2: IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, williamr@2: RSocketServ& aServer); williamr@2: IMPORT_C static CBluetoothSocket* NewL(MBluetoothSocketNotifier& aNotifier, williamr@2: RSocketServ& aServer, williamr@2: RSocket& aSocket); williamr@2: IMPORT_C static CBluetoothSocket* NewLC(MBluetoothSocketNotifier& aNotifier, williamr@2: RSocketServ& aServer, williamr@2: RSocket& aSocket); williamr@2: IMPORT_C ~CBluetoothSocket(); williamr@2: williamr@2: //Forwarding functions to RSocket williamr@2: IMPORT_C TInt Send(const TDesC8& aDesc,TUint someFlags); williamr@2: IMPORT_C TInt Send(const TDesC8& aDesc,TUint someFlags,TSockXfrLength& aLen); williamr@2: IMPORT_C void CancelSend(); williamr@2: IMPORT_C TInt Recv(TDes8& aDesc,TUint flags); williamr@2: IMPORT_C TInt Recv(TDes8& aDesc,TUint flags,TSockXfrLength& aLen); williamr@2: IMPORT_C TInt RecvOneOrMore(TDes8& aDesc,TUint flags,TSockXfrLength& aLen); williamr@2: IMPORT_C void CancelRecv(); williamr@2: IMPORT_C TInt Read(TDes8& aDesc); williamr@2: IMPORT_C void CancelRead(); williamr@2: IMPORT_C TInt Write(const TDesC8& aDesc); williamr@2: IMPORT_C void CancelWrite(); williamr@2: IMPORT_C TInt SendTo(const TDesC8& aDesc,TSockAddr& aSockAddr,TUint flags); williamr@2: IMPORT_C TInt SendTo(const TDesC8& aDesc,TSockAddr& aSockAddr,TUint flags,TSockXfrLength& aLen); williamr@2: IMPORT_C TInt RecvFrom(TDes8& aDesc,TSockAddr& aSockAddr,TUint flags); williamr@2: IMPORT_C TInt RecvFrom(TDes8& aDesc,TSockAddr& aSockAddr,TUint flags,TSockXfrLength& aLen); williamr@2: IMPORT_C TInt Connect(TBTSockAddr& aSockAddr); williamr@2: IMPORT_C TInt Connect(TBTSockAddr& aSockAddr,const TDesC8& aConnectDataOut,TDes8& aConnectDataIn); williamr@2: IMPORT_C TInt Connect(TBTSockAddr& aAddr, TUint16 aServiceBits); williamr@2: IMPORT_C void CancelConnect(); williamr@2: IMPORT_C TInt Bind(TSockAddr& aSockAddr); williamr@2: IMPORT_C TInt SetLocalPort(TInt aPort); williamr@2: IMPORT_C TInt Accept(CBluetoothSocket& aBlankSocket); williamr@2: IMPORT_C TInt Accept(CBluetoothSocket& aBlankSocket,TDes8& aConnectData); williamr@2: IMPORT_C void CancelAccept(); williamr@2: IMPORT_C TInt Listen(TUint qSize); williamr@2: IMPORT_C TInt Listen(TUint qSize,const TDesC8& aConnectData); williamr@2: IMPORT_C TInt Listen(TUint qSize, TUint16 aServiceBits); williamr@2: IMPORT_C TInt SetOpt(TUint aOptionName,TUint aOptionLevel,TInt aOption); williamr@2: IMPORT_C TInt SetOption(TUint aOptionName,TUint aOptionLevel,const TDesC8& aOption); williamr@2: IMPORT_C TInt GetOpt(TUint aOptionName,TUint aOptionLevel,TDes8& aOption); williamr@2: IMPORT_C TInt GetOpt(TUint aOptionName,TUint aOptionLevel,TInt &aOption); williamr@2: IMPORT_C TInt Ioctl(TUint aLevel, TUint aCommand, TDes8* aDesc); williamr@2: IMPORT_C void CancelIoctl(); williamr@2: IMPORT_C TInt GetDisconnectData(TDes8& aDesc); williamr@2: IMPORT_C void LocalName(TSockAddr& aSockAddr); williamr@2: IMPORT_C TUint LocalPort(); williamr@2: IMPORT_C void RemoteName(TSockAddr& aSockAddr); williamr@2: IMPORT_C TInt Shutdown(RSocket::TShutdown aHow); williamr@2: IMPORT_C TInt Shutdown(RSocket::TShutdown aHow,const TDesC8& aDisconnectDataOut,TDes8& aDisconnectDataIn); williamr@2: IMPORT_C void CancelAll(); williamr@2: IMPORT_C TInt Info(TProtocolDesc& aProtocol); williamr@2: IMPORT_C TInt Name(TName& aName); williamr@2: IMPORT_C TInt Transfer(RSocketServ& aServer, const TDesC& aName); williamr@2: williamr@2: williamr@2: //Forwarding functions to RBTBaseband williamr@2: IMPORT_C TInt PhysicalLinkState(TUint32& aState); williamr@2: IMPORT_C TInt PreventRoleSwitch(); williamr@2: IMPORT_C TInt AllowRoleSwitch(); williamr@2: IMPORT_C TInt RequestMasterRole(); williamr@2: IMPORT_C TInt RequestSlaveRole(); williamr@2: IMPORT_C TInt PreventLowPowerModes(TUint32 aLowPowerModes); williamr@2: IMPORT_C TInt AllowLowPowerModes(TUint32 aLowPowerModes); williamr@2: IMPORT_C TInt ActivateSniffRequester(); williamr@2: IMPORT_C TInt ActivateParkRequester(); williamr@2: IMPORT_C TInt CancelLowPowerModeRequester(); williamr@2: IMPORT_C TInt RequestChangeSupportedPacketTypes(TUint16 aPacketTypes); williamr@2: IMPORT_C TInt ActivateBasebandEventNotifier(TUint32 aEventTypes); williamr@2: IMPORT_C void CancelBasebandEventNotifier(); williamr@2: williamr@2: IMPORT_C void SetNotifier(MBluetoothSocketNotifier& aNewNotifier); williamr@2: IMPORT_C TInt SetAutomaticSniffMode(TBool aAutoSniffMode); williamr@2: IMPORT_C TInt SetAutomaticSniffMode(TBool aAutoSniffMode, TInt aIdleSecondsBeforeSniffRequest); williamr@2: IMPORT_C TBool AutomaticSniffMode() const; williamr@2: williamr@2: IMPORT_C void AsyncDelete(); williamr@2: williamr@2: //Callback functions called by active object RunLs. williamr@2: // NB These functions kill the active objects that call them (cf mating spiders) williamr@2: MBluetoothSocketNotifier& Notifier(); williamr@2: void HandleConnectCompleteL(TInt aErr); williamr@2: void HandleAcceptCompleteL(TInt aErr); williamr@2: void HandleShutdownCompleteL(TInt aErr); williamr@2: void HandleSendCompleteL(TInt aErr); williamr@2: void HandleReceiveCompleteL(TInt aErr); williamr@2: void HandleIoctlCompleteL(TInt aErr); williamr@2: void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification aEventNotification); williamr@2: williamr@2: /** williamr@2: @deprecated williamr@2: */ williamr@2: IMPORT_C TInt Ioctl(TUint aCommand,TDes8* aDesc=NULL,TUint aLevel=KLevelUnspecified); williamr@2: williamr@2: /** williamr@2: @deprecated williamr@2: */ williamr@2: IMPORT_C TInt SetOpt(TUint aOptionName,TUint aOptionLevel,const TDesC8& aOption=TPtrC8(NULL,0)); williamr@2: public: williamr@2: RSocket& Socket(); williamr@2: RSocketServ& SocketServer(); williamr@2: RBTBaseband& BTBaseband(); williamr@2: CBTBasebandManager& BTBasebandManager(); williamr@2: williamr@2: private: williamr@2: CBluetoothSocket(MBluetoothSocketNotifier& aNotifier, RSocketServ& aServer); williamr@2: void ConstructL(TUint aSockType,TUint aProtocol); williamr@2: void ConstructL(TUint aSockType,TUint aProtocol, RConnection& aConnection); williamr@2: void ConstructL(const TDesC& aName); williamr@2: void ConstructL(); williamr@2: void ConstructL(RSocket& aSocket); williamr@2: void InitialiseL(); williamr@2: static TInt AsyncDeleteCallBack(TAny *aThisPtr); williamr@2: void ConfigureSocket(); williamr@2: williamr@2: private: williamr@2: RSocket iSocket; williamr@2: RSocketServ& iSockServer; williamr@2: TBTSockAddr iSockAddr; williamr@2: williamr@2: MBluetoothSocketNotifier* iNotifier; williamr@2: williamr@2: CBTConnecter* iBTConnecter; williamr@2: CBTAccepter* iBTAccepter; williamr@2: CBTShutdowner* iBTShutdowner; williamr@2: CBTReceiver* iBTReceiver; //for read, recv etc williamr@2: CBTSender* iBTSender; //for send, write etc williamr@2: CBTIoctler* iBTIoctler; williamr@2: CBTBasebandChangeEventNotifier* iBTBasebandChangeEventNotifier; williamr@2: TUint32 iNotifierEventMask; williamr@2: TBool iSending; williamr@2: TBool iReceiving; williamr@2: williamr@2: RBTBaseband iBTBaseband; williamr@2: CAutoSniffDelayTimer* iAutoSniffDelayTimer; williamr@2: CBTBasebandManager* iBTBasebandManager; williamr@2: CBTBasebandChangeEventDelegate* iBTBasebandChangeEventDelegate; williamr@2: williamr@2: CAsyncCallBack* iAsyncDestroyer; //for async deletion williamr@2: }; williamr@2: williamr@2: williamr@2: class MBluetoothSynchronousLinkNotifier williamr@2: /** SCO and eSCO link notification events. williamr@2: williamr@2: This allows for notification of Connect, Disconnect, Send and williamr@2: Receive events relating to SCO and eSCO links. williamr@2: williamr@2: Mixin class to be used with CBluetoothSynchronousLink williamr@2: Note that although the function signatures allow it, these functions should williamr@2: not be allowed to leave as the error will be ignored. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** Notification that a synchronous link (SCO) has been set up williamr@2: williamr@2: If no error is reported, then the synchronous link is ready for use. williamr@2: @note 1) Observe that although the function signature allows it, this function should williamr@2: not be allowed to leave as the error will be ignored. williamr@2: @note 2) The implementation of this function should NOT be used to delete the associated williamr@2: CBluetoothSynchronousLink object. williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleSetupConnectionCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** Notification that a synchronous link (SCO) has disconnected williamr@2: williamr@2: If no error is reported, then the synchronous link has been closed. williamr@2: @note 1) Observe that although the function signature allows it, this function should williamr@2: not be allowed to leave as the error will be ignored. williamr@2: @note 2) The implementation of this function should NOT be used to delete the associated williamr@2: CBluetoothSynchronousLink object. williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleDisconnectionCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** Notification that a synchronous link (SCO) has been accepted williamr@2: williamr@2: If no error is reported, then we have accepted a request for a synchronous link. williamr@2: That synchronous link is ready for use. williamr@2: @note 1) Observe that although the function signature allows it, this function should williamr@2: not be allowed to leave as the error will be ignored. williamr@2: @note 2) The implementation of this function should NOT be used to delete the associated williamr@2: CBluetoothSynchronousLink object. williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleAcceptConnectionCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** Notification of a send complete event williamr@2: williamr@2: If no error is reported, then an attempt to send synchronous (SCO) data williamr@2: (e.g. voice) over Bluetooth has succeeded. williamr@2: @note 1) Observe that although the function signature allows it, this function should williamr@2: not be allowed to leave as the error will be ignored. williamr@2: @note 2) The implementation of this function should NOT be used to delete the associated williamr@2: CBluetoothSynchronousLink object. williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleSendCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** Notification of a receive complete event williamr@2: williamr@2: If no error is reported, then then we have successfully received williamr@2: a specified quantity of synchronous (SCO) data. williamr@2: @note 1) Observe that although the function signature allows it, this function should williamr@2: not be allowed to leave as the error will be ignored. williamr@2: @note 2) The implementation of this function should NOT be used to delete the associated williamr@2: CBluetoothSynchronousLink object. williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleReceiveCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** williamr@2: Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is. williamr@2: @param aInterface UID of the interface to return williamr@2: @param aObject the container for another interface as specified by aInterface williamr@2: */ williamr@2: IMPORT_C virtual void MBSLN_ExtensionInterfaceL(TUid aInterface, void*& aObject); williamr@2: }; williamr@2: williamr@2: class CBTSynchronousLinkAttacher; williamr@2: class CBTSynchronousLinkDetacher; williamr@2: class CBTSynchronousLinkAccepter; williamr@2: class CBTSynchronousLinkSender; williamr@2: class CBTSynchronousLinkReceiver; williamr@2: class CBTSynchronousLinkBaseband; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A pair of transmit and receive bandwidths for use on synchronous Bluetooth links williamr@2: */ williamr@2: NONSHARABLE_CLASS(TBTSyncBandwidth) williamr@2: { williamr@2: public: williamr@2: IMPORT_C TBTSyncBandwidth(); williamr@2: IMPORT_C TBTSyncBandwidth(TUint aBandwidth); williamr@2: williamr@2: TUint32 iTransmit; williamr@2: TUint32 iReceive; williamr@2: williamr@2: private: williamr@2: // This data padding has been added to help prevent future binary compatibility breaks williamr@2: // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used williamr@2: TUint32 iPadding1; williamr@2: TUint32 iPadding2; williamr@2: }; williamr@2: williamr@2: /** williamr@2: eSCO 64Kbit link utility constant. williamr@2: */ williamr@2: static const TUint KBTSync64KBit = (64000 / 8); williamr@2: williamr@2: /** williamr@2: @internalTechnology williamr@2: Used internally to hold eSCO link parameters. Not intended for use. williamr@2: */ williamr@2: NONSHARABLE_CLASS(TBTeSCOLinkParams) williamr@2: { williamr@2: public: williamr@2: TBTeSCOLinkParams() {}; williamr@2: TBTeSCOLinkParams(TUint aBandwidth, TUint16 aCoding, TUint16 aLatency, TUint8 aRetransmission); williamr@2: williamr@2: TBTSyncBandwidth iBandwidth; williamr@2: TUint16 iCoding; williamr@2: TUint16 iLatency; williamr@2: TUint8 iRetransmissionEffort; williamr@2: }; williamr@2: williamr@2: enum TSCOType williamr@2: /** Bluetooth link SCO type williamr@2: @internalTechnology williamr@2: */ williamr@2: { williamr@2: ESCO=0x01, /*!< Synchronous Connection Oriented link */ williamr@2: EeSCO=0x02 /*!< eSCO link */ williamr@2: }; williamr@2: williamr@2: NONSHARABLE_CLASS(CBluetoothSynchronousLink): public CBase williamr@2: /** Provides Bluetooth SCO functionality. williamr@2: williamr@2: This allows Bluetooth SCO (synchronous) link Connect, Disconnect, Send and Receive. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CBluetoothSynchronousLink* NewL(MBluetoothSynchronousLinkNotifier& aNotifier, williamr@2: RSocketServ& aServer); williamr@2: IMPORT_C static CBluetoothSynchronousLink* NewLC(MBluetoothSynchronousLinkNotifier& aNotifier, williamr@2: RSocketServ& aServer); williamr@2: IMPORT_C ~CBluetoothSynchronousLink(); williamr@2: williamr@2: IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr); williamr@2: IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr, const TUint16 aPacketTypes); williamr@2: IMPORT_C TInt SetupConnection(const TBTDevAddr& aDevAddr, const TBTSyncPackets& aPacketTypes); williamr@2: IMPORT_C void CancelSetup(); williamr@2: IMPORT_C TInt Disconnect(); williamr@2: IMPORT_C TInt Send(const TDesC8& aData); williamr@2: IMPORT_C void CancelSend(); williamr@2: IMPORT_C TInt Receive(TDes8& aData); williamr@2: IMPORT_C void CancelReceive(); williamr@2: IMPORT_C TInt AcceptConnection(); williamr@2: IMPORT_C TInt AcceptConnection(const TBTSyncPackets& aPacketTypes); williamr@2: IMPORT_C void CancelAccept(); williamr@2: williamr@2: IMPORT_C void SetCoding(TUint16 aVoiceSetting); williamr@2: IMPORT_C void SetMaxBandwidth(TBTSyncBandwidth aMaximum); williamr@2: IMPORT_C void SetMaxLatency(TUint16 aLatency); williamr@2: IMPORT_C void SetRetransmissionEffort(TBTeSCORetransmissionTypes aRetransmissionEffort); williamr@2: williamr@2: IMPORT_C TUint16 Coding(); williamr@2: IMPORT_C TBTSyncBandwidth Bandwidth(); williamr@2: IMPORT_C TUint16 Latency(); williamr@2: IMPORT_C TUint8 RetransmissionEffort(); williamr@2: williamr@2: IMPORT_C void RemoteName(TSockAddr& aAddr); williamr@2: williamr@2: IMPORT_C void SetNotifier(MBluetoothSynchronousLinkNotifier& aNotifier); williamr@2: williamr@2: MBluetoothSynchronousLinkNotifier& Notifier(); williamr@2: RSocket& SCOSocket(); williamr@2: RSocket& ESCOSocket(); williamr@2: RSocket& ListeningSCOSocket(); williamr@2: RSocket& ListeningESCOSocket(); williamr@2: RSocketServ& SocketServer(); williamr@2: RBTBaseband& Baseband(); williamr@2: williamr@2: williamr@2: //Callback methods called by active object RunLs. williamr@2: void HandleSetupConnectionCompleteL(TInt aErr, TSCOType aSCOType); williamr@2: void HandleAcceptConnectionCompleteL(TInt aErr, TSCOType aSCOType); williamr@2: void HandleDisconnectionCompleteL(TInt aErr); williamr@2: void HandleSendCompleteL(TInt aErr); williamr@2: void HandleReceiveCompleteL(TInt aErr); williamr@2: williamr@2: private: williamr@2: CBluetoothSynchronousLink(MBluetoothSynchronousLinkNotifier& aNotifier, RSocketServ& aServer); williamr@2: void ConstructL(); williamr@2: void UpdateLinkParams(TSCOType aSCOType); williamr@2: TInt LinkUp(TBTDevAddr aAddr); williamr@2: void LinkDown(); williamr@2: williamr@2: private: williamr@2: CBTSynchronousLinkSender* iBTSynchronousLinkSenderSCO; williamr@2: CBTSynchronousLinkSender* iBTSynchronousLinkSenderESCO; williamr@2: CBTSynchronousLinkReceiver* iBTSynchronousLinkReceiverSCO; williamr@2: CBTSynchronousLinkReceiver* iBTSynchronousLinkReceiverESCO; williamr@2: CBTSynchronousLinkAccepter* iBTSynchronousLinkAccepterSCO; williamr@2: CBTSynchronousLinkAccepter* iBTSynchronousLinkAccepterESCO; williamr@2: CBTSynchronousLinkAttacher* iBTSynchronousLinkAttacherSCO; williamr@2: CBTSynchronousLinkAttacher* iBTSynchronousLinkAttacherESCO; williamr@2: CBTSynchronousLinkDetacher* iBTSynchronousLinkDetacherSCO; williamr@2: CBTSynchronousLinkDetacher* iBTSynchronousLinkDetacherESCO; williamr@2: CBTSynchronousLinkBaseband* iBTSynchronousLinkBaseband; williamr@2: MBluetoothSynchronousLinkNotifier* iNotifier; williamr@2: RSocket iSCOSocket; williamr@2: RSocket iESCOSocket; williamr@2: RSocket iListeningSCOSocket; williamr@2: RSocket iListeningESCOSocket; williamr@2: RBTBaseband iBaseband; williamr@2: RSocketServ& iSockServer; williamr@2: TBTSockAddr iSockAddr; williamr@2: TBuf8<1> iDummySCOShutdownDescriptor; williamr@2: williamr@2: TBTeSCOLinkParams iRequestedLink; williamr@2: TBTeSCOLinkParams iNegotiatedLink; williamr@2: williamr@2: TUint8 iSCOTypes; williamr@2: williamr@2: TBool iOpeningSCO; williamr@2: TBool iOpeningESCO; williamr@2: TBool iOpenedSCO; williamr@2: }; williamr@2: williamr@2: williamr@2: class MBluetoothPhysicalLinksNotifier williamr@2: /** This allows for notifications of Physical link connections & disconnections williamr@2: williamr@2: Mixin class to be used with CBluetoothPhysicalLinks williamr@2: williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** Notification of a requested connection coming up williamr@2: williamr@2: If no error is reported, then that connection is ready for use. williamr@2: @note 1) While this function may leave, any errors are ignored. Implementers are williamr@2: responsible for performing their own cleanup prior to exiting the function. williamr@2: @note 2) The implementation of this function should NOT be used to delete the associated williamr@2: CBluetoothPhysicalLinks object. williamr@2: williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleCreateConnectionCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** Notification of a requested disconnection having taken place williamr@2: williamr@2: If no error is reported, then that connection has been closed. williamr@2: @note 1) While this function may leave, any errors are ignored. Implementers are williamr@2: responsible for performing their own cleanup prior to exiting the function. williamr@2: @note 2) The implementation of this function should NOT be used to delete the associated williamr@2: CBluetoothPhysicalLinks object. williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleDisconnectCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** Notification that all existing connections have been torn down williamr@2: williamr@2: If no error is reported, then there are no Bluetooth connections existing. williamr@2: @note 1) While this function may leave, any errors are ignored. Implementers are williamr@2: responsible for performing their own cleanup prior to exiting the function. williamr@2: @note 2) The implementation of this function should NOT be used to delete the associated williamr@2: CBluetoothPhysicalLinks object. williamr@2: @param aErr the returned error williamr@2: */ williamr@2: virtual void HandleDisconnectAllCompleteL(TInt aErr) = 0; williamr@2: williamr@2: /** williamr@2: Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is. williamr@2: @param aInterface UID of the interface to return williamr@2: @param aObject the container for another interface as specified by aInterface williamr@2: */ williamr@2: IMPORT_C virtual void MBPLN_ExtensionInterfaceL(TUid aInterface, void*& aObject); williamr@2: }; williamr@2: williamr@2: williamr@2: class CBTBasebandConnecter; williamr@2: class CBTBasebandShutdowner; williamr@2: class CBTDisconnector; williamr@2: williamr@2: NONSHARABLE_CLASS(CBluetoothPhysicalLinks): public CBase williamr@2: /** This is used to enumerate members of piconet, and attach and remove members thereof williamr@2: williamr@2: It may also be used for non-service dependent reads and writes. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CBluetoothPhysicalLinks* NewL(MBluetoothPhysicalLinksNotifier& aNotifier, williamr@2: RSocketServ& aServer); williamr@2: IMPORT_C static CBluetoothPhysicalLinks* NewLC(MBluetoothPhysicalLinksNotifier& aNotifier, williamr@2: RSocketServ& aServer); williamr@2: IMPORT_C ~CBluetoothPhysicalLinks(); williamr@2: williamr@2: IMPORT_C TInt CreateConnection(const TBTDevAddr& aDevAddr); williamr@2: IMPORT_C void CancelCreateConnection(); williamr@2: IMPORT_C TInt Disconnect(const TBTDevAddr& aDevAddr); williamr@2: IMPORT_C TInt DisconnectAll(); williamr@2: williamr@2: IMPORT_C TInt Broadcast(const TDesC8& aData); williamr@2: IMPORT_C TInt ReadRaw(TDes8& aData); williamr@2: IMPORT_C TInt Enumerate(RBTDevAddrArray& aBTDevAddrArray, TUint aMaxNumber); williamr@2: williamr@2: williamr@2: //Callback methods called by active object RunLs. williamr@2: //NB These methods kill the active objects that call them williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: void HandleCreateConnectionCompleteL(TInt aErr); williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: void HandleDisconnectCompleteL(TInt aErr); williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: void HandleDisconnectAllCompleteL(TInt aErr); williamr@2: williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: RSocketServ& SockServer(); williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: RBTBaseband& BTBaseband(); williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: MBluetoothPhysicalLinksNotifier& Notifier(); williamr@2: williamr@2: williamr@2: private: williamr@2: CBluetoothPhysicalLinks(MBluetoothPhysicalLinksNotifier& aNotifier, williamr@2: RSocketServ& aServer); williamr@2: void ConstructL(); williamr@2: williamr@2: private: williamr@2: CBTBasebandConnecter* iBTBasebandConnecter; williamr@2: CBTDisconnector* iBTDisconnector; williamr@2: MBluetoothPhysicalLinksNotifier& iNotifier; williamr@2: RSocketServ& iSockServer; williamr@2: RBTBaseband iBTBaseband; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: NONSHARABLE_CLASS(RBluetoothPowerSwitch) williamr@2: /** This is intended for controlling whether the Bluetooth hardware is switched on or not. williamr@2: williamr@2: @publishedPartner williamr@2: @deprecated williamr@2: @see HCI_v2 documentation williamr@2: */ williamr@2: { williamr@2: public: williamr@2: williamr@2: IMPORT_C RBluetoothPowerSwitch(); williamr@2: IMPORT_C void RequestSwitchOn(); williamr@2: IMPORT_C void RequestSwitchOff(); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: class RHCIServerSession; williamr@2: class RSocketBasedHciDirectAccess; williamr@2: williamr@2: NONSHARABLE_CLASS(RHCIDirectAccess) williamr@2: /** williamr@2: API used for licensee-specific direct HCI access williamr@2: williamr@2: This class allows vendor-specific messages to be passed through to the HCI for williamr@2: customised (licensee-specific) HCI functionality. williamr@2: williamr@2: Note: No use of this class should be required by default. It is provided to williamr@2: assist with hardware workarounds, or link policy not implemented by the williamr@2: Bluetooth stack. williamr@2: williamr@2: Do not use unless entirely familar with this API and the specific HCI in use!!!! williamr@2: williamr@2: @publishedPartner williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C RHCIDirectAccess(); williamr@2: //API used for licensee-specific direct HCI access williamr@2: IMPORT_C TInt Open(); williamr@2: IMPORT_C TInt Open(RSocketServ& aSocketServ); williamr@2: IMPORT_C void Close(); williamr@2: williamr@2: IMPORT_C void Ioctl(TUint aCommand, TRequestStatus &aStatus, TDes8* aDesc=NULL,TUint aLevel = KSolBtHCI); williamr@2: IMPORT_C void CancelIoctl(); williamr@2: williamr@2: IMPORT_C void AsyncMessage(TUint aCommand, TRequestStatus &aStatus, TDes8* aDesc); williamr@2: IMPORT_C void CancelAsyncMessage(); williamr@2: williamr@2: IMPORT_C TInt SubSessionHandle(); williamr@2: private: williamr@2: RHCIServerSession* iHCIServerSession; williamr@2: RSocketBasedHciDirectAccess* iSocketAccess; williamr@2: TUint32 iReserved; // Padding for possible future "per-copy" state. williamr@2: }; williamr@2: williamr@2: #endif