Each Blutetooth device has a name, for identifying the device to users etc. The local device name is read and set through the RHostResolver
functions GetHostName()
and SetHostName()
respectively.
The following code shows how to get the local name:
// 1. Connect to the socket server
RSocketServ socketServ;
socketServ.Connect();
TProtocolDesc pInfo;
_LIT(KL2Cap, "L2CAP");
socketServ.FindProtocol(KL2Cap,pInfo);
// 2. Create and initialise an RHostResolver
RHostResolver hr;
hr.Open(socketServ,pInfo.iAddrFamily,pInfo.iProtocol);
// 3. Get the local device name
THostName name;
TInt ret=hr.GetHostName(name);
THostName
is a descriptor buffer of a suitable minimum size.