How to get local bluetooth device information
Article Metadata
The following code gets information for the local bluetooth device:
- Host Controller Interface (HCI) version and revision
- Link Manager Protocol (LMP) version and subversion
- Manufacturer code
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.


(no comments yet)