CBTEngConnMan Class Reference

class CBTEngConnMan : public CBase

Class CBTEngConnMan

This class provides functionality for Bluetooth connection management on profile-level. The class mainly forwards the commands to BTEng server side, which passes the commands to its plug-ins which handle the profile-level (service-level) connection management.

Connection management commands are asynchronous, and the result is passed back to the caller through the MBTEngConnObserver callback interface. Multiple commands can be outstanding simultaneously.

btengconnman.lib
Since
S60 v3.2

Inherits from

Public Member Functions
~CBTEngConnMan ()
IMPORT_C void CancelConnect (const TBTDevAddr &)
IMPORT_C void CancelPairDevice ()
IMPORT_C TInt Connect (const TBTDevAddr &, const TBTDeviceClass &)
IMPORT_C TInt Disconnect (const TBTDevAddr &, TBTDisconnectType )
IMPORT_C TInt GetConnectedAddresses ( RBTDevAddrArray &)
IMPORT_C TInt GetConnectedAddresses ( RBTDevAddrArray &, TBTProfile )
IMPORT_C TInt IsConnectable (const TBTDeviceClass &, TBool &)
IMPORT_C TInt IsConnectable (const TBTDevAddr &, const TBTDeviceClass &, TBool &)
IMPORT_C TInt IsConnected (const TBTDevAddr &, TBTEngConnectionStatus &)
IMPORT_C CBTEngConnMan * NewL ( MBTEngConnObserver *)
IMPORT_C CBTEngConnMan * NewLC ( MBTEngConnObserver *)
IMPORT_C TInt PairDevice (const TBTDevAddr &)
IMPORT_C TInt PairDevice (const TBTDevAddr &, TBTDeviceClass )
IMPORT_C void PrepareDiscovery ()
IMPORT_C void RemoveObserver ()
IMPORT_C TInt SetObserver ( MBTEngConnObserver *)
IMPORT_C TInt StartPairingObserver (const TBTDevAddr &)
IMPORT_C TInt StopPairingObserver (const TBTDevAddr &)
Private Member Functions
CBTEngConnMan ( MBTEngConnObserver *)
void ConstructL ()
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Private Attributes
CBTEngConnHandler * iConnHandler
MBTEngConnObserver * iObserver
TAny * iReserved

Constructor & Destructor Documentation

CBTEngConnMan(MBTEngConnObserver *)

CBTEngConnMan ( MBTEngConnObserver * aObserver ) [private]

C++ default constructor

Since
S60 v3.2

Parameters

MBTEngConnObserver * aObserver Pointer to callback interface that receives connection events.

~CBTEngConnMan()

~CBTEngConnMan ( ) [virtual]

Destructor

Member Functions Documentation

CancelConnect(const TBTDevAddr &)

IMPORT_C void CancelConnect ( const TBTDevAddr & aAddr )

Cancels the creation of a service-level connection to the specified Bluetooth address.

This is part of an asynchronous operation; on completion, the caller is informed through MBTEngConnObserver::ConnectComplete with error code with KErrCancel if successfully canceled, or KErrNotFound if no service-level connection with the specified Bluetooth address existed.

Since
S60 v3.2

Parameters

const TBTDevAddr & aAddr The Bluetooth address of the remote device.

CancelPairDevice()

IMPORT_C void CancelPairDevice ( )

Cancels an ongoing pairing with a Bluetooth device. If this function is issued after the device has been actually paired, the device will not be un-paired.

Since
S60 v3.2

Connect(const TBTDevAddr &, const TBTDeviceClass &)

IMPORT_C TInt Connect ( const TBTDevAddr & aAddr,
const TBTDeviceClass & aDeviceClass
)

Create a service-level connection to the specified Bluetooth address. The decision which profile to use for the service-level connection is taken by BTEng, based on the parameters that are part of the address structure passed as argument.

This is an asynchronous operation; on completion, the caller is informed through MBTEngConnObserver::ConnectComplete with the appropriate error code.

Since
S60 v3.2

Parameters

const TBTDevAddr & aAddr The Bluetooth address of the remote device.
const TBTDeviceClass & aDeviceClass The device class of the remote device. This will be used to select the correct plug-in for creating the service-level connection.

ConstructL()

void ConstructL ( ) [private]

Symbian 2nd-phase constructor

Since
S60 v3.2

Disconnect(const TBTDevAddr &, TBTDisconnectType)

IMPORT_C TInt Disconnect ( const TBTDevAddr & aAddr,
TBTDisconnectType aDiscType
)

