I need to access the local Bluetooth address in an application I'm developing. The phone is an N70, so I'm using Series 60 SDK 2.6.
There is a previous thread on this, with respect to Symbian v7.0s:
http://discussion.forum.nokia.com/fo...p/t-83121.html
In fact, that code does work on a v7.0s phone that I have. However, with version 8.0a, I'm receiving all zeros as the Bluetooth address. Here are two code snippets I have tried:
The first, based on that previous post:
TPckgBuf<TBTDevAddr> iDevAddr;
RSocket iSocket;
RSocketServ iSocketServer;
User::LeaveIfError(iSocketServer.Connect());
TProtocolDesc protocolInfo;
User::LeaveIfError(iSocketServer.FindProtocol(_L("BTLinkManager"), protocolInfo));
User::LeaveIfError(iSocket.Open(iSocketServer,KBTAddrFamily,KSockSeqPacket,KL2CAP));
TRequestStatus aStatus;
TBuf<128> aAddr;
iSocket.Ioctl(KHCILocalAddressIoctl, aStatus, &iDevAddr, KSolBtHCI);
User::WaitForRequest(aStatus);
iDevAddr().GetReadable(aAddr, _L("btaddr: "), _L(":"), _L("Q"));
iLog->Write(aAddr);
THCILocalVersionBuf lvb;
lvb().iLMPSubversion=0; // just for testing if nothing happens
iSocket.Ioctl(KHCILocalVersionIoctl, aStatus, &lvb, KSolBtHCI);
User::WaitForRequest(aStatus);
iLog->WriteFormat(_L("%d %d %d %d %d\n"),
lvb().iHCIVersion,lvb().iHCIRevision,
lvb().iLMPVersion,lvb().iManufacturerName,lvb().iLMPSubversion);
Much to my surprise, this code successfully reads the local version information, but not the bluetooth address.
Here is another snippet I've tried, which also returns all zeros for the Bluetooth address:
User::LeaveIfError(iSocketServer.Connect());
TInt result = iListeningSocket.Open(iSocketServer, KServerTransportName /*RFCOMM*/);
if (result != KErrNone)
{
iSocketServer.Close();
User::Leave(result);
}
// Get a channel to listen on - same as the socket's port number
TInt channel;
User::LeaveIfError(
iListeningSocket.GetOpt(
KRFCOMMGetAvailableServerChannel,
KSolBtRFCOMM, channel));
iFileLog->WriteFormat(_L("Channel %d"),channel);
TBTSockAddr listeningAddress;
listeningAddress.SetPort(channel);
TBuf<128> aAddr;
TBTDevAddr iDevAddr;
iDevAddr = listeningAddress.BTAddr();
iDevAddr.GetReadable(aAddr, _L("BTADDR: "), _L(":"), _L("R"));
iFileLog->Write(aAddr);
I often get channel 4 out of this snippet, but no bluetooth address.
I'm guessing there is some kind of API change between v7.0s and v8.0a/v8.1a that affects this behavior, since there were similar changes wrt the Bluetooth security settings.
I'm building this stuff in Carbide C++ Express v1.1 with the ARMI target for S60 2.6.
Can anybody help me out?
Thanks!
-Jon



