Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

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.

 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZbluetoothQ
     qfnZtopicQUqfnTopicZconnectivityQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX