×
Namespaces

Variants
Actions

Filtering Bluetooth Devices

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: giaperrucci (07 Jun 2007)
Last edited: hamishwillee (31 May 2013)

This small code snippet shows how you can use the TBTDeviceClass to ensure that only a particular class of services and/or devices are found, when using RNotifier class.

RNotifier notifier;
User::LeaveIfError(notifier.Connect());
CleanupClosePushL(notifier);
 
TBTDeviceSelectionParamsPckg filter;
 
// Setting the filter, first the service class then the
// major and minor device class
TBTDeviceClass deviceFilter(EMajorServiceObjectTransfer,
EMajorDevicePhone,
EMinorDevicePhoneUnclassified |
EMinorDevicePhoneCellular |
EMinorDevicePhoneCordless |
EMinorDevicePhoneSmartPhone |
EMinorDevicePhoneWiredModem |
EMinorDevicePhoneCommonISDNAccess );
 
filter().SetDeviceClass(deviceFilter);
TBTDeviceResponseParamsPckg response;
 
TRequestStatus status;
notifier.StartNotifierAndGetResponse(status,
KDeviceSelectionNotifierUid,
filter,
response);
 
User::WaitForRequest(status);
 
if(status.Int() != KErrNone)
{
_LIT(KGetResponse, "StartNotifierAndGetResponse error %d");
console->Printf(KGetResponse, status.Int());
User::Leave(status.Int());
}
 
// Extracting the major and minor device class of the selcected device
TUint8 major = response().DeviceClass().MajorDeviceClass();
TUint8 minor = response().DeviceClass().MinorDeviceClass();
 
CleanupStack::PopAndDestroy(1); // RNotifier

The enumerations e.g. EMajorDevicePhone are defined in btdevice.h, you'll find additional enumerations you can used to create an appropriate filter in that header.

This page was last modified on 31 May 2013, at 02:31.
26 page views in the last 30 days.