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 voidCancelGetEirServiceUUIDs()
IMPORT_C voidCancelRemoteSdpQuery()
IMPORT_C voidCancelSearchRemoteDevice()
IMPORT_C voidCloseRemoteSdpConnection()
IMPORT_C TIntDeleteSdpRecord(const TSdpServRecordHandle)
IMPORT_C TIntGetEirServiceUUIDs(const TBTDevAddr &, TNameEntry *)
IMPORT_C CBTEngDiscovery *NewL(MBTEngSdpResultReceiver *)
IMPORT_C CBTEngDiscovery *NewLC(MBTEngSdpResultReceiver *)
IMPORT_C TIntParseNextSdpAttrValueType(RSdpResultArray &, TInt, TSdpElementType &)
IMPORT_C TIntParseRfcommChannel(RSdpResultArray &, TInt &)
IMPORT_C TIntRegisterSdpRecord(const TUUID &, const TUint, TSdpServRecordHandle &)
IMPORT_C TIntRemoteProtocolChannelQuery(const TBTDevAddr &, const TUUID &)
IMPORT_C TIntRemoteSdpQuery(const TBTDevAddr &, const TUUID &)
IMPORT_C TIntRemoteSdpQuery(const TBTDevAddr &, const TSdpServRecordHandle, const TSdpAttributeID)
IMPORT_C TIntRemoteSdpQuery(const TBTDevAddr &, const TUUID &, const TSdpAttributeID)
IMPORT_C TIntSearchRemoteDevice(CBTDevice *, TUint)
IMPORT_C TIntSearchRemoteDevice(CBTDevice *, TNameEntry *, TUint)
IMPORT_C voidSetNotifier(MBTEngSdpResultReceiver *)
Private Member Functions
CBTEngDiscovery(MBTEngSdpResultReceiver *)
TInt CheckSdpDbHandler()
TInt CheckSdpQueryHandler()
voidConstructL()
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 * aNotifierPointer to callback interface that receives the SDP query results.

~CBTEngDiscovery()

~CBTEngDiscovery()[virtual]

Destructor

Member Functions Documentation

CancelGetEirServiceUUIDs()

IMPORT_C voidCancelGetEirServiceUUIDs()

Cancels an ongoing device service UUIDs retrieval.

Since
S60 5.1

CancelRemoteSdpQuery()

IMPORT_C voidCancelRemoteSdpQuery()

Cancels an ongoing SDP query.

Since
S60 v3.2

CancelSearchRemoteDevice()

IMPORT_C voidCancelSearchRemoteDevice()

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 voidCloseRemoteSdpConnection()

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()

voidConstructL()[private]

Symbian 2nd-phase constructor

Since
S60 v3.2

DeleteSdpRecord(const TSdpServRecordHandle)

IMPORT_C TIntDeleteSdpRecord(const TSdpServRecordHandleaHandle)

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 aHandleHandle to the SDP record to be deleted. Note that this has to be a valid (existing) SDP record.

GetEirServiceUUIDs(const TBTDevAddr &, TNameEntry *)

IMPORT_C TIntGetEirServiceUUIDs(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 & aAddrThe BD address of the device.
TNameEntry * aNameEntryThe 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 = NULLPointer 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 = NULLPointer to callback interface that receives the SDP query results.

ParseNextSdpAttrValueType(RSdpResultArray &, TInt, TSdpElementType &)

IMPORT_C TIntParseNextSdpAttrValueType(RSdpResultArray &aResultArray,
TIntaIndex,
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 & aResultArrayThe array containing the SDP attribute.
TInt aIndexThe position of the element to be parsed, relative to zero (i.e. zero is the first element).
TSdpElementType & aTypeOn return, contains the element type of the element at position aIndex.

ParseRfcommChannel(RSdpResultArray &, TInt &)

IMPORT_C TIntParseRfcommChannel(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 & aResultArrayThe array containing the SDP attribute.
TInt & aChannel

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

IMPORT_C TIntRegisterSdpRecord(const TUUID &aService,
const TUintaChannel,
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 & aServiceUUID of the service to be registered.
const TUint aChannelThe value of the channel of the ProtocolDescriptorList attribute (e.g. the RFCOMM channel), if applicable.
TSdpServRecordHandle & aHandleOn return, contains the service record handle identifying the created service record.

RemoteProtocolChannelQuery(const TBTDevAddr &, const TUUID &)

IMPORT_C TIntRemoteProtocolChannelQuery(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 & aAddrTarget Bluetooth device address for the SDP query.
const TUUID & aServiceThe UUID to search for.

RemoteSdpQuery(const TBTDevAddr &, const TUUID &)

IMPORT_C TIntRemoteSdpQuery(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 & aAddrTarget Bluetooth device address for the SDP query.
const TUUID & aServiceThe UUID to search for.

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

IMPORT_C TIntRemoteSdpQuery(const TBTDevAddr &aAddr,
const TSdpServRecordHandleaHandle,
const TSdpAttributeIDaAttrId
)

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 & aAddrTarget Bluetooth device address for the SDP query.
const TSdpServRecordHandle aHandleThe service record handle identifying the service record to search the attribute from.
const TSdpAttributeID aAttrIdThe service attribute to search for.

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

IMPORT_C TIntRemoteSdpQuery(const TBTDevAddr &aAddr,
const TUUID &aService,
const TSdpAttributeIDaAttrId
)

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 & aAddrTarget Bluetooth device address for the SDP query.
const TUUID & aServiceThe UUID to search for.
const TSdpAttributeID aAttrIdThe service attribute to search for.

SearchRemoteDevice(CBTDevice *, TUint)

IMPORT_C TIntSearchRemoteDevice(CBTDevice *aDevice,
TUintaServiceClass = 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 * aDeviceThe 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 = 0Filter 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 TIntSearchRemoteDevice(CBTDevice *aDevice,
TNameEntry *aNameEntry,
TUintaServiceClass = 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 * aDeviceThe 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 * aNameEntryThe 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 = 0Filter 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 voidSetNotifier(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 * aNotifierCallback 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.