Namespaces
Variants
Actions

Filtering Bluetooth Devices

Jump to: navigation, search
Article Metadata

Article
Created: giaperrucci (07 Jun 2007)
Last edited: hamishwillee (27 Jul 2012)

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 27 July 2012, at 08:30.
67 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved