CBTEngDiscovery Class Reference

class CBTEngDiscovery : public CBase

Class CBTEngDiscovery

This is a helper class that simplifies the usage of Symbian's BluetoothT SDP interface, for registration of SDP records in the local database and for queries of remote SDP databases. Additionally, functionality for searching for and pairing with remote Bluetooth devices.

btengdiscovery.lib
Since
S60 v3.2

Inherits from

Public Member Functions
~CBTEngDiscovery ()
IMPORT_C void CancelGetEirServiceUUIDs ()
IMPORT_C void CancelRemoteSdpQuery ()
IMPORT_C void CancelSearchRemoteDevice ()
IMPORT_C void CloseRemoteSdpConnection ()
IMPORT_C TInt DeleteSdpRecord (const TSdpServRecordHandle )
IMPORT_C TInt GetEirServiceUUIDs (const TBTDevAddr &, TNameEntry *)
IMPORT_C CBTEngDiscovery * NewL ( MBTEngSdpResultReceiver *)
IMPORT_C CBTEngDiscovery * NewLC ( MBTEngSdpResultReceiver *)
IMPORT_C TInt ParseNextSdpAttrValueType ( RSdpResultArray &, TInt , TSdpElementType &)
IMPORT_C TInt ParseRfcommChannel ( RSdpResultArray &, TInt &)
IMPORT_C TInt RegisterSdpRecord (const TUUID &, const TUint , TSdpServRecordHandle &)
IMPORT_C TInt RemoteProtocolChannelQuery (const TBTDevAddr &, const TUUID &)
IMPORT_C TInt RemoteSdpQuery (const TBTDevAddr &, const TUUID &)
IMPORT_C TInt RemoteSdpQuery (const TBTDevAddr &, const TSdpServRecordHandle , const TSdpAttributeID )
IMPORT_C TInt RemoteSdpQuery (const TBTDevAddr &, const TUUID &, const TSdpAttributeID )
IMPORT_C TInt SearchRemoteDevice ( CBTDevice *, TUint )
IMPORT_C TInt SearchRemoteDevice ( CBTDevice *, TNameEntry *, TUint )
IMPORT_C void SetNotifier ( MBTEngSdpResultReceiver *)
Private Member Functions
CBTEngDiscovery ( MBTEngSdpResultReceiver *)
TInt CheckSdpDbHandler ()
TInt CheckSdpQueryHandler ()
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
CBTEngDeviceSearch * iDevSearchHandler
MBTEngSdpResultReceiver * iResultNotifier
CBTEngSdpDbHandler * iSdpDbHandler
CBTEngSdpQuery * iSdpQueryHandler

Constructor & Destructor Documentation

CBTEngDiscovery(MBTEngSdpResultReceiver *)

CBTEngDiscovery ( MBTEngSdpResultReceiver * aNotifier ) [private]

C++ default constructor

Since
S60 v3.2

Parameters

MBTEngSdpResultReceiver * aNotifier Pointer to callback interface that receives the SDP query results.

~CBTEngDiscovery()

~CBTEngDiscovery ( ) [virtual]

Destructor

Member Functions Documentation

CancelGetEirServiceUUIDs()

IMPORT_C void CancelGetEirServiceUUIDs ( )

Cancels an ongoing device service UUIDs retrieval.

Since
S60 5.1

CancelRemoteSdpQuery()

IMPORT_C void CancelRemoteSdpQuery ( )

Cancels an ongoing SDP query.

Since
S60 v3.2

CancelSearchRemoteDevice()

IMPORT_C void CancelSearchRemoteDevice ( )

Cancels an ongoing search for nearby Bluetooth devices. This results in a call to the callback interface method MBTEngSdpResultReceiver::ServiceSearchComplete() with error code KErrAbort.

Since
S60 v3.2

CheckSdpDbHandler()

TInt CheckSdpDbHandler ( ) [private]

Helper function to check that a valid session with the local SDP database exists.

Since
S60 v3.2

CheckSdpQueryHandler()

TInt CheckSdpQueryHandler ( ) [private]

Helper function to check that a valid handler of remote SDP queries exists.

Since
S60 v3.2

CloseRemoteSdpConnection()

IMPORT_C void CloseRemoteSdpConnection ( )

Closes a remote SDP connection. The method should be called after RemoteSdpQuery and RemoteProtocolChannelQuery methods are completed and the CBTEngDiscovery obejct is still kept alive.

Since
S60 v3.2

ConstructL()

void ConstructL ( ) [private]

Symbian 2nd-phase constructor

Since
S60 v3.2

DeleteSdpRecord(const TSdpServRecordHandle)

IMPORT_C TInt DeleteSdpRecord ( const TSdpServRecordHandle aHandle )

Deletes a service record from the local SDP database that was previously registered by through this instance of CBTEngDiscovery .

Since
S60 v3.2

Parameters

const TSdpServRecordHandle aHandle Handle to the SDP record to be deleted. Note that this has to be a valid (existing) SDP record.