Disconnects the creation of a service-level connection with the specified Bluetooth address.

This is an asynchronous operation; on completion, the caller is informed through MBTEngConnObserver::DisconnectComplete with the appropriate error code.

Since
S60 v3.2

Parameters

const TBTDevAddr & aAddr The Bluetooth address of the remote device.
TBTDisconnectType aDiscType The type of disconnection; EGraceful for graceful (normal) disconnection, EImmediate for immediate (forced) disconnection.

GetConnectedAddresses(RBTDevAddrArray &)

IMPORT_C TInt GetConnectedAddresses ( RBTDevAddrArray & aAddrArray )

Gets the remote addresses for all the open Bluetooth connections. These include all baseband connections, so also connections for which no service-level connection is handled by BTEng profile plug-ins.

Since
S60 v3.2

Parameters

RBTDevAddrArray & aAddrArray On return, holds the Bluetooth device addresses of all the connected Bluetooth devices.

GetConnectedAddresses(RBTDevAddrArray &, TBTProfile)

IMPORT_C TInt GetConnectedAddresses ( RBTDevAddrArray & aAddrArray,
TBTProfile aConnectedProfile
)

Gets the remote addresses for all the open Bluetooth connections for the specified profile.

Since
S60 v3.2

Parameters

RBTDevAddrArray & aAddrArray On return, holds the Bluetooth device addresses of the connected Bluetooth devices for the requested profile.
TBTProfile aConnectedProfile The profile for which the existing connections are requested.

IsConnectable(const TBTDeviceClass &, TBool &)

IMPORT_C TInt IsConnectable ( const TBTDeviceClass & aDeviceClass,
TBool & aConnectable
)

Checks whether a service-level connection can be created to a device that advertises the specified Class of Device. Note that this only indicate that a suitable profile plug-in is currently loaded by BTEng, it does does not indicate that a connection would succeed (e.g. the device may refuse the connection or could be out of range).

Since
S60 v3.2

Parameters

const TBTDeviceClass & aDeviceClass The device class of the remote device. This will be used to determine whether the device is connectable or not.
TBool & aConnectable On return, contains the value for indicating whether the device is connectable: ETrue if the device is connectable, EFalse if not.

IsConnectable(const TBTDevAddr &, const TBTDeviceClass &, TBool &)

IMPORT_C TInt IsConnectable ( const TBTDevAddr & aAddr,
const TBTDeviceClass & aDeviceClass,
TBool & aConnectable
)

Checks whether a service-level connection can be created to a device that advertises the specified Class of Device. Note that this only indicate that a suitable profile plug-in is currently loaded by BTEng, it does does not indicate that a connection would succeed (e.g. the device may refuse the connection or could be out of range).

Since
S60 v5.1

Parameters

const TBTDevAddr & aAddr The address of the remote device. This will be used to get service UUIDs in EIR data to determine whether the device is connectable or not.
const TBTDeviceClass & aDeviceClass The device class of the remote device. This will be used to determine whether the device is connectable or not.
TBool & aConnectable On return, contains the value for indicating whether the device is connectable: ETrue if the device is connectable, EFalse if not.

IsConnected(const TBTDevAddr &, TBTEngConnectionStatus &)

IMPORT_C TInt IsConnected ( const TBTDevAddr & aAddr,
TBTEngConnectionStatus & aConnected
)

Checks whether there is a service-level connection to the specified Bluetooth device.

Since
S60 v3.2

Parameters

const TBTDevAddr & aAddr The Bluetooth address of the remote device.
TBTEngConnectionStatus & aConnected On return, holds the connection status for the specified address; ENotConnected if no connection exists, EConnecting if a (service-level) connection is being established, EConnected if a service-level connection exists, and EDisconnecting if a service-level connection is being disconnected.

NewL(MBTEngConnObserver *)

IMPORT_C CBTEngConnMan * NewL ( MBTEngConnObserver * aObserver = NULL ) [static]

Two-phase constructor

Since
S60 v3.2

Parameters

MBTEngConnObserver * aObserver = NULL Pointer to callback interface that receives connection events (see also SetObserver below).

NewLC(MBTEngConnObserver *)

IMPORT_C CBTEngConnMan * NewLC ( MBTEngConnObserver * aObserver = NULL ) [static]

Two-phase constructor

Since
S60 v3.2

Parameters

MBTEngConnObserver * aObserver = NULL Pointer to callback interface that receives connection events (see also SetObserver below).

PairDevice(const TBTDevAddr &)

IMPORT_C TInt PairDevice ( const TBTDevAddr & aAddr )

