Namespaces
Variants
Actions

How to get local bluetooth device information

Jump to: navigation, search
Article Metadata

Article
Created: patrickfrei (26 Oct 2007)
Last edited: hamishwillee (18 Oct 2012)

The following code gets information for the local bluetooth device:

void CBTInfo::GetBTDevInfoL(TDes& aBTHCIVersion, 
TDes& aBTHCIRevision, TDes& aBTLMPVersion,
TDes& aBTLMPSubversion, TDes& aBTManufacturerName)
{
RSocket socket;
RSocketServ socketServer;
TRequestStatus status;
THCILocalVersionBuf lvb;
 
User::LeaveIfError(socketServer.Connect());
CleanupClosePushL<RSocketServ>(socketServer);
 
User::LeaveIfError(socket.Open(socketServer,
KBTAddrFamily, KSockSeqPacket, KL2CAP));
CleanupClosePushL<RSocket>(socket);
 
socket.Ioctl(KHCILocalVersionIoctl, status, &lvb, KSolBtHCI);
User::WaitForRequest(status);
//User::LeaveIfError(status.Int());
 
CleanupStack::PopAndDestroy(2); // socketServer, socket
 
aBTHCIVersion.AppendNum(lvb().iHCIVersion);
aBTHCIRevision.AppendNum(lvb().iHCIRevision);
aBTLMPVersion.AppendNum(lvb().iLMPVersion);
aBTLMPSubversion.AppendNum(lvb().iLMPSubversion);
aBTManufacturerName.AppendNum(lvb().iManufacturerName);
}

Note: The above variables (e.g. iHCIVersion) are officially deprecated on S60 3rd edition devices. Therefore if you uncomment the line "User::LeaveIfError(status.Int());" in the code above, the application will exit with error '-5' (KErrNotSupported). If you comment the line, the according values should be reliable anyway.

This page was last modified on 18 October 2012, at 07:18.
158 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