GetEirServiceUUIDs(const TBTDevAddr &, TNameEntry *)

IMPORT_C TInt GetEirServiceUUIDs ( const TBTDevAddr & aAddr,
TNameEntry * aNameEntry
)

Retieves the information about the service UUIDs in the EIR data of a device specified by a BD address.

The EIR data got through this API is cached data and depends on a previous inquiry that has taken place. Moreover, a lagecy device (pre BT v2.1) doesn't have EIR data at all. Thus to ensure wether a device supports a service or not at present, SDP query would still be the most reliable approach.

When completed, the information are passed back to the client through the callback interface method MBTEngSdpResultReceiver::GetEirServiceUUIDsComplete() .

Since
S60 v5.1

Parameters

const TBTDevAddr & aAddr The BD address of the device.
TNameEntry * aNameEntry The data structure in which the EIR data of the selected device will be stored (passed back thorugh DeviceSearchComplete()). TBluetoothNameRecordWrapper can be constructed from a TNameRecord instance for the purpose of parsing and getting Extended Inquiry Response tags. Ownership of the data structure remains with the caller of this method.

NewL(MBTEngSdpResultReceiver *)

IMPORT_C CBTEngDiscovery * NewL ( MBTEngSdpResultReceiver * aNotifier = NULL ) [static]

Two-phase constructor

Since
S60 v3.2

Parameters

MBTEngSdpResultReceiver * aNotifier = NULL Pointer to callback interface that receives the SDP query results.

NewLC(MBTEngSdpResultReceiver *)

IMPORT_C CBTEngDiscovery * NewLC ( MBTEngSdpResultReceiver * aNotifier = NULL ) [static]

Two-phase constructor

Since
S60 v3.2

Parameters

MBTEngSdpResultReceiver * aNotifier = NULL Pointer to callback interface that receives the SDP query results.

ParseNextSdpAttrValueType(RSdpResultArray &, TInt, TSdpElementType &)

IMPORT_C TInt ParseNextSdpAttrValueType ( RSdpResultArray & aResultArray,
TInt aIndex,
TSdpElementType & aType
) [static]

Static helper function to return the SDP element type of an indexed element in a list (DES or DEA).

Since
S60 v3.2

Parameters

RSdpResultArray & aResultArray The array containing the SDP attribute.
TInt aIndex The position of the element to be parsed, relative to zero (i.e. zero is the first element).
TSdpElementType & aType On return, contains the element type of the element at position aIndex.

ParseRfcommChannel(RSdpResultArray &, TInt &)

IMPORT_C TInt ParseRfcommChannel ( RSdpResultArray & aResultArray,
TInt & aChannel
) [static]

Static helper function to return the protocol channel number from the result array of a ServiceAttributeSearch. This value can be used to obtain e.g. the remote RFCOMM channel after a RemoteProtocolChannelQuery has completed.

Since
S60 v3.2

Parameters

RSdpResultArray & aResultArray The array containing the SDP attribute.
TInt & aChannel

RegisterSdpRecord(const TUUID &, const TUint, TSdpServRecordHandle &)

IMPORT_C TInt RegisterSdpRecord ( const TUUID & aService,
const TUint aChannel,
TSdpServRecordHandle & aHandle
)

Registers an service record in the local SDP database, based on a known service as defined in Bluetooth Engine resource file. The instance of CBTEngDiscovery must be kept alive as long as the service record is needed to be stored (deletion of CBTEngDiscovery will remove all the records stored during the same session).

Since
S60 v3.2

Parameters

const TUUID & aService UUID of the service to be registered.
const TUint aChannel The value of the channel of the ProtocolDescriptorList attribute (e.g. the RFCOMM channel), if applicable.
TSdpServRecordHandle & aHandle On return, contains the service record handle identifying the created service record.

RemoteProtocolChannelQuery(const TBTDevAddr &, const TUUID &)

IMPORT_C TInt RemoteProtocolChannelQuery ( const TBTDevAddr & aAddr,
const TUUID & aService
)

Starts an SDP query. The remote SDP database is searched for the value of the ProtocolDescriptorList attribute in a service record containing the specified UUID, the equivalent of an SDP ServiceAttributeSearch transaction with ProtocolDescriptorList as attribute. This can e.g. be used to search the remote RFCOMM channel. When completed, the results are passed back to the client through the callback interface method MBTEngSdpResultReceiver::AttributeSearchComplete() .

Since
S60 v3.2

Parameters

const TBTDevAddr & aAddr Target Bluetooth device address for the SDP query.
const TUUID & aService The UUID to search for.

RemoteSdpQuery(const TBTDevAddr &, const TUUID &)

IMPORT_C TInt RemoteSdpQuery ( const TBTDevAddr & aAddr,
const TUUID & aService
)

