×
Namespaces

Variants
Actions

How to get local bluetooth device information

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: patrickfrei (26 Oct 2007)
Last edited: hamishwillee (31 May 2013)

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 31 May 2013, at 02:31.
33 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×