You Are Here:

Community: Wiki

This page was last modified on 30 June 2009, at 13:41.

How to handle Bluetooth class of devices (CoD)

From Forum Nokia Wiki


Introduction

This article describes how we can get information about remote class of devices (CoD). CoD means what kind of devices is the remote device is, what kind of services it provides etc. In Symbian C++, TBTDeviceClass is used to implement the concept of CoD. TBTDeviceClass class has been declared in btdevice.h file that is publicly available.

How to Retrieve the CoD

Here we describe how to get the CoD by BTLinkManager. Following code example shows how we get the information.

void CBTInquiryObject::ConstructL()
{
 
_LIT(KBTLinkManagerName,"BTLinkManager");
TProtocolDesc pInfo;
TProtocolName protocolName;
protocolName.Copy( KBTLinkManagerName );
 
User::LeaveIfError( iSocketServer.Connect());
User::LeaveIfError( iSocketServer.FindProtocol( protocolName, pInfo));
User::LeaveIfError( iHostResolver.Open(iSocketServer,pInfo.iAddrFamily,pInfo.iProtocol));
 
iInquirySockAddr.SetAction(KHostResInquiry + KHostResName + KHostResIgnoreCache);
iInquirySockAddr.SetIAC(KGIAC);
}

We get our RunL() called and in RunL() retrieve the CoD information by the following code.

void CBTInquiryObject::RunL()
{
if( iStatus == KErrNone)
{
TInquirySockAddr& sa = TInquirySockAddr::Cast( iEntry().iAddr );
TBuf<24> DeviceAddress(0);
TBuf<40> DeviceName(0);
 
sa.BTAddr().GetReadable(DeviceAddress);
DeviceName.Copy(iEntry().iName);
 
TBuf8<48> DeviceAddress8(0);
TBuf8<80> DeviceName8(0);
DeviceAddress8.Copy(DeviceAddress);
DeviceName8.Copy(DeviceName);
iObserver.LogExtraL(DeviceAddress8, DeviceName8, sa.MajorServiceClass(), sa.MajorClassOfDevice(), sa.MinorClassOfDevice());
// Get next device if no previous errors
iHostResolver.Next( iEntry, iStatus );
SetActive();
}
else
{
TBuf8<12> complete(0);
complete.Copy(_L8("_Complete_")); // just to tell the observer that inquiry is complete
iObserver.LogInfoL( complete,iStatus.Int() );
}
}


Following code classify the CoD as described in btdevice.h.