Starts an SDP query. The remote SDP database is searched for service records containing the specified UUID, the equivalent of an SDP ServiceSearch transaction. When completed, record handles for all matching service records are passed back to the client through the callback interface method MBTEngSdpResultReceiver::ServiceSearchComplete() .

Since
S60 v3.2

Parameters

const TBTDevAddr & aAddr Target Bluetooth device address for the SDP query.
const TUUID & aService The UUID to search for.

RemoteSdpQuery(const TBTDevAddr &, const TSdpServRecordHandle, const TSdpAttributeID)

IMPORT_C TInt RemoteSdpQuery ( const TBTDevAddr & aAddr,
const TSdpServRecordHandle aHandle,
const TSdpAttributeID aAttrId
)

Starts an SDP query. A specific service record on the remote SDP database is queried for the value of a specified attribute, the equivalent of an SDP ServiceAttribute transaction. When completed, the result is passed back to the client through the callback interface method MBTEngSdpResultReceiver::AttributeSearchComplete() .

Since
S60 v3.2

Parameters

const TBTDevAddr & aAddr Target Bluetooth device address for the SDP query.
const TSdpServRecordHandle aHandle The service record handle identifying the service record to search the attribute from.
const TSdpAttributeID aAttrId The service attribute to search for.

RemoteSdpQuery(const TBTDevAddr &, const TUUID &, const TSdpAttributeID)

IMPORT_C TInt RemoteSdpQuery ( const TBTDevAddr & aAddr,
const TUUID & aService,
const TSdpAttributeID aAttrId
)

Starts an SDP query. The remote SDP database is searched for the value of a specified attribute in a service record containing the specified UUID, the equivalent of an SDP ServiceAttributeSearch transaction. When completed, the results are passed back to the client through the callback interface method MBTEngSdpResultReceiver::ServiceAttributeSearchComplete() .

Since
S60 v3.2

Parameters

const TBTDevAddr & aAddr Target Bluetooth device address for the SDP query.
const TUUID & aService The UUID to search for.
const TSdpAttributeID aAttrId The service attribute to search for.

SearchRemoteDevice(CBTDevice *, TUint)

IMPORT_C TInt SearchRemoteDevice ( CBTDevice * aDevice,
TUint aServiceClass = 0
)

Launches to notifier for discovering nearby Bluetooth devices and user selection of one device. When completed, the selected device is passed back to the client through the callback interface method MBTEngSdpResultReceiver::DeviceSearchComplete() .

Since
S60 v3.2

Parameters

CBTDevice * aDevice The data structure in which the result will be stored (passed back thorugh DeviceSearchComplete()). Ownership of the data structure remains with the caller of this method.
TUint aServiceClass = 0 Filter for device search; this will filter the results according to the specified major service class field of the CoD. The default value is zero and will not apply any filter.

SearchRemoteDevice(CBTDevice *, TNameEntry *, TUint)

IMPORT_C TInt SearchRemoteDevice ( CBTDevice * aDevice,
TNameEntry * aNameEntry,
TUint aServiceClass = 0
)

Launches to notifier for discovering nearby Bluetooth devices and user selection of one device. Additionally, this method returns service UUIDs in the EIR data of the selected device. When completed, the selected device and its serivice UUID list are passed back to the client through the callback interface method MBTEngSdpResultReceiver::DeviceSearchComplete() .

Since
S60 v5.1

Parameters

CBTDevice * aDevice The data structure in which the result will be stored (passed back thorugh DeviceSearchComplete()). Ownership of the data structure remains with the caller of this method.
TNameEntry * aNameEntry The data structure in which the EIR data of the selected device will be stored (passed back thorugh DeviceSearchComplete()). TBluetoothNameRecordWrapper can be constructed from a TNameRecord instance for the purpose of parsing and getting Extended Inquiry Response tags. Ownership of the data structure remains with the caller of this method.
TUint aServiceClass = 0 Filter for device search; this will filter the results according to the specified major service class field of the CoD. The default value is zero and will not apply any filter.

SetNotifier(MBTEngSdpResultReceiver *)

IMPORT_C void SetNotifier ( MBTEngSdpResultReceiver * aNotifier )

Sets the callback class for receiving SDP query results. This will replace the current callback interface used to pass back the SDP query results.

Since
S60 v3.2

Parameters

MBTEngSdpResultReceiver * aNotifier Callback class to receive the SDP results.

Member Data Documentation

CBTEngDeviceSearch * iDevSearchHandler

CBTEngDeviceSearch * iDevSearchHandler [private]

Reference to handler of remote device searches. Own.

MBTEngSdpResultReceiver * iResultNotifier

MBTEngSdpResultReceiver * iResultNotifier [private]

Reference to receiver of results. Not own.

CBTEngSdpDbHandler * iSdpDbHandler

CBTEngSdpDbHandler * iSdpDbHandler [private]

Reference to SDP DB handler. Own.

CBTEngSdpQuery * iSdpQueryHandler

CBTEngSdpQuery * iSdpQueryHandler [private]

Reference to handler of remote SDP queries. Own.