Start a pairing (a.k.a. bonding) operation with a remote Bluetooth device. This will launch an authentication dialog as part of the pairing procedure (Except Just Works pairing). Since S60 5.1, a confirmation note will be shown indicating whether pairing succeeded when pairing completes; and user will be queried if he/she wants to set the device as trusted if the device has been paired. This operation finally completes when user answers the query or pairing failed confirmation has been shown.

This is an asynchronous operation; on completion, the caller is informed through MBTEngConnObserver::PairingComplete with the appropriate error code.

Note: this method is intended for operations that only include pairing, and no connection establishment. When requiring authentication/encryption on a Bluetooth link, the preferred method is to pass the security requirements through the TBTSockAddr structure.

Since
S60 v3.2

Parameters

const TBTDevAddr & aAddr

PairDevice(const TBTDevAddr &, TBTDeviceClass)

IMPORT_C TInt PairDevice ( const TBTDevAddr & aAddr,
TBTDeviceClass aDeviceClass
)

Start a pairing (a.k.a. bonding) operation with a remote Bluetooth device. This will launch an authentication dialog as part of the pairing procedure (Except Just Works pairing). Or in case of audio headset whose version is earlier than BT v2.1,and if the auto-pairing feature is supported, the PIN query is not shown but the default PIN (0000) is given automatically. If that fails the PIN query is shown normally. Since S60 5.1, a confirmation note will be shown indicating whether pairing succeeded when pairing completes; and user will be queried if he/she wants to set the device as trusted if the device has been paired. This operation finally completes when user answers the query or pairing failed confirmation has been shown.

This is an asynchronous operation; on completion, the caller is informed through MBTEngConnObserver::PairingComplete with the appropriate error code.

Note: this method is intended for operations that only include pairing, and no connection establishment. When requiring authentication/encryption on a Bluetooth link, the preferred method is to pass the security requirements through the TBTSockAddr structure.

Since
S60 v3.2

Parameters

const TBTDevAddr & aAddr
TBTDeviceClass aDeviceClass

PrepareDiscovery()

IMPORT_C void PrepareDiscovery ( )

Prepares any existing Bluetooth connection topology for performing device discovery. As a result of this call, the server will request the master role on each existing connection. Note: this method is for usage of BTNotif only. It attempts to optimize the existing topology so therefore there is no result to be informed. The functionality is only executed after this function has returned.

Since
S60 v3.2

RemoveObserver()

IMPORT_C void RemoveObserver ( )

Removes the subscription to service-level connection events. Note: this functionality is implicit when destroying CBTConnMan.

Since
S60 v3.2

SetObserver(MBTEngConnObserver *)

IMPORT_C TInt SetObserver ( MBTEngConnObserver * aObserver )

Subscribes to service-level connection events. This will replace any previoously registered callback interface object. The observer is informed of connection events through the MBTEngConnObserver callback interface. Note: the observer is only notified of events related to service-level connections. Generic notifications about Bluetooth baseband events can be obtained through bluetooth.lib.

An observer must be set before issueing any connection-related commands.

Since
S60 v3.2

Parameters

MBTEngConnObserver * aObserver The callback interface through which connection events are passed back.

StartPairingObserver(const TBTDevAddr &)

IMPORT_C TInt StartPairingObserver ( const TBTDevAddr & aAddr ) [static]

Listen to the result of a pairing operation, and launch the authorization notifier if successful. Note: this method is for usage of BTNotif only. The authorization notifier is called independently i.e. there is no callback resulting from calling this function. This function requires LocalServices and WriteDeviceData capabilities.

Since
S60 v5.1

Parameters

const TBTDevAddr & aAddr

StopPairingObserver(const TBTDevAddr &)

IMPORT_C TInt StopPairingObserver ( const TBTDevAddr & aAddr ) [static]

Stop handling the result of a pairing operation. Note: this method is for usage of BTNotif only. The authorization notifier is called independently i.e. there is no callback resulting from calling this function. This function requires LocalServices and WriteDeviceData capabilities.

Since
S60 v5.1

Parameters

const TBTDevAddr & aAddr

Member Data Documentation

CBTEngConnHandler * iConnHandler

CBTEngConnHandler * iConnHandler [private]

Handle to BTEng server side and listener to connection events. Own.

MBTEngConnObserver * iObserver

MBTEngConnObserver * iObserver [private]

Reference to receiver of connection events. Not own.

TAny * iReserved

TAny * iReserved [private]

This field is NOT used. Reserved for future extension. Own.