void CHemeBTBrowserDetailView::LogExtraL(TDesC8 & address, TDesC8 & name, TUint16 aMajServClass,TUint aMajDeviceClass,TUint8 aMinDeviceClass, TDes & aBuf)
{
 
enum TBluetoothDeviceType {EComputer,EPhone,ELANAccessPoint,EAudioVideo, EUnknown};
TBluetoothDeviceType deviceType=EPhone;
 
aBuf.Append(_L("Major Service Class: "));
if (aMajServClass & 0x0001)
aBuf.AppendFormat(_L(" Limited Discoverable Mode "));
 
if (aMajServClass & 0x008)
aBuf.AppendFormat(_L(" Positioning "));
 
if (aMajServClass & 0x0010)
aBuf.AppendFormat(_L(" Networking "));
if (aMajServClass & 0x0020)
aBuf.AppendFormat(_L(" Rendering "));
if (aMajServClass & 0x0040)
aBuf.AppendFormat(_L(" Capturing "));
if (aMajServClass & 0x0080)
aBuf.AppendFormat(_L(" Object Transfer "));
if (aMajServClass & 0x0100)
aBuf.AppendFormat(_L(" Audio "));
if (aMajServClass & 0x0200)
aBuf.AppendFormat(_L(" Telephony "));
if (aMajServClass & 0x0400)
aBuf.AppendFormat(_L(" Information "));
 
 
// Major Device Class is one of these
deviceType=EUnknown;
aBuf.Append(_L("Major Device Class: "));
if (aMajDeviceClass == 0x00)
{
deviceType=EUnknown;
aBuf.AppendFormat(_L(" Miscellaneous"));
}
else if (aMajDeviceClass == 0x01)
{
deviceType=EComputer;
aBuf.AppendFormat(_L(" Computer "));
}
else if (aMajDeviceClass == 0x02)
{
deviceType=EPhone;
aBuf.AppendFormat(_L(" Phone "));
}
else if (aMajDeviceClass == 0x03)
{
deviceType=ELANAccessPoint;
aBuf.AppendFormat(_L(" LAN Access Point "));
}
else if (aMajDeviceClass == 0x04)
{
deviceType=EAudioVideo;
aBuf.AppendFormat(_L(" AudioVideo "));
}
else if (aMajDeviceClass == 0x05)
{
aBuf.AppendFormat(_L(" Peripheral "));
}
else if (aMajDeviceClass == 0x06)
{
aBuf.AppendFormat(_L(" Imaging"));
}
else
{
aBuf.AppendFormat(_L(" Unknown"));
}
 
 
// Minor Device Class
aBuf.Append(_L("Minor Device Class: "));
switch (deviceType)
{
case EComputer:
if (aMinDeviceClass == 0x00)
aBuf.AppendFormat(_L(" Unclassified "));
else if (aMinDeviceClass == 0x01)
aBuf.AppendFormat(_L(" Desktop Computer "));
else if (aMinDeviceClass == 0x02)
aBuf.AppendFormat(_L(" Server Computer "));
else if (aMinDeviceClass == 0x03)
aBuf.AppendFormat(_L(" Laptop "));
else if (aMinDeviceClass == 0x04)
aBuf.AppendFormat(_L(" Handheld Computer "));
else if (aMinDeviceClass == 0x05)
aBuf.AppendFormat(_L(" Palm Computer "));
else if (aMinDeviceClass == 0x06)
aBuf.AppendFormat(_L(" Wearable computer "));
else
aBuf.AppendFormat(_L(" Unknown device type "));
break;
 
case EPhone:
if (aMinDeviceClass == 0x00)
aBuf.AppendFormat(_L(" Unclassified "));
else if (aMinDeviceClass == 0x01)
aBuf.AppendFormat(_L(" Cellular Phone"));
else if (aMinDeviceClass == 0x02)
aBuf.AppendFormat(_L(" Cordless Phone"));
else if (aMinDeviceClass == 0x03)
aBuf.AppendFormat(_L(" Smart Phone "));
else if (aMinDeviceClass == 0x04)
aBuf.AppendFormat(_L(" Modem Phone"));
else if (aMinDeviceClass == 0x05)
aBuf.AppendFormat(_L(" ISDN Phone"));
else
aBuf.AppendFormat(_L(" Unknown device type "));
break;
 
case ELANAccessPoint:
if (aMinDeviceClass == 0x00)
aBuf.AppendFormat(_L(" 0% utilized "));
else if (aMinDeviceClass == 0x08)
aBuf.AppendFormat(_L(" 1-17% utilized "));
else if (aMinDeviceClass == 0x10)
aBuf.AppendFormat(_L(" 17-33% utilized "));
else if (aMinDeviceClass == 0x18)
aBuf.AppendFormat(_L(" 33-50% utilized "));
else if (aMinDeviceClass == 0x20)
aBuf.AppendFormat(_L(" 50-67% utilized "));
else if (aMinDeviceClass == 0x28)
aBuf.AppendFormat(_L(" 67-83% utilized "));
else if (aMinDeviceClass == 0x30)
aBuf.AppendFormat(_L(" 83-99% utilized "));
else if (aMinDeviceClass == 0x38)
aBuf.AppendFormat(_L(" 100% utilized "));
else
aBuf.AppendFormat(_L(" Unknown utilisation "));
break;
 
case EAudioVideo:
if (aMinDeviceClass == 0x00)
aBuf.AppendFormat(_L(" Unclassified "));
else if (aMinDeviceClass == 0x01)
aBuf.AppendFormat(_L(" Headset Profile "));
else if (aMinDeviceClass == 0x02)
aBuf.AppendFormat(_L(" Handsfree "));
else if (aMinDeviceClass == 0x04)
aBuf.AppendFormat(_L(" MicroPhone "));
else if (aMinDeviceClass == 0x05)
aBuf.AppendFormat(_L(" Loudspeaker "));
else if (aMinDeviceClass == 0x06)
aBuf.AppendFormat(_L(" Head Phone "));
else
aBuf.AppendFormat(_L(" Other Audio Video type "));
break;
default:
aBuf.AppendFormat(_L(" Unknown "));
 
break;
}
}

Example Applications

There is a complete SDP property/folder browsing application that can be downloaded from [1].

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fHowE5ftoE5fgetE5flocalE5fBluetoothE5fE44eviceE5fAddressX qdcZpublisherQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fidE2fc764fd1cE2d8b06E2d499aE2d9a6aE2d17c3903d5a65E2fforumE5fnokiaE5fcrawlerE5fagentX qdcZtitleQSxHowE20toE20getE20localE20BluetoothE20E44eviceE20AddressE20E2dE20ForumE20NokiaE20WikiX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qrssZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qfnZdistributionQUxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2fX qfnZtopicQUqfnTopicZbluetoothQRqdcZtypeQUqrdfsZE52esourceQRqmarsZrelevanceQNx100X qfnZtopicQUqfnTopicZconnectivityQRqdcZtypeQUqrdfsZE52esourceQRqmarsZrelevanceQNx100X qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZupdatedQDx2008E2d10E2d02X qfnZuserE5ftagQSxbluetoothX qfnZuserE5ftagQSxconnectivityX qmarsZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