This page was last modified 14:32, 29 June 2007.
Filtering Bluetooth Devices
From Forum Nokia Wiki
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.
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problems with BT GPS devices | eling0167 | Location Based Services and Navigation | 2 | 2008-08-27 08:03 |
| Closing a bluetooth connection | Alfury | Mobile Java Networking & Messaging & Security | 4 | 2008-04-01 16:18 |
| Turning on bluetooth on emulator | marcusneves2005 | Bluetooth Technology | 3 | 2005-03-01 12:34 |
| RSendAsMessage - передача файлов по Bluetooth | Den123 | Russian Developer Forum - Форум Российских разработчиков | 2 | 2008-03-06 17:28 |
| Bluetooth | pirich | PC Suite API and PC Connectivity SDK | 0 | 2003-06-23 10:17 |
