Symbian
Symbian OS Library

FAQ-1258 How can I discover and select a Bluetooth device easily without writing a dialog ?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: PAN (Bluetooth, USB, Irda)
Created: 04/08/2005 Modified: 04/08/2005
Number: FAQ-1258
Platform: Symbian OS v7.0, Symbian OS v7.0s, Symbian OS v8.0, Symbian OS v8.1a

Question:
I need a cross-GUI way of discovering and selecting a Bluetooth device, without re-writing a dialog for every Symbian OS platform. Can I do this by reusing an existing component?

Answer:
An easy way of discovering and selecting a single Bluetooth device from a GUI component, is that of reusing a Notifier.

Following, is an example of how to achieve this simply, using synchronous operations. In your application you should probably make use of this technique using active objects.

The example below initiates a discovery for devices that support the Seial Port Profile.

void GetDeviceAddressL()
{
RNotifier btNotifier;
User::LeaveIfError(btNotifier.Connect());

TBTDeviceSelectionParamsPckg selectionFilter;
TBTDeviceResponseParamsPckg selectionRespone;

selectionFilter().SetUUID(KSerialPortUUID);

TRequestStatus status;
btNotifier.StartNotifierAndGetResponse(status, KDeviceSelectionNotifierUid, selectionFilter, selectionResponse);
User::WaitForRequest(status);

btNotifier.Close();

User::LeaveIfError(status.Int());

// use the response data ....
TBTDeviceName dname = selectionResponse().DeviceName();
TBTDeviceClass dclass = selectionResponse().DeviceClass();
// ... etc...

return;
}